abouttreesummaryrefslogcommitdiff
path: root/srcs/juloo.keyboard2/Config.java
diff options
context:
space:
mode:
authorJules Aguillon2023-08-10 12:57:31 +0200
committerJules Aguillon2023-08-16 12:21:23 +0200
commit500f4e41d3a72f5865aa489c89ad11b947fa54b7 (patch)
tree677781ff5e82c320456f21e91b8ffa41819fd439 /srcs/juloo.keyboard2/Config.java
parent8611dbcfa0ef6d551bf3acb65e5a1990a3ced75b (diff)
downloadunexpected-keyboard-500f4e41d3a72f5865aa489c89ad11b947fa54b7.tar.gz
unexpected-keyboard-500f4e41d3a72f5865aa489c89ad11b947fa54b7.zip
Allow multiple custom layouts
This merges the "Layouts" option with the "Custom layout" option. A custom layout becomes an item in the "Layouts" list among the other layouts. It's possible to add several custom layouts. Selecting the "Custom layout" item in the list opens a second dialog for entering the layout description. Layouts are serialized as JSON object and are decoded solely in the LayoutsPreference class.
Diffstat (limited to 'srcs/juloo.keyboard2/Config.java')
-rw-r--r--srcs/juloo.keyboard2/Config.java38
1 files changed, 1 insertions, 37 deletions
diff --git a/srcs/juloo.keyboard2/Config.java b/srcs/juloo.keyboard2/Config.java
index 24565ab..4684194 100644
--- a/srcs/juloo.keyboard2/Config.java
+++ b/srcs/juloo.keyboard2/Config.java
@@ -3,7 +3,6 @@ package juloo.keyboard2;
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.content.res.Resources;
-import android.content.res.TypedArray;
import android.os.Build;
import android.util.DisplayMetrics;
import android.util.TypedValue;
@@ -28,7 +27,6 @@ final class Config
// From preferences
/** [null] represent the [system] layout. */
public List<KeyboardData> layouts;
- public KeyboardData custom_layout; // Might be 'null'
public boolean show_numpad = false;
// From the 'numpad_layout' option, also apply to the numeric pane.
public boolean inverse_numpad = false;
@@ -114,11 +112,7 @@ final class Config
{
keyboardHeightPercent = _prefs.getInt("keyboard_height", 35);
}
- List<String> layout_names = LayoutsPreference.load_from_preferences(_prefs);
- layouts = new ArrayList<KeyboardData>();
- for (String l : layout_names)
- layouts.add(layout_of_string(res, l));
- custom_layout = KeyboardData.load_string(_prefs.getString("custom_layout", ""));
+ layouts = LayoutsPreference.load_from_preferences(res, _prefs);
inverse_numpad = _prefs.getString("numpad_layout", "default").equals("low_first");
number_row = _prefs.getBoolean("number_row", false);
// The baseline for the swipe distance correspond to approximately the
@@ -335,36 +329,6 @@ final class Config
}
}
- /** Obtained from XML. */
- static List<String> layout_ids_str = null;
- static TypedArray layout_ids_res = null;
-
- /** Might return [null] if the selected layout is "system", "custom" or if
- the name is not recognized. */
- public KeyboardData layout_of_string(Resources res, String name)
- {
- if (layout_ids_str == null)
- {
- layout_ids_str = Arrays.asList(res.getStringArray(R.array.pref_layout_values));
- layout_ids_res = res.obtainTypedArray(R.array.layout_ids);
- }
- int i = layout_ids_str.indexOf(name);
- if (i >= 0)
- {
- int id = layout_ids_res.getResourceId(i, 0);
- if (id > 0)
- return KeyboardData.load(res, id);
- // Fallthrough
- }
- switch (name)
- {
- case "custom": return custom_layout;
- case "system":
- case "none":
- default: return null;
- }
- }
-
char inverse_numpad_char(char c)
{
switch (c)