abouttreesummaryrefslogcommitdiff
path: root/srcs/juloo.keyboard2/Config.java
diff options
context:
space:
mode:
Diffstat (limited to 'srcs/juloo.keyboard2/Config.java')
-rw-r--r--srcs/juloo.keyboard2/Config.java57
1 files changed, 43 insertions, 14 deletions
diff --git a/srcs/juloo.keyboard2/Config.java b/srcs/juloo.keyboard2/Config.java
index 206c12a..9f27e7e 100644
--- a/srcs/juloo.keyboard2/Config.java
+++ b/srcs/juloo.keyboard2/Config.java
@@ -5,6 +5,7 @@ import android.content.res.Configuration;
import android.content.res.Resources;
import android.util.DisplayMetrics;
import android.util.TypedValue;
+import androidx.window.layout.WindowInfoTracker;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@@ -72,13 +73,16 @@ public final class Config
public final IKeyEventHandler handler;
public boolean orientation_landscape = false;
+ public boolean foldable_unfolded = false;
/** Index in 'layouts' of the currently used layout. See
[get_current_layout()] and [set_current_layout()]. */
int current_layout_portrait;
int current_layout_landscape;
+ int current_layout_unfolded_portrait;
+ int current_layout_unfolded_landscape;
public int bottomInsetMin;
- private Config(SharedPreferences prefs, Resources res, IKeyEventHandler h)
+ private Config(SharedPreferences prefs, Resources res, IKeyEventHandler h, Boolean foldableUnfolded)
{
_prefs = prefs;
// static values
@@ -87,7 +91,7 @@ public final class Config
labelTextSize = 0.33f;
sublabelTextSize = 0.22f;
// from prefs
- refresh(res);
+ refresh(res, foldableUnfolded);
// initialized later
shouldOfferVoiceTyping = false;
actionLabel = null;
@@ -100,10 +104,12 @@ public final class Config
/*
** Reload prefs
*/
- public void refresh(Resources res)
+ public void refresh(Resources res, Boolean foldableUnfolded)
{
DisplayMetrics dm = res.getDisplayMetrics();
orientation_landscape = res.getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE;
+ foldable_unfolded = foldableUnfolded;
+
// The height of the keyboard is relative to the height of the screen.
// This is the height of the keyboard if it have 4 rows.
int keyboardHeightPercent;
@@ -114,12 +120,12 @@ public final class Config
{
if ("landscape".equals(show_numpad_s))
show_numpad = true;
- keyboardHeightPercent = _prefs.getInt("keyboard_height_landscape", 50);
+ keyboardHeightPercent = _prefs.getInt(foldable_unfolded ? "keyboard_height_landscape_unfolded" : "keyboard_height_landscape", 50);
characterSizeScale = 1.25f;
}
else
{
- keyboardHeightPercent = _prefs.getInt("keyboard_height", 35);
+ keyboardHeightPercent = _prefs.getInt(foldable_unfolded ? "keyboard_height_unfolded" : "keyboard_height", 35);
}
layouts = LayoutsPreference.load_from_preferences(res, _prefs);
inverse_numpad = _prefs.getString("numpad_layout", "default").equals("low_first");
@@ -170,6 +176,8 @@ public final class Config
pin_entry_enabled = _prefs.getBoolean("pin_entry_enabled", true);
current_layout_portrait = _prefs.getInt("current_layout_portrait", 0);
current_layout_landscape = _prefs.getInt("current_layout_landscape", 0);
+ current_layout_unfolded_portrait = _prefs.getInt("current_layout_unfolded_portrait", 0);
+ current_layout_unfolded_landscape = _prefs.getInt("current_layout_unfolded_landscape", 0);
circle_sensitivity = Integer.valueOf(_prefs.getString("circle_sensitivity", "2"));
clipboard_history_enabled = _prefs.getBoolean("clipboard_history_enabled", false);
bottomInsetMin = Utils.is_navigation_bar_gestural(res) ?
@@ -178,19 +186,34 @@ public final class Config
public int get_current_layout()
{
- return (orientation_landscape)
- ? current_layout_landscape : current_layout_portrait;
+ if (foldable_unfolded) {
+ return (orientation_landscape)
+ ? current_layout_unfolded_landscape : current_layout_unfolded_portrait;
+ } else {
+ return (orientation_landscape)
+ ? current_layout_landscape : current_layout_portrait;
+ }
}
public void set_current_layout(int l)
{
- if (orientation_landscape)
- current_layout_landscape = l;
- else
- current_layout_portrait = l;
+ if (foldable_unfolded) {
+ if (orientation_landscape)
+ current_layout_unfolded_landscape = l;
+ else
+ current_layout_unfolded_portrait = l;
+ } else {
+ if (orientation_landscape)
+ current_layout_landscape = l;
+ else
+ current_layout_portrait = l;
+ }
+
SharedPreferences.Editor e = _prefs.edit();
e.putInt("current_layout_portrait", current_layout_portrait);
e.putInt("current_layout_landscape", current_layout_landscape);
+ e.putInt("current_layout_unfolded_portrait", current_layout_unfolded_portrait);
+ e.putInt("current_layout_unfolded_landscape", current_layout_unfolded_landscape);
e.apply();
}
@@ -213,7 +236,13 @@ public final class Config
/** [get_dip_pref] depending on orientation. */
float get_dip_pref_oriented(DisplayMetrics dm, String pref_base_name, float def_port, float def_land)
{
- String suffix = orientation_landscape ? "_landscape" : "_portrait";
+ final String suffix;
+ if (foldable_unfolded) {
+ suffix = orientation_landscape ? "_landscape_unfolded" : "_portrait_unfolded";
+ } else {
+ suffix = orientation_landscape ? "_landscape" : "_portrait";
+ }
+
float def = orientation_landscape ? def_land : def_port;
return get_dip_pref(dm, pref_base_name + suffix, def);
}
@@ -249,10 +278,10 @@ public final class Config
private static Config _globalConfig = null;
public static void initGlobalConfig(SharedPreferences prefs, Resources res,
- IKeyEventHandler handler)
+ IKeyEventHandler handler, Boolean foldableUnfolded)
{
migrate(prefs);
- _globalConfig = new Config(prefs, res, handler);
+ _globalConfig = new Config(prefs, res, handler, foldableUnfolded);
LayoutModifier.init(_globalConfig, res);
}