From 0b943952333c7578ef99b1bf09b39a18483efaf6 Mon Sep 17 00:00:00 2001 From: juloo Date: Sun, 11 Dec 2016 22:45:58 +0100 Subject: switchToNextInputMethod key --- project.properties | 2 +- res/xml/qwerty.xml | 2 +- srcs/juloo.keyboard2/KeyValue.java | 2 ++ srcs/juloo.keyboard2/Keyboard2.java | 8 ++++++++ 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/project.properties b/project.properties index 00cf62b..916037e 100644 --- a/project.properties +++ b/project.properties @@ -11,4 +11,4 @@ #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt # Project target. -target=android-22 +target=android-23 diff --git a/res/xml/qwerty.xml b/res/xml/qwerty.xml index af9bb3b..20bc45e 100644 --- a/res/xml/qwerty.xml +++ b/res/xml/qwerty.xml @@ -35,7 +35,7 @@ - + diff --git a/srcs/juloo.keyboard2/KeyValue.java b/srcs/juloo.keyboard2/KeyValue.java index 6435f22..50a528d 100644 --- a/srcs/juloo.keyboard2/KeyValue.java +++ b/srcs/juloo.keyboard2/KeyValue.java @@ -12,6 +12,7 @@ class KeyValue public static final int EVENT_SWITCH_NUMERIC = -4; public static final int EVENT_SWITCH_EMOJI = -5; public static final int EVENT_SWITCH_BACK_EMOJI = -6; + public static final int EVENT_CHANGE_METHOD = -7; public static final char CHAR_NONE = '\0'; public static final int FLAG_KEEP_ON = 1; @@ -193,5 +194,6 @@ class KeyValue new KeyValue("tab", "↹", '\t', KeyEvent.KEYCODE_TAB, 0); new KeyValue("space", null, ' ', KeyEvent.KEYCODE_SPACE, 0); + new KeyValue("change_method", "⊞", CHAR_NONE, EVENT_CHANGE_METHOD, FLAG_NOREPEAT); } } diff --git a/srcs/juloo.keyboard2/Keyboard2.java b/srcs/juloo.keyboard2/Keyboard2.java index 3d4fda5..6123093 100644 --- a/srcs/juloo.keyboard2/Keyboard2.java +++ b/srcs/juloo.keyboard2/Keyboard2.java @@ -9,9 +9,11 @@ import android.os.Bundle; import android.text.InputType; import android.preference.PreferenceManager; import android.view.inputmethod.EditorInfo; +import android.view.inputmethod.InputMethodManager; import android.view.KeyEvent; import android.view.View; import android.view.ViewGroup; +import android.util.Log; public class Keyboard2 extends InputMethodService implements SharedPreferences.OnSharedPreferenceChangeListener @@ -123,6 +125,12 @@ public class Keyboard2 extends InputMethodService } else if (eventCode == KeyValue.EVENT_SWITCH_BACK_EMOJI) setInputView(_keyboardView); + else if (eventCode == KeyValue.EVENT_CHANGE_METHOD) + { + InputMethodManager imm = (InputMethodManager)getSystemService(INPUT_METHOD_SERVICE); + + imm.switchToNextInputMethod(getWindow().getWindow().getAttributes().token, false); + } else if ((flags & (KeyValue.FLAG_CTRL | KeyValue.FLAG_ALT)) != 0) handleMetaKeyUp(key, flags); // else if (eventCode == KeyEvent.KEYCODE_DEL) -- cgit v1.2.3