Redesign gesture settings
This commit is contained in:
10
core/base/src/main/res/drawable/action_key_24px.xml
Normal file
10
core/base/src/main/res/drawable/action_key_24px.xml
Normal file
@@ -0,0 +1,10 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="960"
|
||||
android:viewportHeight="960"
|
||||
android:tint="?attr/colorControlNormal">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M660,820Q594,820 547,773Q500,726 500,660Q500,594 547,547Q594,500 660,500Q726,500 773,547Q820,594 820,660Q820,683 814,703.5Q808,724 797,742L892,836Q898,841 901,848.5Q904,856 904,864Q904,872 901,879Q898,886 892,892Q887,897 879.5,900Q872,903 864,903Q856,903 849,900Q842,897 836,892L741,798Q723,809 702.5,814.5Q682,820 660,820ZM220,820Q154,820 107,773Q60,726 60,660Q60,594 107,547Q154,500 220,500Q286,500 333,547Q380,594 380,660Q380,726 333,773Q286,820 220,820ZM220,740Q253,740 276.5,716.5Q300,693 300,660Q300,627 276.5,603.5Q253,580 220,580Q187,580 163.5,603.5Q140,627 140,660Q140,693 163.5,716.5Q187,740 220,740ZM660,740Q693,740 716.5,716.5Q740,693 740,660Q740,627 716.5,603.5Q693,580 660,580Q627,580 603.5,603.5Q580,627 580,660Q580,693 603.5,716.5Q627,740 660,740ZM220,380Q154,380 107,333Q60,286 60,220Q60,154 107,107Q154,60 220,60Q286,60 333,107Q380,154 380,220Q380,286 333,333Q286,380 220,380ZM660,380Q594,380 547,333Q500,286 500,220Q500,154 547,107Q594,60 660,60Q726,60 773,107Q820,154 820,220Q820,286 773,333Q726,380 660,380ZM220,300Q253,300 276.5,276.5Q300,253 300,220Q300,187 276.5,163.5Q253,140 220,140Q187,140 163.5,163.5Q140,187 140,220Q140,253 163.5,276.5Q187,300 220,300ZM660,300Q693,300 716.5,276.5Q740,253 740,220Q740,187 716.5,163.5Q693,140 660,140Q627,140 603.5,163.5Q580,187 580,220Q580,253 603.5,276.5Q627,300 660,300ZM220,660Q220,660 220,660Q220,660 220,660Q220,660 220,660Q220,660 220,660Q220,660 220,660Q220,660 220,660Q220,660 220,660Q220,660 220,660ZM220,220Q220,220 220,220Q220,220 220,220Q220,220 220,220Q220,220 220,220Q220,220 220,220Q220,220 220,220Q220,220 220,220Q220,220 220,220ZM660,220Q660,220 660,220Q660,220 660,220Q660,220 660,220Q660,220 660,220Q660,220 660,220Q660,220 660,220Q660,220 660,220Q660,220 660,220Z"/>
|
||||
</vector>
|
||||
10
core/base/src/main/res/drawable/amp_stories_24px.xml
Normal file
10
core/base/src/main/res/drawable/amp_stories_24px.xml
Normal file
@@ -0,0 +1,10 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="960"
|
||||
android:viewportHeight="960"
|
||||
android:tint="?attr/colorControlNormal">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M320,800Q303,800 291.5,788.5Q280,777 280,760L280,200Q280,183 291.5,171.5Q303,160 320,160L640,160Q657,160 668.5,171.5Q680,183 680,200L680,760Q680,777 668.5,788.5Q657,800 640,800L320,800ZM120,680L120,279Q120,262 131.5,251Q143,240 160,240Q177,240 188.5,251.5Q200,263 200,280L200,681Q200,698 188.5,709Q177,720 160,720Q143,720 131.5,708.5Q120,697 120,680ZM760,680L760,279Q760,262 771.5,251Q783,240 800,240Q817,240 828.5,251.5Q840,263 840,280L840,681Q840,698 828.5,709Q817,720 800,720Q783,720 771.5,708.5Q760,697 760,680ZM360,720L600,720L600,240L360,240L360,720ZM360,720L360,240L360,240L360,720Z"/>
|
||||
</vector>
|
||||
10
core/base/src/main/res/drawable/widgets_add_24px.xml
Normal file
10
core/base/src/main/res/drawable/widgets_add_24px.xml
Normal file
@@ -0,0 +1,10 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="960"
|
||||
android:viewportHeight="960"
|
||||
android:tint="?attr/colorControlNormal">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M638,492L468,322Q462,316 459.5,309Q457,302 457,294Q457,286 459.5,279Q462,272 468,266L638,96Q644,90 651,87.5Q658,85 666,85Q674,85 681,87.5Q688,90 694,96L864,266Q870,272 872.5,279Q875,286 875,294Q875,302 872.5,309Q870,316 864,322L694,492Q688,498 681,500.5Q674,503 666,503Q658,503 651,500.5Q644,498 638,492ZM120,400L120,160Q120,143 131.5,131.5Q143,120 160,120L400,120Q417,120 428.5,131.5Q440,143 440,160L440,400Q440,417 428.5,428.5Q417,440 400,440L160,440Q143,440 131.5,428.5Q120,417 120,400ZM120,800L120,560Q120,543 131.5,531.5Q143,520 160,520L400,520Q417,520 428.5,531.5Q440,543 440,560L440,800Q440,817 428.5,828.5Q417,840 400,840L160,840Q143,840 131.5,828.5Q120,817 120,800ZM200,360L360,360L360,200L200,200L200,360ZM667,408L780,295L667,182L554,295L667,408ZM200,760L360,760L360,600L200,600L200,760ZM360,360L360,360L360,360L360,360ZM554,295L554,295L554,295L554,295ZM360,600L360,600L360,600L360,600ZM600,600L600,600L600,600L600,600Z M680,840Q663,840 651.5,828.5Q640,817 640,800L640,720L559,720Q542,720 531,708.5Q520,697 520,680Q520,663 531.5,651.5Q543,640 560,640L640,640L640,559Q640,542 651.5,531Q663,520 680,520Q697,520 708.5,531.5Q720,543 720,560L720,640L801,640Q818,640 829,651.5Q840,663 840,680Q840,697 828.5,708.5Q817,720 800,720L720,720L720,801Q720,818 708.5,829Q697,840 680,840Z"/>
|
||||
</vector>
|
||||
@@ -812,15 +812,21 @@
|
||||
<string name="preference_gesture_long_press">Long press</string>
|
||||
<string name="preference_gesture_home_button">Home button/gesture</string>
|
||||
<string name="gesture_action_none">Do nothing</string>
|
||||
<string name="gesture_action_open_search">Open search</string>
|
||||
<string name="gesture_action_category_launcher">Launcher pages</string>
|
||||
<string name="gesture_action_category_system">System actions</string>
|
||||
<string name="gesture_action_category_apps">Apps and shortcuts</string>
|
||||
<string name="gesture_action_open_search">Search / app drawer</string>
|
||||
<string name="gesture_action_widgets">Widgets</string>
|
||||
<string name="gesture_action_widgets_indexed">Widgets %1$d</string>
|
||||
<string name="gesture_action_widgets_new">New widgets page</string>
|
||||
<string name="gesture_action_widgets_empty">Empty</string>
|
||||
<string name="gesture_action_widgets_indexed">Widgets (%1$d)</string>
|
||||
<string name="gesture_action_launch_app">Launch app</string>
|
||||
<string name="gesture_action_notifications">Open notification drawer</string>
|
||||
<string name="gesture_action_launch_select_app">Select app or shortcut</string>
|
||||
<string name="gesture_action_notifications">Notifications</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 recent apps</string>
|
||||
<string name="gesture_action_quick_settings">Quick settings</string>
|
||||
<string name="gesture_action_power_menu">Power menu</string>
|
||||
<string name="gesture_action_recents">Recent apps</string>
|
||||
<string name="gesture_action_feed">Feed</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>
|
||||
|
||||
@@ -18,7 +18,7 @@ enum class WidgetScreenTarget {
|
||||
* Returns the UUID used as parent identifier for widget repository operations.
|
||||
* These are deterministic UUIDs generated using UUID v5 (name-based).
|
||||
*/
|
||||
val scopeId: UUID
|
||||
val id: UUID
|
||||
get() = when (this) {
|
||||
Widgets1 -> UUID.fromString("00000000-0000-0000-0000-000000000001")
|
||||
Widgets2 -> UUID.fromString("00000000-0000-0000-0000-000000000002")
|
||||
@@ -31,15 +31,5 @@ enum class WidgetScreenTarget {
|
||||
* The default widget screen target
|
||||
*/
|
||||
val Default = Widgets1
|
||||
|
||||
/**
|
||||
* Get list of available widget screen targets based on configured count.
|
||||
* @param count Number of widget screens to make available (1-4)
|
||||
* @return List of WidgetScreenTarget enum values
|
||||
*/
|
||||
fun getAvailableTargets(count: Int): List<WidgetScreenTarget> {
|
||||
val all = listOf(Widgets1, Widgets2, Widgets3, Widgets4)
|
||||
return all.take(count.coerceIn(1, 4))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -379,44 +379,4 @@ class UiSettings internal constructor(
|
||||
it.copy(widgetsEditButton = editButton)
|
||||
}
|
||||
}
|
||||
|
||||
val widgetScreenCount
|
||||
get() = launcherDataStore.data.map {
|
||||
it.widgetScreenCount.coerceIn(1, 4)
|
||||
}.distinctUntilChanged()
|
||||
|
||||
fun setWidgetScreenCount(count: Int) {
|
||||
val validCount = count.coerceIn(1, 4)
|
||||
launcherDataStore.update { data ->
|
||||
var updatedData = data.copy(widgetScreenCount = validCount)
|
||||
|
||||
// Auto-reset gestures that point to invalid widget screens
|
||||
val resetGesture: (GestureAction) -> GestureAction = { action ->
|
||||
if (action is GestureAction.Widgets) {
|
||||
val targetIndex = when (action.target) {
|
||||
WidgetScreenTarget.Widgets1 -> 1
|
||||
WidgetScreenTarget.Widgets2 -> 2
|
||||
WidgetScreenTarget.Widgets3 -> 3
|
||||
WidgetScreenTarget.Widgets4 -> 4
|
||||
else -> 0
|
||||
}
|
||||
if (targetIndex > validCount) GestureAction.NoAction else action
|
||||
} else {
|
||||
action
|
||||
}
|
||||
}
|
||||
|
||||
updatedData = updatedData.copy(
|
||||
gesturesSwipeUp = resetGesture(updatedData.gesturesSwipeUp),
|
||||
gesturesSwipeDown = resetGesture(updatedData.gesturesSwipeDown),
|
||||
gesturesSwipeLeft = resetGesture(updatedData.gesturesSwipeLeft),
|
||||
gesturesSwipeRight = resetGesture(updatedData.gesturesSwipeRight),
|
||||
gesturesDoubleTap = resetGesture(updatedData.gesturesDoubleTap),
|
||||
gesturesLongPress = resetGesture(updatedData.gesturesLongPress),
|
||||
gesturesHomeButton = resetGesture(updatedData.gesturesHomeButton),
|
||||
)
|
||||
|
||||
updatedData
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user