Commit f9a12970 authored by Theresa's avatar Theresa Committed by Commit Bot

[EoC] Cleanup find toolbar and ViewShiftingActionBarDelegate

Cleanup more left-over code from Chrome Home:
 - Don't use BottomSheet for ViewShiftingActionBarDelegate so that
   copy-paste action bar pushes down top toolbar instead
 - Revert changes that disabled hiding the keyboard during find in page
   when there is a bottom sheet

BUG=833606,833608,814528

Change-Id: I9f2a1262c5ffba20902e1b438cb6175a48363680
Reviewed-on: https://chromium-review.googlesource.com/1015283Reviewed-by: default avatarMatthew Jones <mdjones@chromium.org>
Reviewed-by: default avatarYusuf Ozuysal <yusufo@chromium.org>
Commit-Queue: Theresa <twellington@chromium.org>
Cr-Commit-Position: refs/heads/master@{#551466}
parent 908b82fe
...@@ -188,12 +188,7 @@ public class ToolbarManager implements ToolbarTabController, UrlFocusChangeListe ...@@ -188,12 +188,7 @@ public class ToolbarManager implements ToolbarTabController, UrlFocusChangeListe
final AppMenuHandler menuHandler, AppMenuPropertiesDelegate appMenuPropertiesDelegate, final AppMenuHandler menuHandler, AppMenuPropertiesDelegate appMenuPropertiesDelegate,
Invalidator invalidator, Callback<Boolean> urlFocusChangedCallback) { Invalidator invalidator, Callback<Boolean> urlFocusChangedCallback) {
mActivity = activity; mActivity = activity;
if (activity.getBottomSheet() != null) { mActionBarDelegate = new ViewShiftingActionBarDelegate(activity, controlContainer);
mActionBarDelegate =
new ViewShiftingActionBarDelegate(activity, activity.getBottomSheet());
} else {
mActionBarDelegate = new ViewShiftingActionBarDelegate(activity, controlContainer);
}
mToolbarModel = new ToolbarModel(activity.getBottomSheet(), mToolbarModel = new ToolbarModel(activity.getBottomSheet(),
activity.supportsModernDesign() && FeatureUtilities.isChromeModernDesignEnabled()); activity.supportsModernDesign() && FeatureUtilities.isChromeModernDesignEnabled());
......
...@@ -86,9 +86,6 @@ public class FindToolbar extends LinearLayout ...@@ -86,9 +86,6 @@ public class FindToolbar extends LinearLayout
/** Whether the search key should trigger a new search. */ /** Whether the search key should trigger a new search. */
private boolean mSearchKeyShouldTriggerSearch; private boolean mSearchKeyShouldTriggerSearch;
/** Whether startFinding() should also hide the keyboard. **/
private boolean mHideKeyboardWhileFinding;
private boolean mActive; private boolean mActive;
private Handler mHandler = new Handler(); private Handler mHandler = new Handler();
...@@ -134,7 +131,7 @@ public class FindToolbar extends LinearLayout ...@@ -134,7 +131,7 @@ public class FindToolbar extends LinearLayout
public boolean onKeyDown(int keyCode, KeyEvent event) { public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_ENTER || keyCode == KeyEvent.KEYCODE_F3 if (keyCode == KeyEvent.KEYCODE_ENTER || keyCode == KeyEvent.KEYCODE_F3
|| (keyCode == KeyEvent.KEYCODE_G && event.isCtrlPressed())) { || (keyCode == KeyEvent.KEYCODE_G && event.isCtrlPressed())) {
mFindToolbar.startFinding(!event.isShiftPressed()); mFindToolbar.hideKeyboardAndStartFinding(!event.isShiftPressed());
return true; return true;
} }
return super.onKeyDown(keyCode, event); return super.onKeyDown(keyCode, event);
...@@ -214,8 +211,6 @@ public class FindToolbar extends LinearLayout ...@@ -214,8 +211,6 @@ public class FindToolbar extends LinearLayout
deactivate(); deactivate();
} }
}; };
mHideKeyboardWhileFinding = true;
} }
@Override @Override
...@@ -292,7 +287,7 @@ public class FindToolbar extends LinearLayout ...@@ -292,7 +287,7 @@ public class FindToolbar extends LinearLayout
// Otherwise just revisit the current active match. // Otherwise just revisit the current active match.
if (mSearchKeyShouldTriggerSearch) { if (mSearchKeyShouldTriggerSearch) {
mSearchKeyShouldTriggerSearch = false; mSearchKeyShouldTriggerSearch = false;
startFinding(true); hideKeyboardAndStartFinding(true);
} else { } else {
UiUtils.hideKeyboard(mFindQuery); UiUtils.hideKeyboard(mFindQuery);
mFindInPageBridge.activateFindInPageResultForAccessibility(); mFindInPageBridge.activateFindInPageResultForAccessibility();
...@@ -308,7 +303,7 @@ public class FindToolbar extends LinearLayout ...@@ -308,7 +303,7 @@ public class FindToolbar extends LinearLayout
mFindPrevButton.setOnClickListener(new OnClickListener() { mFindPrevButton.setOnClickListener(new OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
startFinding(false); hideKeyboardAndStartFinding(false);
} }
}); });
...@@ -316,7 +311,7 @@ public class FindToolbar extends LinearLayout ...@@ -316,7 +311,7 @@ public class FindToolbar extends LinearLayout
mFindNextButton.setOnClickListener(new OnClickListener() { mFindNextButton.setOnClickListener(new OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
startFinding(true); hideKeyboardAndStartFinding(true);
} }
}); });
...@@ -335,13 +330,13 @@ public class FindToolbar extends LinearLayout ...@@ -335,13 +330,13 @@ public class FindToolbar extends LinearLayout
protected void findResultSelected(Rect rect) { protected void findResultSelected(Rect rect) {
} }
private void startFinding(boolean forward) { private void hideKeyboardAndStartFinding(boolean forward) {
if (mFindInPageBridge == null) return; if (mFindInPageBridge == null) return;
final String findQuery = mFindQuery.getText().toString(); final String findQuery = mFindQuery.getText().toString();
if (findQuery.length() == 0) return; if (findQuery.length() == 0) return;
if (mHideKeyboardWhileFinding) UiUtils.hideKeyboard(mFindQuery); UiUtils.hideKeyboard(mFindQuery);
mFindInPageBridge.startFinding(findQuery, forward, false); mFindInPageBridge.startFinding(findQuery, forward, false);
mFindInPageBridge.activateFindInPageResultForAccessibility(); mFindInPageBridge.activateFindInPageResultForAccessibility();
mAccessibilityDidActivateResult = true; mAccessibilityDidActivateResult = true;
...@@ -513,13 +508,6 @@ public class FindToolbar extends LinearLayout ...@@ -513,13 +508,6 @@ public class FindToolbar extends LinearLayout
mWindowAndroid = windowAndroid; mWindowAndroid = windowAndroid;
} }
/**
* By default the keyboard is hidden when the user arrows through results. Calling this method
* will disable keyboard hiding while finding.
*/
public void disableHideKeyboardWhileFinding() {
mHideKeyboardWhileFinding = false;
}
/** /**
* Handles updating any visual elements of the find toolbar based on changes to the tab model. * Handles updating any visual elements of the find toolbar based on changes to the tab model.
* @param isIncognito Whether the current tab model is incognito or not. * @param isIncognito Whether the current tab model is incognito or not.
......
...@@ -69,7 +69,6 @@ public class FindToolbarManager { ...@@ -69,7 +69,6 @@ public class FindToolbarManager {
mFindToolbar = (FindToolbar) ((ViewStub) mActivity.findViewById(stubId)).inflate(); mFindToolbar = (FindToolbar) ((ViewStub) mActivity.findViewById(stubId)).inflate();
mFindToolbar.setTabModelSelector(mActivity.getTabModelSelector()); mFindToolbar.setTabModelSelector(mActivity.getTabModelSelector());
mFindToolbar.setWindowAndroid(mActivity.getWindowAndroid()); mFindToolbar.setWindowAndroid(mActivity.getWindowAndroid());
if (mActivity.getBottomSheet() != null) mFindToolbar.disableHideKeyboardWhileFinding();
mFindToolbar.setActionModeCallbackForTextEdit(mCallback); mFindToolbar.setActionModeCallbackForTextEdit(mCallback);
mFindToolbar.setObserver(new FindToolbarObserver() { mFindToolbar.setObserver(new FindToolbarObserver() {
@Override @Override
......
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