abouttreesummaryrefslogcommitdiff
path: root/srcs/juloo.keyboard2/Config.java
diff options
context:
space:
mode:
authorJules Aguillon2023-01-15 23:19:09 +0100
committerJules Aguillon2023-01-15 23:19:09 +0100
commit612657811179eefbb425698fb9a29311a9ee9945 (patch)
tree84f1fb125e01e132f65d89572108b8e7ce852535 /srcs/juloo.keyboard2/Config.java
parent046416389af577844665ddca30adad3798a74e29 (diff)
downloadunexpected-keyboard-612657811179eefbb425698fb9a29311a9ee9945.tar.gz
unexpected-keyboard-612657811179eefbb425698fb9a29311a9ee9945.zip
Avoid switching back from secondary layout automatically
Stay on the secondary layout after a config refresh or onStartInputView. The information is kept until the keyboard is restarted. Additionally, move tweaking the secondary layout to the Config class now that physical equality is not needed.
Diffstat (limited to 'srcs/juloo.keyboard2/Config.java')
-rw-r--r--srcs/juloo.keyboard2/Config.java19
1 files changed, 18 insertions, 1 deletions
diff --git a/srcs/juloo.keyboard2/Config.java b/srcs/juloo.keyboard2/Config.java
index 3a22118..fbb542a 100644
--- a/srcs/juloo.keyboard2/Config.java
+++ b/srcs/juloo.keyboard2/Config.java
@@ -108,7 +108,7 @@ final class Config
keyboardHeightPercent = _prefs.getInt("keyboard_height", 35);
}
layout = layout_of_string(res, _prefs.getString("layout", "none"));
- second_layout = layout_of_string(res, _prefs.getString("second_layout", "none"));
+ second_layout = tweak_secondary_layout(layout_of_string(res, _prefs.getString("second_layout", "none")));
custom_layout = KeyboardData.load_string(_prefs.getString("custom_layout", ""));
inverse_numpad = _prefs.getString("numpad_layout", "default").equals("low_first");
// The baseline for the swipe distance correspond to approximately the
@@ -237,6 +237,23 @@ final class Config
return kw;
}
+ /** Modify a layout to turn it into a secondary layout by changing the
+ "switch_second" key. */
+ KeyboardData tweak_secondary_layout(KeyboardData layout)
+ {
+ if (layout == null)
+ return null;
+ return layout.mapKeys(new KeyboardData.MapKeyValues() {
+ public KeyValue apply(KeyValue key, boolean localized)
+ {
+ if (key.getKind() == KeyValue.Kind.Event
+ && key.getEvent() == KeyValue.Event.SWITCH_SECOND)
+ return KeyValue.getKeyByName("switch_second_back");
+ return key;
+ }
+ });
+ }
+
private float get_dip_pref(DisplayMetrics dm, String pref_name, float def)
{
float value;