Commit f7aa837d authored by Filip Gorski's avatar Filip Gorski Committed by Commit Bot

[Find in page] Incognito Find in page should use incognito keyboard.

Bug: 979043
Change-Id: Ib25a2a3217f2b72b39c459e0cd9f3c1a789ce4bd
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1764608Reviewed-by: default avatarTed Choc <tedchoc@chromium.org>
Commit-Queue: Filip Gorski <fgorski@chromium.org>
Cr-Commit-Position: refs/heads/master@{#690018}
parent cd9d3c7f
......@@ -14,6 +14,7 @@ import android.provider.Settings;
import android.support.annotation.IntDef;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v13.view.inputmethod.EditorInfoCompat;
import android.support.v4.text.BidiFormatter;
import android.text.Editable;
import android.text.InputType;
......@@ -74,11 +75,6 @@ public class UrlBar extends AutocompleteEditText {
int SHARE = 2;
}
// TODO(tedchoc): Replace with EditorInfoCompat#IME_FLAG_NO_PERSONALIZED_LEARNING or
// EditorInfo#IME_FLAG_NO_PERSONALIZED_LEARNING as soon as either is available in
// all build config types.
private static final int IME_FLAG_NO_PERSONALIZED_LEARNING = 0x1000000;
// TextView becomes very slow on long strings, so we limit maximum length
// of what is displayed to the user, see limitDisplayableLength().
private static final int MAX_DISPLAYABLE_LENGTH = 4000;
......@@ -858,7 +854,7 @@ public class UrlBar extends AutocompleteEditText {
public InputConnection onCreateInputConnection(EditorInfo outAttrs) {
InputConnection connection = super.onCreateInputConnection(outAttrs);
if (mUrlBarDelegate == null || !mUrlBarDelegate.allowKeyboardLearning()) {
outAttrs.imeOptions |= IME_FLAG_NO_PERSONALIZED_LEARNING;
outAttrs.imeOptions |= EditorInfoCompat.IME_FLAG_NO_PERSONALIZED_LEARNING;
}
return connection;
}
......
......@@ -14,6 +14,7 @@ import android.os.Handler;
import android.os.Vibrator;
import android.provider.Settings;
import android.support.annotation.IntDef;
import android.support.v13.view.inputmethod.EditorInfoCompat;
import android.support.v4.view.accessibility.AccessibilityEventCompat;
import android.text.Editable;
import android.text.InputType;
......@@ -24,6 +25,8 @@ import android.view.ActionMode;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.View;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputConnection;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.TextView;
......@@ -178,6 +181,15 @@ public class FindToolbar extends LinearLayout {
}
return super.onTextContextMenuItem(id);
}
@Override
public InputConnection onCreateInputConnection(EditorInfo outAttrs) {
InputConnection connection = super.onCreateInputConnection(outAttrs);
if (mFindToolbar.isIncognito()) {
outAttrs.imeOptions |= EditorInfoCompat.IME_FLAG_NO_PERSONALIZED_LEARNING;
}
return connection;
}
}
public FindToolbar(Context context, AttributeSet attrs) {
......@@ -214,7 +226,7 @@ public class FindToolbar extends LinearLayout {
@Override
public void onTabModelSelected(TabModel newModel, TabModel oldModel) {
deactivate();
updateVisualsForTabModel(newModel.isIncognito());
updateVisualsForTabModel(isIncognito());
}
};
......@@ -281,7 +293,7 @@ public class FindToolbar extends LinearLayout {
setPrevNextEnabled(false);
}
if (!mCurrentTab.isIncognito()) {
if (!isIncognito()) {
mLastUserSearch = s.toString();
}
}
......@@ -517,7 +529,7 @@ public class FindToolbar extends LinearLayout {
/** The find toolbar's container must provide access to its TabModel. */
public void setTabModelSelector(TabModelSelector modelSelector) {
mTabModelSelector = modelSelector;
updateVisualsForTabModel(modelSelector != null && modelSelector.isIncognitoSelected());
updateVisualsForTabModel(isIncognito());
}
/**
......@@ -596,7 +608,7 @@ public class FindToolbar extends LinearLayout {
showKeyboard();
// Always show the bar to make the FindToolbar more distinct from the Omnibox.
setResultsBarVisibility(true);
updateVisualsForTabModel(mTabModelSelector.isIncognitoSelected());
updateVisualsForTabModel(isIncognito());
setCurrentState(FindLocationBarState.SHOWN);
}
......@@ -716,7 +728,7 @@ public class FindToolbar extends LinearLayout {
String findText = null;
if (mSettingFindTextProgrammatically) {
findText = mFindInPageBridge.getPreviousFindText();
if (findText.isEmpty() && !mCurrentTab.isIncognito()) {
if (findText.isEmpty() && !isIncognito()) {
findText = mLastUserSearch;
}
mSearchKeyShouldTriggerSearch = true;
......@@ -752,8 +764,7 @@ public class FindToolbar extends LinearLayout {
private void setStatus(String text, boolean failed) {
mFindStatus.setText(text);
mFindStatus.setContentDescription(null);
boolean incognito = mTabModelSelector != null && mTabModelSelector.isIncognitoSelected();
mFindStatus.setTextColor(getStatusColor(failed, incognito));
mFindStatus.setTextColor(getStatusColor(failed, isIncognito()));
}
/**
......@@ -788,4 +799,8 @@ public class FindToolbar extends LinearLayout {
}
mWindowAndroid.getKeyboardDelegate().showKeyboard(mFindQuery);
}
protected boolean isIncognito() {
return mTabModelSelector != null && mTabModelSelector.isIncognitoSelected();
}
}
......@@ -13,6 +13,7 @@ import android.os.Bundle;
import android.os.Handler;
import android.os.ResultReceiver;
import android.os.SystemClock;
import android.support.v13.view.inputmethod.EditorInfoCompat;
import android.text.SpannableString;
import android.text.Spanned;
import android.text.TextUtils;
......@@ -90,7 +91,6 @@ public class ImeAdapterImpl implements ImeAdapter, WindowEventObserver, UserData
private static final float SUGGESTION_HIGHLIGHT_BACKGROUND_TRANSPARENCY = 0.4f;
public static final int COMPOSITION_KEY_CODE = ImeAdapter.COMPOSITION_KEY_CODE;
private static final int IME_FLAG_NO_PERSONALIZED_LEARNING = 0x1000000;
// Color used by AOSP Android for a SuggestionSpan with FLAG_EASY_CORRECT set
private static final int DEFAULT_SUGGESTION_SPAN_COLOR = 0x88C8C8C8;
......@@ -297,10 +297,10 @@ public class ImeAdapterImpl implements ImeAdapter, WindowEventObserver, UserData
// null. This makes sure IME doesn't enter fullscreen mode or open custom UI.
outAttrs.imeOptions = EditorInfo.IME_FLAG_NO_FULLSCREEN | EditorInfo.IME_FLAG_NO_EXTRACT_UI;
// TODO(changwan): Replace with EditorInfoCompat#IME_FLAG_NO_PERSONALIZED_LEARNING or
// EditorInfo#IME_FLAG_NO_PERSONALIZED_LEARNING as soon as either is
// available in all build config types.
if (!allowKeyboardLearning) outAttrs.imeOptions |= IME_FLAG_NO_PERSONALIZED_LEARNING;
if (!allowKeyboardLearning) {
outAttrs.imeOptions |= EditorInfoCompat.IME_FLAG_NO_PERSONALIZED_LEARNING;
}
// Without this line, some third-party IMEs will try to compose text even when
// not on an editable node. Even when we return null here, key events can still go
// through ImeAdapter#dispatchKeyEvent().
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment