Implement the option

This commit is contained in:
Jules Aguillon 2025-03-27 23:17:23 +01:00
parent 459a8eab7d
commit 8018bae620
3 changed files with 18 additions and 13 deletions

View File

@ -30,6 +30,7 @@ public final class Config
// From the 'numpad_layout' option, also apply to the numeric pane. // From the 'numpad_layout' option, also apply to the numeric pane.
public boolean inverse_numpad = false; public boolean inverse_numpad = false;
public boolean add_number_row; public boolean add_number_row;
public boolean number_row_symbols;
public float swipe_dist_px; public float swipe_dist_px;
public float slide_step_px; public float slide_step_px;
// Let the system handle vibration when false. // Let the system handle vibration when false.
@ -122,7 +123,9 @@ public final class Config
} }
layouts = LayoutsPreference.load_from_preferences(res, _prefs); layouts = LayoutsPreference.load_from_preferences(res, _prefs);
inverse_numpad = _prefs.getString("numpad_layout", "default").equals("low_first"); inverse_numpad = _prefs.getString("numpad_layout", "default").equals("low_first");
add_number_row = _prefs.getString("number_row", "default").equals("no_number_row"); 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 // The baseline for the swipe distance correspond to approximately the
// width of a key in portrait mode, as most layouts have 10 columns. // 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. // Multipled by the DPI ratio because most swipes are made in the diagonals.
@ -284,7 +287,7 @@ public final class Config
e.putInt("version", CONFIG_VERSION); e.putInt("version", CONFIG_VERSION);
// Migrations might run on an empty [prefs] for new installs, in this case // Migrations might run on an empty [prefs] for new installs, in this case
// they set the default values of complex options. // they set the default values of complex options.
switch (saved_version) // Fallback switch switch (saved_version)
{ {
case 0: case 0:
// Primary, secondary and custom layout options are merged into the new // 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("")) if (custom_layout != null && !custom_layout.equals(""))
l.add(LayoutsPreference.CustomLayout.parse(custom_layout)); l.add(LayoutsPreference.CustomLayout.parse(custom_layout));
LayoutsPreference.save_to_preferences(e, l); LayoutsPreference.save_to_preferences(e, l);
// Fallthrough
case 1: 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; default: break;
} }
e.apply(); e.apply();

View File

@ -177,14 +177,9 @@ public final class KeyboardData
private static Map<Integer, KeyboardData> _layoutCache = new HashMap<Integer, 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)); return parse_row(res.getXml(res_id));
}
public static Row load_number_row(Resources res) throws Exception
{
return parse_row(res.getXml(R.xml.number_row));
} }
public static KeyboardData load_num_pad(Resources res) throws Exception public static KeyboardData load_num_pad(Resources res) throws Exception

View File

@ -11,7 +11,8 @@ public final class LayoutModifier
{ {
static Config globalConfig; static Config globalConfig;
static KeyboardData.Row bottom_row; 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; static KeyboardData num_pad;
/** Update the layout according to the configuration. /** 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 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()); remove_keys.addAll(added_number_row.getKeys(0).keySet());
} }
// Add the bottom row before computing the extra keys // Add the bottom row before computing the extra keys
@ -204,8 +205,9 @@ public final class LayoutModifier
globalConfig = globalConfig_; globalConfig = globalConfig_;
try try
{ {
number_row = KeyboardData.load_number_row(res); number_row_no_symbols = KeyboardData.load_row(res, R.xml.number_row_no_symbols);
bottom_row = KeyboardData.load_bottom_row(res); 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); num_pad = KeyboardData.load_num_pad(res);
} }
catch (Exception e) catch (Exception e)