Skip to content

Commit ef110d4

Browse files
committed
show text when getevent output is empty
1 parent e20e340 commit ef110d4

2 files changed

Lines changed: 29 additions & 16 deletions

File tree

base/src/main/java/io/github/sds100/keymapper/base/debug/GetEventScreen.kt

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ private enum class RefreshButtonState {
9595
@Composable
9696
private fun GetEventScreen(
9797
modifier: Modifier = Modifier,
98-
state: GetEventViewModel.State,
98+
state: GetEventState,
9999
onBackClick: () -> Unit = {},
100100
onToggleRecordClick: () -> Unit = {},
101101
onRefreshDeviceInfoClick: () -> Unit = {},
@@ -309,11 +309,15 @@ private fun ExpertModeSetupCard(
309309
}
310310

311311
@Composable
312-
private fun InfoContent(modifier: Modifier = Modifier, state: GetEventViewModel.State) {
312+
private fun InfoContent(modifier: Modifier = Modifier, state: GetEventState) {
313313
Column(modifier = modifier) {
314314
if (state.isLoadingDeviceInfo) {
315315
Spacer(Modifier.height(16.dp))
316-
LinearProgressIndicator(modifier = Modifier.fillMaxWidth().padding(horizontal = 16.dp))
316+
LinearProgressIndicator(
317+
modifier = Modifier
318+
.fillMaxWidth()
319+
.padding(horizontal = 16.dp),
320+
)
317321
}
318322

319323
if (state.deviceInfoOutput.isNotEmpty()) {
@@ -339,7 +343,7 @@ private fun InfoContent(modifier: Modifier = Modifier, state: GetEventViewModel.
339343
}
340344

341345
@Composable
342-
private fun EventsContent(modifier: Modifier = Modifier, state: GetEventViewModel.State) {
346+
private fun EventsContent(modifier: Modifier = Modifier, state: GetEventState) {
343347
val verticalScrollState = rememberScrollState()
344348

345349
LaunchedEffect(state.recordingOutput) {
@@ -351,15 +355,23 @@ private fun EventsContent(modifier: Modifier = Modifier, state: GetEventViewMode
351355
Column(modifier = modifier) {
352356
if (state.isRecording) {
353357
Spacer(Modifier.height(16.dp))
354-
LinearProgressIndicator(modifier = Modifier.fillMaxWidth().padding(horizontal = 16.dp))
358+
LinearProgressIndicator(
359+
modifier = Modifier
360+
.fillMaxWidth()
361+
.padding(horizontal = 16.dp),
362+
)
355363
Text(
356364
modifier = Modifier.padding(horizontal = 16.dp, vertical = 8.dp),
357365
text = stringResource(R.string.debug_getevent_events_output_after_recording),
358366
style = MaterialTheme.typography.bodySmall,
359367
)
360-
}
361-
362-
if (!state.isRecording && state.recordingOutput.isNotEmpty()) {
368+
} else if (state.recordingOutput.isEmpty()) {
369+
Text(
370+
modifier = Modifier.padding(horizontal = 16.dp, vertical = 8.dp),
371+
text = stringResource(R.string.debug_getevent_events_empty),
372+
style = MaterialTheme.typography.bodySmall,
373+
)
374+
} else {
363375
SelectionContainer(
364376
modifier = Modifier
365377
.weight(1f)
@@ -386,7 +398,7 @@ private fun EventsContent(modifier: Modifier = Modifier, state: GetEventViewMode
386398
private fun PreviewInfoTab() {
387399
KeyMapperTheme {
388400
GetEventScreen(
389-
state = GetEventViewModel.State(
401+
state = GetEventState(
390402
deviceInfoOutput = """add device 1: /dev/input/event0
391403
bus: 0019
392404
vendor 0001
@@ -423,7 +435,7 @@ add device 2: /dev/input/event1
423435
private fun PreviewInfoTabLoading() {
424436
KeyMapperTheme {
425437
GetEventScreen(
426-
state = GetEventViewModel.State(
438+
state = GetEventState(
427439
isLoadingDeviceInfo = true,
428440
expertModeStatus = ExpertModeStatus.ENABLED,
429441
),
@@ -436,7 +448,7 @@ private fun PreviewInfoTabLoading() {
436448
private fun PreviewInfoTabEmptyOutput() {
437449
KeyMapperTheme {
438450
GetEventScreen(
439-
state = GetEventViewModel.State(
451+
state = GetEventState(
440452
expertModeStatus = ExpertModeStatus.ENABLED,
441453
),
442454
)
@@ -448,7 +460,7 @@ private fun PreviewInfoTabEmptyOutput() {
448460
private fun PreviewRecording() {
449461
KeyMapperTheme {
450462
GetEventScreen(
451-
state = GetEventViewModel.State(
463+
state = GetEventState(
452464
recordingOutput = """/dev/input/event1: EV_KEY KEY_VOLUMEDOWN DOWN
453465
/dev/input/event1: EV_SYN SYN_REPORT 00""",
454466
isRecording = true,
@@ -463,7 +475,7 @@ private fun PreviewRecording() {
463475
private fun PreviewEventsContentOutputIdle() {
464476
KeyMapperTheme {
465477
GetEventScreen(
466-
state = GetEventViewModel.State(
478+
state = GetEventState(
467479
recordingOutput = """/dev/input/event2: EV_KEY KEY_VOLUMEUP DOWN
468480
/dev/input/event2: EV_SYN SYN_REPORT 00""",
469481
isRecording = false,
@@ -478,7 +490,7 @@ private fun PreviewEventsContentOutputIdle() {
478490
private fun PreviewInfoContentOutputAndLoading() {
479491
KeyMapperTheme {
480492
GetEventScreen(
481-
state = GetEventViewModel.State(
493+
state = GetEventState(
482494
deviceInfoOutput = """add device 3: /dev/input/event2
483495
bus: 0019
484496
vendor 0001
@@ -498,7 +510,7 @@ private fun PreviewInfoContentOutputAndLoading() {
498510
private fun PreviewExpertModeDisabled() {
499511
KeyMapperTheme {
500512
GetEventScreen(
501-
state = GetEventViewModel.State(
513+
state = GetEventState(
502514
expertModeStatus = ExpertModeStatus.DISABLED,
503515
),
504516
)

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -650,6 +650,7 @@
650650
<string name="debug_getevent_tab_info">Info</string>
651651
<string name="debug_getevent_tab_events">Events</string>
652652
<string name="debug_getevent_events_output_after_recording">Output appears after recording stops.</string>
653+
<string name="debug_getevent_events_empty">Record events by tapping the record button below. All key maps will be temporarily paused.</string>
653654

654655
<string name="title_pref_report_issue">Report issue</string>
655656

@@ -1462,7 +1463,7 @@
14621463
<string name="customer_email_subject_risk_free" translatable="false">Key Mapper refund query</string>
14631464
<string name="customer_email_subject_bug_report" translatable="false">Key Mapper Bug report</string>
14641465
<string name="customer_email_body" translatable="false">Please fill the following information so I can help you.\n\n1. Device model: %s\n2. Android version: %s\n3. Key Mapper version: %s\n4, Key maps (make a backup in the home screen menu)\n6. Screenshot of Key Mapper home screen\n6. Describe the problem you are having</string>
1465-
<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>
1466+
<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>
14661467
<string name="customer_email_subject_foss_support" translatable="false">Key Mapper FOSS support</string>
14671468
<string name="foss_advanced_triggers_support_body_main">Floating Buttons and Assistant trigger aren\'t sold in this FOSS build because RevenueCat and Google Play in-app billing aren\'t included.\n\nYou can still support development on Ko-fi.</string>
14681469
<string name="foss_advanced_triggers_support_contact_prefix">If you donate and later want those products,\ </string>

0 commit comments

Comments
 (0)