diff --git a/Makefile b/Makefile index 6ad91b8..07b7228 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ PACKAGE_NAME = juloo.keyboard2 ANDROID_PLATFORM_VERSION = android-30 -JAVA_VERSION = 1.8 +JAVA_VERSION = 1.7 SRC_DIR = srcs RES_DIR = res diff --git a/srcs/juloo.keyboard2/Config.java b/srcs/juloo.keyboard2/Config.java index 47fb62a..4022394 100644 --- a/srcs/juloo.keyboard2/Config.java +++ b/srcs/juloo.keyboard2/Config.java @@ -149,34 +149,38 @@ final class Config public KeyboardData modify_layout(KeyboardData kw) { // Update the name to avoid caching in KeyModifier - KeyValue action_key = (actionLabel == null) ? null : + final KeyValue action_key = (actionLabel == null) ? null : KeyValue.getKeyByName("action").withNameAndSymbol(actionLabel, actionLabel); - return kw.replaceKeys(key -> { - if (key == null) - return null; - switch (key.eventCode) + return kw.replaceKeys(new KeyboardData.MapKeys() { + public KeyValue apply(KeyValue key) { - case KeyValue.EVENT_CHANGE_METHOD: - return shouldOfferSwitchingToNextInputMethod ? key : null; - case KeyEvent.KEYCODE_ENTER: - return (swapEnterActionKey && action_key != null) ? action_key : key; - case KeyValue.EVENT_ACTION: - return (swapEnterActionKey && action_key != null) ? - KeyValue.getKeyByName("enter") : action_key; - case KeyValue.EVENT_SWITCH_PROGRAMMING: - return shouldOfferSwitchingToProgramming ? key : null; - default: - if (key.flags != 0) - { - if ((key.flags & KeyValue.FLAG_LOCALIZED) != 0 && - extra_keys != null && - !extra_keys.contains(key.name)) - return null; - if ((key.flags & lockable_modifiers) != 0) - return key.withFlags(key.flags | KeyValue.FLAG_LOCK); - } - return key; - }}); + if (key == null) + return null; + switch (key.eventCode) + { + case KeyValue.EVENT_CHANGE_METHOD: + return shouldOfferSwitchingToNextInputMethod ? key : null; + case KeyEvent.KEYCODE_ENTER: + return (swapEnterActionKey && action_key != null) ? action_key : key; + case KeyValue.EVENT_ACTION: + return (swapEnterActionKey && action_key != null) ? + KeyValue.getKeyByName("enter") : action_key; + case KeyValue.EVENT_SWITCH_PROGRAMMING: + return shouldOfferSwitchingToProgramming ? key : null; + default: + if (key.flags != 0) + { + if ((key.flags & KeyValue.FLAG_LOCALIZED) != 0 && + extra_keys != null && + !extra_keys.contains(key.name)) + return null; + if ((key.flags & lockable_modifiers) != 0) + return key.withFlags(key.flags | KeyValue.FLAG_LOCK); + } + return key; + } + } + }); } private float getDipPref(DisplayMetrics dm, SharedPreferences prefs, String pref_name, float def) diff --git a/srcs/juloo.keyboard2/Keyboard2.java b/srcs/juloo.keyboard2/Keyboard2.java index abea412..5b7935e 100644 --- a/srcs/juloo.keyboard2/Keyboard2.java +++ b/srcs/juloo.keyboard2/Keyboard2.java @@ -294,10 +294,13 @@ public class Keyboard2 extends InputMethodService if (_config.programming_layout == -1) return; KeyboardData layout = - getLayout(_config.programming_layout).replaceKeys(key -> { - if (key != null && key.eventCode == KeyValue.EVENT_SWITCH_PROGRAMMING) - return KeyValue.getKeyByName("switch_text"); - return key; + getLayout(_config.programming_layout).replaceKeys(new KeyboardData.MapKeys() { + public KeyValue apply(KeyValue key) + { + if (key != null && key.eventCode == KeyValue.EVENT_SWITCH_PROGRAMMING) + return KeyValue.getKeyByName("switch_text"); + return key; + } }); _keyboardView.setKeyboard(layout); } diff --git a/srcs/juloo.keyboard2/KeyboardData.java b/srcs/juloo.keyboard2/KeyboardData.java index f0b1d1b..78c1d3f 100644 --- a/srcs/juloo.keyboard2/KeyboardData.java +++ b/srcs/juloo.keyboard2/KeyboardData.java @@ -208,7 +208,10 @@ class KeyboardData } } - public static abstract interface MapKeys extends Function { } + // Not using Function to keep compatibility with Android 6. + public static abstract interface MapKeys { + public KeyValue apply(KeyValue kv); + } /** Parsing utils */