diff options
| author | Jules Aguillon | 2025-03-27 23:25:32 +0100 |
|---|---|---|
| committer | GitHub | 2025-03-27 23:25:32 +0100 |
| commit | 6541054cce964b7243d8779b54b168cda6741aff (patch) | |
| tree | 5a065d34c23316ca25f1ad6605c688619af43b85 /srcs/juloo.keyboard2 | |
| parent | 3971f6243cb5b5ca7f3120d5be8140f7646c9d7e (diff) | |
| download | unexpected-keyboard-6541054cce964b7243d8779b54b168cda6741aff.tar.gz unexpected-keyboard-6541054cce964b7243d8779b54b168cda6741aff.zip | |
Remove symbols from the number row by default (#964)
The number row option is changed into a ListPreference and controls whether the number row contains symbols or not.
Co-authored-by: Joey Schaff <j@jaoh.xyz>
Diffstat (limited to 'srcs/juloo.keyboard2')
| -rw-r--r-- | srcs/juloo.keyboard2/Config.java | 14 | ||||
| -rw-r--r-- | srcs/juloo.keyboard2/KeyboardData.java | 9 | ||||
| -rw-r--r-- | srcs/juloo.keyboard2/LayoutModifier.java | 10 |
3 files changed, 19 insertions, 14 deletions
diff --git a/srcs/juloo.keyboard2/Config.java b/srcs/juloo.keyboard2/Config.java index 7adbe60..206c12a 100644 --- a/srcs/juloo.keyboard2/Config.java +++ b/srcs/juloo.keyboard2/Config.java @@ -30,6 +30,7 @@ public final class Config // From the 'numpad_layout' option, also apply to the numeric pane. public boolean inverse_numpad = false; public boolean add_number_row; + public boolean number_row_symbols; public float swipe_dist_px; public float slide_step_px; // Let the system handle vibration when false. @@ -122,7 +123,9 @@ public final class Config } layouts = LayoutsPreference.load_from_preferences(res, _prefs); inverse_numpad = _prefs.getString("numpad_layout", "default").equals("low_first"); - add_number_row = _prefs.getBoolean("number_row", false); + String number_row = _prefs.getString("number_row", "no_number_row"); + add_number_row = !number_row.equals("no_number_row"); + number_row_symbols = number_row.equals("symbols"); // The baseline for the swipe distance correspond to approximately the // width of a key in portrait mode, as most layouts have 10 columns. // Multipled by the DPI ratio because most swipes are made in the diagonals. @@ -272,7 +275,7 @@ public final class Config /** Config migrations. */ - private static int CONFIG_VERSION = 1; + private static int CONFIG_VERSION = 2; public static void migrate(SharedPreferences prefs) { @@ -284,7 +287,7 @@ public final class Config e.putInt("version", CONFIG_VERSION); // Migrations might run on an empty [prefs] for new installs, in this case // they set the default values of complex options. - switch (saved_version) // Fallback switch + switch (saved_version) { case 0: // Primary, secondary and custom layout options are merged into the new @@ -298,7 +301,12 @@ public final class Config if (custom_layout != null && !custom_layout.equals("")) l.add(LayoutsPreference.CustomLayout.parse(custom_layout)); LayoutsPreference.save_to_preferences(e, l); + // Fallthrough case 1: + boolean add_number_row = prefs.getBoolean("number_row", false); + e.putString("number_row", add_number_row ? "no_symbols" : "no_number_row"); + // Fallthrough + case 2: default: break; } e.apply(); diff --git a/srcs/juloo.keyboard2/KeyboardData.java b/srcs/juloo.keyboard2/KeyboardData.java index fd111bf..e4a7506 100644 --- a/srcs/juloo.keyboard2/KeyboardData.java +++ b/srcs/juloo.keyboard2/KeyboardData.java @@ -177,14 +177,9 @@ public final class KeyboardData private static Map<Integer, KeyboardData> _layoutCache = new HashMap<Integer, KeyboardData>(); - public static Row load_bottom_row(Resources res) throws Exception + public static Row load_row(Resources res, int res_id) throws Exception { - return parse_row(res.getXml(R.xml.bottom_row)); - } - - public static Row load_number_row(Resources res) throws Exception - { - return parse_row(res.getXml(R.xml.number_row)); + return parse_row(res.getXml(res_id)); } public static KeyboardData load_num_pad(Resources res) throws Exception diff --git a/srcs/juloo.keyboard2/LayoutModifier.java b/srcs/juloo.keyboard2/LayoutModifier.java index 7be3fb6..22f15ec 100644 --- a/srcs/juloo.keyboard2/LayoutModifier.java +++ b/srcs/juloo.keyboard2/LayoutModifier.java @@ -11,7 +11,8 @@ public final class LayoutModifier { static Config globalConfig; static KeyboardData.Row bottom_row; - static KeyboardData.Row number_row; + static KeyboardData.Row number_row_no_symbols; + static KeyboardData.Row number_row_symbols; static KeyboardData num_pad; /** Update the layout according to the configuration. @@ -44,7 +45,7 @@ public final class LayoutModifier } else if (globalConfig.add_number_row && !kw.embedded_number_row) // The numpad removes the number row { - added_number_row = modify_number_row(number_row, kw); + added_number_row = modify_number_row(globalConfig.number_row_symbols ? number_row_symbols : number_row_no_symbols, kw); remove_keys.addAll(added_number_row.getKeys(0).keySet()); } // Add the bottom row before computing the extra keys @@ -204,8 +205,9 @@ public final class LayoutModifier globalConfig = globalConfig_; try { - number_row = KeyboardData.load_number_row(res); - bottom_row = KeyboardData.load_bottom_row(res); + number_row_no_symbols = KeyboardData.load_row(res, R.xml.number_row_no_symbols); + number_row_symbols = KeyboardData.load_row(res, R.xml.number_row); + bottom_row = KeyboardData.load_row(res, R.xml.bottom_row); num_pad = KeyboardData.load_num_pad(res); } catch (Exception e) |
