abouttreesummaryrefslogcommitdiff
path: root/srcs/juloo.keyboard2/Config.java
diff options
context:
space:
mode:
authorJules Aguillon2021-04-28 00:23:52 +0200
committerJules Aguillon2021-04-29 01:06:51 +0200
commitd00576ac2d7605c48034dc52e6622f48f680d4ae (patch)
tree4e52e2c1ff1785a2f762fd5de134dfe08a064802 /srcs/juloo.keyboard2/Config.java
parentc86a11944873534c140cd07b7c91d63c939b45b6 (diff)
downloadunexpected-keyboard-d00576ac2d7605c48034dc52e6622f48f680d4ae.tar.gz
unexpected-keyboard-d00576ac2d7605c48034dc52e6622f48f680d4ae.zip
Add the "layout" option again
Some versions of android don't allow to configure several languages.
Diffstat (limited to 'srcs/juloo.keyboard2/Config.java')
-rw-r--r--srcs/juloo.keyboard2/Config.java15
1 files changed, 15 insertions, 0 deletions
diff --git a/srcs/juloo.keyboard2/Config.java b/srcs/juloo.keyboard2/Config.java
index dd42b0e..386dc73 100644
--- a/srcs/juloo.keyboard2/Config.java
+++ b/srcs/juloo.keyboard2/Config.java
@@ -15,6 +15,7 @@ class Config
public final float keyHorizontalInterval;
public final float keyRound;
+ public int layout; // Or '-1' for the system defaults
public float subValueDist;
public boolean vibrateEnabled;
public long vibrateDuration;
@@ -41,6 +42,7 @@ class Config
keyHorizontalInterval = res.getDimension(R.dimen.key_horizontal_interval);
keyRound = res.getDimension(R.dimen.key_round);
// default values
+ layout = -1;
subValueDist = 10f;
vibrateEnabled = true;
vibrateDuration = 20;
@@ -65,6 +67,7 @@ class Config
{
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(_context);
+ layout = layoutId_of_string(prefs.getString("layout", "system"));
subValueDist = prefs.getFloat("sub_value_dist", subValueDist);
vibrateEnabled = prefs.getBoolean("vibrate_enabled", vibrateEnabled);
vibrateDuration = prefs.getInt("vibrate_duration", (int)vibrateDuration);
@@ -87,4 +90,16 @@ class Config
return (TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, value,
_context.getResources().getDisplayMetrics()));
}
+
+ public static int layoutId_of_string(String name)
+ {
+ switch (name)
+ {
+ case "azerty": return R.xml.azerty;
+ case "qwerty": return R.xml.qwerty;
+ case "system": return -1;
+ default: throw new IllegalArgumentException();
+ }
+ }
+
}