From 75df3afda64e6c533bec537b6f36d1dba55a93d6 Mon Sep 17 00:00:00 2001 From: Jules Aguillon Date: Sun, 16 Oct 2022 01:07:24 +0200 Subject: Allow to disable Alt and Meta keys The keys are marked "loc" in the layouts and are handled like the other extra keys. The only difference is that they are enabled by default (for now). --- srcs/juloo.keyboard2/ExtraKeyCheckBoxPreference.java | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'srcs') diff --git a/srcs/juloo.keyboard2/ExtraKeyCheckBoxPreference.java b/srcs/juloo.keyboard2/ExtraKeyCheckBoxPreference.java index 0a98b9d..d0734b9 100644 --- a/srcs/juloo.keyboard2/ExtraKeyCheckBoxPreference.java +++ b/srcs/juloo.keyboard2/ExtraKeyCheckBoxPreference.java @@ -14,6 +14,8 @@ public class ExtraKeyCheckBoxPreference extends CheckBoxPreference { public static String[] extra_keys = new String[] { + "alt", + "meta", "accent_aigu", "accent_grave", "accent_double_aigu", @@ -33,6 +35,18 @@ public class ExtraKeyCheckBoxPreference extends CheckBoxPreference "switch_greekmath", }; + public static boolean default_checked(String name) + { + switch (name) + { + case "alt": + case "meta": + return true; + default: + return false; + } + } + boolean _key_font; public ExtraKeyCheckBoxPreference(Context context, AttributeSet attrs) @@ -43,6 +57,7 @@ public class ExtraKeyCheckBoxPreference extends CheckBoxPreference a.recycle(); String key_name = extra_keys[index]; setKey(pref_key_of_key_name(key_name)); + setDefaultValue(default_checked(key_name)); KeyValue kv = KeyValue.getKeyByName(key_name); setTitle(kv.getString()); _key_font = kv.hasFlags(KeyValue.FLAG_KEY_FONT); @@ -66,7 +81,7 @@ public class ExtraKeyCheckBoxPreference extends CheckBoxPreference HashSet ks = new HashSet(); for (String key_name : extra_keys) { - if (prefs.getBoolean(pref_key_of_key_name(key_name), false)) + if (prefs.getBoolean(pref_key_of_key_name(key_name), default_checked(key_name))) ks.add(KeyValue.getKeyByName(key_name)); } return ks; -- cgit v1.2.3