mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-05-31 11:52:13 +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;
|
||||
mRelativeWidth = relativeWidth;
|
||||
mRelativeHeight = params.mDefaultRelativeRowHeight;
|
||||
mMoreKeysColumnAndFlags = getMoreKeysColumnAndFlagsAndSetNullInArray(params, layoutMoreKeys);
|
||||
mIconId = KeySpecParser.getIconId(keySpec);
|
||||
|
||||
final boolean needsToUpcase = needsToUpcase(mLabelFlags, params.mId.mElementId);
|
||||
final Locale localeForUpcasing = params.mId.getLocale();
|
||||
int actionFlags = 0;
|
||||
|
||||
final String[] languageMoreKeys;
|
||||
if ((mLabelFlags & LABEL_FLAGS_DISABLE_ADDITIONAL_MORE_KEYS) != 0) {
|
||||
languageMoreKeys = null;
|
||||
} else {
|
||||
// same style as additionalMoreKeys (i.e. moreKeys with the % placeholder(s))
|
||||
languageMoreKeys = params.mLocaleKeyTexts.getMoreKeys(keySpec);
|
||||
}
|
||||
final String[] finalMoreKeys = MoreKeySpec.insertAdditionalMoreKeys(languageMoreKeys, layoutMoreKeys);
|
||||
final String[] languageMoreKeys = params.mLocaleKeyTexts.getMoreKeys(keySpec);
|
||||
// todo: after removing old parser this could be done in a less awkward way without almostFinalMoreKeys
|
||||
final String[] almostFinalMoreKeys = MoreKeySpec.insertAdditionalMoreKeys(languageMoreKeys, layoutMoreKeys);
|
||||
mMoreKeysColumnAndFlags = getMoreKeysColumnAndFlagsAndSetNullInArray(params, almostFinalMoreKeys);
|
||||
final String[] finalMoreKeys = almostFinalMoreKeys == null
|
||||
? null
|
||||
: MoreKeySpec.filterOutEmptyString(almostFinalMoreKeys);
|
||||
|
||||
if (finalMoreKeys != null) {
|
||||
actionFlags |= ACTION_FLAGS_ENABLE_LONG_PRESS;
|
||||
|
|
|
@ -154,9 +154,8 @@ open class KeyboardBuilder<KP : KeyboardParams>(protected val mContext: Context,
|
|||
// followFunctionalTextColor: number mode keys, action key
|
||||
// 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
|
||||
// disableAdditionalMoreKeys: keys in pcqwerty row 1
|
||||
// -> 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?
|
||||
// disableAdditionalMoreKeys: only keys in pcqwerty row 1 so there is no number row -> not necessary with the new layouts, just remove it completely
|
||||
// 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
|
||||
// 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];
|
||||
|
||||
@NonNull
|
||||
private static String[] filterOutEmptyString(@Nullable final String[] array) {
|
||||
public static String[] filterOutEmptyString(@Nullable final String[] array) {
|
||||
if (array == null) {
|
||||
return EMPTY_STRING_ARRAY;
|
||||
}
|
||||
|
|
|
@ -45,9 +45,9 @@ class LocaleKeyTexts(dataStream: InputStream?, locale: Locale) {
|
|||
// set default quote moreKeys if necessary
|
||||
// should this also be done with punctuation moreKeys?
|
||||
if ("\'" !in moreKeys)
|
||||
moreKeys["\'"] = arrayOf("‚", "‘", "’", "‹", "›")
|
||||
moreKeys["\'"] = arrayOf("!fixedColumnOrder!5", "‚", "‘", "’", "‹", "›")
|
||||
if ("\"" !in moreKeys)
|
||||
moreKeys["\""] = arrayOf("„", "“", "”", "«", "»")
|
||||
moreKeys["\""] = arrayOf("!fixedColumnOrder!5", "„", "“", "”", "«", "»")
|
||||
if ("!" !in moreKeys)
|
||||
moreKeys["!"] = arrayOf("¡")
|
||||
if ("?" !in moreKeys)
|
||||
|
@ -91,11 +91,14 @@ class LocaleKeyTexts(dataStream: InputStream?, locale: Locale) {
|
|||
|
||||
private fun addMoreKeys(split: List<String>) {
|
||||
if (split.size == 1) return
|
||||
val existingMoreKeys = moreKeys[split.first()]
|
||||
if (existingMoreKeys == null)
|
||||
moreKeys[split.first()] = Array(split.size - 1) { split[it + 1] }
|
||||
else
|
||||
moreKeys[split.first()] = mergeMoreKeys(existingMoreKeys, split.drop(1))
|
||||
val key = split.first()
|
||||
val existingMoreKeys = moreKeys[key]
|
||||
val newMoreKeys = if (existingMoreKeys == null)
|
||||
Array(split.size - 1) { split[it + 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>) {
|
||||
|
@ -192,6 +195,16 @@ private fun mergeMoreKeys(original: Array<String>, added: List<String>): Array<S
|
|||
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) {
|
||||
val locales = params.mSecondaryLocales + params.mId.locale
|
||||
params.mLocaleKeyTexts = moreKeysAndLabels.getOrPut(locales.joinToString { it.toString() }) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue