Merge "Don't show important notice on password field"
commit
4c628b9d5b
|
@ -31,6 +31,7 @@ public final class InputAttributes {
|
||||||
|
|
||||||
final public String mTargetApplicationPackageName;
|
final public String mTargetApplicationPackageName;
|
||||||
final public boolean mInputTypeNoAutoCorrect;
|
final public boolean mInputTypeNoAutoCorrect;
|
||||||
|
final public boolean mIsPasswordField;
|
||||||
final public boolean mIsSettingsSuggestionStripOn;
|
final public boolean mIsSettingsSuggestionStripOn;
|
||||||
final public boolean mApplicationSpecifiedCompletionOn;
|
final public boolean mApplicationSpecifiedCompletionOn;
|
||||||
final public boolean mShouldInsertSpacesAutomatically;
|
final public boolean mShouldInsertSpacesAutomatically;
|
||||||
|
@ -56,6 +57,7 @@ public final class InputAttributes {
|
||||||
Log.w(TAG, String.format("Unexpected input class: inputType=0x%08x"
|
Log.w(TAG, String.format("Unexpected input class: inputType=0x%08x"
|
||||||
+ " imeOptions=0x%08x", inputType, editorInfo.imeOptions));
|
+ " imeOptions=0x%08x", inputType, editorInfo.imeOptions));
|
||||||
}
|
}
|
||||||
|
mIsPasswordField = false;
|
||||||
mIsSettingsSuggestionStripOn = false;
|
mIsSettingsSuggestionStripOn = false;
|
||||||
mInputTypeNoAutoCorrect = false;
|
mInputTypeNoAutoCorrect = false;
|
||||||
mApplicationSpecifiedCompletionOn = false;
|
mApplicationSpecifiedCompletionOn = false;
|
||||||
|
@ -71,10 +73,11 @@ public final class InputAttributes {
|
||||||
final boolean flagAutoComplete =
|
final boolean flagAutoComplete =
|
||||||
0 != (inputType & InputType.TYPE_TEXT_FLAG_AUTO_COMPLETE);
|
0 != (inputType & InputType.TYPE_TEXT_FLAG_AUTO_COMPLETE);
|
||||||
|
|
||||||
|
mIsPasswordField = InputTypeUtils.isPasswordInputType(inputType)
|
||||||
|
|| InputTypeUtils.isVisiblePasswordInputType(inputType);
|
||||||
// TODO: Have a helper method in InputTypeUtils
|
// TODO: Have a helper method in InputTypeUtils
|
||||||
// Make sure that passwords are not displayed in {@link SuggestionStripView}.
|
// Make sure that passwords are not displayed in {@link SuggestionStripView}.
|
||||||
if (InputTypeUtils.isPasswordInputType(inputType)
|
if (mIsPasswordField
|
||||||
|| InputTypeUtils.isVisiblePasswordInputType(inputType)
|
|
||||||
|| InputTypeUtils.isEmailVariation(variation)
|
|| InputTypeUtils.isEmailVariation(variation)
|
||||||
|| InputType.TYPE_TEXT_VARIATION_URI == variation
|
|| InputType.TYPE_TEXT_VARIATION_URI == variation
|
||||||
|| InputType.TYPE_TEXT_VARIATION_FILTER == variation
|
|| InputType.TYPE_TEXT_VARIATION_FILTER == variation
|
||||||
|
|
|
@ -1327,10 +1327,10 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
return false;
|
return false;
|
||||||
if (mSuggestionStripView.isShowingAddToDictionaryHint())
|
if (mSuggestionStripView.isShowingAddToDictionaryHint())
|
||||||
return true;
|
return true;
|
||||||
if (ImportantNoticeUtils.hasNewImportantNoticeAndNotInSetupWizard(this))
|
|
||||||
return true;
|
|
||||||
if (null == currentSettings)
|
if (null == currentSettings)
|
||||||
return false;
|
return false;
|
||||||
|
if (ImportantNoticeUtils.shouldShowImportantNotice(this, currentSettings.mInputAttributes))
|
||||||
|
return true;
|
||||||
if (!currentSettings.isSuggestionStripVisible())
|
if (!currentSettings.isSuggestionStripVisible())
|
||||||
return false;
|
return false;
|
||||||
if (currentSettings.isApplicationSpecifiedCompletionsOn())
|
if (currentSettings.isApplicationSpecifiedCompletionsOn())
|
||||||
|
@ -1359,11 +1359,13 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
public void setSuggestedWords(final SuggestedWords suggestedWords, final boolean shouldShow) {
|
public void setSuggestedWords(final SuggestedWords suggestedWords, final boolean shouldShow) {
|
||||||
mInputLogic.setSuggestedWords(suggestedWords);
|
mInputLogic.setSuggestedWords(suggestedWords);
|
||||||
if (mSuggestionStripView != null) {
|
if (mSuggestionStripView != null) {
|
||||||
|
final SettingsValues currentSettings = mSettings.getCurrent();
|
||||||
final boolean showSuggestions;
|
final boolean showSuggestions;
|
||||||
if (SuggestedWords.EMPTY == suggestedWords
|
if (SuggestedWords.EMPTY == suggestedWords
|
||||||
|| suggestedWords.isPunctuationSuggestions()
|
|| suggestedWords.isPunctuationSuggestions()
|
||||||
|| !mSettings.getCurrent().isSuggestionsRequested()) {
|
|| !currentSettings.isSuggestionsRequested()) {
|
||||||
showSuggestions = !mSuggestionStripView.maybeShowImportantNoticeTitle();
|
showSuggestions = !mSuggestionStripView.maybeShowImportantNoticeTitle(
|
||||||
|
currentSettings.mInputAttributes);
|
||||||
} else {
|
} else {
|
||||||
showSuggestions = true;
|
showSuggestions = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,11 +39,13 @@ import com.android.inputmethod.keyboard.MainKeyboardView;
|
||||||
import com.android.inputmethod.keyboard.MoreKeysPanel;
|
import com.android.inputmethod.keyboard.MoreKeysPanel;
|
||||||
import com.android.inputmethod.latin.AudioAndHapticFeedbackManager;
|
import com.android.inputmethod.latin.AudioAndHapticFeedbackManager;
|
||||||
import com.android.inputmethod.latin.Constants;
|
import com.android.inputmethod.latin.Constants;
|
||||||
|
import com.android.inputmethod.latin.InputAttributes;
|
||||||
import com.android.inputmethod.latin.LatinImeLogger;
|
import com.android.inputmethod.latin.LatinImeLogger;
|
||||||
import com.android.inputmethod.latin.R;
|
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.define.ProductionFlag;
|
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.suggestions.MoreSuggestions.MoreSuggestionsListener;
|
||||||
import com.android.inputmethod.latin.utils.CollectionUtils;
|
import com.android.inputmethod.latin.utils.CollectionUtils;
|
||||||
import com.android.inputmethod.latin.utils.ImportantNoticeUtils;
|
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
|
// 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
|
// 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.
|
// the notice. In all cases, it returns true if it was shown, false otherwise.
|
||||||
public boolean maybeShowImportantNoticeTitle() {
|
public boolean maybeShowImportantNoticeTitle(final InputAttributes inputAttributes) {
|
||||||
if (!ImportantNoticeUtils.hasNewImportantNoticeAndNotInSetupWizard(getContext())) {
|
if (!ImportantNoticeUtils.shouldShowImportantNotice(getContext(), inputAttributes)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final int width = getWidth();
|
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) {
|
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.
|
// 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.
|
// 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.provider.Settings.SettingNotFoundException;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
|
import com.android.inputmethod.latin.InputAttributes;
|
||||||
import com.android.inputmethod.latin.R;
|
import com.android.inputmethod.latin.R;
|
||||||
|
|
||||||
public final class ImportantNoticeUtils {
|
public final class ImportantNoticeUtils {
|
||||||
|
@ -62,11 +63,18 @@ public final class ImportantNoticeUtils {
|
||||||
return context.getResources().getInteger(R.integer.config_important_notice_version);
|
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 SharedPreferences prefs = getImportantNoticePreferences(context);
|
||||||
final int lastVersion = prefs.getInt(KEY_IMPORTANT_NOTICE_VERSION, 0);
|
final int lastVersion = prefs.getInt(KEY_IMPORTANT_NOTICE_VERSION, 0);
|
||||||
return getCurrentImportantNoticeVersion(context) > lastVersion
|
return getCurrentImportantNoticeVersion(context) > lastVersion;
|
||||||
&& !isInSystemSetupWizard(context);
|
}
|
||||||
|
|
||||||
|
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) {
|
public static void updateLastImportantNoticeVersion(final Context context) {
|
||||||
|
|
Loading…
Reference in New Issue