Skip to content

Commit c36ffae

Browse files
Settings: gate technique switches by stored technique, not menu mode (#2242)
While the menu is open the runtime current technique is MENU, so the existing != ITEM_SCAN/RADAR/POINT_SCAN gates always passed and the "Switch to [current technique]" item always rendered. Switch to AccessTechnique.getStoredTechnique(), which reads the user's underlying technique from preferences and is unaffected by the transient MENU state. The current technique is now correctly hidden from the Settings list. Co-authored-by: Owen McGirr <o.a.mcgirr@gmail.com>
1 parent 98f2f59 commit c36ffae

1 file changed

Lines changed: 11 additions & 5 deletions

File tree

app/src/main/java/com/enaboapps/switchify/service/menu/menus/settings/SettingsMenuStructure.kt

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,15 @@ class SettingsMenuStructure(
2828
* technique (and, for radar/point scan, not in directional scan mode). The
2929
* head-control toggle appears only when camera permission has been granted.
3030
*/
31-
fun buildSettingsMenuObject(): MenuStructure = MenuStructure(
31+
fun buildSettingsMenuObject(): MenuStructure {
32+
// While the menu is open the current technique is MENU, so resolve the
33+
// user's underlying technique from preferences to gate which switches
34+
// to show.
35+
val storedTechnique = AccessTechnique.getStoredTechnique()
36+
return MenuStructure(
3237
id = MenuConstants.MenuIds.SETTINGS_MENU,
3338
items = listOfNotNull(
34-
if (AccessTechnique.getCurrentTechnique() != AccessTechnique.Technique.ITEM_SCAN) {
39+
if (storedTechnique != AccessTechnique.Technique.ITEM_SCAN) {
3540
MenuItemRegistry.getDefinition(
3641
MenuConstants.MenuIds.SETTINGS_MENU,
3742
MenuConstants.ItemIds.Settings.SWITCH_TO_ITEM_SCAN
@@ -42,7 +47,7 @@ class SettingsMenuStructure(
4247
)
4348
}
4449
} else null,
45-
if (AccessTechnique.getCurrentTechnique() != AccessTechnique.Technique.RADAR &&
50+
if (storedTechnique != AccessTechnique.Technique.RADAR &&
4651
!scanSettings.isDirectionalScanMode()
4752
) {
4853
MenuItemRegistry.getDefinition(
@@ -55,7 +60,7 @@ class SettingsMenuStructure(
5560
)
5661
}
5762
} else null,
58-
if (AccessTechnique.getCurrentTechnique() != AccessTechnique.Technique.POINT_SCAN &&
63+
if (storedTechnique != AccessTechnique.Technique.POINT_SCAN &&
5964
!scanSettings.isDirectionalScanMode()
6065
) {
6166
MenuItemRegistry.getDefinition(
@@ -117,5 +122,6 @@ class SettingsMenuStructure(
117122
),
118123
context = accessibilityService,
119124
coroutineScope = coroutineScope
120-
)
125+
)
126+
}
121127
}

0 commit comments

Comments
 (0)