abouttreesummaryrefslogcommitdiff
path: root/srcs/juloo.keyboard2/Keyboard2.java
diff options
context:
space:
mode:
authorJules Aguillon2023-12-30 00:56:55 +0100
committerJules Aguillon2023-12-30 00:56:55 +0100
commit51a41ec90af505b153cc7a016de3c1e8a18dc427 (patch)
treed8e0464eadb3032c36192c483370d5c720fe43ae /srcs/juloo.keyboard2/Keyboard2.java
parent7e7a5e4425a7825a9b0d899d6d13710acae82600 (diff)
downloadunexpected-keyboard-51a41ec90af505b153cc7a016de3c1e8a18dc427.tar.gz
unexpected-keyboard-51a41ec90af505b153cc7a016de3c1e8a18dc427.zip
Voice IME chooser popup
Bring a popup for choosing the voice IME when the voice key is pressed for the first time or the list of voice IMEs installed on the device change. A preference stores the last selected IME and the last seen list of IMEs.
Diffstat (limited to 'srcs/juloo.keyboard2/Keyboard2.java')
-rw-r--r--srcs/juloo.keyboard2/Keyboard2.java27
1 files changed, 4 insertions, 23 deletions
diff --git a/srcs/juloo.keyboard2/Keyboard2.java b/srcs/juloo.keyboard2/Keyboard2.java
index d045396..0e91f8c 100644
--- a/srcs/juloo.keyboard2/Keyboard2.java
+++ b/srcs/juloo.keyboard2/Keyboard2.java
@@ -151,7 +151,7 @@ public class Keyboard2 extends InputMethodService
_config.shouldOfferSwitchingToNextInputMethod = true;
else
_config.shouldOfferSwitchingToNextInputMethod = shouldOfferSwitchingToNextInputMethod();
- _config.shouldOfferVoiceTyping = (get_voice_typing_im(imm) != null);
+ _config.shouldOfferVoiceTyping = true;
KeyboardData default_layout = null;
_config.extra_keys_subtype = null;
if (VERSION.SDK_INT >= 12)
@@ -224,20 +224,6 @@ public class Keyboard2 extends InputMethodService
_keyboardView.reset();
}
- /** Returns the id and subtype of the voice typing IM. Returns [null] if none
- is installed or if the feature is unsupported. */
- SimpleEntry<String, InputMethodSubtype> get_voice_typing_im(InputMethodManager imm)
- {
- if (VERSION.SDK_INT < 11) // Due to InputMethodSubtype
- return null;
- 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"))
- return new SimpleEntry(im.getId(), imst);
- return null;
- }
-
private KeyboardData refresh_special_layout(EditorInfo info)
{
switch (info.inputType & InputType.TYPE_MASK_CLASS)
@@ -433,14 +419,9 @@ public class Keyboard2 extends InputMethodService
break;
case SWITCH_VOICE_TYPING:
- SimpleEntry<String, InputMethodSubtype> im = get_voice_typing_im(get_imm());
- if (im == null)
- return;
- // Best-effort. Good enough for triggering Google's voice typing.
- if (VERSION.SDK_INT < 28)
- switchInputMethod(im.getKey());
- else
- switchInputMethod(im.getKey(), im.getValue());
+ if (!VoiceImeSwitcher.switch_to_voice_ime(Keyboard2.this, get_imm(),
+ Config.globalPrefs()))
+ _config.shouldOfferVoiceTyping = false;
break;
}
}