abouttreesummaryrefslogcommitdiff
path: root/srcs/juloo.keyboard2/Config.java
diff options
context:
space:
mode:
authorJules Aguillon2023-11-19 20:10:45 +0100
committerJules Aguillon2023-11-19 20:10:45 +0100
commit44adb555449110e1fbe8238fed7ed87aa0f9aa5b (patch)
tree965004198ebb3dfe1924bbfd608bed93f31f6b63 /srcs/juloo.keyboard2/Config.java
parent15de829138b7121fa6ad139782c5f192ecc1a402 (diff)
downloadunexpected-keyboard-44adb555449110e1fbe8238fed7ed87aa0f9aa5b.tar.gz
unexpected-keyboard-44adb555449110e1fbe8238fed7ed87aa0f9aa5b.zip
Separately persisted current layout in landscape mode
Remember the selected layout in portrait and landscape mode independently. This allows to define a layout specific to landscape without having to switch manually.
Diffstat (limited to 'srcs/juloo.keyboard2/Config.java')
-rw-r--r--srcs/juloo.keyboard2/Config.java22
1 files changed, 18 insertions, 4 deletions
diff --git a/srcs/juloo.keyboard2/Config.java b/srcs/juloo.keyboard2/Config.java
index b6eb4b9..94b0861 100644
--- a/srcs/juloo.keyboard2/Config.java
+++ b/srcs/juloo.keyboard2/Config.java
@@ -66,7 +66,10 @@ final class Config
public final IKeyEventHandler handler;
public boolean orientation_landscape = false;
- public int current_layout; // Index in 'layouts' of the currently used layout
+ /** Index in 'layouts' of the currently used layout. See
+ [get_current_layout()] and [set_current_layout()]. */
+ int current_layout_portrait;
+ int current_layout_landscape;
private Config(SharedPreferences prefs, Resources res, IKeyEventHandler h)
{
@@ -155,14 +158,25 @@ final class Config
extra_keys_param = ExtraKeysPreference.get_extra_keys(_prefs);
extra_keys_custom = CustomExtraKeysPreference.get(_prefs);
pin_entry_enabled = _prefs.getBoolean("pin_entry_enabled", true);
- current_layout = _prefs.getInt("current_layout", 0);
+ current_layout_portrait = _prefs.getInt("current_layout_portrait", 0);
+ current_layout_landscape = _prefs.getInt("current_layout_landscape", 0);
+ }
+
+ public int get_current_layout()
+ {
+ return (orientation_landscape)
+ ? current_layout_landscape : current_layout_portrait;
}
public void set_current_layout(int l)
{
- current_layout = l;
+ if (orientation_landscape)
+ current_layout_landscape = l;
+ else
+ current_layout_portrait = l;
SharedPreferences.Editor e = _prefs.edit();
- e.putInt("current_layout", l);
+ e.putInt("current_layout_portrait", current_layout_portrait);
+ e.putInt("current_layout_landscape", current_layout_landscape);
e.apply();
}