abouttreesummaryrefslogcommitdiff
path: root/srcs/juloo.keyboard2/Config.java
diff options
context:
space:
mode:
authorJules Aguillon2022-04-16 23:36:54 +0200
committerJules Aguillon2022-04-16 23:36:54 +0200
commit9a8c4f291da8babf3560e509554c78e1991cb22c (patch)
tree8051ab1abe74a7ce4dd6a5b78a1155871b3b6bed /srcs/juloo.keyboard2/Config.java
parent14cc318a0eb1f7ccd7695ed5ad6ef27f2428ffe9 (diff)
downloadunexpected-keyboard-9a8c4f291da8babf3560e509554c78e1991cb22c.tar.gz
unexpected-keyboard-9a8c4f291da8babf3560e509554c78e1991cb22c.zip
Fix compatibility with Android 6
Android 6 uses Java 1.7, the only incompatible feature in use was lambdas.
Diffstat (limited to 'srcs/juloo.keyboard2/Config.java')
-rw-r--r--srcs/juloo.keyboard2/Config.java56
1 files changed, 30 insertions, 26 deletions
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)