Always update voice key visibility
Bug: 15128166 Change-Id: Ie15724c323efa3b102f6aebddc3bda210aad1727
This commit is contained in:
parent
3ca65c8fd5
commit
aa4b2c7127
4 changed files with 26 additions and 29 deletions
|
@ -115,9 +115,7 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions {
|
||||||
final int keyboardHeight = ResourceUtils.getDefaultKeyboardHeight(res);
|
final int keyboardHeight = ResourceUtils.getDefaultKeyboardHeight(res);
|
||||||
builder.setKeyboardGeometry(keyboardWidth, keyboardHeight);
|
builder.setKeyboardGeometry(keyboardWidth, keyboardHeight);
|
||||||
builder.setSubtype(mSubtypeSwitcher.getCurrentSubtype());
|
builder.setSubtype(mSubtypeSwitcher.getCurrentSubtype());
|
||||||
builder.setVoiceInputKeyEnabled(mSubtypeSwitcher.isShortcutImeEnabled()
|
builder.setVoiceInputKeyEnabled(settingsValues.mShowsVoiceInputKey);
|
||||||
&& settingsValues.mShowsVoiceInputKey
|
|
||||||
&& !settingsValues.mInputAttributes.hasNoMicrophoneKeyOption());
|
|
||||||
builder.setLanguageSwitchKeyEnabled(mLatinIME.shouldShowLanguageSwitchKey());
|
builder.setLanguageSwitchKeyEnabled(mLatinIME.shouldShowLanguageSwitchKey());
|
||||||
mKeyboardLayoutSet = builder.build();
|
mKeyboardLayoutSet = builder.build();
|
||||||
mCurrentSettingsValues = settingsValues;
|
mCurrentSettingsValues = settingsValues;
|
||||||
|
|
|
@ -738,6 +738,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
}
|
}
|
||||||
Log.i(TAG, "Starting input. Cursor position = "
|
Log.i(TAG, "Starting input. Cursor position = "
|
||||||
+ editorInfo.initialSelStart + "," + editorInfo.initialSelEnd);
|
+ editorInfo.initialSelStart + "," + editorInfo.initialSelEnd);
|
||||||
|
// TODO: Consolidate these checks with {@link InputAttributes}.
|
||||||
if (InputAttributes.inPrivateImeOptions(null, NO_MICROPHONE_COMPAT, editorInfo)) {
|
if (InputAttributes.inPrivateImeOptions(null, NO_MICROPHONE_COMPAT, editorInfo)) {
|
||||||
Log.w(TAG, "Deprecated private IME option specified: " + editorInfo.privateImeOptions);
|
Log.w(TAG, "Deprecated private IME option specified: " + editorInfo.privateImeOptions);
|
||||||
Log.w(TAG, "Use " + getPackageName() + "." + NO_MICROPHONE + " instead");
|
Log.w(TAG, "Use " + getPackageName() + "." + NO_MICROPHONE + " instead");
|
||||||
|
@ -1343,11 +1344,11 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
if (!onEvaluateInputViewShown()) {
|
if (!onEvaluateInputViewShown()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mSuggestionStripView.updateVisibility(isSuggestionStripVisible, isFullscreenMode());
|
||||||
if (!isSuggestionStripVisible) {
|
if (!isSuggestionStripVisible) {
|
||||||
mSuggestionStripView.setVisibility(isFullscreenMode() ? View.GONE : View.INVISIBLE);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mSuggestionStripView.setVisibility(View.VISIBLE);
|
|
||||||
|
|
||||||
final SettingsValues currentSettings = mSettings.getCurrent();
|
final SettingsValues currentSettings = mSettings.getCurrent();
|
||||||
final boolean showSuggestions;
|
final boolean showSuggestions;
|
||||||
|
|
|
@ -28,6 +28,7 @@ import com.android.inputmethod.compat.AppWorkaroundsUtils;
|
||||||
import com.android.inputmethod.latin.InputAttributes;
|
import com.android.inputmethod.latin.InputAttributes;
|
||||||
import com.android.inputmethod.latin.R;
|
import com.android.inputmethod.latin.R;
|
||||||
import com.android.inputmethod.latin.RichInputMethodManager;
|
import com.android.inputmethod.latin.RichInputMethodManager;
|
||||||
|
import com.android.inputmethod.latin.SubtypeSwitcher;
|
||||||
import com.android.inputmethod.latin.utils.AsyncResultHolder;
|
import com.android.inputmethod.latin.utils.AsyncResultHolder;
|
||||||
import com.android.inputmethod.latin.utils.ResourceUtils;
|
import com.android.inputmethod.latin.utils.ResourceUtils;
|
||||||
import com.android.inputmethod.latin.utils.TargetPackageInfoGetterTask;
|
import com.android.inputmethod.latin.utils.TargetPackageInfoGetterTask;
|
||||||
|
@ -122,7 +123,10 @@ public final class SettingsValues {
|
||||||
mKeyPreviewPopupOn = Settings.readKeyPreviewPopupEnabled(prefs, res);
|
mKeyPreviewPopupOn = Settings.readKeyPreviewPopupEnabled(prefs, res);
|
||||||
mSlidingKeyInputPreviewEnabled = prefs.getBoolean(
|
mSlidingKeyInputPreviewEnabled = prefs.getBoolean(
|
||||||
DebugSettings.PREF_SLIDING_KEY_INPUT_PREVIEW, true);
|
DebugSettings.PREF_SLIDING_KEY_INPUT_PREVIEW, true);
|
||||||
mShowsVoiceInputKey = needsToShowVoiceInputKey(prefs, res);
|
mShowsVoiceInputKey = needsToShowVoiceInputKey(prefs, res)
|
||||||
|
&& !mInputAttributes.mIsPasswordField
|
||||||
|
&& !mInputAttributes.hasNoMicrophoneKeyOption()
|
||||||
|
&& SubtypeSwitcher.getInstance().isShortcutImeEnabled();
|
||||||
final String autoCorrectionThresholdRawValue = prefs.getString(
|
final String autoCorrectionThresholdRawValue = prefs.getString(
|
||||||
Settings.PREF_AUTO_CORRECTION_THRESHOLD,
|
Settings.PREF_AUTO_CORRECTION_THRESHOLD,
|
||||||
res.getString(R.string.auto_correction_threshold_mode_index_modest));
|
res.getString(R.string.auto_correction_threshold_mode_index_modest));
|
||||||
|
|
|
@ -48,6 +48,7 @@ import com.android.inputmethod.latin.R;
|
||||||
import com.android.inputmethod.latin.SuggestedWords;
|
import com.android.inputmethod.latin.SuggestedWords;
|
||||||
import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo;
|
import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo;
|
||||||
import com.android.inputmethod.latin.settings.Settings;
|
import com.android.inputmethod.latin.settings.Settings;
|
||||||
|
import com.android.inputmethod.latin.settings.SettingsValues;
|
||||||
import com.android.inputmethod.latin.suggestions.MoreSuggestionsView.MoreSuggestionsListener;
|
import com.android.inputmethod.latin.suggestions.MoreSuggestionsView.MoreSuggestionsListener;
|
||||||
import com.android.inputmethod.latin.utils.ImportantNoticeUtils;
|
import com.android.inputmethod.latin.utils.ImportantNoticeUtils;
|
||||||
|
|
||||||
|
@ -89,19 +90,17 @@ public final class SuggestionStripView extends RelativeLayout implements OnClick
|
||||||
private static class StripVisibilityGroup {
|
private static class StripVisibilityGroup {
|
||||||
private final View mSuggestionStripView;
|
private final View mSuggestionStripView;
|
||||||
private final View mSuggestionsStrip;
|
private final View mSuggestionsStrip;
|
||||||
private final View mVoiceKey;
|
|
||||||
private final View mAddToDictionaryStrip;
|
private final View mAddToDictionaryStrip;
|
||||||
private final View mImportantNoticeStrip;
|
private final View mImportantNoticeStrip;
|
||||||
|
|
||||||
public StripVisibilityGroup(final View suggestionStripView,
|
public StripVisibilityGroup(final View suggestionStripView,
|
||||||
final ViewGroup suggestionsStrip, final ImageButton voiceKey,
|
final ViewGroup suggestionsStrip, final ViewGroup addToDictionaryStrip,
|
||||||
final ViewGroup addToDictionaryStrip, final View importantNoticeStrip) {
|
final View importantNoticeStrip) {
|
||||||
mSuggestionStripView = suggestionStripView;
|
mSuggestionStripView = suggestionStripView;
|
||||||
mSuggestionsStrip = suggestionsStrip;
|
mSuggestionsStrip = suggestionsStrip;
|
||||||
mVoiceKey = voiceKey;
|
|
||||||
mAddToDictionaryStrip = addToDictionaryStrip;
|
mAddToDictionaryStrip = addToDictionaryStrip;
|
||||||
mImportantNoticeStrip = importantNoticeStrip;
|
mImportantNoticeStrip = importantNoticeStrip;
|
||||||
showSuggestionsStrip(false /* voiceKeyEnabled */);
|
showSuggestionsStrip();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLayoutDirection(final boolean isRtlLanguage) {
|
public void setLayoutDirection(final boolean isRtlLanguage) {
|
||||||
|
@ -113,23 +112,20 @@ public final class SuggestionStripView extends RelativeLayout implements OnClick
|
||||||
ViewCompat.setLayoutDirection(mImportantNoticeStrip, layoutDirection);
|
ViewCompat.setLayoutDirection(mImportantNoticeStrip, layoutDirection);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void showSuggestionsStrip(final boolean enableVoiceKey) {
|
public void showSuggestionsStrip() {
|
||||||
mSuggestionsStrip.setVisibility(VISIBLE);
|
mSuggestionsStrip.setVisibility(VISIBLE);
|
||||||
mVoiceKey.setVisibility(enableVoiceKey ? VISIBLE : INVISIBLE);
|
|
||||||
mAddToDictionaryStrip.setVisibility(INVISIBLE);
|
mAddToDictionaryStrip.setVisibility(INVISIBLE);
|
||||||
mImportantNoticeStrip.setVisibility(INVISIBLE);
|
mImportantNoticeStrip.setVisibility(INVISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void showAddToDictionaryStrip() {
|
public void showAddToDictionaryStrip() {
|
||||||
mSuggestionsStrip.setVisibility(INVISIBLE);
|
mSuggestionsStrip.setVisibility(INVISIBLE);
|
||||||
mVoiceKey.setVisibility(INVISIBLE);
|
|
||||||
mAddToDictionaryStrip.setVisibility(VISIBLE);
|
mAddToDictionaryStrip.setVisibility(VISIBLE);
|
||||||
mImportantNoticeStrip.setVisibility(INVISIBLE);
|
mImportantNoticeStrip.setVisibility(INVISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void showImportantNoticeStrip(final boolean enableVoiceKey) {
|
public void showImportantNoticeStrip() {
|
||||||
mSuggestionsStrip.setVisibility(INVISIBLE);
|
mSuggestionsStrip.setVisibility(INVISIBLE);
|
||||||
mVoiceKey.setVisibility(enableVoiceKey ? VISIBLE : INVISIBLE);
|
|
||||||
mAddToDictionaryStrip.setVisibility(INVISIBLE);
|
mAddToDictionaryStrip.setVisibility(INVISIBLE);
|
||||||
mImportantNoticeStrip.setVisibility(VISIBLE);
|
mImportantNoticeStrip.setVisibility(VISIBLE);
|
||||||
}
|
}
|
||||||
|
@ -159,7 +155,7 @@ public final class SuggestionStripView extends RelativeLayout implements OnClick
|
||||||
mVoiceKey = (ImageButton)findViewById(R.id.suggestions_strip_voice_key);
|
mVoiceKey = (ImageButton)findViewById(R.id.suggestions_strip_voice_key);
|
||||||
mAddToDictionaryStrip = (ViewGroup)findViewById(R.id.add_to_dictionary_strip);
|
mAddToDictionaryStrip = (ViewGroup)findViewById(R.id.add_to_dictionary_strip);
|
||||||
mImportantNoticeStrip = findViewById(R.id.important_notice_strip);
|
mImportantNoticeStrip = findViewById(R.id.important_notice_strip);
|
||||||
mStripVisibilityGroup = new StripVisibilityGroup(this, mSuggestionsStrip, mVoiceKey,
|
mStripVisibilityGroup = new StripVisibilityGroup(this, mSuggestionsStrip,
|
||||||
mAddToDictionaryStrip, mImportantNoticeStrip);
|
mAddToDictionaryStrip, mImportantNoticeStrip);
|
||||||
|
|
||||||
for (int pos = 0; pos < SuggestedWords.MAX_SUGGESTIONS; pos++) {
|
for (int pos = 0; pos < SuggestedWords.MAX_SUGGESTIONS; pos++) {
|
||||||
|
@ -207,15 +203,13 @@ public final class SuggestionStripView extends RelativeLayout implements OnClick
|
||||||
mMainKeyboardView = (MainKeyboardView)inputView.findViewById(R.id.keyboard_view);
|
mMainKeyboardView = (MainKeyboardView)inputView.findViewById(R.id.keyboard_view);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isVoiceKeyEnabled() {
|
public void updateVisibility(final boolean shouldBeVisible, final boolean isFullscreenMode) {
|
||||||
if (mMainKeyboardView == null) {
|
final int visibility = shouldBeVisible ? VISIBLE : (isFullscreenMode ? GONE : INVISIBLE);
|
||||||
return false;
|
setVisibility(visibility);
|
||||||
}
|
final SettingsValues currentSettingsValues = Settings.getInstance().getCurrent();
|
||||||
final Keyboard keyboard = mMainKeyboardView.getKeyboard();
|
final boolean shouldShowVoiceKey = (currentSettingsValues != null)
|
||||||
if (keyboard == null) {
|
&& currentSettingsValues.mShowsVoiceInputKey;
|
||||||
return false;
|
mVoiceKey.setVisibility(shouldShowVoiceKey ? VISIBLE : INVISIBLE);
|
||||||
}
|
|
||||||
return keyboard.mId.mHasShortcutKey;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSuggestions(final SuggestedWords suggestedWords, final boolean isRtlLanguage) {
|
public void setSuggestions(final SuggestedWords suggestedWords, final boolean isRtlLanguage) {
|
||||||
|
@ -224,7 +218,7 @@ public final class SuggestionStripView extends RelativeLayout implements OnClick
|
||||||
mSuggestedWords = suggestedWords;
|
mSuggestedWords = suggestedWords;
|
||||||
mSuggestionsCountInStrip = mLayoutHelper.layoutAndReturnSuggestionCountInStrip(
|
mSuggestionsCountInStrip = mLayoutHelper.layoutAndReturnSuggestionCountInStrip(
|
||||||
mSuggestedWords, mSuggestionsStrip, this);
|
mSuggestedWords, mSuggestionsStrip, this);
|
||||||
mStripVisibilityGroup.showSuggestionsStrip(isVoiceKeyEnabled());
|
mStripVisibilityGroup.showSuggestionsStrip();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int setMoreSuggestionsHeight(final int remainingHeight) {
|
public int setMoreSuggestionsHeight(final int remainingHeight) {
|
||||||
|
@ -271,7 +265,7 @@ public final class SuggestionStripView extends RelativeLayout implements OnClick
|
||||||
dismissMoreSuggestionsPanel();
|
dismissMoreSuggestionsPanel();
|
||||||
}
|
}
|
||||||
mLayoutHelper.layoutImportantNotice(mImportantNoticeStrip, importantNoticeTitle);
|
mLayoutHelper.layoutImportantNotice(mImportantNoticeStrip, importantNoticeTitle);
|
||||||
mStripVisibilityGroup.showImportantNoticeStrip(isVoiceKeyEnabled());
|
mStripVisibilityGroup.showImportantNoticeStrip();
|
||||||
mImportantNoticeStrip.setOnClickListener(this);
|
mImportantNoticeStrip.setOnClickListener(this);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -279,7 +273,7 @@ public final class SuggestionStripView extends RelativeLayout implements OnClick
|
||||||
public void clear() {
|
public void clear() {
|
||||||
mSuggestionsStrip.removeAllViews();
|
mSuggestionsStrip.removeAllViews();
|
||||||
removeAllDebugInfoViews();
|
removeAllDebugInfoViews();
|
||||||
mStripVisibilityGroup.showSuggestionsStrip(false /* enableVoiceKey */);
|
mStripVisibilityGroup.showSuggestionsStrip();
|
||||||
dismissMoreSuggestionsPanel();
|
dismissMoreSuggestionsPanel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue