abouttreesummaryrefslogcommitdiff
path: root/srcs/juloo.keyboard2/Config.java
diff options
context:
space:
mode:
authorJules Aguillon2022-06-05 19:30:53 +0200
committerJules Aguillon2022-06-05 19:30:53 +0200
commit5cc7fdf6d79ab0d497c771de409934786a95b146 (patch)
tree5cf334965d4733aefd950763316e6e2e6f883700 /srcs/juloo.keyboard2/Config.java
parentcc571ea1ca6e583024f9295b131ec199aa66cfd8 (diff)
downloadunexpected-keyboard-5cc7fdf6d79ab0d497c771de409934786a95b146.tar.gz
unexpected-keyboard-5cc7fdf6d79ab0d497c771de409934786a95b146.zip
Refactor: Separate Events and Keyevents and use enums
Negative values for internal events are preventing further refactoring. Add a new kind of key and split internal events (now Event) and Android's key events (now Keyevent). Use enums events and modifiers outside of the KeyValue class. Internally, they are converted to and from integer.
Diffstat (limited to 'srcs/juloo.keyboard2/Config.java')
-rw-r--r--srcs/juloo.keyboard2/Config.java33
1 files changed, 19 insertions, 14 deletions
diff --git a/srcs/juloo.keyboard2/Config.java b/srcs/juloo.keyboard2/Config.java
index e014fbd..f2fe1b8 100644
--- a/srcs/juloo.keyboard2/Config.java
+++ b/srcs/juloo.keyboard2/Config.java
@@ -36,7 +36,7 @@ final class Config
public float keyVerticalInterval;
public float keyHorizontalInterval;
public boolean preciseRepeat;
- public Set<Integer> lockable_modifiers = new HashSet<Integer>();
+ public Set<KeyValue.Modifier> lockable_modifiers = new HashSet<KeyValue.Modifier>();
public float characterSize; // Ratio
public int accents; // Values are R.values.pref_accents_v_*
public int theme; // Values are R.style.*
@@ -128,14 +128,14 @@ final class Config
horizontalMargin = getDipPref(dm, prefs, "horizontal_margin", horizontalMargin) + res.getDimension(R.dimen.extra_horizontal_margin);
preciseRepeat = prefs.getBoolean("precise_repeat", preciseRepeat);
lockable_modifiers.clear();
- if (prefs.getBoolean("lockable_shift", true)) lockable_modifiers.add(KeyValue.MOD_SHIFT);
- if (prefs.getBoolean("lockable_ctrl", false)) lockable_modifiers.add(KeyValue.MOD_CTRL);
- if (prefs.getBoolean("lockable_alt", false)) lockable_modifiers.add(KeyValue.MOD_ALT);
- if (prefs.getBoolean("lockable_fn", false)) lockable_modifiers.add(KeyValue.MOD_FN);
- if (prefs.getBoolean("lockable_meta", false)) lockable_modifiers.add(KeyValue.MOD_META);
- if (prefs.getBoolean("lockable_sup", false)) lockable_modifiers.add(KeyValue.MOD_SUPERSCRIPT);
- if (prefs.getBoolean("lockable_sub", false)) lockable_modifiers.add(KeyValue.MOD_SUBSCRIPT);
- if (prefs.getBoolean("lockable_box", false)) lockable_modifiers.add(KeyValue.MOD_BOX);
+ if (prefs.getBoolean("lockable_shift", true)) lockable_modifiers.add(KeyValue.Modifier.SHIFT);
+ if (prefs.getBoolean("lockable_ctrl", false)) lockable_modifiers.add(KeyValue.Modifier.CTRL);
+ if (prefs.getBoolean("lockable_alt", false)) lockable_modifiers.add(KeyValue.Modifier.ALT);
+ if (prefs.getBoolean("lockable_fn", false)) lockable_modifiers.add(KeyValue.Modifier.FN);
+ if (prefs.getBoolean("lockable_meta", false)) lockable_modifiers.add(KeyValue.Modifier.META);
+ if (prefs.getBoolean("lockable_sup", false)) lockable_modifiers.add(KeyValue.Modifier.SUPERSCRIPT);
+ if (prefs.getBoolean("lockable_sub", false)) lockable_modifiers.add(KeyValue.Modifier.SUBSCRIPT);
+ if (prefs.getBoolean("lockable_box", false)) lockable_modifiers.add(KeyValue.Modifier.BOX);
characterSize = prefs.getFloat("character_size", characterSize);
accents = Integer.valueOf(prefs.getString("accents", "1"));
theme = getThemeId(res, prefs.getString("theme", ""));
@@ -171,17 +171,22 @@ final class Config
case Event:
switch (key.getEvent())
{
- case KeyValue.EVENT_CHANGE_METHOD:
+ case CHANGE_METHOD:
return shouldOfferSwitchingToNextInputMethod ? key : null;
- case KeyEvent.KEYCODE_ENTER:
- return (swapEnterActionKey && action_key != null) ? action_key : key;
- case KeyValue.EVENT_ACTION:
+ case ACTION:
return (swapEnterActionKey && action_key != null) ?
KeyValue.getKeyByName("enter") : action_key;
- case KeyValue.EVENT_SWITCH_PROGRAMMING:
+ case SWITCH_PROGRAMMING:
return shouldOfferSwitchingToProgramming ? key : null;
}
break;
+ case Keyevent:
+ switch (key.getKeyevent())
+ {
+ case KeyEvent.KEYCODE_ENTER:
+ return (swapEnterActionKey && action_key != null) ? action_key : key;
+ }
+ break;
case Modifier:
if (lockable_modifiers.contains(key.getModifier()))
return key.withFlags(flags | KeyValue.FLAG_LOCK);