Feat: Added custom gestures.
Added Gestures: - DoubleTap. - Swipe: Up, Down, Left, Right. Signed-off-by: HeCodes2Much <wayne6324@gmail.com>
This commit is contained in:
@@ -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<ActionService> = WeakReference(null)
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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()
|
||||
}
|
||||
}
|
||||
@@ -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 -> {}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -32,15 +32,17 @@ class PreferenceViewModel @Inject constructor(
|
||||
private val timeTextSizeLiveData: MutableLiveData<Float> = MutableLiveData()
|
||||
private val appTextSizeLiveData: MutableLiveData<Float> = MutableLiveData()
|
||||
private val batteryTextSizeLiveData: MutableLiveData<Float> = MutableLiveData()
|
||||
private val tapLockScreenLiveData: MutableLiveData<Boolean> = MutableLiveData()
|
||||
private val swipeNotificationLiveData: MutableLiveData<Boolean> = MutableLiveData()
|
||||
private val swipeSearchLiveData: MutableLiveData<Boolean> = MutableLiveData()
|
||||
private val autoOpenAppsLiveData: MutableLiveData<Boolean> = MutableLiveData()
|
||||
private val autoKeyboardLiveData: MutableLiveData<Boolean> = MutableLiveData()
|
||||
private val lockSettingsLiveData: MutableLiveData<Boolean> = MutableLiveData()
|
||||
private val appPaddingSizeLiveData: MutableLiveData<Float> = MutableLiveData()
|
||||
|
||||
private val searchEngineLiveData: MutableLiveData<Constants.SearchEngines> = MutableLiveData()
|
||||
private val doubleTapActionLiveData: MutableLiveData<Constants.Action> = MutableLiveData()
|
||||
private val swipeUpActionLiveData: MutableLiveData<Constants.Action> = MutableLiveData()
|
||||
private val swipeDownActionLiveData: MutableLiveData<Constants.Action> = MutableLiveData()
|
||||
private val swipeLeftActionLiveData: MutableLiveData<Constants.Action> = MutableLiveData()
|
||||
private val swipeRightActionLiveData: MutableLiveData<Constants.Action> = 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) {
|
||||
|
||||
@@ -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">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/gestures_lock_text"
|
||||
android:id="@+id/gestures_double_tap_text"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:gravity="left|center"
|
||||
android:text="@string/settings_double_tap_lock"
|
||||
android:text="@string/settings_double_tap"
|
||||
android:textSize="@dimen/text_large"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:ignore="RtlHardcoded"
|
||||
style="@style/TextDefaultStyle" />
|
||||
|
||||
<androidx.appcompat.widget.SwitchCompat
|
||||
android:id="@+id/gestures_lock_switchCompat"
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/gestures_double_tap_control"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:thumb="@drawable/shape_switch_thumb"
|
||||
app:track="@drawable/selector_switch"
|
||||
android:scaleY="0.8"
|
||||
android:scaleX="0.7" />
|
||||
android:gravity="left|center"
|
||||
android:text="@string/settings_double_tap"
|
||||
android:textSize="@dimen/text_large"
|
||||
tools:ignore="RtlHardcoded"
|
||||
style="@style/TextDefaultStyle" />
|
||||
|
||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||
|
||||
@@ -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">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/gestures_notification_text"
|
||||
android:id="@+id/gestures_swipe_up_text"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:gravity="left|center"
|
||||
android:text="@string/settings_swipe_down_notification"
|
||||
android:text="@string/settings_swipe_up"
|
||||
android:textSize="@dimen/text_large"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:ignore="RtlHardcoded"
|
||||
style="@style/TextDefaultStyle" />
|
||||
|
||||
<androidx.appcompat.widget.SwitchCompat
|
||||
android:id="@+id/gestures_notification_switchCompat"
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/gestures_swipe_up_control"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:thumb="@drawable/shape_switch_thumb"
|
||||
app:track="@drawable/selector_switch"
|
||||
android:scaleY="0.8"
|
||||
android:scaleX="0.7" />
|
||||
android:gravity="left|center"
|
||||
android:text="@string/settings_swipe_up"
|
||||
android:textSize="@dimen/text_large"
|
||||
tools:ignore="RtlHardcoded"
|
||||
style="@style/TextDefaultStyle" />
|
||||
|
||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||
|
||||
@@ -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">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/gestures_search_text"
|
||||
android:id="@+id/gestures_swipe_down_text"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:gravity="left|center"
|
||||
android:text="@string/settings_swipe_up_search"
|
||||
android:text="@string/settings_swipe_down"
|
||||
android:textSize="@dimen/text_large"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:ignore="RtlHardcoded"
|
||||
style="@style/TextDefaultStyle" />
|
||||
|
||||
<androidx.appcompat.widget.SwitchCompat
|
||||
android:id="@+id/gestures_search_switchCompat"
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/gestures_swipe_down_control"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:thumb="@drawable/shape_switch_thumb"
|
||||
app:track="@drawable/selector_switch"
|
||||
android:scaleY="0.8"
|
||||
android:scaleX="0.7" />
|
||||
android:gravity="left|center"
|
||||
android:text="@string/settings_swipe_down"
|
||||
android:textSize="@dimen/text_large"
|
||||
tools:ignore="RtlHardcoded"
|
||||
style="@style/TextDefaultStyle" />
|
||||
|
||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||
|
||||
<androidx.appcompat.widget.LinearLayoutCompat
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginHorizontal="20dp"
|
||||
android:layout_marginVertical="10dp"
|
||||
android:orientation="horizontal"
|
||||
tools:ignore="MissingConstraints">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/gestures_swipe_left_text"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:gravity="left|center"
|
||||
android:text="@string/settings_swipe_left"
|
||||
android:textSize="@dimen/text_large"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:ignore="RtlHardcoded"
|
||||
style="@style/TextDefaultStyle" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/gestures_swipe_left_control"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="left|center"
|
||||
android:text="@string/settings_swipe_left"
|
||||
android:textSize="@dimen/text_large"
|
||||
tools:ignore="RtlHardcoded"
|
||||
style="@style/TextDefaultStyle" />
|
||||
|
||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||
|
||||
<androidx.appcompat.widget.LinearLayoutCompat
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginHorizontal="20dp"
|
||||
android:layout_marginVertical="10dp"
|
||||
android:orientation="horizontal"
|
||||
tools:ignore="MissingConstraints">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/gestures_swipe_right_text"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:gravity="left|center"
|
||||
android:text="@string/settings_swipe_right"
|
||||
android:textSize="@dimen/text_large"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:ignore="RtlHardcoded"
|
||||
style="@style/TextDefaultStyle" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/gestures_swipe_right_control"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="left|center"
|
||||
android:text="@string/settings_swipe_right"
|
||||
android:textSize="@dimen/text_large"
|
||||
tools:ignore="RtlHardcoded"
|
||||
style="@style/TextDefaultStyle" />
|
||||
|
||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||
|
||||
@@ -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">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:layout_width="match_parent"
|
||||
|
||||
@@ -76,9 +76,12 @@
|
||||
<string name="settings_manager_hidden">Hidden Apps</string>
|
||||
|
||||
<string name="settings_select_wallpaper">Select Wallpaper</string>
|
||||
<string name="settings_double_tap_lock">Double tap to lock</string>
|
||||
<string name="settings_swipe_down_notification">Swipe down expand notification</string>
|
||||
<string name="settings_swipe_up_search">Swipe up open search view</string>
|
||||
<string name="settings_double_tap">Double Tap</string>
|
||||
<string name="settings_swipe_up">Swipe Up</string>
|
||||
<string name="settings_swipe_down">Swipe Down</string>
|
||||
<string name="settings_swipe_left">Swipe Left</string>
|
||||
<string name="settings_swipe_right">Swipe Right</string>
|
||||
|
||||
|
||||
<string name="settings_search_engine">Search Engine</string>
|
||||
|
||||
@@ -92,6 +95,17 @@
|
||||
<string name="settings_reload_app_backup">Preferences backed up.</string>
|
||||
<string name="settings_reload_app_restore">Preferences restored. Restarting.</string>
|
||||
|
||||
<string name="settings_actions_open_app">Open App</string>
|
||||
<string name="settings_actions_lock_screen">Lock Screen</string>
|
||||
<string name="settings_actions_show_notifications">Show Notifications</string>
|
||||
<string name="settings_actions_show_app_list">Show Apps List</string>
|
||||
<string name="settings_actions_show_favorite_list">Show Favorites List</string>
|
||||
<string name="settings_actions_open_quick_settings">Open Quick Settings</string>
|
||||
<string name="settings_actions_show_recents">Show Recents</string>
|
||||
<string name="settings_actions_open_power_dialog">Open Power Dialog</string>
|
||||
<string name="settings_actions_take_a_screenshot">Take a ScreenShot</string>
|
||||
<string name="settings_actions_disabled">Disabled</string>
|
||||
|
||||
<string name="authentication_title">Authentication</string>
|
||||
<string name="authentication_subtitle">Log in using your biometric credentials.</string>
|
||||
<string name="authentication_cancel">Authentication Cancel</string>
|
||||
|
||||
Reference in New Issue
Block a user