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).
---
res/xml/bone.xml | 4 ++--
res/xml/bottom_row.xml | 4 ++--
res/xml/neo2.xml | 4 ++--
res/xml/numeric.xml | 2 +-
srcs/juloo.keyboard2/ExtraKeyCheckBoxPreference.java | 17 ++++++++++++++++-
5 files changed, 23 insertions(+), 8 deletions(-)
diff --git a/res/xml/bone.xml b/res/xml/bone.xml
index 391c9f9..c107e88 100644
--- a/res/xml/bone.xml
+++ b/res/xml/bone.xml
@@ -36,8 +36,8 @@
-
-
+
+
diff --git a/res/xml/bottom_row.xml b/res/xml/bottom_row.xml
index 14e28a2..bfd4e90 100644
--- a/res/xml/bottom_row.xml
+++ b/res/xml/bottom_row.xml
@@ -1,7 +1,7 @@
-
-
+
+
diff --git a/res/xml/neo2.xml b/res/xml/neo2.xml
index f20c8b9..1ed75b8 100644
--- a/res/xml/neo2.xml
+++ b/res/xml/neo2.xml
@@ -39,8 +39,8 @@
-
-
+
+
diff --git a/res/xml/numeric.xml b/res/xml/numeric.xml
index 087b625..ba1081f 100644
--- a/res/xml/numeric.xml
+++ b/res/xml/numeric.xml
@@ -20,7 +20,7 @@
-
+
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