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