diff --git a/res/values/strings.xml b/res/values/strings.xml
index 3d68d1f..8c3eb36 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -21,6 +21,8 @@
Duration
Precise cursor movements
Modulate key repeat speed by swiping more or less
+ Lockable modifiers
+ Modifier that can be locked by typing them twice
Style
Margin bottom
Keyboard height
diff --git a/res/xml/settings.xml b/res/xml/settings.xml
index 7ae8542..9a1bcae 100644
--- a/res/xml/settings.xml
+++ b/res/xml/settings.xml
@@ -9,6 +9,13 @@
+
+
+
+
+
+
+
diff --git a/srcs/juloo.keyboard2/Config.java b/srcs/juloo.keyboard2/Config.java
index b477c92..cd9629a 100644
--- a/srcs/juloo.keyboard2/Config.java
+++ b/srcs/juloo.keyboard2/Config.java
@@ -33,6 +33,7 @@ final class Config
public float keyVerticalInterval;
public float keyHorizontalInterval;
public boolean preciseRepeat;
+ public int lockable_modifiers;
public float characterSize; // Ratio
public int accents; // Values are R.values.pref_accents_v_*
public int theme; // Values are R.style.*
@@ -114,6 +115,12 @@ final class Config
keyHeight = dm.heightPixels * keyboardHeightPercent / 100 / 4;
horizontalMargin = getDipPref(dm, prefs, "horizontal_margin", horizontalMargin) + res.getDimension(R.dimen.extra_horizontal_margin);
preciseRepeat = prefs.getBoolean("precise_repeat", preciseRepeat);
+ lockable_modifiers =
+ (prefs.getBoolean("lockable_shift", true) ? KeyValue.FLAG_SHIFT : 0)
+ | (prefs.getBoolean("lockable_ctrl", false) ? KeyValue.FLAG_CTRL : 0)
+ | (prefs.getBoolean("lockable_alt", false) ? KeyValue.FLAG_ALT : 0)
+ | (prefs.getBoolean("lockable_fn", false) ? KeyValue.FLAG_FN : 0)
+ | (prefs.getBoolean("lockable_meta", false) ? KeyValue.FLAG_META : 0);
characterSize = prefs.getFloat("character_size", characterSize);
accents = Integer.valueOf(prefs.getString("accents", "1"));
theme = getThemeId(res, prefs.getString("theme", ""));
@@ -143,8 +150,13 @@ final class Config
return (swapEnterActionKey && action_key != null) ?
KeyValue.getKeyByName("enter") : action_key;
default:
- if ((key.flags & key_flags_to_remove) != 0)
- return null;
+ if (key.flags != 0)
+ {
+ if ((key.flags & key_flags_to_remove) != 0)
+ return null;
+ if ((key.flags & lockable_modifiers) != 0)
+ return key.withFlags(key.flags | KeyValue.FLAG_LOCK);
+ }
return key;
}});
}
diff --git a/srcs/juloo.keyboard2/KeyValue.java b/srcs/juloo.keyboard2/KeyValue.java
index ec29991..dd42f42 100644
--- a/srcs/juloo.keyboard2/KeyValue.java
+++ b/srcs/juloo.keyboard2/KeyValue.java
@@ -87,6 +87,11 @@ class KeyValue
return new KeyValue(name, s, c, eventCode, flags);
}
+ public KeyValue withFlags(int f)
+ {
+ return new KeyValue(name, symbol, char_, eventCode, f);
+ }
+
private static HashMap keys = new HashMap();
public KeyValue(String n, String s, char c, int e, int f)
@@ -154,7 +159,7 @@ class KeyValue
static
{
addModifierKey("shift", "\uE808",
- FLAG_LOCK | FLAG_SHIFT | FLAG_KEY_FONT | FLAG_SMALLER_FONT);
+ FLAG_SHIFT | FLAG_KEY_FONT | FLAG_SMALLER_FONT);
addModifierKey("ctrl", "Ctrl", FLAG_CTRL | FLAG_SMALLER_FONT);
addModifierKey("alt", "Alt", FLAG_ALT | FLAG_SMALLER_FONT);
addModifierKey("accent_aigu", "◌́", FLAG_ACCENT2);