Gestures
This commit is contained in:
@@ -732,4 +732,21 @@
|
||||
<string name="preference_layout_search_results">Arrangement of search results</string>
|
||||
<string name="search_results_order_top_down">Top-down</string>
|
||||
<string name="search_results_order_bottom_up">Bottom-up</string>
|
||||
<string name="preference_screen_gestures">Gestures</string>
|
||||
<string name="preference_screen_gestures_summary">Gestures</string>
|
||||
<string name="preference_gesture_swipe_down">Swipe down</string>
|
||||
<string name="preference_gesture_swipe_left">Swipe left</string>
|
||||
<string name="preference_gesture_swipe_right">Swipe right</string>
|
||||
<string name="preference_gesture_double_tap">Double tap</string>
|
||||
<string name="preference_gesture_long_press">Long press</string>
|
||||
<string name="gesture_action_none">None</string>
|
||||
<string name="gesture_action_open_search">Open search</string>
|
||||
<string name="gesture_action_notifications">Open notification drawer</string>
|
||||
<string name="gesture_action_lock_screen">Turn off screen</string>
|
||||
<string name="gesture_action_quick_settings">Open quick settings</string>
|
||||
<string name="gesture_action_power_menu">Show power menu</string>
|
||||
<string name="gesture_action_recents">Open recents</string>
|
||||
<string name="gesture_failed_message">You have performed a \"%1$s\" gesture. This gesture is currently set to trigger a \"%2$s\" action. However, the action could not be performed for the following reason:</string>
|
||||
<string name="missing_permission_accessibility_gesture_failed">The launcher\'s accessibility service needs to be enabled to perform this action.</string>
|
||||
<string name="missing_permission_accessibility_gesture_settings">This action requires the launcher\'s accessibility service to be enabled.</string>
|
||||
</resources>
|
||||
@@ -47,6 +47,12 @@ interface PermissionsManager {
|
||||
* May not be called by anything else.
|
||||
*/
|
||||
fun reportNotificationListenerState(running: Boolean)
|
||||
|
||||
/**
|
||||
* Special function for the accessibility service to report its status.
|
||||
* May not be called by anything else.
|
||||
*/
|
||||
fun reportAccessibilityServiceState(running: Boolean)
|
||||
}
|
||||
|
||||
enum class PermissionGroup {
|
||||
@@ -56,6 +62,7 @@ enum class PermissionGroup {
|
||||
ExternalStorage,
|
||||
Notifications,
|
||||
AppShortcuts,
|
||||
Accessibility,
|
||||
}
|
||||
|
||||
internal class PermissionsManagerImpl(
|
||||
@@ -77,6 +84,7 @@ internal class PermissionsManagerImpl(
|
||||
checkPermissionOnce(PermissionGroup.Location)
|
||||
)
|
||||
private val notificationsPermissionState = MutableStateFlow(false)
|
||||
private val accessibilityPermissionState = MutableStateFlow(false)
|
||||
private val appShortcutsPermissionState = MutableStateFlow(
|
||||
checkPermissionOnce(PermissionGroup.AppShortcuts)
|
||||
)
|
||||
@@ -90,6 +98,7 @@ internal class PermissionsManagerImpl(
|
||||
permissionGroup.ordinal
|
||||
)
|
||||
}
|
||||
|
||||
PermissionGroup.Location -> {
|
||||
ActivityCompat.requestPermissions(
|
||||
context,
|
||||
@@ -97,6 +106,7 @@ internal class PermissionsManagerImpl(
|
||||
permissionGroup.ordinal
|
||||
)
|
||||
}
|
||||
|
||||
PermissionGroup.Contacts -> {
|
||||
ActivityCompat.requestPermissions(
|
||||
context,
|
||||
@@ -104,6 +114,7 @@ internal class PermissionsManagerImpl(
|
||||
permissionGroup.ordinal
|
||||
)
|
||||
}
|
||||
|
||||
PermissionGroup.ExternalStorage -> {
|
||||
if (isAtLeastApiLevel(Build.VERSION_CODES.R)) {
|
||||
val intent =
|
||||
@@ -120,6 +131,7 @@ internal class PermissionsManagerImpl(
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
PermissionGroup.Notifications -> {
|
||||
try {
|
||||
context.startActivity(Intent(Settings.ACTION_NOTIFICATION_LISTENER_SETTINGS))
|
||||
@@ -127,10 +139,20 @@ internal class PermissionsManagerImpl(
|
||||
CrashReporter.logException(e)
|
||||
}
|
||||
}
|
||||
|
||||
PermissionGroup.AppShortcuts -> {
|
||||
context.tryStartActivity(Intent(Settings.ACTION_MANAGE_DEFAULT_APPS_SETTINGS))
|
||||
pendingPermissionRequests.add(PermissionGroup.AppShortcuts)
|
||||
}
|
||||
|
||||
PermissionGroup.Accessibility -> {
|
||||
try {
|
||||
context.tryStartActivity(Intent(Settings.ACTION_ACCESSIBILITY_SETTINGS))
|
||||
pendingPermissionRequests.add(PermissionGroup.Accessibility)
|
||||
} catch (e: ActivityNotFoundException) {
|
||||
CrashReporter.logException(e)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -139,12 +161,15 @@ internal class PermissionsManagerImpl(
|
||||
PermissionGroup.Calendar -> {
|
||||
calendarPermissions.all { context.checkPermission(it) }
|
||||
}
|
||||
|
||||
PermissionGroup.Location -> {
|
||||
locationPermissions.all { context.checkPermission(it) }
|
||||
}
|
||||
|
||||
PermissionGroup.Contacts -> {
|
||||
contactPermissions.all { context.checkPermission(it) }
|
||||
}
|
||||
|
||||
PermissionGroup.ExternalStorage -> {
|
||||
if (isAtLeastApiLevel(Build.VERSION_CODES.R)) {
|
||||
Environment.isExternalStorageManager()
|
||||
@@ -152,12 +177,18 @@ internal class PermissionsManagerImpl(
|
||||
externalStoragePermissions.all { context.checkPermission(it) }
|
||||
}
|
||||
}
|
||||
|
||||
PermissionGroup.Notifications -> {
|
||||
notificationsPermissionState.value
|
||||
}
|
||||
|
||||
PermissionGroup.AppShortcuts -> {
|
||||
context.getSystemService<LauncherApps>()?.hasShortcutHostPermission() == true
|
||||
}
|
||||
|
||||
PermissionGroup.Accessibility -> {
|
||||
accessibilityPermissionState.value
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -169,6 +200,7 @@ internal class PermissionsManagerImpl(
|
||||
PermissionGroup.ExternalStorage -> externalStoragePermissionState
|
||||
PermissionGroup.Notifications -> notificationsPermissionState
|
||||
PermissionGroup.AppShortcuts -> appShortcutsPermissionState
|
||||
PermissionGroup.Accessibility -> accessibilityPermissionState
|
||||
}
|
||||
}
|
||||
|
||||
@@ -186,6 +218,7 @@ internal class PermissionsManagerImpl(
|
||||
PermissionGroup.ExternalStorage -> externalStoragePermissionState.value = granted
|
||||
PermissionGroup.Notifications -> notificationsPermissionState.value = granted
|
||||
PermissionGroup.AppShortcuts -> appShortcutsPermissionState.value = granted
|
||||
PermissionGroup.Accessibility -> accessibilityPermissionState.value = granted
|
||||
}
|
||||
}
|
||||
|
||||
@@ -197,10 +230,12 @@ internal class PermissionsManagerImpl(
|
||||
externalStoragePermissionState.value =
|
||||
checkPermissionOnce(PermissionGroup.ExternalStorage)
|
||||
}
|
||||
|
||||
PermissionGroup.AppShortcuts -> {
|
||||
appShortcutsPermissionState.value =
|
||||
checkPermissionOnce(PermissionGroup.AppShortcuts)
|
||||
}
|
||||
|
||||
else -> {}
|
||||
}
|
||||
iterator.remove()
|
||||
@@ -211,6 +246,10 @@ internal class PermissionsManagerImpl(
|
||||
notificationsPermissionState.value = running
|
||||
}
|
||||
|
||||
override fun reportAccessibilityServiceState(running: Boolean) {
|
||||
accessibilityPermissionState.value = running
|
||||
}
|
||||
|
||||
companion object {
|
||||
private val calendarPermissions = arrayOf(Manifest.permission.READ_CALENDAR)
|
||||
private val locationPermissions = arrayOf(
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package de.mm20.launcher2.preferences
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.Color
|
||||
import de.mm20.launcher2.preferences.Settings.SearchBarSettings.SearchBarColors
|
||||
import scheme.Scheme
|
||||
|
||||
@@ -14,11 +13,12 @@ fun createFactorySettings(context: Context): Settings {
|
||||
.setColorScheme(Settings.AppearanceSettings.ColorScheme.Default)
|
||||
.setDimWallpaper(false)
|
||||
.setBlurWallpaper(true)
|
||||
.setCustomColors(Settings.AppearanceSettings.CustomColors.newBuilder()
|
||||
.setAdvancedMode(false)
|
||||
.setBaseColors(DefaultCustomColorsBase)
|
||||
.setLightScheme(DefaultLightCustomColorScheme)
|
||||
.setDarkScheme(DefaultDarkCustomColorScheme)
|
||||
.setCustomColors(
|
||||
Settings.AppearanceSettings.CustomColors.newBuilder()
|
||||
.setAdvancedMode(false)
|
||||
.setBaseColors(DefaultCustomColorsBase)
|
||||
.setLightScheme(DefaultLightCustomColorScheme)
|
||||
.setDarkScheme(DefaultDarkCustomColorScheme)
|
||||
)
|
||||
.setFont(Settings.AppearanceSettings.Font.Outfit)
|
||||
.build()
|
||||
@@ -168,21 +168,29 @@ fun createFactorySettings(context: Context): Settings {
|
||||
.setBottomSearchBar(false)
|
||||
.setReverseSearchResults(false)
|
||||
)
|
||||
.setGestures(
|
||||
Settings.GestureSettings.newBuilder()
|
||||
.setDoubleTap(Settings.GestureSettings.GestureAction.LockScreen)
|
||||
.setLongPress(Settings.GestureSettings.GestureAction.None)
|
||||
.setSwipeDown(Settings.GestureSettings.GestureAction.OpenNotificationDrawer)
|
||||
.setSwipeLeft(Settings.GestureSettings.GestureAction.None)
|
||||
.setSwipeRight(Settings.GestureSettings.GestureAction.None)
|
||||
)
|
||||
.build()
|
||||
}
|
||||
|
||||
internal val DefaultCustomColorsBase: Settings.AppearanceSettings.CustomColors.BaseColors
|
||||
get() {
|
||||
val scheme = Scheme.light(0xFFACE330.toInt())
|
||||
return Settings.AppearanceSettings.CustomColors.BaseColors.newBuilder()
|
||||
.setAccent1(scheme.primary)
|
||||
.setAccent2(scheme.secondary)
|
||||
.setAccent3(scheme.tertiary)
|
||||
.setNeutral1(scheme.surface)
|
||||
.setNeutral2(scheme.surfaceVariant)
|
||||
.setError(scheme.error)
|
||||
.build()
|
||||
}
|
||||
get() {
|
||||
val scheme = Scheme.light(0xFFACE330.toInt())
|
||||
return Settings.AppearanceSettings.CustomColors.BaseColors.newBuilder()
|
||||
.setAccent1(scheme.primary)
|
||||
.setAccent2(scheme.secondary)
|
||||
.setAccent3(scheme.tertiary)
|
||||
.setNeutral1(scheme.surface)
|
||||
.setNeutral2(scheme.surfaceVariant)
|
||||
.setError(scheme.error)
|
||||
.build()
|
||||
}
|
||||
|
||||
internal val DefaultLightCustomColorScheme: Settings.AppearanceSettings.CustomColors.Scheme
|
||||
get() {
|
||||
|
||||
+9
@@ -1,6 +1,7 @@
|
||||
package de.mm20.launcher2.preferences.migrations
|
||||
|
||||
import de.mm20.launcher2.preferences.Settings
|
||||
import de.mm20.launcher2.preferences.Settings.GestureSettings
|
||||
import de.mm20.launcher2.preferences.Settings.LayoutSettings
|
||||
|
||||
class Migration_11_12: VersionedMigration(11, 12) {
|
||||
@@ -30,6 +31,14 @@ class Migration_11_12: VersionedMigration(11, 12) {
|
||||
.setBottomSearchBar(false)
|
||||
.setReverseSearchResults(false)
|
||||
)
|
||||
.setGestures(
|
||||
GestureSettings.newBuilder()
|
||||
.setDoubleTap(GestureSettings.GestureAction.LockScreen)
|
||||
.setLongPress(GestureSettings.GestureAction.None)
|
||||
.setSwipeDown(GestureSettings.GestureAction.OpenNotificationDrawer)
|
||||
.setSwipeLeft(GestureSettings.GestureAction.None)
|
||||
.setSwipeRight(GestureSettings.GestureAction.None)
|
||||
)
|
||||
}
|
||||
}
|
||||
return builder
|
||||
|
||||
@@ -299,4 +299,22 @@ message Settings {
|
||||
bool reverse_search_results = 3;
|
||||
}
|
||||
LayoutSettings layout = 27;
|
||||
|
||||
message GestureSettings {
|
||||
enum GestureAction {
|
||||
None = 0;
|
||||
OpenSearch = 1;
|
||||
OpenNotificationDrawer = 2;
|
||||
LockScreen = 3;
|
||||
OpenQuickSettings = 4;
|
||||
OpenRecents = 5;
|
||||
OpenPowerDialog = 6;
|
||||
}
|
||||
GestureAction swipe_down = 1;
|
||||
GestureAction swipe_left = 2;
|
||||
GestureAction swipe_right = 3;
|
||||
GestureAction double_tap = 4;
|
||||
GestureAction long_press = 5;
|
||||
}
|
||||
GestureSettings gestures = 28;
|
||||
}
|
||||
Reference in New Issue
Block a user