mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-04-20 14:19:08 +00:00
Merge 86d4d0dfaf
into fe7f1a1b38
This commit is contained in:
commit
4a845c8d24
10 changed files with 238 additions and 200 deletions
|
@ -148,6 +148,8 @@ public class KeyboardView extends View {
|
||||||
|
|
||||||
mPaint.setAntiAlias(true);
|
mPaint.setAntiAlias(true);
|
||||||
mTypeface = Settings.getInstance().getCustomTypeface();
|
mTypeface = Settings.getInstance().getCustomTypeface();
|
||||||
|
|
||||||
|
setFitsSystemWindows(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
|
|
|
@ -16,6 +16,7 @@ import helium314.keyboard.keyboard.internal.KeyboardParams;
|
||||||
import helium314.keyboard.keyboard.internal.PopupKeySpec;
|
import helium314.keyboard.keyboard.internal.PopupKeySpec;
|
||||||
import helium314.keyboard.latin.R;
|
import helium314.keyboard.latin.R;
|
||||||
import helium314.keyboard.latin.common.StringUtils;
|
import helium314.keyboard.latin.common.StringUtils;
|
||||||
|
import helium314.keyboard.latin.utils.ResourceUtils;
|
||||||
import helium314.keyboard.latin.utils.TypefaceUtils;
|
import helium314.keyboard.latin.utils.TypefaceUtils;
|
||||||
|
|
||||||
public final class PopupKeysKeyboard extends Keyboard {
|
public final class PopupKeysKeyboard extends Keyboard {
|
||||||
|
@ -65,7 +66,7 @@ public final class PopupKeysKeyboard extends Keyboard {
|
||||||
public void setParameters(final int numKeys, final int numColumn, final int keyWidth,
|
public void setParameters(final int numKeys, final int numColumn, final int keyWidth,
|
||||||
final int rowHeight, final int coordXInParent, final int parentKeyboardWidth,
|
final int rowHeight, final int coordXInParent, final int parentKeyboardWidth,
|
||||||
final boolean isPopupKeysFixedColumn, final boolean isPopupKeysFixedOrder,
|
final boolean isPopupKeysFixedColumn, final boolean isPopupKeysFixedOrder,
|
||||||
final int dividerWidth) {
|
final int dividerWidth, Context context) {
|
||||||
mIsPopupKeysFixedOrder = isPopupKeysFixedOrder;
|
mIsPopupKeysFixedOrder = isPopupKeysFixedOrder;
|
||||||
if (parentKeyboardWidth / keyWidth < Math.min(numKeys, numColumn)) {
|
if (parentKeyboardWidth / keyWidth < Math.min(numKeys, numColumn)) {
|
||||||
throw new IllegalArgumentException("Keyboard is too small to hold popup keys: "
|
throw new IllegalArgumentException("Keyboard is too small to hold popup keys: "
|
||||||
|
@ -305,7 +306,7 @@ public final class PopupKeysKeyboard extends Keyboard {
|
||||||
: (spaceForKeys > 0 ? spaceForKeys : defaultColumns); // in last case setParameters will throw an exception
|
: (spaceForKeys > 0 ? spaceForKeys : defaultColumns); // in last case setParameters will throw an exception
|
||||||
mParams.setParameters(popupKeys.length, finalNumColumns, keyWidth,
|
mParams.setParameters(popupKeys.length, finalNumColumns, keyWidth,
|
||||||
rowHeight, key.getX() + key.getWidth() / 2, keyboard.mId.mWidth,
|
rowHeight, key.getX() + key.getWidth() / 2, keyboard.mId.mWidth,
|
||||||
key.isPopupKeysFixedColumn(), key.isPopupKeysFixedOrder(), dividerWidth);
|
key.isPopupKeysFixedColumn(), key.isPopupKeysFixedOrder(), dividerWidth, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int getMaxKeyWidth(final Key parentKey, final int minKeyWidth,
|
private static int getMaxKeyWidth(final Key parentKey, final int minKeyWidth,
|
||||||
|
|
|
@ -71,6 +71,7 @@ class ClipboardHistoryView @JvmOverloads constructor(
|
||||||
getEnabledClipboardToolbarKeys(context.prefs())
|
getEnabledClipboardToolbarKeys(context.prefs())
|
||||||
.forEach { toolbarKeys.add(createToolbarKey(context, KeyboardIconsSet.instance, it)) }
|
.forEach { toolbarKeys.add(createToolbarKey(context, KeyboardIconsSet.instance, it)) }
|
||||||
keyboardAttr.recycle()
|
keyboardAttr.recycle()
|
||||||
|
fitsSystemWindows = true
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
|
override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
|
||||||
|
|
|
@ -37,9 +37,10 @@ class ClipboardLayoutParams(ctx: Context) {
|
||||||
defaultKeyboardWidth, defaultKeyboardWidth).toInt()
|
defaultKeyboardWidth, defaultKeyboardWidth).toInt()
|
||||||
}
|
}
|
||||||
val bottomPadding = (res.getFraction(R.fraction.config_keyboard_bottom_padding_holo,
|
val bottomPadding = (res.getFraction(R.fraction.config_keyboard_bottom_padding_holo,
|
||||||
defaultKeyboardHeight, defaultKeyboardHeight) * sv.mBottomPaddingScale).toInt()
|
defaultKeyboardHeight, defaultKeyboardHeight) * sv.mBottomPaddingScale).toInt()
|
||||||
|
|
||||||
val topPadding = res.getFraction(R.fraction.config_keyboard_top_padding_holo,
|
val topPadding = res.getFraction(R.fraction.config_keyboard_top_padding_holo,
|
||||||
defaultKeyboardHeight, defaultKeyboardHeight).toInt()
|
defaultKeyboardHeight, defaultKeyboardHeight).toInt()
|
||||||
|
|
||||||
val rowCount = KeyboardParams.DEFAULT_KEYBOARD_ROWS + if (sv.mShowsNumberRow) 1 else 0
|
val rowCount = KeyboardParams.DEFAULT_KEYBOARD_ROWS + if (sv.mShowsNumberRow) 1 else 0
|
||||||
bottomRowKeyboardHeight = (defaultKeyboardHeight - bottomPadding - topPadding) / rowCount - keyVerticalGap / 2
|
bottomRowKeyboardHeight = (defaultKeyboardHeight - bottomPadding - topPadding) / rowCount - keyVerticalGap / 2
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
*/
|
*/
|
||||||
package helium314.keyboard.keyboard.emoji
|
package helium314.keyboard.keyboard.emoji
|
||||||
|
|
||||||
import android.content.res.Resources
|
import android.content.Context
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.widget.LinearLayout
|
import android.widget.LinearLayout
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
|
@ -14,13 +14,14 @@ import helium314.keyboard.latin.R
|
||||||
import helium314.keyboard.latin.settings.Settings
|
import helium314.keyboard.latin.settings.Settings
|
||||||
import helium314.keyboard.latin.utils.ResourceUtils
|
import helium314.keyboard.latin.utils.ResourceUtils
|
||||||
|
|
||||||
internal class EmojiLayoutParams(res: Resources) {
|
internal class EmojiLayoutParams(ctx: Context) {
|
||||||
private val emojiListBottomMargin: Int
|
private val emojiListBottomMargin: Int
|
||||||
val emojiKeyboardHeight: Int
|
val emojiKeyboardHeight: Int
|
||||||
private val emojiCategoryPageIdViewHeight: Int
|
private val emojiCategoryPageIdViewHeight: Int
|
||||||
val bottomRowKeyboardHeight: Int
|
val bottomRowKeyboardHeight: Int
|
||||||
|
|
||||||
init {
|
init {
|
||||||
|
val res = ctx.resources
|
||||||
val sv = Settings.getValues()
|
val sv = Settings.getValues()
|
||||||
val defaultKeyboardHeight = ResourceUtils.getKeyboardHeight(res, sv)
|
val defaultKeyboardHeight = ResourceUtils.getKeyboardHeight(res, sv)
|
||||||
|
|
||||||
|
|
|
@ -87,8 +87,7 @@ public final class EmojiPalettesView extends LinearLayout
|
||||||
super(context, attrs, defStyle);
|
super(context, attrs, defStyle);
|
||||||
mColors = Settings.getValues().mColors;
|
mColors = Settings.getValues().mColors;
|
||||||
final KeyboardLayoutSet.Builder builder = new KeyboardLayoutSet.Builder(context, null);
|
final KeyboardLayoutSet.Builder builder = new KeyboardLayoutSet.Builder(context, null);
|
||||||
final Resources res = context.getResources();
|
mEmojiLayoutParams = new EmojiLayoutParams(context);
|
||||||
mEmojiLayoutParams = new EmojiLayoutParams(res);
|
|
||||||
builder.setSubtype(RichInputMethodSubtype.Companion.getEmojiSubtype());
|
builder.setSubtype(RichInputMethodSubtype.Companion.getEmojiSubtype());
|
||||||
builder.setKeyboardGeometry(ResourceUtils.getKeyboardWidth(context, Settings.getValues()),
|
builder.setKeyboardGeometry(ResourceUtils.getKeyboardWidth(context, Settings.getValues()),
|
||||||
mEmojiLayoutParams.getEmojiKeyboardHeight());
|
mEmojiLayoutParams.getEmojiKeyboardHeight());
|
||||||
|
@ -106,6 +105,7 @@ public final class EmojiPalettesView extends LinearLayout
|
||||||
R.styleable.EmojiPalettesView_categoryPageIndicatorColor, 0);
|
R.styleable.EmojiPalettesView_categoryPageIndicatorColor, 0);
|
||||||
emojiPalettesViewAttr.recycle();
|
emojiPalettesViewAttr.recycle();
|
||||||
mEmojiLayoutManager = new LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false);
|
mEmojiLayoutManager = new LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false);
|
||||||
|
setFitsSystemWindows(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -8,14 +8,9 @@ package helium314.keyboard.keyboard.internal;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.res.TypedArray;
|
import android.content.res.TypedArray;
|
||||||
import android.graphics.Insets;
|
|
||||||
import android.os.Build;
|
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.util.SparseIntArray;
|
import android.util.SparseIntArray;
|
||||||
|
|
||||||
import android.view.WindowInsets;
|
|
||||||
import android.view.WindowManager;
|
|
||||||
import android.view.WindowMetrics;
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
|
@ -230,16 +225,6 @@ public class KeyboardParams {
|
||||||
mBottomPadding = (int) (keyboardAttr.getFraction(
|
mBottomPadding = (int) (keyboardAttr.getFraction(
|
||||||
R.styleable.Keyboard_keyboardBottomPadding, height, height, 0)
|
R.styleable.Keyboard_keyboardBottomPadding, height, height, 0)
|
||||||
* Settings.getValues().mBottomPaddingScale);
|
* Settings.getValues().mBottomPaddingScale);
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= 35) {
|
|
||||||
WindowManager wm = context.getSystemService(WindowManager.class);
|
|
||||||
WindowMetrics windowMetrics = wm.getCurrentWindowMetrics();
|
|
||||||
WindowInsets windowInsets = windowMetrics.getWindowInsets();
|
|
||||||
int insetTypes = WindowInsets.Type.systemBars() | WindowInsets.Type.displayCutout();
|
|
||||||
Insets insets = windowInsets.getInsetsIgnoringVisibility(insetTypes);
|
|
||||||
mBottomPadding += insets.bottom;
|
|
||||||
}
|
|
||||||
|
|
||||||
mLeftPadding = (int) (keyboardAttr.getFraction(
|
mLeftPadding = (int) (keyboardAttr.getFraction(
|
||||||
R.styleable.Keyboard_keyboardLeftPadding, width, width, 0)
|
R.styleable.Keyboard_keyboardLeftPadding, width, width, 0)
|
||||||
* Settings.getValues().mSidePaddingScale);
|
* Settings.getValues().mSidePaddingScale);
|
||||||
|
|
|
@ -23,6 +23,7 @@ import helium314.keyboard.latin.utils.DictionaryInfoUtils.USER_DICTIONARY_SUFFIX
|
||||||
import helium314.keyboard.latin.utils.LayoutType
|
import helium314.keyboard.latin.utils.LayoutType
|
||||||
import helium314.keyboard.latin.utils.LayoutType.Companion.folder
|
import helium314.keyboard.latin.utils.LayoutType.Companion.folder
|
||||||
import helium314.keyboard.latin.utils.LayoutUtilsCustom
|
import helium314.keyboard.latin.utils.LayoutUtilsCustom
|
||||||
|
import helium314.keyboard.latin.utils.Log
|
||||||
import helium314.keyboard.latin.utils.ScriptUtils.SCRIPT_LATIN
|
import helium314.keyboard.latin.utils.ScriptUtils.SCRIPT_LATIN
|
||||||
import helium314.keyboard.latin.utils.ScriptUtils.script
|
import helium314.keyboard.latin.utils.ScriptUtils.script
|
||||||
import helium314.keyboard.latin.utils.SubtypeSettings
|
import helium314.keyboard.latin.utils.SubtypeSettings
|
||||||
|
@ -51,6 +52,14 @@ class App : Application() {
|
||||||
checkVersionUpgrade(this)
|
checkVersionUpgrade(this)
|
||||||
app = this
|
app = this
|
||||||
Defaults.initDynamicDefaults(this)
|
Defaults.initDynamicDefaults(this)
|
||||||
|
|
||||||
|
val packageInfo = packageManager.getPackageInfo(packageName, 0)
|
||||||
|
@Suppress("DEPRECATION")
|
||||||
|
Log.i(
|
||||||
|
"startup", "Starting ${applicationInfo.processName} version ${packageInfo.versionName} (${
|
||||||
|
packageInfo.versionCode
|
||||||
|
}) on Android ${android.os.Build.VERSION.RELEASE} (SDK ${android.os.Build.VERSION.SDK_INT})"
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
|
@ -6,6 +6,7 @@ import androidx.compose.animation.AnimatedVisibility
|
||||||
import androidx.compose.foundation.layout.Box
|
import androidx.compose.foundation.layout.Box
|
||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.Column
|
||||||
import androidx.compose.foundation.layout.ColumnScope
|
import androidx.compose.foundation.layout.ColumnScope
|
||||||
|
import androidx.compose.foundation.layout.PaddingValues
|
||||||
import androidx.compose.foundation.layout.fillMaxSize
|
import androidx.compose.foundation.layout.fillMaxSize
|
||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
|
@ -20,6 +21,7 @@ import androidx.compose.material3.Icon
|
||||||
import androidx.compose.material3.IconButton
|
import androidx.compose.material3.IconButton
|
||||||
import androidx.compose.material3.LocalTextStyle
|
import androidx.compose.material3.LocalTextStyle
|
||||||
import androidx.compose.material3.MaterialTheme
|
import androidx.compose.material3.MaterialTheme
|
||||||
|
import androidx.compose.material3.Scaffold
|
||||||
import androidx.compose.material3.Surface
|
import androidx.compose.material3.Surface
|
||||||
import androidx.compose.material3.Text
|
import androidx.compose.material3.Text
|
||||||
import androidx.compose.material3.TextField
|
import androidx.compose.material3.TextField
|
||||||
|
@ -58,36 +60,41 @@ fun SearchSettingsScreen(
|
||||||
content = {
|
content = {
|
||||||
if (content != null) content()
|
if (content != null) content()
|
||||||
else {
|
else {
|
||||||
Column(Modifier.verticalScroll(rememberScrollState())) {
|
Scaffold { innerPadding ->
|
||||||
settings.forEach {
|
Column(
|
||||||
if (it is Int) {
|
Modifier.verticalScroll(rememberScrollState())
|
||||||
PreferenceCategory(stringResource(it))
|
.then(Modifier.padding(bottom = innerPadding.calculateBottomPadding()))
|
||||||
} else {
|
) {
|
||||||
// this only animates appearing prefs
|
settings.forEach {
|
||||||
// a solution would be using a list(visible to key)
|
if (it is Int) {
|
||||||
AnimatedVisibility(visible = it != null) {
|
PreferenceCategory(stringResource(it))
|
||||||
if (it != null)
|
} else {
|
||||||
SettingsActivity.settingsContainer[it]?.Preference()
|
// this only animates appearing prefs
|
||||||
|
// a solution would be using a list(visible to key)
|
||||||
|
AnimatedVisibility(visible = it != null) {
|
||||||
|
if (it != null)
|
||||||
|
SettingsActivity.settingsContainer[it]?.Preference()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// lazyColumn has janky scroll for a while (not sure why compose gets smoother after a while)
|
||||||
|
// maybe related to unnecessary recompositions? but even for just displaying text it's there
|
||||||
|
// didn't manage to improve things with @Immutable list wrapper and other lazy list hints
|
||||||
|
// so for now: just use "normal" Column
|
||||||
|
// even though it takes up to ~50% longer to load it's much better UX
|
||||||
|
// and the missing appear animations could be added
|
||||||
|
// LazyColumn {
|
||||||
|
// items(prefs.filterNotNull(), key = { it }) {
|
||||||
|
// Box(Modifier.animateItem()) {
|
||||||
|
// if (it is Int)
|
||||||
|
// PreferenceCategory(stringResource(it))
|
||||||
|
// else
|
||||||
|
// SettingsActivity.settingsContainer[it]!!.Preference()
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
// lazyColumn has janky scroll for a while (not sure why compose gets smoother after a while)
|
|
||||||
// maybe related to unnecessary recompositions? but even for just displaying text it's there
|
|
||||||
// didn't manage to improve things with @Immutable list wrapper and other lazy list hints
|
|
||||||
// so for now: just use "normal" Column
|
|
||||||
// even though it takes up to ~50% longer to load it's much better UX
|
|
||||||
// and the missing appear animations could be added
|
|
||||||
// LazyColumn {
|
|
||||||
// items(prefs.filterNotNull(), key = { it }) {
|
|
||||||
// Box(Modifier.animateItem()) {
|
|
||||||
// if (it is Int)
|
|
||||||
// PreferenceCategory(stringResource(it))
|
|
||||||
// else
|
|
||||||
// SettingsActivity.settingsContainer[it]!!.Preference()
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
filteredItems = { SettingsActivity.settingsContainer.filter(it) },
|
filteredItems = { SettingsActivity.settingsContainer.filter(it) },
|
||||||
|
@ -195,9 +202,11 @@ fun <T: Any?> SearchScreen(
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
val items = filteredItems(searchText.text)
|
val items = filteredItems(searchText.text)
|
||||||
LazyColumn {
|
Scaffold { innerPadding ->
|
||||||
items(items) {
|
LazyColumn(contentPadding = PaddingValues.Absolute(bottom = innerPadding.calculateBottomPadding())) {
|
||||||
itemContent(it)
|
items(items) {
|
||||||
|
itemContent(it)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@ import androidx.compose.material3.HorizontalDivider
|
||||||
import androidx.compose.material3.Icon
|
import androidx.compose.material3.Icon
|
||||||
import androidx.compose.material3.IconButton
|
import androidx.compose.material3.IconButton
|
||||||
import androidx.compose.material3.MaterialTheme
|
import androidx.compose.material3.MaterialTheme
|
||||||
|
import androidx.compose.material3.Scaffold
|
||||||
import androidx.compose.material3.Surface
|
import androidx.compose.material3.Surface
|
||||||
import androidx.compose.material3.Switch
|
import androidx.compose.material3.Switch
|
||||||
import androidx.compose.material3.Text
|
import androidx.compose.material3.Text
|
||||||
|
@ -140,163 +141,191 @@ fun SubtypeScreen(
|
||||||
itemContent = { },
|
itemContent = { },
|
||||||
filteredItems = { emptyList<String>() }
|
filteredItems = { emptyList<String>() }
|
||||||
) {
|
) {
|
||||||
Column(
|
Scaffold { innerPadding ->
|
||||||
modifier = Modifier.verticalScroll(scrollState).padding(horizontal = 12.dp),
|
Column(
|
||||||
verticalArrangement = Arrangement.spacedBy(8.dp),
|
modifier = Modifier.verticalScroll(scrollState).padding(horizontal = 12.dp)
|
||||||
) {
|
.then(Modifier.padding(bottom = innerPadding.calculateBottomPadding())),
|
||||||
MainLayoutRow(currentSubtype, customMainLayouts) { setCurrentSubtype(it) }
|
verticalArrangement = Arrangement.spacedBy(8.dp),
|
||||||
if (availableLocalesForScript.size > 1) {
|
) {
|
||||||
WithSmallTitle(stringResource(R.string.secondary_locale)) {
|
MainLayoutRow(currentSubtype, customMainLayouts) { setCurrentSubtype(it) }
|
||||||
TextButton(onClick = { showSecondaryLocaleDialog = true }) {
|
if (availableLocalesForScript.size > 1) {
|
||||||
val text = getSecondaryLocales(currentSubtype.extraValues).joinToString(", ") {
|
WithSmallTitle(stringResource(R.string.secondary_locale)) {
|
||||||
it.localizedDisplayName(ctx)
|
TextButton(onClick = { showSecondaryLocaleDialog = true }) {
|
||||||
}.ifEmpty { stringResource(R.string.action_none) }
|
val text = getSecondaryLocales(currentSubtype.extraValues).joinToString(", ") {
|
||||||
Text(text, Modifier.fillMaxWidth())
|
it.localizedDisplayName(ctx)
|
||||||
}
|
}.ifEmpty { stringResource(R.string.action_none) }
|
||||||
}
|
Text(text, Modifier.fillMaxWidth())
|
||||||
}
|
|
||||||
Row {
|
|
||||||
TextButton(onClick = { showKeyOrderDialog = true }, Modifier.weight(1f))
|
|
||||||
{ Text(stringResource(R.string.popup_order)) }
|
|
||||||
DefaultButton(currentSubtype.getExtraValueOf(ExtraValue.POPUP_ORDER) == null) {
|
|
||||||
setCurrentSubtype(currentSubtype.without(ExtraValue.POPUP_ORDER))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Row {
|
|
||||||
TextButton(onClick = { showHintOrderDialog = true }, Modifier.weight(1f))
|
|
||||||
{ Text(stringResource(R.string.hint_source)) }
|
|
||||||
DefaultButton(currentSubtype.getExtraValueOf(ExtraValue.HINT_ORDER) == null) {
|
|
||||||
setCurrentSubtype(currentSubtype.without(ExtraValue.HINT_ORDER))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (currentSubtype.locale.script() == ScriptUtils.SCRIPT_LATIN) {
|
|
||||||
WithSmallTitle(stringResource(R.string.show_popup_keys_title)) {
|
|
||||||
val explicitValue = currentSubtype.getExtraValueOf(ExtraValue.MORE_POPUPS)
|
|
||||||
val value = explicitValue ?: prefs.getString(Settings.PREF_MORE_POPUP_KEYS, Defaults.PREF_MORE_POPUP_KEYS)!!
|
|
||||||
Row {
|
|
||||||
TextButton(onClick = { showMorePopupsDialog = true }, Modifier.weight(1f))
|
|
||||||
{ Text(stringResource(morePopupKeysResId(value))) }
|
|
||||||
DefaultButton(explicitValue == null) {
|
|
||||||
setCurrentSubtype(currentSubtype.without(ExtraValue.MORE_POPUPS))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
Row {
|
||||||
if (hasLocalizedNumberRow(currentSubtype.locale, ctx)) {
|
TextButton(onClick = { showKeyOrderDialog = true }, Modifier.weight(1f))
|
||||||
Row(verticalAlignment = Alignment.CenterVertically) {
|
{ Text(stringResource(R.string.popup_order)) }
|
||||||
val checked = currentSubtype.getExtraValueOf(ExtraValue.LOCALIZED_NUMBER_ROW)?.toBoolean()
|
DefaultButton(currentSubtype.getExtraValueOf(ExtraValue.POPUP_ORDER) == null) {
|
||||||
Text(stringResource(R.string.localized_number_row), Modifier.weight(1f))
|
setCurrentSubtype(currentSubtype.without(ExtraValue.POPUP_ORDER))
|
||||||
Switch(
|
|
||||||
checked = checked ?: prefs.getBoolean(Settings.PREF_LOCALIZED_NUMBER_ROW, Defaults.PREF_LOCALIZED_NUMBER_ROW),
|
|
||||||
onCheckedChange = {
|
|
||||||
setCurrentSubtype(currentSubtype.with(ExtraValue.LOCALIZED_NUMBER_ROW, it.toString()))
|
|
||||||
}
|
|
||||||
)
|
|
||||||
DefaultButton(checked == null) {
|
|
||||||
setCurrentSubtype(currentSubtype.without(ExtraValue.LOCALIZED_NUMBER_ROW))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
Row {
|
||||||
HorizontalDivider()
|
TextButton(onClick = { showHintOrderDialog = true }, Modifier.weight(1f))
|
||||||
Text(stringResource(R.string.settings_screen_secondary_layouts), style = MaterialTheme.typography.titleMedium)
|
{ Text(stringResource(R.string.hint_source)) }
|
||||||
LayoutType.entries.forEach { type ->
|
DefaultButton(currentSubtype.getExtraValueOf(ExtraValue.HINT_ORDER) == null) {
|
||||||
if (type == LayoutType.MAIN) return@forEach
|
setCurrentSubtype(currentSubtype.without(ExtraValue.HINT_ORDER))
|
||||||
WithSmallTitle(stringResource(type.displayNameId)) {
|
}
|
||||||
val explicitLayout = currentSubtype.layoutName(type)
|
}
|
||||||
val layout = explicitLayout ?: Settings.readDefaultLayoutName(type, prefs)
|
if (currentSubtype.locale.script() == ScriptUtils.SCRIPT_LATIN) {
|
||||||
val defaultLayouts = LayoutUtils.getAvailableLayouts(type, ctx)
|
WithSmallTitle(stringResource(R.string.show_popup_keys_title)) {
|
||||||
val customLayouts = LayoutUtilsCustom.getLayoutFiles(type, ctx).map { it.name }
|
val explicitValue = currentSubtype.getExtraValueOf(ExtraValue.MORE_POPUPS)
|
||||||
DropDownField(
|
val value = explicitValue ?: prefs.getString(
|
||||||
items = defaultLayouts + customLayouts,
|
Settings.PREF_MORE_POPUP_KEYS,
|
||||||
selectedItem = layout,
|
Defaults.PREF_MORE_POPUP_KEYS
|
||||||
onSelected = {
|
)!!
|
||||||
setCurrentSubtype(currentSubtype.withLayout(type, it))
|
Row {
|
||||||
},
|
TextButton(onClick = { showMorePopupsDialog = true }, Modifier.weight(1f))
|
||||||
extraButton = { DefaultButton(explicitLayout == null) {
|
{ Text(stringResource(morePopupKeysResId(value))) }
|
||||||
setCurrentSubtype(currentSubtype.withoutLayout(type))
|
DefaultButton(explicitValue == null) {
|
||||||
} },
|
setCurrentSubtype(currentSubtype.without(ExtraValue.MORE_POPUPS))
|
||||||
) {
|
}
|
||||||
val displayName = if (LayoutUtilsCustom.isCustomLayout(it)) LayoutUtilsCustom.getDisplayName(it)
|
}
|
||||||
else it.getStringResourceOrName("layout_", ctx)
|
}
|
||||||
var showLayoutEditDialog by remember { mutableStateOf(false) }
|
}
|
||||||
Row(
|
if (hasLocalizedNumberRow(currentSubtype.locale, ctx)) {
|
||||||
horizontalArrangement = Arrangement.SpaceBetween,
|
Row(verticalAlignment = Alignment.CenterVertically) {
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
val checked = currentSubtype.getExtraValueOf(ExtraValue.LOCALIZED_NUMBER_ROW)?.toBoolean()
|
||||||
modifier = Modifier.fillMaxWidth()
|
Text(stringResource(R.string.localized_number_row), Modifier.weight(1f))
|
||||||
|
Switch(
|
||||||
|
checked = checked ?: prefs.getBoolean(
|
||||||
|
Settings.PREF_LOCALIZED_NUMBER_ROW,
|
||||||
|
Defaults.PREF_LOCALIZED_NUMBER_ROW
|
||||||
|
),
|
||||||
|
onCheckedChange = {
|
||||||
|
setCurrentSubtype(currentSubtype.with(ExtraValue.LOCALIZED_NUMBER_ROW, it.toString()))
|
||||||
|
}
|
||||||
|
)
|
||||||
|
DefaultButton(checked == null) {
|
||||||
|
setCurrentSubtype(currentSubtype.without(ExtraValue.LOCALIZED_NUMBER_ROW))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
HorizontalDivider()
|
||||||
|
Text(
|
||||||
|
stringResource(R.string.settings_screen_secondary_layouts),
|
||||||
|
style = MaterialTheme.typography.titleMedium
|
||||||
|
)
|
||||||
|
LayoutType.entries.forEach { type ->
|
||||||
|
if (type == LayoutType.MAIN) return@forEach
|
||||||
|
WithSmallTitle(stringResource(type.displayNameId)) {
|
||||||
|
val explicitLayout = currentSubtype.layoutName(type)
|
||||||
|
val layout = explicitLayout ?: Settings.readDefaultLayoutName(type, prefs)
|
||||||
|
val defaultLayouts = LayoutUtils.getAvailableLayouts(type, ctx)
|
||||||
|
val customLayouts = LayoutUtilsCustom.getLayoutFiles(type, ctx).map { it.name }
|
||||||
|
DropDownField(
|
||||||
|
items = defaultLayouts + customLayouts,
|
||||||
|
selectedItem = layout,
|
||||||
|
onSelected = {
|
||||||
|
setCurrentSubtype(currentSubtype.withLayout(type, it))
|
||||||
|
},
|
||||||
|
extraButton = {
|
||||||
|
DefaultButton(explicitLayout == null) {
|
||||||
|
setCurrentSubtype(currentSubtype.withoutLayout(type))
|
||||||
|
}
|
||||||
|
},
|
||||||
) {
|
) {
|
||||||
Text(displayName)
|
val displayName =
|
||||||
if (LayoutUtilsCustom.isCustomLayout(it))
|
if (LayoutUtilsCustom.isCustomLayout(it)) LayoutUtilsCustom.getDisplayName(it)
|
||||||
IconButton({ showLayoutEditDialog = true }) { Icon(painterResource(R.drawable.ic_edit), stringResource(R.string.edit_layout)) }
|
else it.getStringResourceOrName("layout_", ctx)
|
||||||
|
var showLayoutEditDialog by remember { mutableStateOf(false) }
|
||||||
|
Row(
|
||||||
|
horizontalArrangement = Arrangement.SpaceBetween,
|
||||||
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
|
modifier = Modifier.fillMaxWidth()
|
||||||
|
) {
|
||||||
|
Text(displayName)
|
||||||
|
if (LayoutUtilsCustom.isCustomLayout(it))
|
||||||
|
IconButton({
|
||||||
|
showLayoutEditDialog = true
|
||||||
|
}) {
|
||||||
|
Icon(
|
||||||
|
painterResource(R.drawable.ic_edit),
|
||||||
|
stringResource(R.string.edit_layout)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (showLayoutEditDialog)
|
||||||
|
LayoutEditDialog(
|
||||||
|
onDismissRequest = { showLayoutEditDialog = false },
|
||||||
|
layoutType = type,
|
||||||
|
initialLayoutName = it,
|
||||||
|
isNameValid = null
|
||||||
|
)
|
||||||
}
|
}
|
||||||
if (showLayoutEditDialog)
|
|
||||||
LayoutEditDialog(
|
|
||||||
onDismissRequest = { showLayoutEditDialog = false },
|
|
||||||
layoutType = type,
|
|
||||||
initialLayoutName = it,
|
|
||||||
isNameValid = null
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
if (showSecondaryLocaleDialog)
|
||||||
if (showSecondaryLocaleDialog)
|
MultiListPickerDialog(
|
||||||
MultiListPickerDialog(
|
onDismissRequest = { showSecondaryLocaleDialog = false },
|
||||||
onDismissRequest = { showSecondaryLocaleDialog = false },
|
onConfirmed = { locales ->
|
||||||
onConfirmed = { locales ->
|
val newValue = locales.joinToString(Separators.KV) { it.toLanguageTag() }
|
||||||
val newValue = locales.joinToString(Separators.KV) { it.toLanguageTag() }
|
setCurrentSubtype(
|
||||||
setCurrentSubtype(
|
if (newValue.isEmpty()) currentSubtype.without(ExtraValue.SECONDARY_LOCALES)
|
||||||
if (newValue.isEmpty()) currentSubtype.without(ExtraValue.SECONDARY_LOCALES)
|
else currentSubtype.with(ExtraValue.SECONDARY_LOCALES, newValue)
|
||||||
else currentSubtype.with(ExtraValue.SECONDARY_LOCALES, newValue)
|
)
|
||||||
)
|
},
|
||||||
},
|
title = { Text(stringResource(R.string.locales_with_dict)) },
|
||||||
title = { Text(stringResource(R.string.locales_with_dict)) },
|
items = availableLocalesForScript,
|
||||||
items = availableLocalesForScript,
|
initialSelection = currentSubtype.getExtraValueOf(ExtraValue.SECONDARY_LOCALES)
|
||||||
initialSelection = currentSubtype.getExtraValueOf(ExtraValue.SECONDARY_LOCALES)
|
?.split(Separators.KV)?.map { it.constructLocale() }.orEmpty(),
|
||||||
?.split(Separators.KV)?.map { it.constructLocale() }.orEmpty(),
|
getItemName = { it.localizedDisplayName(ctx) }
|
||||||
getItemName = { it.localizedDisplayName(ctx) }
|
)
|
||||||
)
|
if (showKeyOrderDialog) {
|
||||||
if (showKeyOrderDialog) {
|
val setting = currentSubtype.getExtraValueOf(ExtraValue.POPUP_ORDER)
|
||||||
val setting = currentSubtype.getExtraValueOf(ExtraValue.POPUP_ORDER)
|
PopupOrderDialog(
|
||||||
PopupOrderDialog(
|
onDismissRequest = { showKeyOrderDialog = false },
|
||||||
onDismissRequest = { showKeyOrderDialog = false },
|
initialValue = setting ?: prefs.getString(
|
||||||
initialValue = setting ?: prefs.getString(Settings.PREF_POPUP_KEYS_ORDER, Defaults.PREF_POPUP_KEYS_ORDER)!!,
|
Settings.PREF_POPUP_KEYS_ORDER,
|
||||||
title = stringResource(R.string.popup_order),
|
Defaults.PREF_POPUP_KEYS_ORDER
|
||||||
showDefault = setting != null,
|
)!!,
|
||||||
onConfirmed = {
|
title = stringResource(R.string.popup_order),
|
||||||
setCurrentSubtype(
|
showDefault = setting != null,
|
||||||
if (it == null) currentSubtype.without(ExtraValue.POPUP_ORDER)
|
onConfirmed = {
|
||||||
else currentSubtype.with(ExtraValue.POPUP_ORDER, it)
|
setCurrentSubtype(
|
||||||
)
|
if (it == null) currentSubtype.without(ExtraValue.POPUP_ORDER)
|
||||||
}
|
else currentSubtype.with(ExtraValue.POPUP_ORDER, it)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
if (showHintOrderDialog) {
|
)
|
||||||
val setting = currentSubtype.getExtraValueOf(ExtraValue.HINT_ORDER)
|
}
|
||||||
PopupOrderDialog(
|
if (showHintOrderDialog) {
|
||||||
onDismissRequest = { showHintOrderDialog = false },
|
val setting = currentSubtype.getExtraValueOf(ExtraValue.HINT_ORDER)
|
||||||
initialValue = setting ?: prefs.getString(Settings.PREF_POPUP_KEYS_LABELS_ORDER, Defaults.PREF_POPUP_KEYS_LABELS_ORDER)!!,
|
PopupOrderDialog(
|
||||||
title = stringResource(R.string.hint_source),
|
onDismissRequest = { showHintOrderDialog = false },
|
||||||
showDefault = setting != null,
|
initialValue = setting ?: prefs.getString(
|
||||||
onConfirmed = {
|
Settings.PREF_POPUP_KEYS_LABELS_ORDER,
|
||||||
setCurrentSubtype(
|
Defaults.PREF_POPUP_KEYS_LABELS_ORDER
|
||||||
if (it == null) currentSubtype.without(ExtraValue.HINT_ORDER)
|
)!!,
|
||||||
else currentSubtype.with(ExtraValue.HINT_ORDER, it)
|
title = stringResource(R.string.hint_source),
|
||||||
)
|
showDefault = setting != null,
|
||||||
}
|
onConfirmed = {
|
||||||
)
|
setCurrentSubtype(
|
||||||
}
|
if (it == null) currentSubtype.without(ExtraValue.HINT_ORDER)
|
||||||
if (showMorePopupsDialog) {
|
else currentSubtype.with(ExtraValue.HINT_ORDER, it)
|
||||||
val items = listOf(POPUP_KEYS_NORMAL, POPUP_KEYS_MAIN, POPUP_KEYS_MORE, POPUP_KEYS_ALL)
|
)
|
||||||
val explicitValue = currentSubtype.getExtraValueOf(ExtraValue.MORE_POPUPS)
|
}
|
||||||
val value = explicitValue ?: prefs.getString(Settings.PREF_MORE_POPUP_KEYS, Defaults.PREF_MORE_POPUP_KEYS)
|
)
|
||||||
ListPickerDialog(
|
}
|
||||||
onDismissRequest = { showMorePopupsDialog = false },
|
if (showMorePopupsDialog) {
|
||||||
items = items,
|
val items = listOf(POPUP_KEYS_NORMAL, POPUP_KEYS_MAIN, POPUP_KEYS_MORE, POPUP_KEYS_ALL)
|
||||||
getItemName = { stringResource(morePopupKeysResId(it)) },
|
val explicitValue = currentSubtype.getExtraValueOf(ExtraValue.MORE_POPUPS)
|
||||||
selectedItem = value,
|
val value = explicitValue ?: prefs.getString(Settings.PREF_MORE_POPUP_KEYS, Defaults.PREF_MORE_POPUP_KEYS)
|
||||||
onItemSelected = { setCurrentSubtype(currentSubtype.with(ExtraValue.MORE_POPUPS, it)) }
|
ListPickerDialog(
|
||||||
)
|
onDismissRequest = { showMorePopupsDialog = false },
|
||||||
|
items = items,
|
||||||
|
getItemName = { stringResource(morePopupKeysResId(it)) },
|
||||||
|
selectedItem = value,
|
||||||
|
onItemSelected = { setCurrentSubtype(currentSubtype.with(ExtraValue.MORE_POPUPS, it)) }
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue