diff options
| author | Jules Aguillon | 2024-05-29 11:56:26 +0200 |
|---|---|---|
| committer | Jules Aguillon | 2024-05-29 11:56:26 +0200 |
| commit | 304375268d520687d41dc7834c442347d638da9c (patch) | |
| tree | 9271983cd081ef4bcc60d4f4956370c26d1287ef /srcs/juloo.keyboard2/Config.java | |
| parent | 9d89297c15fa855215560890b46d993f732bd35a (diff) | |
| download | unexpected-keyboard-304375268d520687d41dc7834c442347d638da9c.tar.gz unexpected-keyboard-304375268d520687d41dc7834c442347d638da9c.zip | |
Fix uninitialized bottom_row when editing custom layout
This happen when opening the settings from the launcher activity without
ever opening the keyboard.
To remove this bug entirely, the KeyboardData.init method is removed,
the pieces needing initialization are now cached in Config.
Diffstat (limited to 'srcs/juloo.keyboard2/Config.java')
| -rw-r--r-- | srcs/juloo.keyboard2/Config.java | 36 |
1 files changed, 26 insertions, 10 deletions
diff --git a/srcs/juloo.keyboard2/Config.java b/srcs/juloo.keyboard2/Config.java index 9e9774b..09b3157 100644 --- a/srcs/juloo.keyboard2/Config.java +++ b/srcs/juloo.keyboard2/Config.java @@ -28,13 +28,17 @@ public final class Config public final float labelTextSize; public final float sublabelTextSize; + public final KeyboardData.Row bottom_row; + public final KeyboardData.Row number_row; + public final KeyboardData num_pad; + // From preferences /** [null] represent the [system] layout. */ public List<KeyboardData> layouts; public boolean show_numpad = false; // From the 'numpad_layout' option, also apply to the numeric pane. public boolean inverse_numpad = false; - public boolean number_row; + public boolean add_number_row; public float swipe_dist_px; public float slide_step_px; // Let the system handle vibration when false. @@ -86,6 +90,16 @@ public final class Config keyPadding = res.getDimension(R.dimen.key_padding); labelTextSize = 0.33f; sublabelTextSize = 0.22f; + try + { + number_row = KeyboardData.load_number_row(res); + bottom_row = KeyboardData.load_bottom_row(res); + num_pad = KeyboardData.load_num_pad(res); + } + catch (Exception e) + { + throw new RuntimeException(e.getMessage()); // Not recoverable + } // from prefs refresh(res); // initialized later @@ -123,7 +137,7 @@ public final class Config } layouts = LayoutsPreference.load_from_preferences(res, _prefs); inverse_numpad = _prefs.getString("numpad_layout", "default").equals("low_first"); - number_row = _prefs.getBoolean("number_row", false); + add_number_row = _prefs.getBoolean("number_row", false); // 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. @@ -223,11 +237,13 @@ public final class Config extra_keys_subtype.compute(extra_keys, new ExtraKeys.Query(kw.script, present)); } - KeyboardData.Row number_row = null; - if (this.number_row && !show_numpad) - number_row = modify_number_row(KeyboardData.number_row, kw); - if (number_row != null) - remove_keys.addAll(number_row.getKeys(0).keySet()); + KeyboardData.Row added_number_row = null; + if (add_number_row && !show_numpad) + added_number_row = modify_number_row(number_row, kw); + if (added_number_row != null) + remove_keys.addAll(added_number_row.getKeys(0).keySet()); + if (kw.bottom_row) + kw = kw.insert_row(bottom_row, kw.rows.size()); kw = kw.mapKeys(new KeyboardData.MapKeyValues() { public KeyValue apply(KeyValue key, boolean localized) { @@ -279,9 +295,9 @@ public final class Config } }); if (show_numpad) - kw = kw.addNumPad(modify_numpad(KeyboardData.num_pad, kw)); - if (number_row != null) - kw = kw.addTopRow(number_row); + kw = kw.addNumPad(modify_numpad(num_pad, kw)); + if (added_number_row != null) + kw = kw.insert_row(added_number_row, 0); if (extra_keys.size() > 0) kw = kw.addExtraKeys(extra_keys.entrySet().iterator()); return kw; |
