diff --git a/app/src/main/java/helium314/keyboard/accessibility/KeyCodeDescriptionMapper.kt b/app/src/main/java/helium314/keyboard/accessibility/KeyCodeDescriptionMapper.kt index 382d894dc..338c77250 100644 --- a/app/src/main/java/helium314/keyboard/accessibility/KeyCodeDescriptionMapper.kt +++ b/app/src/main/java/helium314/keyboard/accessibility/KeyCodeDescriptionMapper.kt @@ -57,7 +57,7 @@ internal class KeyCodeDescriptionMapper private constructor() { */ fun getDescriptionForKey(context: Context, keyboard: Keyboard?, key: Key, shouldObscure: Boolean): String? { val code = key.code - if (code == Constants.CODE_SWITCH_ALPHA_SYMBOL) { + if (code == Constants.CODE_SWITCH_ALPHA_SYMBOL || code == Constants.CODE_SWITCH_SYMBOL || code == Constants.CODE_SWITCH_ALPHA) { val description = getDescriptionForSwitchAlphaSymbol(context, keyboard) if (description != null) { return description diff --git a/app/src/main/java/helium314/keyboard/keyboard/Key.java b/app/src/main/java/helium314/keyboard/keyboard/Key.java index 6ab00c667..fd8cffdff 100644 --- a/app/src/main/java/helium314/keyboard/keyboard/Key.java +++ b/app/src/main/java/helium314/keyboard/keyboard/Key.java @@ -26,10 +26,11 @@ import java.util.Arrays; import java.util.Locale; import static helium314.keyboard.keyboard.internal.KeyboardIconsSet.ICON_UNDEFINED; -import static helium314.keyboard.latin.common.Constants.CODE_ALPHA_FROM_NUMPAD; import static helium314.keyboard.latin.common.Constants.CODE_OUTPUT_TEXT; import static helium314.keyboard.latin.common.Constants.CODE_SHIFT; +import static helium314.keyboard.latin.common.Constants.CODE_SWITCH_ALPHA; import static helium314.keyboard.latin.common.Constants.CODE_SWITCH_ALPHA_SYMBOL; +import static helium314.keyboard.latin.common.Constants.CODE_SWITCH_SYMBOL; import static helium314.keyboard.latin.common.Constants.CODE_UNSPECIFIED; import androidx.annotation.NonNull; @@ -517,7 +518,7 @@ public class Key implements Comparable { } public final boolean isModifier() { - return mCode == CODE_SHIFT || mCode == CODE_SWITCH_ALPHA_SYMBOL || mCode == CODE_ALPHA_FROM_NUMPAD; + return mCode == CODE_SHIFT || mCode == CODE_SWITCH_ALPHA_SYMBOL || mCode == CODE_SWITCH_ALPHA || mCode == CODE_SWITCH_SYMBOL; } public final boolean isRepeatable() { diff --git a/app/src/main/java/helium314/keyboard/keyboard/PointerTracker.java b/app/src/main/java/helium314/keyboard/keyboard/PointerTracker.java index b47295a69..a9a86ed7f 100644 --- a/app/src/main/java/helium314/keyboard/keyboard/PointerTracker.java +++ b/app/src/main/java/helium314/keyboard/keyboard/PointerTracker.java @@ -1114,7 +1114,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element, } } if (code == Constants.CODE_SWITCH_ALPHA_SYMBOL) { - sListener.onCodeInput(Constants.CODE_NUMPAD, Constants.NOT_A_COORDINATE, Constants.NOT_A_COORDINATE, false); + sListener.onCodeInput(Constants.CODE_SWITCH_NUMPAD, Constants.NOT_A_COORDINATE, Constants.NOT_A_COORDINATE, false); return; } diff --git a/app/src/main/java/helium314/keyboard/keyboard/clipboard/ClipboardHistoryView.kt b/app/src/main/java/helium314/keyboard/keyboard/clipboard/ClipboardHistoryView.kt index 0f0c21ba8..a225f280f 100644 --- a/app/src/main/java/helium314/keyboard/keyboard/clipboard/ClipboardHistoryView.kt +++ b/app/src/main/java/helium314/keyboard/keyboard/clipboard/ClipboardHistoryView.kt @@ -102,7 +102,7 @@ class ClipboardHistoryView @JvmOverloads constructor( } alphabetKey = findViewById(R.id.key_alphabet) alphabetKey.setBackgroundResource(functionalKeyBackgroundId) - alphabetKey.tag = Constants.CODE_ALPHA_FROM_CLIPBOARD + alphabetKey.tag = Constants.CODE_SWITCH_ALPHA alphabetKey.setOnTouchListener(this) alphabetKey.setOnClickListener(this) deleteKey = findViewById(R.id.key_delete) diff --git a/app/src/main/java/helium314/keyboard/keyboard/emoji/EmojiPalettesView.java b/app/src/main/java/helium314/keyboard/keyboard/emoji/EmojiPalettesView.java index 783ac3c72..6435b25b9 100644 --- a/app/src/main/java/helium314/keyboard/keyboard/emoji/EmojiPalettesView.java +++ b/app/src/main/java/helium314/keyboard/keyboard/emoji/EmojiPalettesView.java @@ -237,7 +237,7 @@ public final class EmojiPalettesView extends LinearLayout // {@link #startEmojiPalettes(String,int,float,Typeface)}. mAlphabetKeyLeft = findViewById(R.id.key_alphabet); mAlphabetKeyLeft.setBackgroundResource(mFunctionalKeyBackgroundId); - mAlphabetKeyLeft.setTag(Constants.CODE_ALPHA_FROM_EMOJI); + mAlphabetKeyLeft.setTag(Constants.CODE_SWITCH_ALPHA); mAlphabetKeyLeft.setOnTouchListener(this); mAlphabetKeyLeft.setOnClickListener(this); mSpacebar = findViewById(R.id.key_space); diff --git a/app/src/main/java/helium314/keyboard/keyboard/internal/KeyboardBuilder.kt b/app/src/main/java/helium314/keyboard/keyboard/internal/KeyboardBuilder.kt index cdeaed546..5caebb7f9 100644 --- a/app/src/main/java/helium314/keyboard/keyboard/internal/KeyboardBuilder.kt +++ b/app/src/main/java/helium314/keyboard/keyboard/internal/KeyboardBuilder.kt @@ -207,6 +207,7 @@ open class KeyboardBuilder(protected val mContext: Context, } // reduce width of symbol and action key if in the row, and add this width to space to keep other key size constant + // todo: this assumes fixed layout for symbols keys, which will change soon! private fun reduceSymbolAndActionKeyWidth(row: ArrayList) { val spaceKey = row.first { it.mCode == Constants.CODE_SPACE } val symbolKey = row.firstOrNull { it.mCode == Constants.CODE_SWITCH_ALPHA_SYMBOL } diff --git a/app/src/main/java/helium314/keyboard/keyboard/internal/KeyboardCodesSet.java b/app/src/main/java/helium314/keyboard/keyboard/internal/KeyboardCodesSet.java index 27fc16e1a..e10f48f5d 100644 --- a/app/src/main/java/helium314/keyboard/keyboard/internal/KeyboardCodesSet.java +++ b/app/src/main/java/helium314/keyboard/keyboard/internal/KeyboardCodesSet.java @@ -32,6 +32,8 @@ public final class KeyboardCodesSet { "key_shift", "key_capslock", "key_switch_alpha_symbol", + "key_switch_alpha", + "key_switch_symbol", "key_output_text", "key_delete", "key_settings", @@ -41,13 +43,9 @@ public final class KeyboardCodesSet { "key_shift_enter", "key_language_switch", "key_emoji", - "key_alpha_from_emoji", "key_unspecified", "key_clipboard", - "key_alpha_from_clipboard", "key_numpad", - "key_alphaNumpad", - "key_symbolNumpad", "key_start_onehanded", "key_stop_onehanded", "key_switch_onehanded" @@ -60,6 +58,8 @@ public final class KeyboardCodesSet { Constants.CODE_SHIFT, Constants.CODE_CAPSLOCK, Constants.CODE_SWITCH_ALPHA_SYMBOL, + Constants.CODE_SWITCH_ALPHA, + Constants.CODE_SWITCH_SYMBOL, Constants.CODE_OUTPUT_TEXT, Constants.CODE_DELETE, Constants.CODE_SETTINGS, @@ -69,13 +69,9 @@ public final class KeyboardCodesSet { Constants.CODE_SHIFT_ENTER, Constants.CODE_LANGUAGE_SWITCH, Constants.CODE_EMOJI, - Constants.CODE_ALPHA_FROM_EMOJI, Constants.CODE_UNSPECIFIED, Constants.CODE_CLIPBOARD, - Constants.CODE_ALPHA_FROM_CLIPBOARD, - Constants.CODE_NUMPAD, - Constants.CODE_ALPHA_FROM_NUMPAD, - Constants.CODE_SYMBOL_FROM_NUMPAD, + Constants.CODE_SWITCH_NUMPAD, Constants.CODE_START_ONE_HANDED_MODE, Constants.CODE_STOP_ONE_HANDED_MODE, Constants.CODE_SWITCH_ONE_HANDED_MODE diff --git a/app/src/main/java/helium314/keyboard/keyboard/internal/KeyboardState.java b/app/src/main/java/helium314/keyboard/keyboard/internal/KeyboardState.java index 4f2fc295b..a7f222cba 100644 --- a/app/src/main/java/helium314/keyboard/keyboard/internal/KeyboardState.java +++ b/app/src/main/java/helium314/keyboard/keyboard/internal/KeyboardState.java @@ -67,7 +67,6 @@ public final class KeyboardState { private final ShiftKeyState mShiftKeyState = new ShiftKeyState("Shift"); private final ModifierKeyState mSymbolKeyState = new ModifierKeyState("Symbol"); - private final ModifierKeyState mAlphaNumpadKeyState = new ModifierKeyState("AlphaNumpad"); private final AlphabetShiftState mAlphabetShiftState = new AlphabetShiftState(); // TODO: Merge {@link #mSwitchState}, {@link #mIsAlphabetMode}, {@link #mAlphabetShiftState}, @@ -76,12 +75,12 @@ public final class KeyboardState { private static final int SWITCH_STATE_ALPHA = 0; private static final int SWITCH_STATE_SYMBOL_BEGIN = 1; private static final int SWITCH_STATE_SYMBOL = 2; - private static final int SWITCH_STATE_MOMENTARY_ALPHA_AND_SYMBOL = 3; - private static final int SWITCH_STATE_MOMENTARY_SYMBOL_AND_MORE = 4; - private static final int SWITCH_STATE_MOMENTARY_ALPHA_SHIFT = 5; + private static final int SWITCH_STATE_NUMPAD = 3; + private static final int SWITCH_STATE_MOMENTARY_ALPHA_AND_SYMBOL = 4; + private static final int SWITCH_STATE_MOMENTARY_SYMBOL_AND_MORE = 5; + private static final int SWITCH_STATE_MOMENTARY_ALPHA_SHIFT = 6; + private static final int SWITCH_STATE_MOMENTARY_FROM_NUMPAD = 7; private int mSwitchState = SWITCH_STATE_ALPHA; - private static final int SWITCH_STATE_NUMPAD = 6; - private static final int SWITCH_STATE_MOMENTARY_NUMPAD_AND_ALPHA = 7; private static final int MODE_ALPHABET = 0; private static final int MODE_SYMBOLS = 1; @@ -290,23 +289,6 @@ public final class KeyboardState { } } - private void toggleNumpadAndAlphabet(final int autoCapsFlags, final int recapitalizeMode) { - if (DEBUG_INTERNAL_ACTION) { - Log.d(TAG, "toggleNumpadAndAlphabet: " - + stateToString(autoCapsFlags, recapitalizeMode)); - } - if (mMode == MODE_NUMPAD) { - mPrevMainKeyboardWasShiftLocked = mAlphabetShiftState.isShiftLocked(); - setAlphabetKeyboard(autoCapsFlags, recapitalizeMode); - if (mPrevMainKeyboardWasShiftLocked) { - setShiftLocked(true); - } - mPrevMainKeyboardWasShiftLocked = false; - } else { - setNumpadKeyboard(); - } - } - // TODO: Remove this method. Come up with a more comprehensive way to reset the keyboard layout // when a keyboard layout set doesn't get reloaded in LatinIME.onStartInputViewInternal(). private void resetKeyboardStateToAlphabet(final int autoCapsFlags, final int recapitalizeMode) { @@ -439,9 +421,13 @@ public final class KeyboardState { } else if (code == Constants.CODE_CAPSLOCK) { // Nothing to do here. See {@link #onReleaseKey(int,boolean)}. } else if (code == Constants.CODE_SWITCH_ALPHA_SYMBOL) { - onPressSymbol(autoCapsFlags, recapitalizeMode); - } else if (code == Constants.CODE_ALPHA_FROM_NUMPAD) { - onPressAlphaNumpad(autoCapsFlags, recapitalizeMode); + onPressAlphaSymbol(autoCapsFlags, recapitalizeMode); + } else if (code == Constants.CODE_SWITCH_SYMBOL) { + // don't start sliding, causes issues with fully customizable layouts + // (also does not allow chording, but can be fixed later) + } else if (code == Constants.CODE_SWITCH_ALPHA) { + // don't start sliding, causes issues with fully customizable layouts + // (also does not allow chording, but can be fixed later) } else { mShiftKeyState.onOtherKeyPressed(); mSymbolKeyState.onOtherKeyPressed(); @@ -476,21 +462,21 @@ public final class KeyboardState { } else if (code == Constants.CODE_CAPSLOCK) { setShiftLocked(!mAlphabetShiftState.isShiftLocked()); } else if (code == Constants.CODE_SWITCH_ALPHA_SYMBOL) { + onReleaseAlphaSymbol(withSliding, autoCapsFlags, recapitalizeMode); + } else if (code == Constants.CODE_SWITCH_SYMBOL) { onReleaseSymbol(withSliding, autoCapsFlags, recapitalizeMode); - } else if (code == Constants.CODE_ALPHA_FROM_NUMPAD) { - onReleaseAlphaNumpad(withSliding, autoCapsFlags, recapitalizeMode); + } else if (code == Constants.CODE_SWITCH_ALPHA) { + onReleaseAlpha(withSliding, autoCapsFlags, recapitalizeMode); } } - private void onPressSymbol(final int autoCapsFlags, - final int recapitalizeMode) { + private void onPressAlphaSymbol(final int autoCapsFlags, final int recapitalizeMode) { toggleAlphabetAndSymbols(autoCapsFlags, recapitalizeMode); mSymbolKeyState.onPress(); mSwitchState = SWITCH_STATE_MOMENTARY_ALPHA_AND_SYMBOL; } - private void onReleaseSymbol(final boolean withSliding, final int autoCapsFlags, - final int recapitalizeMode) { + private void onReleaseAlphaSymbol(final boolean withSliding, final int autoCapsFlags, final int recapitalizeMode) { if (mSymbolKeyState.isChording()) { // Switch back to the previous keyboard mode if the user chords the mode change key and // another key, then releases the mode change key. @@ -504,27 +490,18 @@ public final class KeyboardState { mSymbolKeyState.onRelease(); } - private void onPressAlphaNumpad(final int autoCapsFlags, - final int recapitalizeMode) { - toggleNumpadAndAlphabet(autoCapsFlags, recapitalizeMode); - mAlphaNumpadKeyState.onPress(); - mSwitchState = SWITCH_STATE_MOMENTARY_NUMPAD_AND_ALPHA; + private void onReleaseSymbol(final boolean withSliding, final int autoCapsFlags, final int recapitalizeMode) { + final int oldMode = mMode; + setSymbolsKeyboard(); + if (withSliding && oldMode == MODE_NUMPAD) + mSwitchState = SWITCH_STATE_MOMENTARY_FROM_NUMPAD; } - private void onReleaseAlphaNumpad(final boolean withSliding, final int autoCapsFlags, - final int recapitalizeMode) { - if (mAlphaNumpadKeyState.isChording()) { - // Switch back to the previous keyboard mode if the user chords the mode change key and - // another key, then releases the mode change key. - toggleNumpadAndAlphabet(autoCapsFlags, recapitalizeMode); - } else if (!withSliding) { - // If the mode change key is being released without sliding, we should remember - // caps lock mode and reset alphabet shift state. - mPrevMainKeyboardWasShiftLocked = mAlphabetShiftState.isShiftLocked(); - mAlphabetShiftState.setShiftLocked(false); - - } - mAlphaNumpadKeyState.onRelease(); + private void onReleaseAlpha(final boolean withSliding, final int autoCapsFlags, final int recapitalizeMode) { + final int oldMode = mMode; + setAlphabetKeyboard(autoCapsFlags, recapitalizeMode); + if (withSliding && oldMode == MODE_NUMPAD) + mSwitchState = SWITCH_STATE_MOMENTARY_FROM_NUMPAD; } public void onUpdateShiftState(final int autoCapsFlags, final int recapitalizeMode) { @@ -701,18 +678,10 @@ public final class KeyboardState { } // Switch back to the previous keyboard mode if the user cancels sliding input. switch (mSwitchState) { - case SWITCH_STATE_MOMENTARY_ALPHA_AND_SYMBOL: - toggleAlphabetAndSymbols(autoCapsFlags, recapitalizeMode); - break; - case SWITCH_STATE_MOMENTARY_SYMBOL_AND_MORE: - toggleShiftInSymbols(); - break; - case SWITCH_STATE_MOMENTARY_ALPHA_SHIFT: - setAlphabetKeyboard(autoCapsFlags, recapitalizeMode); - break; - case SWITCH_STATE_MOMENTARY_NUMPAD_AND_ALPHA: - toggleNumpadAndAlphabet(autoCapsFlags, recapitalizeMode); - break; + case SWITCH_STATE_MOMENTARY_ALPHA_AND_SYMBOL -> toggleAlphabetAndSymbols(autoCapsFlags, recapitalizeMode); + case SWITCH_STATE_MOMENTARY_SYMBOL_AND_MORE -> toggleShiftInSymbols(); + case SWITCH_STATE_MOMENTARY_ALPHA_SHIFT -> setAlphabetKeyboard(autoCapsFlags, recapitalizeMode); + case SWITCH_STATE_MOMENTARY_FROM_NUMPAD -> setNumpadKeyboard(); } } @@ -738,16 +707,6 @@ public final class KeyboardState { } } break; - case SWITCH_STATE_MOMENTARY_NUMPAD_AND_ALPHA: - if (code == Constants.CODE_ALPHA_FROM_NUMPAD) { - // Detected only the mode change key has been pressed, and then released. - if (mMode == MODE_NUMPAD) { - mSwitchState = SWITCH_STATE_NUMPAD; - } else { - mSwitchState = SWITCH_STATE_ALPHA; - } - } - break; case SWITCH_STATE_MOMENTARY_SYMBOL_AND_MORE: if (code == Constants.CODE_SHIFT) { // Detected only the shift key has been pressed on symbol layout, and then @@ -793,7 +752,7 @@ public final class KeyboardState { updateAlphabetShiftState(autoCapsFlags, recapitalizeMode); } else if (code == Constants.CODE_EMOJI) { setEmojiKeyboard(); - } else if (code == Constants.CODE_ALPHA_FROM_EMOJI) { + } else if (code == Constants.CODE_SWITCH_ALPHA) { setAlphabetKeyboard(autoCapsFlags, recapitalizeMode); } else if (code == Constants.CODE_CLIPBOARD) { // Note: Printing clipboard content is handled in @@ -801,11 +760,9 @@ public final class KeyboardState { if (Settings.getInstance().getCurrent().mClipboardHistoryEnabled) { setClipboardKeyboard(); } - } else if (code == Constants.CODE_ALPHA_FROM_CLIPBOARD) { - setAlphabetKeyboard(autoCapsFlags, recapitalizeMode); - } else if (code == Constants.CODE_NUMPAD) { + } else if (code == Constants.CODE_SWITCH_NUMPAD) { setNumpadKeyboard(); - } else if (code == Constants.CODE_SYMBOL_FROM_NUMPAD) { + } else if (code == Constants.CODE_SWITCH_SYMBOL) { setSymbolsKeyboard(); } else if (code == Constants.CODE_START_ONE_HANDED_MODE) { setOneHandedModeEnabled(true); @@ -826,17 +783,17 @@ public final class KeyboardState { } private static String switchStateToString(final int switchState) { - switch (switchState) { - case SWITCH_STATE_ALPHA: return "ALPHA"; - case SWITCH_STATE_SYMBOL_BEGIN: return "SYMBOL-BEGIN"; - case SWITCH_STATE_SYMBOL: return "SYMBOL"; - case SWITCH_STATE_MOMENTARY_ALPHA_AND_SYMBOL: return "MOMENTARY-ALPHA-SYMBOL"; - case SWITCH_STATE_MOMENTARY_SYMBOL_AND_MORE: return "MOMENTARY-SYMBOL-MORE"; - case SWITCH_STATE_MOMENTARY_ALPHA_SHIFT: return "MOMENTARY-ALPHA_SHIFT"; - case SWITCH_STATE_NUMPAD: return "NUMPAD"; - case SWITCH_STATE_MOMENTARY_NUMPAD_AND_ALPHA: return "MOMENTARY-NUMPAD-ALPHA"; - default: return null; - } + return switch (switchState) { + case SWITCH_STATE_ALPHA -> "ALPHA"; + case SWITCH_STATE_SYMBOL_BEGIN -> "SYMBOL-BEGIN"; + case SWITCH_STATE_SYMBOL -> "SYMBOL"; + case SWITCH_STATE_MOMENTARY_ALPHA_AND_SYMBOL -> "MOMENTARY-ALPHA-SYMBOL"; + case SWITCH_STATE_MOMENTARY_SYMBOL_AND_MORE -> "MOMENTARY-SYMBOL-MORE"; + case SWITCH_STATE_MOMENTARY_ALPHA_SHIFT -> "MOMENTARY-ALPHA_SHIFT"; + case SWITCH_STATE_NUMPAD -> "NUMPAD"; + case SWITCH_STATE_MOMENTARY_FROM_NUMPAD -> "MOMENTARY-FROM-NUMPAD"; + default -> null; + }; } @Override diff --git a/app/src/main/java/helium314/keyboard/keyboard/internal/keyboard_parser/KeyboardParser.kt b/app/src/main/java/helium314/keyboard/keyboard/internal/keyboard_parser/KeyboardParser.kt index ef457f0b7..4c7675eb3 100644 --- a/app/src/main/java/helium314/keyboard/keyboard/internal/keyboard_parser/KeyboardParser.kt +++ b/app/src/main/java/helium314/keyboard/keyboard/internal/keyboard_parser/KeyboardParser.kt @@ -413,9 +413,18 @@ abstract class KeyboardParser(private val params: KeyboardParams, private val co // for comma and period: label will override default, popupKeys will be appended val width = relativeWidth ?: params.mDefaultRelativeKeyWidth return when (key) { + FunctionalKey.SYMBOL_ALPHA -> KeyParams( + if (params.mId.isAlphabetKeyboard) getToSymbolLabel() else params.mLocaleKeyboardInfos.labelAlphabet, + Constants.CODE_SWITCH_ALPHA_SYMBOL, + params, + width, + Key.LABEL_FLAGS_PRESERVE_CASE or Key.LABEL_FLAGS_FOLLOW_FUNCTIONAL_TEXT_COLOR, + Key.BACKGROUND_TYPE_FUNCTIONAL, + null + ) FunctionalKey.SYMBOL -> KeyParams( getToSymbolLabel(), - getToSymbolCode(), + Constants.CODE_SWITCH_SYMBOL, params, width, Key.LABEL_FLAGS_PRESERVE_CASE or Key.LABEL_FLAGS_FOLLOW_FUNCTIONAL_TEXT_COLOR, @@ -424,7 +433,7 @@ abstract class KeyboardParser(private val params: KeyboardParams, private val co ) FunctionalKey.ALPHA -> KeyParams( params.mLocaleKeyboardInfos.labelAlphabet, - getToAlphaCode(), + Constants.CODE_SWITCH_ALPHA, params, width, Key.LABEL_FLAGS_PRESERVE_CASE or Key.LABEL_FLAGS_FOLLOW_FUNCTIONAL_TEXT_COLOR, @@ -660,16 +669,6 @@ abstract class KeyboardParser(private val params: KeyboardParams, private val co params.mLocaleKeyboardInfos.labelAlphabet else params.mLocaleKeyboardInfos.labelSymbol - private fun getToSymbolCode() = - if (params.mId.mElementId == KeyboardId.ELEMENT_NUMPAD) - Constants.CODE_SYMBOL_FROM_NUMPAD - else Constants.CODE_SWITCH_ALPHA_SYMBOL - - private fun getToAlphaCode() = - if (params.mId.mElementId == KeyboardId.ELEMENT_NUMPAD) - Constants.CODE_ALPHA_FROM_NUMPAD - else Constants.CODE_SWITCH_ALPHA_SYMBOL - private fun getShiftLabel(): String { val elementId = params.mId.mElementId if (elementId == KeyboardId.ELEMENT_SYMBOLS_SHIFTED) @@ -820,7 +819,7 @@ abstract class KeyboardParser(private val params: KeyboardParams, private val co } protected enum class FunctionalKey { - EMOJI, LANGUAGE_SWITCH, COM, EMOJI_COM, ACTION, DELETE, PERIOD, COMMA, SPACE, SHIFT, NUMPAD, SYMBOL, ALPHA, ZWNJ + EMOJI, LANGUAGE_SWITCH, COM, EMOJI_COM, ACTION, DELETE, PERIOD, COMMA, SPACE, SHIFT, NUMPAD, SYMBOL, ALPHA, SYMBOL_ALPHA, ZWNJ } } diff --git a/app/src/main/java/helium314/keyboard/latin/common/Constants.java b/app/src/main/java/helium314/keyboard/latin/common/Constants.java index 75b4bb26b..b8a619c56 100644 --- a/app/src/main/java/helium314/keyboard/latin/common/Constants.java +++ b/app/src/main/java/helium314/keyboard/latin/common/Constants.java @@ -196,6 +196,7 @@ public final class Constants { * These should be aligned with constants in * {@link helium314.keyboard.keyboard.internal.KeyboardCodesSet}. */ + // todo: switch to using KeyCode for internal values? for FlorisBoard modifier key(code) compatibility public static final int CODE_SHIFT = -1; public static final int CODE_CAPSLOCK = -2; public static final int CODE_SWITCH_ALPHA_SYMBOL = -3; @@ -210,14 +211,12 @@ public final class Constants { public static final int CODE_CLIPBOARD = -12; public static final int CODE_SHIFT_ENTER = -13; public static final int CODE_SYMBOL_SHIFT = -14; - public static final int CODE_ALPHA_FROM_EMOJI = -15; - public static final int CODE_ALPHA_FROM_CLIPBOARD = -16; public static final int CODE_START_ONE_HANDED_MODE = -17; public static final int CODE_STOP_ONE_HANDED_MODE = -18; public static final int CODE_SWITCH_ONE_HANDED_MODE = -19; - public static final int CODE_NUMPAD = -20; - public static final int CODE_ALPHA_FROM_NUMPAD = -21; - public static final int CODE_SYMBOL_FROM_NUMPAD = -22; + public static final int CODE_SWITCH_NUMPAD = -20; + public static final int CODE_SWITCH_ALPHA = -21; + public static final int CODE_SWITCH_SYMBOL = -22; public static final int CODE_SELECT_ALL = -23; public static final int CODE_COPY = -24; public static final int CODE_LEFT = -25; @@ -243,7 +242,9 @@ public final class Constants { switch (code) { case CODE_SHIFT: return "shift"; case CODE_CAPSLOCK: return "capslock"; - case CODE_SWITCH_ALPHA_SYMBOL: return "symbol"; + case CODE_SWITCH_ALPHA_SYMBOL: return "alpha_symbol"; + case CODE_SWITCH_ALPHA: return "alpha"; + case CODE_SWITCH_SYMBOL: return "symbol"; case CODE_OUTPUT_TEXT: return "text"; case CODE_DELETE: return "delete"; case CODE_SETTINGS: return "settings"; @@ -254,8 +255,6 @@ public final class Constants { case CODE_EMOJI: return "emoji"; case CODE_CLIPBOARD: return "clipboard"; case CODE_SHIFT_ENTER: return "shiftEnter"; - case CODE_ALPHA_FROM_EMOJI: return "alpha"; - case CODE_ALPHA_FROM_CLIPBOARD: return "alpha"; case CODE_UNSPECIFIED: return "unspec"; case CODE_TAB: return "tab"; case CODE_ENTER: return "enter"; @@ -263,9 +262,7 @@ public final class Constants { case CODE_START_ONE_HANDED_MODE: return "startOneHandedMode"; case CODE_STOP_ONE_HANDED_MODE: return "stopOneHandedMode"; case CODE_SWITCH_ONE_HANDED_MODE: return "switchOneHandedMode"; - case CODE_NUMPAD: return "numpad"; - case CODE_ALPHA_FROM_NUMPAD: return "alphaNumpad"; - case CODE_SYMBOL_FROM_NUMPAD: return "symbolNumpad"; + case CODE_SWITCH_NUMPAD: return "numpad"; default: if (code < CODE_SPACE) return String.format("\\u%02X", code); if (code < 0x100) return String.format("%c", code); diff --git a/app/src/main/java/helium314/keyboard/latin/inputlogic/InputLogic.java b/app/src/main/java/helium314/keyboard/latin/inputlogic/InputLogic.java index 1f548cbf7..42c843664 100644 --- a/app/src/main/java/helium314/keyboard/latin/inputlogic/InputLogic.java +++ b/app/src/main/java/helium314/keyboard/latin/inputlogic/InputLogic.java @@ -488,7 +488,9 @@ public final class InputLogic { } if (!inputTransaction.didAutoCorrect() && processedEvent.getMKeyCode() != Constants.CODE_SHIFT && processedEvent.getMKeyCode() != Constants.CODE_CAPSLOCK - && processedEvent.getMKeyCode() != Constants.CODE_SWITCH_ALPHA_SYMBOL) + && processedEvent.getMKeyCode() != Constants.CODE_SWITCH_ALPHA_SYMBOL + && processedEvent.getMKeyCode() != Constants.CODE_SWITCH_ALPHA + && processedEvent.getMKeyCode() != Constants.CODE_SWITCH_SYMBOL) mLastComposedWord.deactivate(); if (Constants.CODE_DELETE != processedEvent.getMKeyCode()) { mEnteredText = null; @@ -744,12 +746,10 @@ public final class InputLogic { case Constants.CODE_CAPSLOCK: case Constants.CODE_SYMBOL_SHIFT: case Constants.CODE_SWITCH_ALPHA_SYMBOL: + case Constants.CODE_SWITCH_ALPHA: + case Constants.CODE_SWITCH_SYMBOL: + case Constants.CODE_SWITCH_NUMPAD: case Constants.CODE_EMOJI: - case Constants.CODE_ALPHA_FROM_EMOJI: - case Constants.CODE_ALPHA_FROM_CLIPBOARD: - case Constants.CODE_NUMPAD: - case Constants.CODE_ALPHA_FROM_NUMPAD: - case Constants.CODE_SYMBOL_FROM_NUMPAD: case Constants.CODE_START_ONE_HANDED_MODE: case Constants.CODE_STOP_ONE_HANDED_MODE: case Constants.CODE_SWITCH_ONE_HANDED_MODE: diff --git a/app/src/main/res/values-sw600dp/functional-keys.xml b/app/src/main/res/values-sw600dp/functional-keys.xml index f44de015f..a5296108a 100644 --- a/app/src/main/res/values-sw600dp/functional-keys.xml +++ b/app/src/main/res/values-sw600dp/functional-keys.xml @@ -4,5 +4,5 @@ ;action 10% shift 10%; shift" ";delete 10%" - "symbol, comma, space, period, emoji_com" + "symbol_alpha, comma, space, period, emoji_com" diff --git a/app/src/main/res/values/functional-keys.xml b/app/src/main/res/values/functional-keys.xml index 285039d6b..6fe085de4 100644 --- a/app/src/main/res/values/functional-keys.xml +++ b/app/src/main/res/values/functional-keys.xml @@ -18,5 +18,5 @@ split into two groups. Space bar will be adjusted in code for language and emoji keys, and other keys in symbol layouts --> - "symbol 15%, comma, space, period, action 15%" + "symbol_alpha 15%, comma, space, period, action 15%"