abouttreesummaryrefslogcommitdiff
path: root/srcs/juloo.keyboard2
diff options
context:
space:
mode:
Diffstat (limited to 'srcs/juloo.keyboard2')
-rw-r--r--srcs/juloo.keyboard2/Config.java19
-rw-r--r--srcs/juloo.keyboard2/KeyEventHandler.java7
-rw-r--r--srcs/juloo.keyboard2/KeyValue.java6
-rw-r--r--srcs/juloo.keyboard2/Keyboard2.java16
-rw-r--r--srcs/juloo.keyboard2/LayoutListPreference.java25
5 files changed, 50 insertions, 23 deletions
diff --git a/srcs/juloo.keyboard2/Config.java b/srcs/juloo.keyboard2/Config.java
index b2c23a5..6c1dced 100644
--- a/srcs/juloo.keyboard2/Config.java
+++ b/srcs/juloo.keyboard2/Config.java
@@ -25,7 +25,7 @@ final class Config
// From preferences
public int layout; // Or '-1' for the system defaults
- public int programming_layout; // Or '-1' for none
+ public int second_layout; // Or '-1' for none
public boolean show_numpad = false;
public float swipe_dist_px;
public boolean vibrateEnabled;
@@ -46,7 +46,7 @@ final class Config
// Dynamically set
public boolean shouldOfferSwitchingToNextInputMethod;
- public boolean shouldOfferSwitchingToProgramming;
+ public boolean shouldOfferSwitchingToSecond;
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
@@ -65,7 +65,7 @@ final class Config
sublabelTextSize = 0.22f;
// default values
layout = -1;
- programming_layout = -1;
+ second_layout = -1;
vibrateEnabled = true;
longPressTimeout = 600;
longPressInterval = 65;
@@ -81,7 +81,7 @@ final class Config
refresh(res);
// initialized later
shouldOfferSwitchingToNextInputMethod = false;
- shouldOfferSwitchingToProgramming = false;
+ shouldOfferSwitchingToSecond = false;
actionLabel = null;
actionId = 0;
swapEnterActionKey = false;
@@ -115,10 +115,8 @@ final class Config
{
keyboardHeightPercent = _prefs.getInt("keyboard_height", 35);
}
- 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);
+ layout = layoutId_of_string(_prefs.getString("layout", "none"));
+ second_layout = layoutId_of_string(_prefs.getString("second_layout", "none"));
// 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.
@@ -185,8 +183,8 @@ final class Config
case ACTION:
return (swapEnterActionKey && action_key != null) ?
KeyValue.getKeyByName("enter") : action_key;
- case SWITCH_PROGRAMMING:
- return shouldOfferSwitchingToProgramming ? key : null;
+ case SWITCH_SECOND:
+ return shouldOfferSwitchingToSecond ? key : null;
}
break;
case Keyevent:
@@ -249,6 +247,7 @@ final class Config
{
switch (name)
{
+ case "system": case "none": return -1;
case "azerty": return R.xml.azerty;
case "bangla": return R.xml.bangla;
case "bgph1": return R.xml.local_bgph1;
diff --git a/srcs/juloo.keyboard2/KeyEventHandler.java b/srcs/juloo.keyboard2/KeyEventHandler.java
index 4623dec..5d23903 100644
--- a/srcs/juloo.keyboard2/KeyEventHandler.java
+++ b/srcs/juloo.keyboard2/KeyEventHandler.java
@@ -27,13 +27,14 @@ class KeyEventHandler implements Config.IKeyEventHandler
switch (key.getEvent())
{
case CONFIG: _recv.showKeyboardConfig(); break;
- case SWITCH_TEXT: _recv.switchMain(); break;
+ case SWITCH_TEXT:
+ case SWITCH_SECOND_BACK: _recv.switchMain(); break;
case SWITCH_NUMERIC: _recv.switchNumeric(); break;
case SWITCH_EMOJI: _recv.setPane_emoji(); break;
case SWITCH_BACK_EMOJI: _recv.setPane_normal(); break;
case CHANGE_METHOD: _recv.switchToNextInputMethod(); break;
case ACTION: _recv.performAction(); break;
- case SWITCH_PROGRAMMING: _recv.switchProgramming(); break;
+ case SWITCH_SECOND: _recv.switchSecond(); break;
case SWITCH_GREEKMATH: _recv.switchGreekmath(); break;
case CAPS_LOCK: _recv.enableCapsLock(); break;
}
@@ -107,7 +108,7 @@ class KeyEventHandler implements Config.IKeyEventHandler
public void switchMain();
public void switchNumeric();
- public void switchProgramming();
+ public void switchSecond();
public void switchGreekmath();
public void sendKeyEvent(int eventAction, int eventCode, int meta);
diff --git a/srcs/juloo.keyboard2/KeyValue.java b/srcs/juloo.keyboard2/KeyValue.java
index e8155f6..0c19eb7 100644
--- a/srcs/juloo.keyboard2/KeyValue.java
+++ b/srcs/juloo.keyboard2/KeyValue.java
@@ -15,7 +15,8 @@ final class KeyValue
SWITCH_BACK_EMOJI,
CHANGE_METHOD,
ACTION,
- SWITCH_PROGRAMMING,
+ SWITCH_SECOND,
+ SWITCH_SECOND_BACK,
SWITCH_GREEKMATH,
CAPS_LOCK,
}
@@ -304,7 +305,8 @@ final class KeyValue
addEventKey("switch_numeric", "123+", Event.SWITCH_NUMERIC, FLAG_SMALLER_FONT);
addEventKey("switch_emoji", 0x01, Event.SWITCH_EMOJI, FLAG_SMALLER_FONT);
addEventKey("switch_back_emoji", "ABC", Event.SWITCH_BACK_EMOJI, 0);
- addEventKey("switch_programming", "Prog", Event.SWITCH_PROGRAMMING, FLAG_SMALLER_FONT);
+ addEventKey("switch_second", 0x13, Event.SWITCH_SECOND, FLAG_SMALLER_FONT);
+ addEventKey("switch_second_back", 0x14, Event.SWITCH_SECOND_BACK, FLAG_SMALLER_FONT);
addEventKey("switch_greekmath", "πλ∇¬", Event.SWITCH_GREEKMATH, FLAG_SMALLER_FONT);
addEventKey("change_method", 0x09, Event.CHANGE_METHOD, FLAG_SMALLER_FONT);
addEventKey("action", "Action", Event.ACTION, FLAG_SMALLER_FONT); // Will always be replaced
diff --git a/srcs/juloo.keyboard2/Keyboard2.java b/srcs/juloo.keyboard2/Keyboard2.java
index 7bf9812..d2fdb2c 100644
--- a/srcs/juloo.keyboard2/Keyboard2.java
+++ b/srcs/juloo.keyboard2/Keyboard2.java
@@ -157,9 +157,9 @@ public class Keyboard2 extends InputMethodService
refreshAccentsOption(imm, subtype);
}
}
- _config.shouldOfferSwitchingToProgramming =
- _config.programming_layout != -1 &&
- _currentTextLayout != _config.programming_layout;
+ _config.shouldOfferSwitchingToSecond =
+ _config.second_layout != -1 &&
+ _currentTextLayout != _config.second_layout;
}
private String actionLabel_of_imeAction(int action)
@@ -343,17 +343,17 @@ public class Keyboard2 extends InputMethodService
_keyboardView.setKeyboard(getLayout(R.xml.greekmath));
}
- public void switchProgramming()
+ public void switchSecond()
{
- if (_config.programming_layout == -1)
+ if (_config.second_layout == -1)
return;
KeyboardData layout =
- getLayout(_config.programming_layout).mapKeys(new KeyboardData.MapKeyValues() {
+ getLayout(_config.second_layout).mapKeys(new KeyboardData.MapKeyValues() {
public KeyValue apply(KeyValue key, boolean localized)
{
if (key.getKind() == KeyValue.Kind.Event
- && key.getEvent() == KeyValue.Event.SWITCH_PROGRAMMING)
- return KeyValue.getKeyByName("switch_text");
+ && key.getEvent() == KeyValue.Event.SWITCH_SECOND)
+ return KeyValue.getKeyByName("switch_second_back");
return key;
}
});
diff --git a/srcs/juloo.keyboard2/LayoutListPreference.java b/srcs/juloo.keyboard2/LayoutListPreference.java
new file mode 100644
index 0000000..9e3072c
--- /dev/null
+++ b/srcs/juloo.keyboard2/LayoutListPreference.java
@@ -0,0 +1,25 @@
+package juloo.keyboard2;
+
+import android.content.Context;
+import android.content.res.Resources;
+import android.content.res.TypedArray;
+import android.preference.ListPreference;
+import android.util.AttributeSet;
+
+public class LayoutListPreference extends ListPreference
+{
+ public LayoutListPreference(Context context, AttributeSet attrs)
+ {
+ super(context, attrs);
+ final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.LayoutListPreference);
+ String defaultString = a.getString(R.styleable.LayoutListPreference_defaultString);
+ a.recycle();
+ Resources res = context.getResources();
+ String[] entries = res.getStringArray(R.array.pref_layout_entries);
+ entries[0] = defaultString;
+ setEntries(entries);
+ setEntryValues(res.getStringArray(R.array.pref_layout_values));
+ setSummary("%s");
+ setDefaultValue("none");
+ }
+}