abouttreesummaryrefslogcommitdiff
diff options
context:
space:
mode:
-rw-r--r--res/values/strings.xml2
-rw-r--r--res/xml/settings.xml7
-rw-r--r--srcs/juloo.keyboard2/Config.java16
-rw-r--r--srcs/juloo.keyboard2/KeyValue.java7
4 files changed, 29 insertions, 3 deletions
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 @@
<string name="pref_vibrate_duration_title">Duration</string>
<string name="pref_precise_repeat_title">Precise cursor movements</string>
<string name="pref_precise_repeat_summary">Modulate key repeat speed by swiping more or less</string>
+ <string name="pref_lockable_keys_title">Lockable modifiers</string>
+ <string name="pref_lockable_keys_summary">Modifier that can be locked by typing them twice</string>
<string name="pref_category_style">Style</string>
<string name="pref_margin_bottom_title">Margin bottom</string>
<string name="pref_keyboard_height_title">Keyboard height</string>
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 @@
<juloo.common.IntSlideBarPreference android:key="longpress_timeout" android:title="@string/pref_long_timeout_title" android:summary="%sms" android:defaultValue="600" min="50" max="2000"/>
<juloo.common.IntSlideBarPreference android:key="longpress_interval" android:title="@string/pref_long_interval_title" android:summary="%sms" android:defaultValue="25" min="5" max="100"/>
<CheckBoxPreference android:key="precise_repeat" android:title="@string/pref_precise_repeat_title" android:summary="@string/pref_precise_repeat_summary" android:defaultValue="true"/>
+ <PreferenceScreen android:title="@string/pref_lockable_keys_title" android:summary="@string/pref_lockable_keys_summary">
+ <CheckBoxPreference android:key="lockable_shift" android:title="Shift" android:defaultValue="true"/>
+ <CheckBoxPreference android:key="lockable_ctrl" android:title="Ctrl" android:defaultValue="false"/>
+ <CheckBoxPreference android:key="lockable_alt" android:title="Alt" android:defaultValue="false"/>
+ <CheckBoxPreference android:key="lockable_fn" android:title="Fn" android:defaultValue="false"/>
+ <CheckBoxPreference android:key="lockable_meta" android:title="Meta" android:defaultValue="false"/>
+ </PreferenceScreen>
</PreferenceCategory>
<PreferenceCategory android:title="@string/pref_category_vibrate">
<CheckBoxPreference android:key="vibrate_enabled" android:title="@string/pref_vibrate_title" android:summary="@string/pref_vibrate_summary" android:defaultValue="true"/>
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<String, KeyValue> keys = new HashMap<String, KeyValue>();
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);