From 0b943952333c7578ef99b1bf09b39a18483efaf6 Mon Sep 17 00:00:00 2001 From: juloo Date: Sun, 11 Dec 2016 22:45:58 +0100 Subject: switchToNextInputMethod key --- srcs/juloo.keyboard2/KeyValue.java | 2 ++ srcs/juloo.keyboard2/Keyboard2.java | 8 ++++++++ 2 files changed, 10 insertions(+) (limited to 'srcs/juloo.keyboard2') 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