abouttreesummaryrefslogcommitdiff
path: root/srcs/juloo.keyboard2/Config.java
diff options
context:
space:
mode:
authorJules Aguillon2022-04-03 17:15:12 +0200
committerJules Aguillon2022-04-03 17:15:12 +0200
commitaa78229b2aef963d5f840b72d8aa3cad3a78dfc4 (patch)
tree4ea7950b7a62829890ba0e9dc1b8108b39dcc902 /srcs/juloo.keyboard2/Config.java
parentd62e7647e0feb9c3c7d363c50f31f1aaf101ecd0 (diff)
downloadunexpected-keyboard-aa78229b2aef963d5f840b72d8aa3cad3a78dfc4.tar.gz
unexpected-keyboard-aa78229b2aef963d5f840b72d8aa3cad3a78dfc4.zip
Add the Programming Layout option
Allow specifying a layout for programming and add a key for switching to it easily. The switching key is placed on the top edge of the space bar. The option has no effect by default because the ergonomic isn't ideal, it needs to be enabled explicitly. Users of Latin-script languages certainly prefer to use one layout (for programming or not). This feature might be removed in favor of a better language-switching mechanisms in the future.
Diffstat (limited to 'srcs/juloo.keyboard2/Config.java')
-rw-r--r--srcs/juloo.keyboard2/Config.java13
1 files changed, 11 insertions, 2 deletions
diff --git a/srcs/juloo.keyboard2/Config.java b/srcs/juloo.keyboard2/Config.java
index 3c436c3..427b0f2 100644
--- a/srcs/juloo.keyboard2/Config.java
+++ b/srcs/juloo.keyboard2/Config.java
@@ -23,6 +23,7 @@ final class Config
// From preferences
public int layout; // Or '-1' for the system defaults
+ public int programming_layout; // Or '-1' for none
public float swipe_dist_px;
public boolean vibrateEnabled;
public long vibrateDuration;
@@ -41,6 +42,7 @@ final class Config
// Dynamically set
public boolean shouldOfferSwitchingToNextInputMethod;
+ public boolean shouldOfferSwitchingToProgramming;
public String actionLabel; // Might be 'null'
public int actionId; // Meaningful only when 'actionLabel' isn't 'null'
public boolean swapEnterActionKey; // Swap the "enter" and "action" keys
@@ -58,6 +60,7 @@ final class Config
sublabelTextSize = res.getFloat(R.integer.sublabel_text_size);
// default values
layout = -1;
+ programming_layout = -1;
vibrateEnabled = true;
vibrateDuration = 20;
longPressTimeout = 600;
@@ -74,6 +77,7 @@ final class Config
refresh(context);
// initialized later
shouldOfferSwitchingToNextInputMethod = false;
+ shouldOfferSwitchingToProgramming = false;
actionLabel = null;
actionId = 0;
swapEnterActionKey = false;
@@ -101,7 +105,10 @@ final class Config
{
keyboardHeightPercent = prefs.getInt("keyboard_height", 35);
}
- layout = layoutId_of_string(prefs.getString("layout", "system"));
+ String layout_s = prefs.getString("layout", "system");
+ layout = layout_s.equals("system") ? -1 : layoutId_of_string(layout_s);
+ String prog_layout_s = prefs.getString("programming_layout", "none");
+ programming_layout = prog_layout_s.equals("none") ? -1 : layoutId_of_string(prog_layout_s);
// The swipe distance is defined relatively to the "exact physical pixels
// per inch of the screen", which isn't affected by the scaling settings.
// Take the mean of both dimensions as an approximation of the diagonal.
@@ -156,6 +163,8 @@ final class Config
case KeyValue.EVENT_ACTION:
return (swapEnterActionKey && action_key != null) ?
KeyValue.getKeyByName("enter") : action_key;
+ case KeyValue.EVENT_SWITCH_PROGRAMMING:
+ return shouldOfferSwitchingToProgramming ? key : null;
default:
if (key.flags != 0)
{
@@ -214,7 +223,7 @@ final class Config
case "qwerty_sv_se": return R.xml.qwerty_sv_se;
case "qwertz": return R.xml.qwertz;
case "ru_jcuken": return R.xml.local_ru_jcuken;
- case "system": default: return -1;
+ default: throw new IllegalArgumentException("layoutId_of_string: Unknown layout: " + name);
}
}