Skip to content

Commit d679113

Browse files
committed
feat: complete the new advanced triggers screen
1 parent 9f47822 commit d679113

File tree

7 files changed

+37
-14
lines changed

7 files changed

+37
-14
lines changed

app/src/main/java/io/github/sds100/keymapper/MainFragment.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ class MainFragment : Fragment() {
154154

155155
backStackEntry.handleRouteArgs<NavDestination.NewKeyMap> { args ->
156156
keyMapViewModel.loadNewKeyMap(groupUid = args.groupUid)
157+
args.triggerSetupShortcut?.let { triggerViewModel.showTriggerSetup(it) }
157158
}
158159

159160
ConfigKeyMapScreen(

app/src/main/java/io/github/sds100/keymapper/trigger/ConfigTriggerViewModel.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@ import io.github.sds100.keymapper.base.trigger.ConfigTriggerUseCase
1212
import io.github.sds100.keymapper.base.trigger.RecordTriggerController
1313
import io.github.sds100.keymapper.base.trigger.TriggerSetupDelegate
1414
import io.github.sds100.keymapper.base.trigger.TriggerSetupShortcut
15-
import io.github.sds100.keymapper.base.utils.navigation.NavDestination
1615
import io.github.sds100.keymapper.base.utils.navigation.NavigationProvider
17-
import io.github.sds100.keymapper.base.utils.navigation.navigate
1816
import io.github.sds100.keymapper.base.utils.ui.DialogProvider
1917
import io.github.sds100.keymapper.base.utils.ui.ResourceProvider
2018
import kotlinx.coroutines.launch
@@ -53,7 +51,7 @@ class ConfigTriggerViewModel @Inject constructor(
5351
override fun showTriggerSetup(shortcut: TriggerSetupShortcut) {
5452
when (shortcut) {
5553
TriggerSetupShortcut.ASSISTANT -> viewModelScope.launch {
56-
navigate("purchase_assistant_trigger", NavDestination.AdvancedTriggers)
54+
navigateToAdvancedTriggers("purchase_assistant_trigger")
5755
}
5856

5957
else -> super.showTriggerSetup(shortcut)

base/src/main/java/io/github/sds100/keymapper/base/home/KeyMapListViewModel.kt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -511,9 +511,16 @@ class KeyMapListViewModel(
511511
}
512512

513513
TriggerError.ASSISTANT_TRIGGER_NOT_PURCHASED, TriggerError.FLOATING_BUTTONS_NOT_PURCHASED -> {
514-
navigate(
514+
val result = navigate(
515515
"purchase_advanced_trigger",
516516
NavDestination.AdvancedTriggers,
517+
) ?: return@launch
518+
519+
val groupUid = listKeyMaps.keyMapGroup.first().group?.uid
520+
521+
navigate(
522+
"use_advanced_trigger",
523+
NavDestination.NewKeyMap(groupUid = groupUid, triggerSetupShortcut = result)
517524
)
518525
}
519526

base/src/main/java/io/github/sds100/keymapper/base/trigger/BaseConfigTriggerViewModel.kt

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,11 +158,19 @@ abstract class BaseConfigTriggerViewModel(
158158

159159
fun onAdvancedTriggersClick() {
160160
onboarding.viewedAdvancedTriggers()
161+
161162
viewModelScope.launch {
162-
navigate("advanced_triggers_click", NavDestination.AdvancedTriggers)
163+
navigateToAdvancedTriggers("advanced_triggers_click")
163164
}
164165
}
165166

167+
suspend fun navigateToAdvancedTriggers(navKey: String) {
168+
val result: TriggerSetupShortcut =
169+
navigate(navKey, NavDestination.AdvancedTriggers) ?: return
170+
171+
showTriggerSetup(result)
172+
}
173+
166174
private fun buildUiState(
167175
keyMapState: State<KeyMap>,
168176
showDeviceDescriptors: Boolean,
@@ -461,7 +469,7 @@ abstract class BaseConfigTriggerViewModel(
461469

462470
is RecordTriggerState.Completed,
463471
RecordTriggerState.Idle,
464-
-> recordTrigger.startRecording(enableEvdevRecording = false)
472+
-> recordTrigger.startRecording(enableEvdevRecording = false)
465473
}
466474

467475
// Show dialog if the accessibility service is disabled or crashed

base/src/main/java/io/github/sds100/keymapper/base/utils/navigation/NavDestination.kt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import io.github.sds100.keymapper.base.actions.tapscreen.PickCoordinateResult
77
import io.github.sds100.keymapper.base.constraints.ConstraintData
88
import io.github.sds100.keymapper.base.system.apps.ChooseAppShortcutResult
99
import io.github.sds100.keymapper.base.system.intents.ConfigIntentResult
10+
import io.github.sds100.keymapper.base.trigger.TriggerSetupShortcut
1011
import io.github.sds100.keymapper.system.apps.ActivityInfo
1112
import io.github.sds100.keymapper.system.bluetooth.BluetoothDeviceInfo
1213
import kotlinx.serialization.Serializable
@@ -151,6 +152,11 @@ abstract class NavDestination<R>(val isCompose: Boolean = false) {
151152
data class NewKeyMap(
152153
val groupUid: String?,
153154
val floatingButtonToUse: String? = null,
155+
/**
156+
* The trigger shortcut to immediately launch
157+
* when navigating to the screen to create a key map.
158+
*/
159+
val triggerSetupShortcut: TriggerSetupShortcut? = null
154160
) : NavDestination<Unit>(isCompose = true) {
155161
override val id: String = ID_CONFIG_KEY_MAP
156162
}
@@ -177,8 +183,11 @@ abstract class NavDestination<R>(val isCompose: Boolean = false) {
177183
override val id: String = ID_LOG
178184
}
179185

186+
/**
187+
* This returns a trigger setup shortcut if an advanced trigger is used.
188+
*/
180189
@Serializable
181-
data object AdvancedTriggers : NavDestination<Unit>(isCompose = true) {
190+
data object AdvancedTriggers : NavDestination<TriggerSetupShortcut?>(isCompose = true) {
182191
override val id: String = ID_ADVANCED_TRIGGERS
183192
}
184193
}

base/src/main/java/io/github/sds100/keymapper/base/utils/navigation/NavigationProvider.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,13 +130,13 @@ class NavigationProviderImpl @Inject constructor() : NavigationProvider {
130130
}
131131

132132
/**
133-
* @param data The data in String or JSON format to return.
133+
* @param jsonData The data in String or JSON format to return.
134134
*/
135-
override suspend fun popBackStackWithResult(data: String) {
135+
override suspend fun popBackStackWithResult(jsonData: String) {
136136
_onReturnResult.subscriptionCount.first { it > 0 }
137137

138138
Timber.d("Navigation: Popping back stack with result")
139-
_onReturnResult.emit(data)
139+
_onReturnResult.emit(jsonData)
140140
}
141141
}
142142

@@ -152,7 +152,7 @@ interface NavigationProvider {
152152
val onReturnResult: StateFlow<String?>
153153
fun handledReturnResult()
154154

155-
suspend fun popBackStackWithResult(data: String)
155+
suspend fun popBackStackWithResult(jsonData: String)
156156
suspend fun popBackStack()
157157
}
158158

base/src/main/res/values/strings.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1218,7 +1218,7 @@
12181218
<string name="learn_more_button">Learn more</string>
12191219

12201220
<string name="on_screen_floating_buttons_title">On-screen floating buttons</string>
1221-
<string name="on_screen_floating_buttons_description">Make instant shortcuts and macros in any app, game or on your lock screen.</string>
1221+
<string name="on_screen_floating_buttons_description">Not enough buttons? Make instant shortcuts and macros in any app, game or on your lock screen!</string>
12221222
<string name="feature_use_in_games">Use in games</string>
12231223
<string name="feature_use_on_lock_screen">Use on lock screen</string>
12241224

@@ -1261,7 +1261,7 @@
12611261
<string name="purchasing_contact_email" translatable="false">contact@keymapper.club</string>
12621262
<string name="customer_email_subject" translatable="false">Key Mapper Pro query</string>
12631263
<string name="customer_email_body" translatable="false">Please fill the following information so I can help you.\n\n1. Device model:\n2. Android version:\n3. Key maps (make a back up in the home screen menu):\n4. Screenshot of Key Mapper home screen:\n5. Describe the problem you are having:</string>
1264-
<string name="purchase_thank_you_title">Thank you for supporting the app\u00A0❤️!</string>
1264+
<string name="purchase_thank_you_title">Thank you for supporting the app!</string>
12651265
<string name="purchase_thank_you_message">Your purchase was successful. As a paying user of Key\u00A0Mapper you will receive priority support to help you use the app. There is now a button in the shop to contact the developer.</string>
12661266
<string name="purchasing_not_implemented_bottom_sheet_text">The advanced triggers are paid feature but you downloaded the FOSS build of Key Mapper that does not include this closed source module or Google Play billing. Please download Key Mapper from Google Play to get access to this feature.</string>
12671267
<string name="purchasing_download_key_mapper_from_google_play">Download Play build</string>
@@ -1539,7 +1539,7 @@
15391539
<string name="summary_pref_pro_mode_auto_start_at_boot">PRO Mode will start itself whenever you turn on or restart your device</string>
15401540

15411541
<string name="title_pref_key_event_actions_use_system_bridge">Key event actions</string>
1542-
<string name="summary_pref_key_event_actions_use_system_bridge">Select how key event actions are run</string>
1542+
<string name="summary_pref_key_event_actions_use_system_bridge">Select how key event actions are performed</string>
15431543

15441544
<string name="pro_mode_emergency_tip_title">Emergency tip</string>
15451545
<string name="pro_mode_emergency_tip_text">If your power button stops working, hold down the power button for 10 seconds and release to disable PRO Mode.</string>

0 commit comments

Comments
 (0)