avoid duplicate symbols moreKeys

This commit is contained in:
Helium314 2023-12-28 09:43:06 +01:00
parent 2c03623b8a
commit 33ea631235
5 changed files with 8 additions and 7 deletions

View file

@ -344,7 +344,10 @@ public class Key implements Comparable<Key> {
mMoreKeys = moreKeys;
mMoreKeysColumnAndFlags = key.mMoreKeysColumnAndFlags;
mBackgroundType = key.mBackgroundType;
mActionFlags = key.mActionFlags;
if (moreKeys == null && mCode > Constants.CODE_SPACE && (key.mActionFlags & ACTION_FLAGS_ENABLE_LONG_PRESS) != 0)
mActionFlags = key.mActionFlags - ACTION_FLAGS_ENABLE_LONG_PRESS;
else
mActionFlags = key.mActionFlags;
mKeyVisualAttributes = key.mKeyVisualAttributes;
mOptionalAttributes = key.mOptionalAttributes;
mHashCode = key.mHashCode;

View file

@ -110,6 +110,7 @@ open class KeyboardBuilder<KP : KeyboardParams>(protected val mContext: Context,
fun load(xmlId: Int, id: KeyboardId): KeyboardBuilder<KP> {
mParams.mId = id
if (id.isEmojiKeyboard) {
setAllowRedundantMoreKeys(true)
readAttributes(R.xml.kbd_emoji_category1) // all the same anyway, gridRows are ignored
keysInRows = EmojiParser(mParams, mContext).parse()
} else {

View file

@ -117,7 +117,7 @@ public final class MoreKeySpec {
public void addLetter(@NonNull final Key key) {
final int code = key.getCode();
if (Character.isAlphabetic(code)) {
if (code > 32) {
mCodes.put(code, 0);
} else if (code == Constants.CODE_OUTPUT_TEXT) {
mTexts.add(key.getOutputText());
@ -126,7 +126,7 @@ public final class MoreKeySpec {
public boolean contains(@NonNull final MoreKeySpec moreKey) {
final int code = moreKey.mCode;
if (Character.isAlphabetic(code) && mCodes.indexOfKey(code) >= 0) {
if (mCodes.indexOfKey(code) >= 0) {
return true;
} else return code == Constants.CODE_OUTPUT_TEXT && mTexts.contains(moreKey.mOutputText);
}

View file

@ -823,7 +823,7 @@ abstract class KeyboardParser(private val params: KeyboardParams, private val co
params.mId.mElementId == KeyboardId.ELEMENT_ALPHABET
else -> true
}
val allowRedundantMoreKeys = name != "nordic" && name != "serbian_qwertz"
val allowRedundantMoreKeys = name != "nordic" && name != "serbian_qwertz" && params.mId.mElementId != KeyboardId.ELEMENT_SYMBOLS
// essentially this is default for 4 row and non-alphabet layouts, maybe this could be determined automatically instead of using a list
// todo: check the difference between default (i.e. none) and holo (test behavior on keyboard)
// todo: null for MoreKeysKeyboard only

View file

@ -32,9 +32,6 @@ const val MORE_KEYS_ORDER_DEFAULT = "$MORE_KEYS_LANGUAGE_PRIORITY,true;$MORE_KEY
// todo:
// could be done later:
// some way to allow hint labels in symbols layout
// remove duplicate symbol moreKeys
// in remove_symbol_duplicates.patch
// issues, see comments
// maybe put "language" moreKeys into a different category when not using alphabet layout
// because disabling language moreKeys will remove e.g. quote moreKeys