abouttreesummaryrefslogcommitdiff
path: root/srcs
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
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')
-rw-r--r--srcs/juloo.keyboard2/Config.java22
-rw-r--r--srcs/juloo.keyboard2/Keyboard2.java6
2 files changed, 20 insertions, 8 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();
}
diff --git a/srcs/juloo.keyboard2/Keyboard2.java b/srcs/juloo.keyboard2/Keyboard2.java
index a0766ab..6bc2103 100644
--- a/srcs/juloo.keyboard2/Keyboard2.java
+++ b/srcs/juloo.keyboard2/Keyboard2.java
@@ -44,7 +44,7 @@ public class Keyboard2 extends InputMethodService
if (_currentSpecialLayout != null)
return _currentSpecialLayout;
KeyboardData layout = null;
- int layout_i = _config.current_layout;
+ int layout_i = _config.get_current_layout();
if (layout_i >= _config.layouts.size())
layout_i = 0;
if (layout_i < _config.layouts.size())
@@ -62,8 +62,6 @@ public class Keyboard2 extends InputMethodService
void setTextLayout(int l)
{
- if (l == _config.current_layout)
- return;
_config.set_current_layout(l);
_currentSpecialLayout = null;
_keyboardView.setKeyboard(current_layout());
@@ -72,7 +70,7 @@ public class Keyboard2 extends InputMethodService
void incrTextLayout(int delta)
{
int s = _config.layouts.size();
- setTextLayout((_config.current_layout + delta + s) % s);
+ setTextLayout((_config.get_current_layout() + delta + s) % s);
}
void setSpecialLayout(KeyboardData l)