Don't show important notice on password field
Bug: 10587358 Change-Id: Ieff7960e5e2b8609fddeb173af578a5d9b2c4d98
This commit is contained in:
parent
95d16561e0
commit
ce78a2d8ab
4 changed files with 27 additions and 12 deletions
|
@ -31,6 +31,7 @@ public final class InputAttributes {
|
|||
|
||||
final public String mTargetApplicationPackageName;
|
||||
final public boolean mInputTypeNoAutoCorrect;
|
||||
final public boolean mIsPasswordField;
|
||||
final public boolean mIsSettingsSuggestionStripOn;
|
||||
final public boolean mApplicationSpecifiedCompletionOn;
|
||||
final public boolean mShouldInsertSpacesAutomatically;
|
||||
|
@ -56,6 +57,7 @@ public final class InputAttributes {
|
|||
Log.w(TAG, String.format("Unexpected input class: inputType=0x%08x"
|
||||
+ " imeOptions=0x%08x", inputType, editorInfo.imeOptions));
|
||||
}
|
||||
mIsPasswordField = false;
|
||||
mIsSettingsSuggestionStripOn = false;
|
||||
mInputTypeNoAutoCorrect = false;
|
||||
mApplicationSpecifiedCompletionOn = false;
|
||||
|
@ -71,10 +73,11 @@ public final class InputAttributes {
|
|||
final boolean flagAutoComplete =
|
||||
0 != (inputType & InputType.TYPE_TEXT_FLAG_AUTO_COMPLETE);
|
||||
|
||||
mIsPasswordField = InputTypeUtils.isPasswordInputType(inputType)
|
||||
|| InputTypeUtils.isVisiblePasswordInputType(inputType);
|
||||
// TODO: Have a helper method in InputTypeUtils
|
||||
// Make sure that passwords are not displayed in {@link SuggestionStripView}.
|
||||
if (InputTypeUtils.isPasswordInputType(inputType)
|
||||
|| InputTypeUtils.isVisiblePasswordInputType(inputType)
|
||||
if (mIsPasswordField
|
||||
|| InputTypeUtils.isEmailVariation(variation)
|
||||
|| InputType.TYPE_TEXT_VARIATION_URI == variation
|
||||
|| InputType.TYPE_TEXT_VARIATION_FILTER == variation
|
||||
|
|
|
@ -1319,10 +1319,10 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
|||
return false;
|
||||
if (mSuggestionStripView.isShowingAddToDictionaryHint())
|
||||
return true;
|
||||
if (ImportantNoticeUtils.hasNewImportantNoticeAndNotInSetupWizard(this))
|
||||
return true;
|
||||
if (null == currentSettings)
|
||||
return false;
|
||||
if (ImportantNoticeUtils.shouldShowImportantNotice(this, currentSettings.mInputAttributes))
|
||||
return true;
|
||||
if (!currentSettings.isSuggestionStripVisible())
|
||||
return false;
|
||||
if (currentSettings.isApplicationSpecifiedCompletionsOn())
|
||||
|
@ -1351,11 +1351,13 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
|||
public void setSuggestedWords(final SuggestedWords suggestedWords, final boolean shouldShow) {
|
||||
mInputLogic.setSuggestedWords(suggestedWords);
|
||||
if (mSuggestionStripView != null) {
|
||||
final SettingsValues currentSettings = mSettings.getCurrent();
|
||||
final boolean showSuggestions;
|
||||
if (SuggestedWords.EMPTY == suggestedWords
|
||||
|| suggestedWords.isPunctuationSuggestions()
|
||||
|| !mSettings.getCurrent().isSuggestionsRequested()) {
|
||||
showSuggestions = !mSuggestionStripView.maybeShowImportantNoticeTitle();
|
||||
|| !currentSettings.isSuggestionsRequested()) {
|
||||
showSuggestions = !mSuggestionStripView.maybeShowImportantNoticeTitle(
|
||||
currentSettings.mInputAttributes);
|
||||
} else {
|
||||
showSuggestions = true;
|
||||
}
|
||||
|
|
|
@ -39,11 +39,13 @@ import com.android.inputmethod.keyboard.MainKeyboardView;
|
|||
import com.android.inputmethod.keyboard.MoreKeysPanel;
|
||||
import com.android.inputmethod.latin.AudioAndHapticFeedbackManager;
|
||||
import com.android.inputmethod.latin.Constants;
|
||||
import com.android.inputmethod.latin.InputAttributes;
|
||||
import com.android.inputmethod.latin.LatinImeLogger;
|
||||
import com.android.inputmethod.latin.R;
|
||||
import com.android.inputmethod.latin.SuggestedWords;
|
||||
import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo;
|
||||
import com.android.inputmethod.latin.define.ProductionFlag;
|
||||
import com.android.inputmethod.latin.settings.Settings;
|
||||
import com.android.inputmethod.latin.suggestions.MoreSuggestions.MoreSuggestionsListener;
|
||||
import com.android.inputmethod.latin.utils.CollectionUtils;
|
||||
import com.android.inputmethod.latin.utils.ImportantNoticeUtils;
|
||||
|
@ -226,8 +228,8 @@ public final class SuggestionStripView extends RelativeLayout implements OnClick
|
|||
// This method checks if we should show the important notice (checks on permanent storage if
|
||||
// it has been shown once already or not, and if in the setup wizard). If applicable, it shows
|
||||
// the notice. In all cases, it returns true if it was shown, false otherwise.
|
||||
public boolean maybeShowImportantNoticeTitle() {
|
||||
if (!ImportantNoticeUtils.hasNewImportantNoticeAndNotInSetupWizard(getContext())) {
|
||||
public boolean maybeShowImportantNoticeTitle(final InputAttributes inputAttributes) {
|
||||
if (!ImportantNoticeUtils.shouldShowImportantNotice(getContext(), inputAttributes)) {
|
||||
return false;
|
||||
}
|
||||
final int width = getWidth();
|
||||
|
@ -431,6 +433,6 @@ public final class SuggestionStripView extends RelativeLayout implements OnClick
|
|||
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
|
||||
// Called by the framework when the size is known. Show the important notice if applicable.
|
||||
// This may be overriden by showing suggestions later, if applicable.
|
||||
maybeShowImportantNoticeTitle();
|
||||
maybeShowImportantNoticeTitle(Settings.getInstance().getCurrent().mInputAttributes);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ import android.provider.Settings;
|
|||
import android.provider.Settings.SettingNotFoundException;
|
||||
import android.util.Log;
|
||||
|
||||
import com.android.inputmethod.latin.InputAttributes;
|
||||
import com.android.inputmethod.latin.R;
|
||||
|
||||
public final class ImportantNoticeUtils {
|
||||
|
@ -62,11 +63,18 @@ public final class ImportantNoticeUtils {
|
|||
return context.getResources().getInteger(R.integer.config_important_notice_version);
|
||||
}
|
||||
|
||||
public static boolean hasNewImportantNoticeAndNotInSetupWizard(final Context context) {
|
||||
private static boolean hasNewImportantNotice(final Context context) {
|
||||
final SharedPreferences prefs = getImportantNoticePreferences(context);
|
||||
final int lastVersion = prefs.getInt(KEY_IMPORTANT_NOTICE_VERSION, 0);
|
||||
return getCurrentImportantNoticeVersion(context) > lastVersion
|
||||
&& !isInSystemSetupWizard(context);
|
||||
return getCurrentImportantNoticeVersion(context) > lastVersion;
|
||||
}
|
||||
|
||||
public static boolean shouldShowImportantNotice(final Context context,
|
||||
final InputAttributes inputAttributes) {
|
||||
if (inputAttributes == null || inputAttributes.mIsPasswordField) {
|
||||
return false;
|
||||
}
|
||||
return hasNewImportantNotice(context) && !isInSystemSetupWizard(context);
|
||||
}
|
||||
|
||||
public static void updateLastImportantNoticeVersion(final Context context) {
|
||||
|
|
Loading…
Reference in a new issue