From e745c812691462380695da2275757e3f29bbbdb2 Mon Sep 17 00:00:00 2001 From: Jules Aguillon Date: Sat, 26 Nov 2022 22:30:45 +0100 Subject: Allow using a custom layout Add an option for specifying an XML layout description as a string. The option is a bit rough at the moment: - No documentation, users have to be aware of the keyboard's code to use this option. - No error are shown, the layout will fallback to qwerty on error. --- srcs/juloo.keyboard2/Config.java | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'srcs/juloo.keyboard2/Config.java') diff --git a/srcs/juloo.keyboard2/Config.java b/srcs/juloo.keyboard2/Config.java index 5fb2ab5..8404946 100644 --- a/srcs/juloo.keyboard2/Config.java +++ b/srcs/juloo.keyboard2/Config.java @@ -26,6 +26,7 @@ final class Config // From preferences public KeyboardData layout; // Or 'null' for the system defaults public KeyboardData second_layout; // Or 'null' for none + public KeyboardData custom_layout; // Might be 'null' public boolean show_numpad = false; public float swipe_dist_px; public boolean vibrateEnabled; @@ -66,6 +67,7 @@ final class Config // default values layout = null; second_layout = null; + custom_layout = null; vibrateEnabled = true; longPressTimeout = 600; longPressInterval = 65; @@ -117,6 +119,7 @@ final class Config } layout = layout_of_string(res, _prefs.getString("layout", "none")); second_layout = layout_of_string(res, _prefs.getString("second_layout", "none")); + custom_layout = KeyboardData.load_string(_prefs.getString("custom_layout", "")); // 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. @@ -252,6 +255,7 @@ final class Config switch (name) { case "system": case "none": return null; + case "custom": if (custom_layout != null) return custom_layout; break; case "azerty": id = R.xml.azerty; break; case "bangla": id = R.xml.bangla; break; case "bgph1": id = R.xml.local_bgph1; break; -- cgit v1.2.3