Skip to content

Commit e32b2b7

Browse files
4di-helloclaude
andcommitted
Settings: a field to try the keyboard on the appearance and suggestion screens
To see a changed theme, key size or suggestion setting, one had to leave the settings and open another app. A text field at the top of the appearance and suggestion screens lets you try the keyboard right there. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VuiaMhLXwhErf9shhrr1uD
1 parent 5966a60 commit e32b2b7

5 files changed

Lines changed: 57 additions & 2 deletions

File tree

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// SPDX-License-Identifier: GPL-3.0-only
2+
package helium314.keyboard.settings
3+
4+
import androidx.compose.foundation.layout.fillMaxWidth
5+
import androidx.compose.foundation.layout.padding
6+
import androidx.compose.material3.Icon
7+
import androidx.compose.material3.IconButton
8+
import androidx.compose.material3.MaterialTheme
9+
import androidx.compose.material3.OutlinedTextField
10+
import androidx.compose.material3.Text
11+
import androidx.compose.runtime.Composable
12+
import androidx.compose.runtime.getValue
13+
import androidx.compose.runtime.saveable.rememberSaveable
14+
import androidx.compose.runtime.setValue
15+
import androidx.compose.runtime.mutableStateOf
16+
import androidx.compose.ui.Modifier
17+
import androidx.compose.ui.res.painterResource
18+
import androidx.compose.ui.res.stringResource
19+
import androidx.compose.ui.unit.dp
20+
import helium314.keyboard.latin.R
21+
22+
/**
23+
* Text field to try the keyboard directly in the settings, e.g. to see a changed theme
24+
* or key size without leaving the settings.
25+
*/
26+
@Composable
27+
fun KeyboardTestField(modifier: Modifier = Modifier) {
28+
var text by rememberSaveable { mutableStateOf("") }
29+
OutlinedTextField(
30+
value = text,
31+
onValueChange = { text = it },
32+
label = { Text(stringResource(R.string.keyboard_test_field)) },
33+
supportingText = { Text(stringResource(R.string.keyboard_test_field_hint)) },
34+
trailingIcon = if (text.isEmpty()) null else {
35+
{
36+
IconButton(onClick = { text = "" }) {
37+
Icon(painterResource(R.drawable.ic_close), stringResource(R.string.delete))
38+
}
39+
}
40+
},
41+
textStyle = contentTextDirectionStyle.merge(MaterialTheme.typography.bodyLarge),
42+
maxLines = 3,
43+
modifier = modifier
44+
.fillMaxWidth()
45+
.padding(horizontal = 16.dp, vertical = 4.dp)
46+
)
47+
}

‎app/src/main/java/helium314/keyboard/settings/screens/AppearanceScreen.kt‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import helium314.keyboard.settings.preferences.ListPreference
2929
import helium314.keyboard.settings.SettingsWithoutKey
3030
import helium314.keyboard.settings.Setting
3131
import helium314.keyboard.settings.preferences.Preference
32+
import helium314.keyboard.settings.KeyboardTestField
3233
import helium314.keyboard.settings.SearchSettingsScreen
3334
import helium314.keyboard.settings.SettingsActivity
3435
import helium314.keyboard.settings.preferences.SliderPreference
@@ -158,7 +159,8 @@ fun AppearanceScreen(
158159
SearchSettingsScreen(
159160
onClickBack = onClickBack,
160161
title = stringResource(R.string.settings_screen_appearance),
161-
settings = items
162+
settings = items,
163+
headerContent = { KeyboardTestField() },
162164
)
163165
}
164166

‎app/src/main/java/helium314/keyboard/settings/screens/SuggestionsScreen.kt‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ import helium314.keyboard.latin.utils.ToolbarMode
4040
import helium314.keyboard.latin.utils.getActivity
4141
import helium314.keyboard.latin.utils.prefs
4242
import helium314.keyboard.settings.fineTuneExpanded
43+
import helium314.keyboard.settings.KeyboardTestField
4344
import helium314.keyboard.settings.SearchSettingsScreen
4445
import helium314.keyboard.settings.Setting
4546
import helium314.keyboard.settings.SettingsActivity
@@ -109,7 +110,8 @@ fun SuggestionsScreen(
109110
SearchSettingsScreen(
110111
onClickBack = onClickBack,
111112
title = stringResource(R.string.settings_screen_suggestions),
112-
settings = items
113+
settings = items,
114+
headerContent = { KeyboardTestField() },
113115
)
114116
}
115117

‎app/src/main/res/values-de/strings.xml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,8 @@
135135
<string name="voice" tools:keep="@string/voice">Spracheingabe</string>
136136
<string name="theme_name_dynamic" tools:keep="@string/theme_name_dynamic">Dynamische Farben</string>
137137
<string name="settings_screen_appearance">Aussehen</string>
138+
<string name="keyboard_test_field">Tastatur hier ausprobieren</string>
139+
<string name="keyboard_test_field_hint">Änderungen sind beim nächsten Öffnen der Tastatur sichtbar</string>
138140
<string name="show_popup_hints">Funktionale Hinweise anzeigen</string>
139141
<string name="message_add_custom_layout">Datei in einem kompatiblen Format auswählen. Information zu den Formaten ist %s verfügbar.</string>
140142
<string name="select_color_key_background">Tastenhintergrund</string>

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1456,6 +1456,8 @@ New dictionary:
14561456
<string name="app_language_system">System default</string>
14571457
<!-- Settings screen title for appearance preferences -->
14581458
<string name="settings_screen_appearance">Appearance</string>
1459+
<string name="keyboard_test_field">Try the keyboard here</string>
1460+
<string name="keyboard_test_field_hint">Changes are shown the next time the keyboard opens</string>
14591461
<!-- Settings screen title for toolbar preferences -->
14601462
<string name="settings_screen_toolbar">Toolbar</string>
14611463
<string name="settings_screen_ai_integration">AI Integration</string>

0 commit comments

Comments
 (0)