abouttreesummaryrefslogcommitdiff
path: root/srcs/juloo.keyboard2/Config.java
diff options
context:
space:
mode:
authorJules Aguillon2022-06-05 17:26:34 +0200
committerJules Aguillon2022-06-05 17:46:22 +0200
commite10c587dc5286db64a6f55010637f0c3f9f62d59 (patch)
tree2c39dd330f1915e3c1f8bb353c5db13c3a6c3bd4 /srcs/juloo.keyboard2/Config.java
parentd03e96da3e99e1e0edb78367499c22f574079583 (diff)
downloadunexpected-keyboard-e10c587dc5286db64a6f55010637f0c3f9f62d59.tar.gz
unexpected-keyboard-e10c587dc5286db64a6f55010637f0c3f9f62d59.zip
Refactor: Abstract KeyValue fields
The meaning of the public fields of KeyValue was quite complicated and not handled consistently accross the app. Make these fields private and add a more abstract API on top. The meaning of these fields changed recently and it wasn't an easy change. I plan on making more changes in the future.
Diffstat (limited to 'srcs/juloo.keyboard2/Config.java')
-rw-r--r--srcs/juloo.keyboard2/Config.java39
1 files changed, 21 insertions, 18 deletions
diff --git a/srcs/juloo.keyboard2/Config.java b/srcs/juloo.keyboard2/Config.java
index 6e4ea49..e014fbd 100644
--- a/srcs/juloo.keyboard2/Config.java
+++ b/srcs/juloo.keyboard2/Config.java
@@ -163,28 +163,31 @@ final class Config
boolean is_extra_key = extra_keys.contains(key.name);
if (is_extra_key)
extra_keys.remove(key.name);
- switch (key.code)
+ int flags = key.getFlags();
+ if ((flags & KeyValue.FLAG_LOCALIZED) != 0 && !is_extra_key)
+ return null;
+ switch (key.getKind())
{
- 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)
+ case Event:
+ switch (key.getEvent())
{
- if ((key.flags & KeyValue.FLAG_LOCALIZED) != 0 && !is_extra_key)
- return null;
- if ((key.flags & KeyValue.FLAG_MODIFIER) != 0
- && lockable_modifiers.contains(key.code))
- return key.withFlags(key.flags | KeyValue.FLAG_LOCK);
+ 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;
}
- return key;
+ break;
+ case Modifier:
+ if (lockable_modifiers.contains(key.getModifier()))
+ return key.withFlags(flags | KeyValue.FLAG_LOCK);
+ break;
}
+ return key;
}
});
if (extra_keys.size() > 0)