diff --git a/app/src/main/java/com/github/droidworksstudio/launcher/accessibility/ActionService.kt b/app/src/main/java/com/github/droidworksstudio/launcher/accessibility/ActionService.kt index 9e30ccf..41e96df 100644 --- a/app/src/main/java/com/github/droidworksstudio/launcher/accessibility/ActionService.kt +++ b/app/src/main/java/com/github/droidworksstudio/launcher/accessibility/ActionService.kt @@ -5,6 +5,8 @@ import android.accessibilityservice.AccessibilityServiceInfo import android.content.Context import android.content.Intent import android.os.Build +import android.os.Handler +import android.os.Looper import android.provider.Settings import android.view.accessibility.AccessibilityEvent import androidx.annotation.RequiresApi @@ -61,6 +63,7 @@ class ActionService : AccessibilityService() { return performGlobalAction(GLOBAL_ACTION_QUICK_SETTINGS) } + @RequiresApi(Build.VERSION_CODES.P) fun openPowerDialog(): Boolean { return performGlobalAction(GLOBAL_ACTION_POWER_DIALOG) } @@ -78,22 +81,23 @@ class ActionService : AccessibilityService() { companion object { fun runAccessibilityMode(context: Context) { if (instance() == null) { - val state: String = context.getString(R.string.accessibility_settings_enable) + // Create a Handler that posts to the main thread + Handler(Looper.getMainLooper()).post { + val state: String = context.getString(R.string.accessibility_settings_enable) - val builder = MaterialAlertDialogBuilder(context) - - builder.setTitle(R.string.accessibility_settings_title) - builder.setMessage(R.string.accessibility_service_desc) - builder.setPositiveButton(state) { _, _ -> - val intent = Intent(Settings.ACTION_ACCESSIBILITY_SETTINGS) - context.startActivity(intent) + val builder = MaterialAlertDialogBuilder(context) + builder.setTitle(R.string.accessibility_settings_title) + builder.setMessage(R.string.accessibility_service_desc) + builder.setPositiveButton(state) { _, _ -> + val intent = Intent(Settings.ACTION_ACCESSIBILITY_SETTINGS) + context.startActivity(intent) + } + builder.setNegativeButton(android.R.string.cancel) { dialog, _ -> + dialog.dismiss() + } + builder.show() } - builder.setNegativeButton(android.R.string.cancel) { dialog, _ -> - dialog.dismiss() - } - builder.show() } - return } private var mInstance: WeakReference = WeakReference(null) diff --git a/app/src/main/java/com/github/droidworksstudio/launcher/helper/AppHelper.kt b/app/src/main/java/com/github/droidworksstudio/launcher/helper/AppHelper.kt index 4d7ecab..b75d9a9 100644 --- a/app/src/main/java/com/github/droidworksstudio/launcher/helper/AppHelper.kt +++ b/app/src/main/java/com/github/droidworksstudio/launcher/helper/AppHelper.kt @@ -44,7 +44,7 @@ class AppHelper @Inject constructor() { } @SuppressLint("WrongConstant", "PrivateApi") - private fun expandQuickSettings(context: Context) { + fun expandQuickSettings(context: Context) { try { Class.forName(Constants.QUICKSETTINGS_MANAGER) .getMethod(Constants.QUICKSETTINGS_METHOD) @@ -192,33 +192,4 @@ class AppHelper @Inject constructor() { fun restoreSharedPreferences(context: Context) { context.restoreSharedPreferences(context.getString(R.string.settings_backups_file)) } - - fun enableAppAsAccessibilityService(context: Context, accessibilityState: Boolean) { - val state: String = if (accessibilityState) { - context.getString(R.string.accessibility_settings_disable) - } else { - context.getString(R.string.accessibility_settings_enable) - } - - when (state) { - "Enable" -> { - val builder = MaterialAlertDialogBuilder(context) - - builder.setTitle(R.string.accessibility_settings_title) - builder.setMessage(R.string.accessibility_service_desc) - builder.setPositiveButton(state) { _, _ -> - val intent = Intent(Settings.ACTION_ACCESSIBILITY_SETTINGS) - context.startActivity(intent) - } - builder.setNegativeButton(android.R.string.cancel) { dialog, _ -> - dialog.dismiss() - } - builder.show() - } - - else -> { - return - } - } - } } \ No newline at end of file diff --git a/app/src/main/java/com/github/droidworksstudio/launcher/helper/PreferenceHelper.kt b/app/src/main/java/com/github/droidworksstudio/launcher/helper/PreferenceHelper.kt index 77984b7..84ced7d 100644 --- a/app/src/main/java/com/github/droidworksstudio/launcher/helper/PreferenceHelper.kt +++ b/app/src/main/java/com/github/droidworksstudio/launcher/helper/PreferenceHelper.kt @@ -106,22 +106,10 @@ class PreferenceHelper @Inject constructor(@ApplicationContext context: Context) get() = prefs.getFloat(Constants.DAILY_WORD_TEXT_SIZE, 18f) set(value) = prefs.edit().putFloat(Constants.DAILY_WORD_TEXT_SIZE, value).apply() - var tapLockScreen: Boolean - get() = prefs.getBoolean(Constants.DOUBLE_TAP_LOCK, false) - set(value) = prefs.edit().putBoolean(Constants.DOUBLE_TAP_LOCK, value).apply() - var settingsLock: Boolean get() = prefs.getBoolean(Constants.TOGGLE_SETTING_LOCK, false) set(value) = prefs.edit().putBoolean(Constants.TOGGLE_SETTING_LOCK, value).apply() - var swipeNotification: Boolean - get() = prefs.getBoolean(Constants.SWIPE_NOTIFICATION, true) - set(value) = prefs.edit().putBoolean(Constants.SWIPE_NOTIFICATION, value).apply() - - var swipeSearch: Boolean - get() = prefs.getBoolean(Constants.SWIPE_SEARCH, false) - set(value) = prefs.edit().putBoolean(Constants.SWIPE_SEARCH, value).apply() - var searchEngines: Constants.SearchEngines get() { return try { @@ -136,4 +124,36 @@ class PreferenceHelper @Inject constructor(@ApplicationContext context: Context) } } set(value) = prefs.edit().putString(Constants.SEARCH_ENGINE, value.name).apply() + + var swipeUpAction: Constants.Action + get() = loadAction(Constants.SWIPE_UP_ACTION, Constants.Action.ShowRecents) + set(value) = storeAction(Constants.SWIPE_UP_ACTION, value) + + var swipeDownAction: Constants.Action + get() = loadAction(Constants.SWIPE_DOWN_ACTION, Constants.Action.ShowNotification) + set(value) = storeAction(Constants.SWIPE_DOWN_ACTION, value) + + var swipeLeftAction: Constants.Action + get() = loadAction(Constants.SWIPE_LEFT_ACTION, Constants.Action.ShowAppList) + set(value) = storeAction(Constants.SWIPE_LEFT_ACTION, value) + + var swipeRightAction: Constants.Action + get() = loadAction(Constants.SWIPE_RIGHT_ACTION, Constants.Action.ShowFavoriteList) + set(value) = storeAction(Constants.SWIPE_RIGHT_ACTION, value) + + var doubleTapAction: Constants.Action + get() = loadAction(Constants.DOUBLE_TAP_ACTION, Constants.Action.LockScreen) + set(value) = storeAction(Constants.DOUBLE_TAP_ACTION, value) + + private fun loadAction(prefString: String, default: Constants.Action): Constants.Action { + val string = prefs.getString( + prefString, + default.toString() + ).toString() + return Constants.Action.valueOf(string) + } + + private fun storeAction(prefString: String, value: Constants.Action) { + prefs.edit().putString(prefString, value.name).apply() + } } \ No newline at end of file diff --git a/app/src/main/java/com/github/droidworksstudio/launcher/ui/home/HomeFragment.kt b/app/src/main/java/com/github/droidworksstudio/launcher/ui/home/HomeFragment.kt index 6ffca95..d908e7d 100644 --- a/app/src/main/java/com/github/droidworksstudio/launcher/ui/home/HomeFragment.kt +++ b/app/src/main/java/com/github/droidworksstudio/launcher/ui/home/HomeFragment.kt @@ -8,6 +8,8 @@ import android.content.IntentFilter import android.os.BatteryManager import android.os.Build import android.os.Bundle +import android.os.Handler +import android.os.Looper import android.text.format.DateFormat import android.util.Log import android.view.* @@ -25,7 +27,6 @@ import com.github.droidworksstudio.common.launchApp import com.github.droidworksstudio.common.launchCalendar import com.github.droidworksstudio.common.launchClock import com.github.droidworksstudio.common.openBatteryManager -import com.github.droidworksstudio.common.searchView import com.github.droidworksstudio.common.showLongToast import com.github.droidworksstudio.launcher.R import com.github.droidworksstudio.launcher.accessibility.ActionService @@ -38,6 +39,7 @@ import com.github.droidworksstudio.launcher.listener.OnItemClickedListener import com.github.droidworksstudio.launcher.listener.OnSwipeTouchListener import com.github.droidworksstudio.launcher.listener.ScrollEventListener import com.github.droidworksstudio.launcher.ui.bottomsheetdialog.AppInfoBottomSheetFragment +import com.github.droidworksstudio.launcher.utils.Constants import com.github.droidworksstudio.launcher.viewmodel.AppViewModel import com.github.droidworksstudio.launcher.viewmodel.PreferenceViewModel import dagger.hilt.android.AndroidEntryPoint @@ -295,33 +297,81 @@ class HomeFragment : Fragment(), @RequiresApi(Build.VERSION_CODES.P) override fun onDoubleClick() { super.onDoubleClick() - if (preferenceHelper.tapLockScreen) { - ActionService.runAccessibilityMode(context) - ActionService.instance()?.lockScreen() - } else { - return + handleOtherAction(preferenceHelper.doubleTapAction) + } + + @RequiresApi(Build.VERSION_CODES.P) + override fun onSwipeUp() { + super.onSwipeUp() + handleOtherAction(preferenceHelper.swipeUpAction) + } + + @RequiresApi(Build.VERSION_CODES.P) + override fun onSwipeDown() { + super.onSwipeDown() + handleOtherAction(preferenceHelper.swipeDownAction) + } + + @RequiresApi(Build.VERSION_CODES.P) + override fun onSwipeLeft() { + super.onSwipeLeft() + handleOtherAction(preferenceHelper.swipeLeftAction) + } + + @RequiresApi(Build.VERSION_CODES.P) + override fun onSwipeRight() { + super.onSwipeRight() + handleOtherAction(preferenceHelper.swipeRightAction) + } + } + } + + @RequiresApi(Build.VERSION_CODES.P) + private fun handleOtherAction(action: Constants.Action) { + when (action) { +// Constants.Action.OpenApp -> {} + + Constants.Action.LockScreen -> { + ActionService.runAccessibilityMode(context) + ActionService.instance()?.lockScreen() + } + + Constants.Action.ShowNotification -> { + appHelper.expandNotificationDrawer(context) + } + + Constants.Action.ShowAppList -> { + Handler(Looper.getMainLooper()).post { + findNavController().navigate(R.id.action_HomeFragment_to_DrawFragment) } } - override fun onSwipeLeft() { - super.onSwipeLeft() - findNavController().navigate(R.id.action_HomeFragment_to_DrawFragment) + Constants.Action.ShowFavoriteList -> { + Handler(Looper.getMainLooper()).post { + findNavController().navigate(R.id.action_HomeFragment_to_FavoriteFragment) + } } - override fun onSwipeRight() { - super.onSwipeRight() - findNavController().navigate(R.id.action_HomeFragment_to_FavoriteFragment) + Constants.Action.OpenQuickSettings -> { + appHelper.expandQuickSettings(context) } - override fun onSwipeDown() { - super.onSwipeDown() - if (preferenceHelper.swipeNotification) appHelper.expandNotificationDrawer(context) + Constants.Action.ShowRecents -> { + ActionService.runAccessibilityMode(context) + ActionService.instance()?.showRecents() } - override fun onSwipeUp() { - super.onSwipeUp() - if (preferenceHelper.swipeSearch) context.searchView() + Constants.Action.OpenPowerDialog -> { + ActionService.runAccessibilityMode(context) + ActionService.instance()?.openPowerDialog() } + + Constants.Action.TakeScreenShot -> { + ActionService.runAccessibilityMode(context) + ActionService.instance()?.takeScreenShot() + } + + Constants.Action.Disabled -> {} } } diff --git a/app/src/main/java/com/github/droidworksstudio/launcher/ui/settings/SettingsFragment.kt b/app/src/main/java/com/github/droidworksstudio/launcher/ui/settings/SettingsFragment.kt index f6337c6..6ff0fb2 100644 --- a/app/src/main/java/com/github/droidworksstudio/launcher/ui/settings/SettingsFragment.kt +++ b/app/src/main/java/com/github/droidworksstudio/launcher/ui/settings/SettingsFragment.kt @@ -79,8 +79,14 @@ class SettingsFragment : Fragment(), packageInfo.versionName ) - val searchEngine = preferenceHelper.searchEngines.toString() - binding.searchEngineText.text = searchEngine + binding.searchEngineText.text = preferenceHelper.searchEngines.getString(context) + + binding.gesturesDoubleTapControl.text = preferenceHelper.doubleTapAction.getString(context) + binding.gesturesSwipeUpControl.text = preferenceHelper.swipeUpAction.getString(context) + binding.gesturesSwipeDownControl.text = preferenceHelper.swipeDownAction.getString(context) + binding.gesturesSwipeLeftControl.text = preferenceHelper.swipeLeftAction.getString(context) + binding.gesturesSwipeRightControl.text = + preferenceHelper.swipeRightAction.getString(context) } @SuppressLint("SetTextI18n") @@ -96,9 +102,6 @@ class SettingsFragment : Fragment(), binding.appIconsSwitchCompat.isChecked = preferenceHelper.showAppIcon binding.automaticKeyboardSwitchCompat.isChecked = preferenceHelper.automaticKeyboard binding.automaticOpenAppSwitchCompat.isChecked = preferenceHelper.automaticOpenApp - binding.gesturesLockSwitchCompat.isChecked = preferenceHelper.tapLockScreen - binding.gesturesNotificationSwitchCompat.isChecked = preferenceHelper.swipeNotification - binding.gesturesSearchSwitchCompat.isChecked = preferenceHelper.swipeSearch binding.lockSettingsSwitchCompat.isChecked = preferenceHelper.settingsLock } @@ -143,10 +146,6 @@ class SettingsFragment : Fragment(), bottomSheetFragment.show(parentFragmentManager, "BottomSheetDialog") } - binding.miscellaneousSearchEngine.setOnClickListener { - showSearchEngineDialog() - } - binding.shareView.setOnClickListener { appHelper.shareAppButton(requireContext()) } @@ -196,22 +195,6 @@ class SettingsFragment : Fragment(), preferenceViewModel.setShowAppIcons(isChecked) } - binding.gesturesLockSwitchCompat.setOnCheckedChangeListener { _, isChecked -> - appHelper.enableAppAsAccessibilityService( - requireContext(), - preferenceHelper.tapLockScreen - ) - preferenceViewModel.setDoubleTapLock(isChecked) - } - - binding.gesturesNotificationSwitchCompat.setOnCheckedChangeListener { _, isChecked -> - preferenceViewModel.setSwipeNotification(isChecked) - } - - binding.gesturesSearchSwitchCompat.setOnCheckedChangeListener { _, isChecked -> - preferenceViewModel.setSwipeSearch(isChecked) - } - binding.automaticKeyboardSwitchCompat.setOnCheckedChangeListener { _, isChecked -> preferenceViewModel.setAutoKeyboard(isChecked) } @@ -228,6 +211,30 @@ class SettingsFragment : Fragment(), @SuppressLint("ClickableViewAccessibility") private fun observeSwipeTouchListener() { binding.touchArea.setOnTouchListener(getSwipeGestureListener(context)) + + binding.miscellaneousSearchEngine.setOnClickListener { + showSearchEngineDialog() + } + + binding.gesturesDoubleTapText.setOnClickListener { + swipeActionClickEvent(Constants.Swipe.DoubleTap) + } + + binding.gesturesSwipeUpText.setOnClickListener { + swipeActionClickEvent(Constants.Swipe.Up) + } + + binding.gesturesSwipeDownText.setOnClickListener { + swipeActionClickEvent(Constants.Swipe.Down) + } + + binding.gesturesSwipeLeftText.setOnClickListener { + swipeActionClickEvent(Constants.Swipe.Left) + } + + binding.gesturesSwipeRightText.setOnClickListener { + swipeActionClickEvent(Constants.Swipe.Right) + } } private fun getSwipeGestureListener(context: Context): View.OnTouchListener { @@ -247,7 +254,7 @@ class SettingsFragment : Fragment(), private fun showSearchEngineDialog() { // Get the array of SearchEngines enum values - val items = Constants.SearchEngines.values() + val items = Constants.SearchEngines.entries.toTypedArray() // Map the enum values to their string representations val itemStrings = items.map { it.getString(context) }.toTypedArray() @@ -257,36 +264,58 @@ class SettingsFragment : Fragment(), dialog.setTitle("Select a Search Engine") dialog.setItems(itemStrings) { _, which -> val selectedItem = items[which] - when (selectedItem) { - Constants.SearchEngines.Google -> { - preferenceViewModel.setSearchEngine(Constants.SearchEngines.Google) - binding.searchEngineText.text = preferenceHelper.searchEngines.name + preferenceViewModel.setSearchEngine(selectedItem) + binding.searchEngineText.text = preferenceHelper.searchEngines.name + } + dialog.show() + } + + private fun swipeActionClickEvent(swipe: Constants.Swipe) { + // Get the array of SearchEngines enum values + val actions = Constants.Action.entries.toTypedArray() + // Map the enum values to their string representations + val actionStrings = actions.map { it.getString(context) }.toTypedArray() + + val dialog = MaterialAlertDialogBuilder(context) + + dialog.setTitle("Select a Action") + dialog.setItems(actionStrings) { _, which -> + val selectedAction = actions[which] + when (swipe) { + Constants.Swipe.DoubleTap -> { + preferenceViewModel.setDoubleTap(selectedAction) + binding.gesturesDoubleTapControl.text = + preferenceHelper.doubleTapAction.getString(context) } - Constants.SearchEngines.Bing -> { - preferenceViewModel.setSearchEngine(Constants.SearchEngines.Bing) - binding.searchEngineText.text = preferenceHelper.searchEngines.name + Constants.Swipe.Up -> { + preferenceViewModel.setSwipeUp(selectedAction) + binding.gesturesSwipeUpControl.text = + preferenceHelper.swipeUpAction.getString(context) + } - Constants.SearchEngines.Brave -> { - preferenceViewModel.setSearchEngine(Constants.SearchEngines.Brave) - binding.searchEngineText.text = preferenceHelper.searchEngines.name + Constants.Swipe.Down -> { + preferenceViewModel.setSwipeDown(selectedAction) + binding.gesturesSwipeDownControl.text = + preferenceHelper.swipeDownAction.getString(context) + } - Constants.SearchEngines.Yahoo -> { - preferenceViewModel.setSearchEngine(Constants.SearchEngines.Yahoo) - binding.searchEngineText.text = preferenceHelper.searchEngines.name + Constants.Swipe.Left -> { + preferenceViewModel.setSwipeLeft(selectedAction) + binding.gesturesSwipeLeftControl.text = + preferenceHelper.swipeLeftAction.getString(context) + } - Constants.SearchEngines.DuckDuckGo -> { - preferenceViewModel.setSearchEngine(Constants.SearchEngines.DuckDuckGo) - binding.searchEngineText.text = preferenceHelper.searchEngines.name + Constants.Swipe.Right -> { + preferenceViewModel.setSwipeRight(selectedAction) + binding.gesturesSwipeRightControl.text = + preferenceHelper.swipeRightAction.getString(context) + } - Constants.SearchEngines.SwissCow -> { - preferenceViewModel.setSearchEngine(Constants.SearchEngines.SwissCow) - binding.searchEngineText.text = preferenceHelper.searchEngines.name - } } } dialog.show() diff --git a/app/src/main/java/com/github/droidworksstudio/launcher/utils/Constants.kt b/app/src/main/java/com/github/droidworksstudio/launcher/utils/Constants.kt index 841f107..ab84dd5 100644 --- a/app/src/main/java/com/github/droidworksstudio/launcher/utils/Constants.kt +++ b/app/src/main/java/com/github/droidworksstudio/launcher/utils/Constants.kt @@ -1,6 +1,7 @@ package com.github.droidworksstudio.launcher.utils import android.content.Context +import androidx.compose.ui.res.stringResource import com.github.droidworksstudio.launcher.R object Constants { @@ -17,10 +18,6 @@ object Constants { const val SHOW_DAILY_WORD = "SHOW_DAILY_WORD" const val SHOW_BATTERY = "SHOW_BATTERY" const val SHOW_STATUS_BAR = "SHOW_STATUS_BAR" - const val DOUBLE_TAP_LOCK = "DOUBLE_TAP_LOCK" - - const val SWIPE_NOTIFICATION = "SWIPE_NOTIFICATION" - const val SWIPE_SEARCH = "SWIPE_SEARCH" const val DATE_COLOR = "DATE_COLOR" const val TIME_COLOR = "TIME_COLOR" @@ -89,4 +86,46 @@ object Constants { } } } + + const val SWIPE_UP_ACTION = "SWIPE_UP_ACTION" + const val SWIPE_DOWN_ACTION = "SWIPE_DOWN_ACTION" + const val SWIPE_LEFT_ACTION = "SWIPE_LEFT_ACTION" + const val SWIPE_RIGHT_ACTION = "SWIPE_RIGHT_ACTION" + const val DOUBLE_TAP_ACTION = "DOUBLE_TAP_ACTION" + + enum class Action { + // OpenApp, + LockScreen, + ShowNotification, + ShowAppList, + ShowFavoriteList, + OpenQuickSettings, + ShowRecents, + OpenPowerDialog, + TakeScreenShot, + Disabled; + + fun getString(context: Context): String { + return when (this) { +// OpenApp -> context.getString(R.string.settings_actions_open_app) + LockScreen -> context.getString(R.string.settings_actions_lock_screen) + ShowNotification -> context.getString(R.string.settings_actions_show_notifications) + ShowAppList -> context.getString(R.string.settings_actions_show_app_list) + ShowFavoriteList -> context.getString(R.string.settings_actions_show_favorite_list) + OpenQuickSettings -> context.getString(R.string.settings_actions_open_quick_settings) + ShowRecents -> context.getString(R.string.settings_actions_show_recents) + OpenPowerDialog -> context.getString(R.string.settings_actions_open_power_dialog) + TakeScreenShot -> context.getString(R.string.settings_actions_take_a_screenshot) + Disabled -> context.getString(R.string.settings_actions_disabled) + } + } + } + + enum class Swipe { + DoubleTap, + Left, + Right, + Up, + Down; + } } \ No newline at end of file diff --git a/app/src/main/java/com/github/droidworksstudio/launcher/viewmodel/PreferenceViewModel.kt b/app/src/main/java/com/github/droidworksstudio/launcher/viewmodel/PreferenceViewModel.kt index f869c08..647b312 100644 --- a/app/src/main/java/com/github/droidworksstudio/launcher/viewmodel/PreferenceViewModel.kt +++ b/app/src/main/java/com/github/droidworksstudio/launcher/viewmodel/PreferenceViewModel.kt @@ -32,15 +32,17 @@ class PreferenceViewModel @Inject constructor( private val timeTextSizeLiveData: MutableLiveData = MutableLiveData() private val appTextSizeLiveData: MutableLiveData = MutableLiveData() private val batteryTextSizeLiveData: MutableLiveData = MutableLiveData() - private val tapLockScreenLiveData: MutableLiveData = MutableLiveData() - private val swipeNotificationLiveData: MutableLiveData = MutableLiveData() - private val swipeSearchLiveData: MutableLiveData = MutableLiveData() private val autoOpenAppsLiveData: MutableLiveData = MutableLiveData() private val autoKeyboardLiveData: MutableLiveData = MutableLiveData() private val lockSettingsLiveData: MutableLiveData = MutableLiveData() private val appPaddingSizeLiveData: MutableLiveData = MutableLiveData() private val searchEngineLiveData: MutableLiveData = MutableLiveData() + private val doubleTapActionLiveData: MutableLiveData = MutableLiveData() + private val swipeUpActionLiveData: MutableLiveData = MutableLiveData() + private val swipeDownActionLiveData: MutableLiveData = MutableLiveData() + private val swipeLeftActionLiveData: MutableLiveData = MutableLiveData() + private val swipeRightActionLiveData: MutableLiveData = MutableLiveData() fun setFirstLaunch(firstLaunch: Boolean) { preferenceHelper.firstLaunch = firstLaunch @@ -147,19 +149,29 @@ class PreferenceViewModel @Inject constructor( appPaddingSizeLiveData.postValue(preferenceHelper.homeAppPadding) } - fun setDoubleTapLock(tapLockScreen: Boolean) { - preferenceHelper.tapLockScreen = tapLockScreen - tapLockScreenLiveData.postValue((preferenceHelper.tapLockScreen)) + fun setDoubleTap(action: Constants.Action) { + preferenceHelper.doubleTapAction = action + doubleTapActionLiveData.postValue((preferenceHelper.doubleTapAction)) } - fun setSwipeNotification(swipeNotification: Boolean) { - preferenceHelper.swipeNotification = swipeNotification - swipeNotificationLiveData.postValue((preferenceHelper.swipeNotification)) + fun setSwipeUp(action: Constants.Action) { + preferenceHelper.swipeUpAction = action + swipeUpActionLiveData.postValue((preferenceHelper.swipeUpAction)) } - fun setSwipeSearch(swipeSearch: Boolean) { - preferenceHelper.swipeSearch = swipeSearch - swipeSearchLiveData.postValue((preferenceHelper.swipeSearch)) + fun setSwipeDown(action: Constants.Action) { + preferenceHelper.swipeDownAction = action + swipeDownActionLiveData.postValue((preferenceHelper.swipeDownAction)) + } + + fun setSwipeLeft(action: Constants.Action) { + preferenceHelper.swipeLeftAction = action + swipeLeftActionLiveData.postValue((preferenceHelper.swipeLeftAction)) + } + + fun setSwipeRight(action: Constants.Action) { + preferenceHelper.swipeRightAction = action + swipeRightActionLiveData.postValue((preferenceHelper.swipeRightAction)) } fun setAutoKeyboard(autoKeyboard: Boolean) { diff --git a/app/src/main/res/layout/fragment_settings.xml b/app/src/main/res/layout/fragment_settings.xml index 6a854c8..02056a6 100644 --- a/app/src/main/res/layout/fragment_settings.xml +++ b/app/src/main/res/layout/fragment_settings.xml @@ -589,30 +589,32 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginHorizontal="20dp" + android:layout_marginVertical="10dp" android:orientation="horizontal" tools:ignore="MissingConstraints"> - + android:gravity="left|center" + android:text="@string/settings_double_tap" + android:textSize="@dimen/text_large" + tools:ignore="RtlHardcoded" + style="@style/TextDefaultStyle" /> @@ -620,30 +622,32 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginHorizontal="20dp" + android:layout_marginVertical="10dp" android:orientation="horizontal" tools:ignore="MissingConstraints"> - + android:gravity="left|center" + android:text="@string/settings_swipe_up" + android:textSize="@dimen/text_large" + tools:ignore="RtlHardcoded" + style="@style/TextDefaultStyle" /> @@ -651,30 +655,98 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginHorizontal="20dp" + android:layout_marginVertical="10dp" android:orientation="horizontal" tools:ignore="MissingConstraints"> - + android:gravity="left|center" + android:text="@string/settings_swipe_down" + android:textSize="@dimen/text_large" + tools:ignore="RtlHardcoded" + style="@style/TextDefaultStyle" /> + + + + + + + + + + + + + + + + @@ -698,6 +770,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginHorizontal="20dp" + android:layout_marginVertical="10dp" android:orientation="horizontal" tools:ignore="MissingConstraints"> @@ -732,7 +805,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" - tools:ignore="MissingConstraints"> + tools:ignore="MissingConstraints,TooManyViews"> Hidden Apps Select Wallpaper - Double tap to lock - Swipe down expand notification - Swipe up open search view + Double Tap + Swipe Up + Swipe Down + Swipe Left + Swipe Right + Search Engine @@ -92,6 +95,17 @@ Preferences backed up. Preferences restored. Restarting. + Open App + Lock Screen + Show Notifications + Show Apps List + Show Favorites List + Open Quick Settings + Show Recents + Open Power Dialog + Take a ScreenShot + Disabled + Authentication Log in using your biometric credentials. Authentication Cancel