Skip to content

Commit 85edf19

Browse files
committed
#1582 show trigger shortcuts in similar way to action and constraint shortcuts
1 parent 282c06e commit 85edf19

File tree

3 files changed

+63
-25
lines changed

3 files changed

+63
-25
lines changed

app/src/main/java/io/github/sds100/keymapper/mappings/keymaps/trigger/BaseConfigTriggerViewModel.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -636,8 +636,8 @@ abstract class BaseConfigTriggerViewModel(
636636
}
637637

638638
val linkType = when {
639-
trigger.mode is TriggerMode.Sequence && (index < trigger.keys.lastIndex || shortcutCount > 0) -> LinkType.ARROW
640-
(index < trigger.keys.lastIndex || shortcutCount > 0) -> LinkType.PLUS
639+
trigger.mode is TriggerMode.Sequence && (index < trigger.keys.lastIndex) -> LinkType.ARROW
640+
(index < trigger.keys.lastIndex) -> LinkType.PLUS
641641
else -> LinkType.HIDDEN
642642
}
643643

app/src/main/java/io/github/sds100/keymapper/mappings/keymaps/trigger/TriggerScreen.kt

Lines changed: 60 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -198,13 +198,24 @@ private fun TriggerScreenVertical(
198198
textAlign = TextAlign.Center,
199199
)
200200

201-
ShortcutRow(
202-
modifier = Modifier
203-
.padding(16.dp)
204-
.fillMaxWidth(),
205-
shortcuts = configState.shortcuts,
206-
onClick = onClickShortcut,
207-
)
201+
if (configState.shortcuts.isNotEmpty()) {
202+
Column(horizontalAlignment = Alignment.CenterHorizontally) {
203+
Text(
204+
text = stringResource(R.string.trigger_shortcuts_header),
205+
style = MaterialTheme.typography.titleSmall,
206+
)
207+
208+
Spacer(Modifier.height(8.dp))
209+
210+
ShortcutRow(
211+
modifier = Modifier
212+
.padding(horizontal = 16.dp)
213+
.fillMaxWidth(),
214+
shortcuts = configState.shortcuts,
215+
onClick = onClickShortcut,
216+
)
217+
}
218+
}
208219
}
209220
}
210221

@@ -285,15 +296,30 @@ private fun TriggerScreenHorizontal(
285296
textAlign = TextAlign.Center,
286297
)
287298
Column {
288-
ShortcutRow(
289-
modifier = Modifier
290-
.padding(16.dp)
291-
.fillMaxWidth()
292-
.weight(1f)
293-
.verticalScroll(state = rememberScrollState()),
294-
shortcuts = configState.shortcuts,
295-
onClick = onClickShortcut,
296-
)
299+
if (configState.shortcuts.isNotEmpty()) {
300+
Column(
301+
modifier = Modifier
302+
.weight(1f)
303+
.verticalScroll(state = rememberScrollState()),
304+
horizontalAlignment = Alignment.CenterHorizontally,
305+
verticalArrangement = Arrangement.Center,
306+
) {
307+
Text(
308+
text = stringResource(R.string.trigger_shortcuts_header),
309+
style = MaterialTheme.typography.titleSmall,
310+
)
311+
312+
Spacer(Modifier.height(8.dp))
313+
314+
ShortcutRow(
315+
modifier = Modifier
316+
.padding(horizontal = 16.dp)
317+
.fillMaxWidth(),
318+
shortcuts = configState.shortcuts,
319+
onClick = onClickShortcut,
320+
)
321+
}
322+
}
297323

298324
RecordTriggerButtonRow(
299325
modifier = Modifier.padding(start = 8.dp, end = 8.dp, bottom = 8.dp),
@@ -419,12 +445,23 @@ private fun TriggerList(
419445
}
420446
}
421447

422-
item(key = "shortcuts", contentType = "shortcuts") {
423-
ShortcutRow(
424-
modifier = Modifier.fillMaxWidth(),
425-
shortcuts = shortcuts,
426-
onClick = { onClickShortcut(it) },
427-
)
448+
if (shortcuts.isNotEmpty()) {
449+
item(key = "shortcuts", contentType = "shortcuts") {
450+
Column(horizontalAlignment = Alignment.CenterHorizontally) {
451+
Text(
452+
text = stringResource(R.string.trigger_shortcuts_header),
453+
style = MaterialTheme.typography.titleSmall,
454+
)
455+
456+
Spacer(Modifier.height(8.dp))
457+
458+
ShortcutRow(
459+
modifier = Modifier.fillMaxWidth(),
460+
shortcuts = shortcuts,
461+
onClick = { onClickShortcut(it) },
462+
)
463+
}
464+
}
428465
}
429466
}
430467
}
@@ -521,7 +558,7 @@ private val sampleList = listOf(
521558
id = "id3",
522559
assistantType = AssistantTriggerType.DEVICE,
523560
clickType = ClickType.DOUBLE_PRESS,
524-
linkType = LinkType.ARROW,
561+
linkType = LinkType.HIDDEN,
525562
error = null,
526563
),
527564
)

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1372,6 +1372,7 @@
13721372
<string name="trigger_key_fingerprint_gesture_down">Swipe down fingerprint reader</string>
13731373
<string name="trigger_key_fingerprint_gesture_left">Swipe left fingerprint reader</string>
13741374
<string name="trigger_key_fingerprint_gesture_right">Swipe right fingerprint reader</string>
1375+
<string name="trigger_shortcuts_header">Advanced triggers</string>
13751376

13761377
<!-- Action screen -->
13771378
<string name="action_list_item_remove">Remove</string>

0 commit comments

Comments
 (0)