better behavior when keyboard is shown

This commit is contained in:
Helium314 2025-02-06 16:32:36 +01:00
parent ae461fe8b6
commit edc883adf3
7 changed files with 36 additions and 35 deletions

View file

@ -76,6 +76,7 @@ SPDX-License-Identifier: Apache-2.0 AND GPL-3.0-only
<activity android:name="helium314.keyboard.settings.SettingsActivity2"
android:theme="@style/platformActivityTheme"
android:windowSoftInputMode="adjustResize"
android:label="@string/ime_settings"
android:exported="true">
<intent-filter>

View file

@ -69,7 +69,6 @@ fun SearchPrefScreen(
}
Surface(
color = MaterialTheme.colorScheme.surfaceContainer,
//shadowElevation = TopAppBarDefaults.??
) {
Column {
TopAppBar(
@ -99,10 +98,9 @@ fun SearchPrefScreen(
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 16.dp, vertical = 8.dp),
//colors = TextFieldDefaults.colors(
// textColor = MaterialTheme.colorScheme.onSurface,
// backgroundColor = MaterialTheme.colorScheme.surface
//)
colors = TextFieldDefaults.colors(
focusedContainerColor = MaterialTheme.colorScheme.surface
)
)
}
}
@ -122,11 +120,7 @@ fun SearchPrefScreen(
else
CompositionLocalProvider(LocalTextStyle provides MaterialTheme.typography.bodyLarge) {
val filteredPrefs = SettingsActivity2.allPrefs.filter(searchText.text)
LazyColumn(
//state = listState, // better not, remembering scroll state when changing search term feels wrong
// todo: scrolling should consider keyboard, but not working, from https://developer.android.com/develop/ui/compose/layouts/insets#ime-animations
//modifier = Modifier.imePadding().imeNestedScroll()
) {
LazyColumn {
items(filteredPrefs) {
it.Preference()
}
@ -192,20 +186,15 @@ fun <T: Any> SearchScreen(
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 16.dp, vertical = 8.dp),
//colors = TextFieldDefaults.colors(
// textColor = MaterialTheme.colorScheme.onSurface,
// backgroundColor = MaterialTheme.colorScheme.surface
//)
colors = TextFieldDefaults.colors(
focusedContainerColor = MaterialTheme.colorScheme.surface
)
)
}
}
CompositionLocalProvider(LocalTextStyle provides MaterialTheme.typography.bodyLarge) {
val filteredItems = items.filter { filter(searchText.text, it) }
LazyColumn(
//state = listState, // better not, remembering scroll state when changing search term feels wrong
// todo: scrolling should consider keyboard, but not working, from https://developer.android.com/develop/ui/compose/layouts/insets#ime-animations
//modifier = Modifier.imePadding().imeNestedScroll()
) {
LazyColumn {
items(filteredItems) {
itemContent(it)
}

View file

@ -14,18 +14,11 @@ import helium314.keyboard.latin.utils.prefs
import kotlinx.coroutines.flow.MutableStateFlow
// todo (roughly in order)
// make all prefs actually work
// advanced (not much)
// try moving the recomposition of pref change somewhere else, so it's not duplicated everywhere
// make the pref lists more compact (compare with old settings)
// try making text size similar to old state (also in dialogs)
// more similar dialog style args (for all dialogs, or for none)
// check whether dialogs have the same colors, i think currently it's a bit inconsistent
// see all the properties for each alertDialog -> any way to set it in a single place?
// title too huge for bg image and text on spacebar dialogs, also maybe somewhere else -> where to set in one place?
// try making a dialog with reduced padding
// avoid duplicate code in SearchScreen
// work on todos in other files
// check dark and light theme (don't have dynamic)
// rename both settingsActivities
// work on todos in other files
// calling KeyboardSwitcher.getInstance().forceUpdateKeyboardTheme(requireContext()) while keyboard is showing shows just full screen background
// but reload while keyboard is showing would be great (isn't it at least semi-done when changing one-handed mode?)
// use better / more structured and clear names and arrangement of files

View file

@ -1,9 +1,11 @@
package helium314.keyboard.settings.dialogs
import android.widget.Toast
import androidx.compose.foundation.layout.imePadding
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import helium314.keyboard.latin.R
import helium314.keyboard.latin.utils.Log
@ -46,5 +48,6 @@ fun CustomizeLayoutDialog(
valid
},
singleLine = false,
modifier = Modifier.imePadding()
)
}

View file

@ -10,9 +10,12 @@ import androidx.compose.material3.TextButton
import androidx.compose.material3.contentColorFor
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.window.DialogProperties
import helium314.keyboard.settings.Theme
@Composable
fun ThreeButtonAlertDialog(
@ -54,7 +57,20 @@ fun ThreeButtonAlertDialog(
text = text,
shape = MaterialTheme.shapes.medium,
containerColor = MaterialTheme.colorScheme.surface,
textContentColor = contentColorFor( MaterialTheme.colorScheme.surface),
properties = DialogProperties(),
textContentColor = contentColorFor(MaterialTheme.colorScheme.surface),
properties = DialogProperties(decorFitsSystemWindows = false), // otherwise Modifier.imePadding() is ignored
)
}
@Preview
@Composable
private fun Preview() {
Theme {
ThreeButtonAlertDialog(
onDismissRequest = {},
onConfirmed = { },
text = { Text("hello") },
title = { Text("title") },
)
}
}

View file

@ -110,9 +110,9 @@ fun AdvancedSettingsScreen(
SettingsActivity2.allPrefs.map[Settings.PREF_ENABLE_EMOJI_ALT_PHYSICAL_KEY]!!.Preference()
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q)
SettingsActivity2.allPrefs.map[Settings.PREF_SHOW_SETUP_WIZARD_ICON]!!.Preference()
SettingsActivity2.allPrefs.map[Settings.PREF_ABC_AFTER_SYMBOL_SPACE]!!.Preference() // todo: this is ugly
SettingsActivity2.allPrefs.map[Settings.PREF_ABC_AFTER_EMOJI]!!.Preference() // todo: this is ugly
SettingsActivity2.allPrefs.map[Settings.PREF_ABC_AFTER_CLIP]!!.Preference() // todo: this is ugly
SettingsActivity2.allPrefs.map[Settings.PREF_ABC_AFTER_SYMBOL_SPACE]!!.Preference()
SettingsActivity2.allPrefs.map[Settings.PREF_ABC_AFTER_EMOJI]!!.Preference()
SettingsActivity2.allPrefs.map[Settings.PREF_ABC_AFTER_CLIP]!!.Preference()
SettingsActivity2.allPrefs.map[Settings.PREF_CUSTOM_CURRENCY_KEY]!!.Preference()
SettingsActivity2.allPrefs.map[Settings.PREF_MORE_POPUP_KEYS]!!.Preference()
SettingsActivity2.allPrefs.map[NonSettingsPrefs.CUSTOM_SYMBOLS_NUMBER_LAYOUTS]!!.Preference()

View file

@ -34,7 +34,6 @@ import helium314.keyboard.latin.utils.DeviceProtectedUtils
import helium314.keyboard.latin.utils.Log
import helium314.keyboard.latin.utils.getActivity
import helium314.keyboard.latin.utils.getStringResourceOrName
import helium314.keyboard.latin.utils.infoDialog
import helium314.keyboard.latin.utils.prefs
import helium314.keyboard.latin.utils.switchTo
import helium314.keyboard.settings.AllPrefs