@@ -5,7 +5,9 @@ import android.content.Intent
55import android.os.Build
66import androidx.activity.compose.rememberLauncherForActivityResult
77import androidx.activity.result.contract.ActivityResultContracts.CreateDocument
8+ import androidx.compose.foundation.layout.Arrangement
89import androidx.compose.foundation.layout.Column
10+ import androidx.compose.foundation.layout.FlowRow
911import androidx.compose.foundation.layout.Spacer
1012import androidx.compose.foundation.layout.calculateEndPadding
1113import androidx.compose.foundation.layout.calculateStartPadding
@@ -63,6 +65,7 @@ import io.github.sds100.keymapper.base.compose.KeyMapperTheme
6365import io.github.sds100.keymapper.base.utils.ui.compose.KeyMapperSegmentedButtonRow
6466import io.github.sds100.keymapper.base.utils.ui.compose.OptionPageButton
6567import io.github.sds100.keymapper.base.utils.ui.compose.OptionsHeaderRow
68+ import io.github.sds100.keymapper.base.utils.ui.compose.RadioButtonText
6669import io.github.sds100.keymapper.base.utils.ui.compose.SwitchPreferenceCompose
6770import io.github.sds100.keymapper.base.utils.ui.compose.icons.FolderManaged
6871import io.github.sds100.keymapper.base.utils.ui.compose.icons.KeyMapperIcons
@@ -172,6 +175,7 @@ fun SettingsScreen(modifier: Modifier = Modifier, viewModel: SettingsViewModel)
172175 }
173176 },
174177 onShareLogcatClick = viewModel::onShareLogcatClick,
178+ onKeyEventActionMethodSelected = viewModel::onKeyEventActionMethodSelected
175179 )
176180 }
177181}
@@ -247,11 +251,13 @@ private fun Content(
247251 onShareLogcatClick : () -> Unit = { },
248252 onHideHomeScreenAlertsToggled : (Boolean ) -> Unit = { },
249253 onShowDeviceDescriptorsToggled : (Boolean ) -> Unit = { },
254+ onKeyEventActionMethodSelected : (isProModeSelected: Boolean ) -> Unit = {}
250255) {
251256 Column (
252257 modifier
253258 .verticalScroll(rememberScrollState())
254259 .padding(horizontal = 16 .dp),
260+ verticalArrangement = Arrangement .spacedBy(8 .dp)
255261 ) {
256262 Spacer (modifier = Modifier .height(8 .dp))
257263
@@ -261,8 +267,6 @@ private fun Content(
261267 text = stringResource(R .string.settings_section_customize_experience_title),
262268 )
263269
264- Spacer (modifier = Modifier .height(8 .dp))
265-
266270 Text (
267271 text = stringResource(R .string.title_pref_dark_theme),
268272 style = MaterialTheme .typography.bodyLarge,
@@ -274,7 +278,6 @@ private fun Content(
274278 Theme .DARK to stringResource(R .string.theme_dark),
275279 )
276280
277- Spacer (modifier = Modifier .height(8 .dp))
278281
279282 KeyMapperSegmentedButtonRow (
280283 modifier = Modifier .fillMaxWidth(),
@@ -283,7 +286,6 @@ private fun Content(
283286 onStateSelected = onThemeSelected,
284287 )
285288
286- Spacer (modifier = Modifier .height(8 .dp))
287289
288290 OptionPageButton (
289291 title = stringResource(R .string.title_pref_show_toggle_keymaps_notification),
@@ -292,7 +294,6 @@ private fun Content(
292294 onClick = onPauseResumeNotificationClick,
293295 )
294296
295- Spacer (modifier = Modifier .height(8 .dp))
296297
297298 SwitchPreferenceCompose (
298299 title = stringResource(R .string.title_pref_hide_home_screen_alerts),
@@ -302,15 +303,13 @@ private fun Content(
302303 onCheckedChange = onHideHomeScreenAlertsToggled,
303304 )
304305
305- Spacer (modifier = Modifier .height(8 .dp))
306306
307307 OptionsHeaderRow (
308308 modifier = Modifier .fillMaxWidth(),
309309 icon = Icons .Outlined .Gamepad ,
310310 text = stringResource(R .string.settings_section_key_maps_title),
311311 )
312312
313- Spacer (modifier = Modifier .height(8 .dp))
314313
315314 OptionPageButton (
316315 title = stringResource(R .string.title_pref_default_options),
@@ -319,7 +318,6 @@ private fun Content(
319318 onClick = onDefaultOptionsClick,
320319 )
321320
322- Spacer (modifier = Modifier .height(8 .dp))
323321
324322 SwitchPreferenceCompose (
325323 title = stringResource(R .string.title_pref_force_vibrate),
@@ -329,7 +327,6 @@ private fun Content(
329327 onCheckedChange = onForceVibrateToggled,
330328 )
331329
332- Spacer (modifier = Modifier .height(8 .dp))
333330
334331 SwitchPreferenceCompose (
335332 title = stringResource(R .string.title_pref_show_device_descriptors),
@@ -339,15 +336,13 @@ private fun Content(
339336 onCheckedChange = onShowDeviceDescriptorsToggled,
340337 )
341338
342- Spacer (modifier = Modifier .height(8 .dp))
343339
344340 OptionsHeaderRow (
345341 modifier = Modifier .fillMaxWidth(),
346342 icon = KeyMapperIcons .FolderManaged ,
347343 text = stringResource(R .string.settings_section_data_management_title),
348344 )
349345
350- Spacer (modifier = Modifier .height(8 .dp))
351346
352347 OptionPageButton (
353348 title = if (state.autoBackupLocation == null ) {
@@ -361,15 +356,22 @@ private fun Content(
361356 onClick = onAutomaticBackupClick,
362357 )
363358
364- Spacer (modifier = Modifier .height(8 .dp))
365359
366360 OptionsHeaderRow (
367361 modifier = Modifier .fillMaxWidth(),
368362 icon = Icons .Rounded .Construction ,
369363 text = stringResource(R .string.settings_section_power_user_title),
370364 )
371365
372- Spacer (modifier = Modifier .height(8 .dp))
366+
367+ KeyEventActionMethodRow (
368+ modifier = Modifier
369+ .fillMaxWidth()
370+ .padding(horizontal = 16 .dp),
371+ isProModeSelected = state.keyEventActionsUseSystemBridege,
372+ onSelected = onKeyEventActionMethodSelected
373+ )
374+
373375
374376 OptionPageButton (
375377 title = stringResource(R .string.title_pref_pro_mode),
@@ -401,15 +403,13 @@ private fun Content(
401403 enabled = isAutoSwitchImeSupported,
402404 )
403405
404- Spacer (modifier = Modifier .height(8 .dp))
405406
406407 OptionsHeaderRow (
407408 modifier = Modifier .fillMaxWidth(),
408409 icon = Icons .Rounded .Code ,
409410 text = stringResource(R .string.settings_section_debugging_title),
410411 )
411412
412- Spacer (modifier = Modifier .height(8 .dp))
413413
414414 SwitchPreferenceCompose (
415415 title = stringResource(R .string.title_pref_toggle_logging),
@@ -419,8 +419,6 @@ private fun Content(
419419 onCheckedChange = onLoggingToggled,
420420 )
421421
422- Spacer (modifier = Modifier .height(8 .dp))
423-
424422 OptionPageButton (
425423 title = stringResource(R .string.title_pref_view_and_share_log),
426424 text = stringResource(R .string.summary_pref_view_and_share_log),
@@ -439,7 +437,47 @@ private fun Content(
439437 }
440438}
441439
442- @Preview(heightDp = 1200 )
440+ @Composable
441+ private fun KeyEventActionMethodRow (
442+ modifier : Modifier = Modifier ,
443+ isProModeSelected : Boolean ,
444+ onSelected : (isProModeSelected: Boolean ) -> Unit
445+ ) {
446+ Column (modifier) {
447+ val buttonStates = listOf (
448+ false to stringResource(R .string.fix_key_event_action_input_method_title),
449+ true to stringResource(R .string.pro_mode_app_bar_title)
450+ )
451+
452+ Text (
453+ text = stringResource(R .string.title_pref_key_event_actions_use_system_bridge),
454+ style = MaterialTheme .typography.bodyLarge
455+ )
456+
457+ Text (
458+ text = stringResource(R .string.summary_pref_key_event_actions_use_system_bridge),
459+ style = MaterialTheme .typography.bodyMedium
460+ )
461+
462+ Spacer (modifier = Modifier .height(8 .dp))
463+
464+ FlowRow (
465+ modifier = Modifier .fillMaxWidth(),
466+ horizontalArrangement = Arrangement .spacedBy(16 .dp),
467+ verticalArrangement = Arrangement .spacedBy(4 .dp)
468+ ) {
469+ for ((isProMode, text) in buttonStates) {
470+ RadioButtonText (
471+ text = text,
472+ isSelected = isProMode == isProModeSelected,
473+ onSelected = { onSelected(isProMode) },
474+ )
475+ }
476+ }
477+ }
478+ }
479+
480+ @Preview(heightDp = 1500 )
443481@Composable
444482private fun Preview () {
445483 KeyMapperTheme {
@@ -449,4 +487,4 @@ private fun Preview() {
449487 )
450488 }
451489 }
452- }
490+ }
0 commit comments