abouttreesummaryrefslogcommitdiff
path: root/srcs/juloo.keyboard2
diff options
context:
space:
mode:
Diffstat (limited to 'srcs/juloo.keyboard2')
-rw-r--r--srcs/juloo.keyboard2/ExtraKeyCheckBoxPreference.java3
-rw-r--r--srcs/juloo.keyboard2/KeyEventHandler.java2
-rw-r--r--srcs/juloo.keyboard2/KeyValue.java3
-rw-r--r--srcs/juloo.keyboard2/Keyboard2.java22
4 files changed, 30 insertions, 0 deletions
diff --git a/srcs/juloo.keyboard2/ExtraKeyCheckBoxPreference.java b/srcs/juloo.keyboard2/ExtraKeyCheckBoxPreference.java
index 8938d2d..8f7471a 100644
--- a/srcs/juloo.keyboard2/ExtraKeyCheckBoxPreference.java
+++ b/srcs/juloo.keyboard2/ExtraKeyCheckBoxPreference.java
@@ -16,6 +16,7 @@ public class ExtraKeyCheckBoxPreference extends CheckBoxPreference
{
"alt",
"meta",
+ "voice_typing",
"accent_aigu",
"accent_grave",
"accent_double_aigu",
@@ -56,6 +57,8 @@ public class ExtraKeyCheckBoxPreference extends CheckBoxPreference
{
switch (name)
{
+ case "voice_typing":
+ return true;
default:
return false;
}
diff --git a/srcs/juloo.keyboard2/KeyEventHandler.java b/srcs/juloo.keyboard2/KeyEventHandler.java
index 1a591c8..70b54b9 100644
--- a/srcs/juloo.keyboard2/KeyEventHandler.java
+++ b/srcs/juloo.keyboard2/KeyEventHandler.java
@@ -59,6 +59,7 @@ class KeyEventHandler implements Config.IKeyEventHandler
case SWITCH_SECOND_BACK: _recv.set_layout(Layout.Primary); break;
case SWITCH_GREEKMATH: _recv.set_layout(Layout.Greekmath); break;
case CAPS_LOCK: _recv.set_shift_state(true, true); break;
+ case SWITCH_VOICE_TYPING: _recv.switch_voice_typing(); break;
}
break;
case Keyevent:
@@ -182,6 +183,7 @@ class KeyEventHandler implements Config.IKeyEventHandler
{
public void switchInputMethod();
public void switchToPrevInputMethod();
+ public void switch_voice_typing();
public void setPane_emoji();
public void setPane_normal();
public void showKeyboardConfig();
diff --git a/srcs/juloo.keyboard2/KeyValue.java b/srcs/juloo.keyboard2/KeyValue.java
index 3e84ce8..9f4d985 100644
--- a/srcs/juloo.keyboard2/KeyValue.java
+++ b/srcs/juloo.keyboard2/KeyValue.java
@@ -19,6 +19,7 @@ final class KeyValue
SWITCH_SECOND_BACK,
SWITCH_GREEKMATH,
CAPS_LOCK,
+ SWITCH_VOICE_TYPING,
}
// Must be evaluated in the reverse order of their values.
@@ -343,6 +344,7 @@ final class KeyValue
case "change_method_prev": return eventKey(0x09, Event.CHANGE_METHOD_PREV, FLAG_SMALLER_FONT);
case "action": return eventKey("Action", Event.ACTION, FLAG_SMALLER_FONT); // Will always be replaced
case "capslock": return eventKey(0x12, Event.CAPS_LOCK, 0);
+ case "voice_typing": return eventKey(0x15, Event.SWITCH_VOICE_TYPING, FLAG_SMALLER_FONT);
case "esc": return keyeventKey("Esc", KeyEvent.KEYCODE_ESCAPE, FLAG_SMALLER_FONT);
case "enter": return keyeventKey(0x0E, KeyEvent.KEYCODE_ENTER, 0);
@@ -451,6 +453,7 @@ final class KeyValue
/* Keys description is shown in the settings. */
addKeyDescr("capslock", "Caps lock");
addKeyDescr("switch_greekmath", "Greek & math symbols");
+ addKeyDescr("voice_typing", "Voice typing");
}
// Substitute for [assert], which has no effect on Android.
diff --git a/srcs/juloo.keyboard2/Keyboard2.java b/srcs/juloo.keyboard2/Keyboard2.java
index c41a22f..e5bd726 100644
--- a/srcs/juloo.keyboard2/Keyboard2.java
+++ b/srcs/juloo.keyboard2/Keyboard2.java
@@ -399,6 +399,28 @@ public class Keyboard2 extends InputMethodService
Keyboard2.this.switchToPreviousInputMethod();
}
+ public void switch_voice_typing()
+ {
+ if (VERSION.SDK_INT < 11) // Due to InputMethodSubtype
+ return;
+ InputMethodManager imm = (InputMethodManager)getSystemService(INPUT_METHOD_SERVICE);
+ for (InputMethodInfo im : imm.getEnabledInputMethodList())
+ {
+ for (InputMethodSubtype imst : imm.getEnabledInputMethodSubtypeList(im, true))
+ {
+ // Switch to the first IM that has a subtype of this mode
+ if (imst.getMode().equals("voice"))
+ {
+ // Best-effort. Good enough for triggering Google's voice typing
+ if (VERSION.SDK_INT < 28)
+ Keyboard2.this.switchInputMethod(im.getId());
+ else
+ Keyboard2.this.switchInputMethod(im.getId(), imst);
+ }
+ }
+ }
+ }
+
public void setPane_emoji()
{
if (_emojiPane == null)