mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-06-03 21:30:12 +00:00
fix order of quote moreKeys (#302)
This commit is contained in:
parent
8045ecc8a3
commit
ff06aa9701
4 changed files with 30 additions and 20 deletions
|
@ -1186,21 +1186,19 @@ public class Key implements Comparable<Key> {
|
||||||
mLabelFlags = labelFlags;
|
mLabelFlags = labelFlags;
|
||||||
mRelativeWidth = relativeWidth;
|
mRelativeWidth = relativeWidth;
|
||||||
mRelativeHeight = params.mDefaultRelativeRowHeight;
|
mRelativeHeight = params.mDefaultRelativeRowHeight;
|
||||||
mMoreKeysColumnAndFlags = getMoreKeysColumnAndFlagsAndSetNullInArray(params, layoutMoreKeys);
|
|
||||||
mIconId = KeySpecParser.getIconId(keySpec);
|
mIconId = KeySpecParser.getIconId(keySpec);
|
||||||
|
|
||||||
final boolean needsToUpcase = needsToUpcase(mLabelFlags, params.mId.mElementId);
|
final boolean needsToUpcase = needsToUpcase(mLabelFlags, params.mId.mElementId);
|
||||||
final Locale localeForUpcasing = params.mId.getLocale();
|
final Locale localeForUpcasing = params.mId.getLocale();
|
||||||
int actionFlags = 0;
|
int actionFlags = 0;
|
||||||
|
|
||||||
final String[] languageMoreKeys;
|
final String[] languageMoreKeys = params.mLocaleKeyTexts.getMoreKeys(keySpec);
|
||||||
if ((mLabelFlags & LABEL_FLAGS_DISABLE_ADDITIONAL_MORE_KEYS) != 0) {
|
// todo: after removing old parser this could be done in a less awkward way without almostFinalMoreKeys
|
||||||
languageMoreKeys = null;
|
final String[] almostFinalMoreKeys = MoreKeySpec.insertAdditionalMoreKeys(languageMoreKeys, layoutMoreKeys);
|
||||||
} else {
|
mMoreKeysColumnAndFlags = getMoreKeysColumnAndFlagsAndSetNullInArray(params, almostFinalMoreKeys);
|
||||||
// same style as additionalMoreKeys (i.e. moreKeys with the % placeholder(s))
|
final String[] finalMoreKeys = almostFinalMoreKeys == null
|
||||||
languageMoreKeys = params.mLocaleKeyTexts.getMoreKeys(keySpec);
|
? null
|
||||||
}
|
: MoreKeySpec.filterOutEmptyString(almostFinalMoreKeys);
|
||||||
final String[] finalMoreKeys = MoreKeySpec.insertAdditionalMoreKeys(languageMoreKeys, layoutMoreKeys);
|
|
||||||
|
|
||||||
if (finalMoreKeys != null) {
|
if (finalMoreKeys != null) {
|
||||||
actionFlags |= ACTION_FLAGS_ENABLE_LONG_PRESS;
|
actionFlags |= ACTION_FLAGS_ENABLE_LONG_PRESS;
|
||||||
|
|
|
@ -154,8 +154,7 @@ open class KeyboardBuilder<KP : KeyboardParams>(protected val mContext: Context,
|
||||||
// followFunctionalTextColor: number mode keys, action key
|
// followFunctionalTextColor: number mode keys, action key
|
||||||
// keepBackgroundAspectRatio: lxx and rounded action more keys, lxx no-border action and emoji, moreKeys keyboard view
|
// keepBackgroundAspectRatio: lxx and rounded action more keys, lxx no-border action and emoji, moreKeys keyboard view
|
||||||
// disableKeyHintLabel: keys in pcqwerty row 1 and number row
|
// disableKeyHintLabel: keys in pcqwerty row 1 and number row
|
||||||
// disableAdditionalMoreKeys: keys in pcqwerty row 1
|
// disableAdditionalMoreKeys: only keys in pcqwerty row 1 so there is no number row -> not necessary with the new layouts, just remove it completely
|
||||||
// -> probably can't define the related layouts in a simple way, better use some json or xml or anything more reasonable than the simple text format
|
|
||||||
// maybe remove some of the flags? or keep supporting them?
|
// maybe remove some of the flags? or keep supporting them?
|
||||||
// for pcqwerty: hasShiftedLetterHint -> hasShiftedLetterHint|shiftedLetterActivated when shift is enabled, need to consider if the flag is used
|
// for pcqwerty: hasShiftedLetterHint -> hasShiftedLetterHint|shiftedLetterActivated when shift is enabled, need to consider if the flag is used
|
||||||
// actually period key also has shifted letter hint
|
// actually period key also has shifted letter hint
|
||||||
|
|
|
@ -219,7 +219,7 @@ public final class MoreKeySpec {
|
||||||
private static final String[] EMPTY_STRING_ARRAY = new String[0];
|
private static final String[] EMPTY_STRING_ARRAY = new String[0];
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
private static String[] filterOutEmptyString(@Nullable final String[] array) {
|
public static String[] filterOutEmptyString(@Nullable final String[] array) {
|
||||||
if (array == null) {
|
if (array == null) {
|
||||||
return EMPTY_STRING_ARRAY;
|
return EMPTY_STRING_ARRAY;
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,9 +45,9 @@ class LocaleKeyTexts(dataStream: InputStream?, locale: Locale) {
|
||||||
// set default quote moreKeys if necessary
|
// set default quote moreKeys if necessary
|
||||||
// should this also be done with punctuation moreKeys?
|
// should this also be done with punctuation moreKeys?
|
||||||
if ("\'" !in moreKeys)
|
if ("\'" !in moreKeys)
|
||||||
moreKeys["\'"] = arrayOf("‚", "‘", "’", "‹", "›")
|
moreKeys["\'"] = arrayOf("!fixedColumnOrder!5", "‚", "‘", "’", "‹", "›")
|
||||||
if ("\"" !in moreKeys)
|
if ("\"" !in moreKeys)
|
||||||
moreKeys["\""] = arrayOf("„", "“", "”", "«", "»")
|
moreKeys["\""] = arrayOf("!fixedColumnOrder!5", "„", "“", "”", "«", "»")
|
||||||
if ("!" !in moreKeys)
|
if ("!" !in moreKeys)
|
||||||
moreKeys["!"] = arrayOf("¡")
|
moreKeys["!"] = arrayOf("¡")
|
||||||
if ("?" !in moreKeys)
|
if ("?" !in moreKeys)
|
||||||
|
@ -91,11 +91,14 @@ class LocaleKeyTexts(dataStream: InputStream?, locale: Locale) {
|
||||||
|
|
||||||
private fun addMoreKeys(split: List<String>) {
|
private fun addMoreKeys(split: List<String>) {
|
||||||
if (split.size == 1) return
|
if (split.size == 1) return
|
||||||
val existingMoreKeys = moreKeys[split.first()]
|
val key = split.first()
|
||||||
if (existingMoreKeys == null)
|
val existingMoreKeys = moreKeys[key]
|
||||||
moreKeys[split.first()] = Array(split.size - 1) { split[it + 1] }
|
val newMoreKeys = if (existingMoreKeys == null)
|
||||||
else
|
Array(split.size - 1) { split[it + 1] }
|
||||||
moreKeys[split.first()] = mergeMoreKeys(existingMoreKeys, split.drop(1))
|
else mergeMoreKeys(existingMoreKeys, split.drop(1))
|
||||||
|
moreKeys[key] = if (key == "'" || key == "\"") // also do for parenthesis?
|
||||||
|
addFixedColumnOrder(newMoreKeys)
|
||||||
|
else newMoreKeys
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun addExtraKey(split: List<String>) {
|
private fun addExtraKey(split: List<String>) {
|
||||||
|
@ -192,6 +195,16 @@ private fun mergeMoreKeys(original: Array<String>, added: List<String>): Array<S
|
||||||
return moreKeys.toTypedArray()
|
return moreKeys.toTypedArray()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun addFixedColumnOrder(moreKeys: Array<String>): Array<String> {
|
||||||
|
if (moreKeys.none { it.startsWith("!fixedColumnOrder") })
|
||||||
|
return arrayOf("!fixedColumnOrder!${moreKeys.size}", *moreKeys)
|
||||||
|
val newMoreKeys = moreKeys.filterNot { it.startsWith("!fixedColumnOrder") }
|
||||||
|
return Array(newMoreKeys.size + 1) {
|
||||||
|
if (it == 0) "!fixedColumnOrder!${newMoreKeys.size}"
|
||||||
|
else newMoreKeys[it - 1]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun addLocaleKeyTextsToParams(context: Context, params: KeyboardParams, moreKeysSetting: Int) {
|
fun addLocaleKeyTextsToParams(context: Context, params: KeyboardParams, moreKeysSetting: Int) {
|
||||||
val locales = params.mSecondaryLocales + params.mId.locale
|
val locales = params.mSecondaryLocales + params.mId.locale
|
||||||
params.mLocaleKeyTexts = moreKeysAndLabels.getOrPut(locales.joinToString { it.toString() }) {
|
params.mLocaleKeyTexts = moreKeysAndLabels.getOrPut(locales.joinToString { it.toString() }) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue