Skip to content

Commit

Permalink
Merge pull request #573 from Helium314/fix_voice_key
Browse files Browse the repository at this point in the history
Hide voice input key and disable setting if no voice input available
  • Loading branch information
MajeurAndroid authored Mar 21, 2022
2 parents 08247bd + 9ccea39 commit c71acea
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ public InputAttributes(final EditorInfo editorInfo, final boolean isFullscreenMo
final boolean noMicrophone = mIsPasswordField
|| InputTypeUtils.isEmailVariation(variation)
|| InputType.TYPE_TEXT_VARIATION_URI == variation
|| hasNoMicrophoneKeyOption();
|| hasNoMicrophoneKeyOption()
|| !RichInputMethodManager.getInstance().hasShortcutIme();
mShouldShowVoiceInputKey = !noMicrophone;

mDisableGestureFloatingPreviewText = InputAttributes.inPrivateImeOptions(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -584,6 +584,10 @@ public void switchToShortcutIme(final InputMethodService context) {
switchToTargetIME(imiId, mShortcutSubtype, context);
}

public boolean hasShortcutIme() {
return mShortcutInputMethodInfo != null;
}

private void switchToTargetIME(final String imiId, final InputMethodSubtype subtype,
final InputMethodService context) {
final IBinder token = context.getWindow().getWindow().getAttributes().token;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,9 @@ public void onResume() {
final Preference voiceInputKeyOption = findPreference(Settings.PREF_VOICE_INPUT_KEY);
if (voiceInputKeyOption != null) {
RichInputMethodManager.getInstance().refreshSubtypeCaches();
voiceInputKeyOption.setEnabled(VOICE_IME_ENABLED);
voiceInputKeyOption.setSummary(VOICE_IME_ENABLED
boolean voiceKeyEnabled = VOICE_IME_ENABLED && RichInputMethodManager.getInstance().hasShortcutIme();
voiceInputKeyOption.setEnabled(voiceKeyEnabled);
voiceInputKeyOption.setSummary(voiceKeyEnabled
? null : getText(R.string.voice_input_disabled_summary));
}
}
Expand Down

0 comments on commit c71acea

Please sign in to comment.