Commit 8d642d00 authored by Matthew Jones's avatar Matthew Jones Committed by Commit Bot

Expand EoC when peeking bar is tapped

This change allows the toolbar for EoC to have a default click
listener attached to it. If the close button click listener does not
intercept the tap, the default one will. The new behavior is to expand
the bottom sheet when the toolbar is tapped.

Bug: 827371
Change-Id: I6ffe9388ad989a8db7a8ce19cff1b7c65b24379f
Reviewed-on: https://chromium-review.googlesource.com/1002985
Commit-Queue: Matthew Jones <mdjones@chromium.org>
Reviewed-by: default avatarTheresa <twellington@chromium.org>
Cr-Commit-Position: refs/heads/master@{#549236}
parent 175cbea6
...@@ -132,6 +132,13 @@ public class ContextualSuggestionsCoordinator { ...@@ -132,6 +132,13 @@ public class ContextualSuggestionsCoordinator {
mBottomSheetController.getBottomSheet().removeObserver(observer); mBottomSheetController.getBottomSheet().removeObserver(observer);
} }
/**
* Expand the {@link BottomSheet}.
*/
void expandBottomSheet() {
mBottomSheetController.expandSheet();
}
/** Removes contextual suggestions from the {@link BottomSheet}. */ /** Removes contextual suggestions from the {@link BottomSheet}. */
void removeSuggestions() { void removeSuggestions() {
if (mToolbarCoordinator != null) { if (mToolbarCoordinator != null) {
......
...@@ -192,6 +192,7 @@ class ContextualSuggestionsMediator implements EnabledStateMonitor.Observer, Fet ...@@ -192,6 +192,7 @@ class ContextualSuggestionsMediator implements EnabledStateMonitor.Observer, Fet
mHasRecordedPeekEventForTab = false; mHasRecordedPeekEventForTab = false;
mModel.setClusterList(new ClusterList(Collections.emptyList())); mModel.setClusterList(new ClusterList(Collections.emptyList()));
mModel.setCloseButtonOnClickListener(null); mModel.setCloseButtonOnClickListener(null);
mModel.setDefaultToolbarClickListener(null);
mModel.setTitle(null); mModel.setTitle(null);
mCoordinator.removeSuggestions(); mCoordinator.removeSuggestions();
mCurrentRequestUrl = ""; mCurrentRequestUrl = "";
...@@ -214,6 +215,7 @@ class ContextualSuggestionsMediator implements EnabledStateMonitor.Observer, Fet ...@@ -214,6 +215,7 @@ class ContextualSuggestionsMediator implements EnabledStateMonitor.Observer, Fet
clearSuggestions(); clearSuggestions();
}); });
mModel.setDefaultToolbarClickListener(view -> mCoordinator.expandBottomSheet());
mModel.setTitle(title); mModel.setTitle(title);
mCoordinator.preloadContentInSheet(); mCoordinator.preloadContentInSheet();
} }
......
...@@ -23,6 +23,7 @@ class ContextualSuggestionsModel ...@@ -23,6 +23,7 @@ class ContextualSuggestionsModel
static final PropertyKey CLOSE_BUTTON_ON_CLICK_LISTENER = new PropertyKey(); static final PropertyKey CLOSE_BUTTON_ON_CLICK_LISTENER = new PropertyKey();
static final PropertyKey TITLE = new PropertyKey(); static final PropertyKey TITLE = new PropertyKey();
static final PropertyKey TOOLBAR_SHADOW_VISIBILITY = new PropertyKey(); static final PropertyKey TOOLBAR_SHADOW_VISIBILITY = new PropertyKey();
static final PropertyKey DEFAULT_TOOLBAR_ON_CLICK_LISTENER = new PropertyKey();
private PropertyKey() {} private PropertyKey() {}
} }
...@@ -76,6 +77,7 @@ class ContextualSuggestionsModel ...@@ -76,6 +77,7 @@ class ContextualSuggestionsModel
ClusterListObservable mClusterListObservable = new ClusterListObservable(); ClusterListObservable mClusterListObservable = new ClusterListObservable();
private OnClickListener mCloseButtonOnClickListener; private OnClickListener mCloseButtonOnClickListener;
private OnClickListener mDefaultToolbarOnClickListener;
private String mTitle; private String mTitle;
private boolean mToolbarShadowVisibility; private boolean mToolbarShadowVisibility;
...@@ -128,4 +130,19 @@ class ContextualSuggestionsModel ...@@ -128,4 +130,19 @@ class ContextualSuggestionsModel
boolean getToolbarShadowVisibility() { boolean getToolbarShadowVisibility() {
return mToolbarShadowVisibility; return mToolbarShadowVisibility;
} }
/**
* @param listener The default toolbar {@link OnClickListener}.
*/
void setDefaultToolbarClickListener(OnClickListener listener) {
mDefaultToolbarOnClickListener = listener;
notifyPropertyChanged(PropertyKey.DEFAULT_TOOLBAR_ON_CLICK_LISTENER);
}
/**
* @return The default toolbar {@link OnClickListener}.
*/
OnClickListener getDefaultToolbarClickListener() {
return mDefaultToolbarOnClickListener;
}
} }
...@@ -43,6 +43,8 @@ class ToolbarCoordinator { ...@@ -43,6 +43,8 @@ class ToolbarCoordinator {
// needs to be bound on creation. // needs to be bound on creation.
mModelChangeProcessor.onPropertyChanged(mModel, PropertyKey.CLOSE_BUTTON_ON_CLICK_LISTENER); mModelChangeProcessor.onPropertyChanged(mModel, PropertyKey.CLOSE_BUTTON_ON_CLICK_LISTENER);
mModelChangeProcessor.onPropertyChanged(mModel, PropertyKey.TITLE); mModelChangeProcessor.onPropertyChanged(mModel, PropertyKey.TITLE);
mModelChangeProcessor.onPropertyChanged(
mModel, PropertyKey.DEFAULT_TOOLBAR_ON_CLICK_LISTENER);
} }
/** @return The content {@link View}. */ /** @return The content {@link View}. */
......
...@@ -21,6 +21,8 @@ class ToolbarViewBinder ...@@ -21,6 +21,8 @@ class ToolbarViewBinder
view.setTitle(model.getTitle()); view.setTitle(model.getTitle());
} else if (propertyKey == PropertyKey.TOOLBAR_SHADOW_VISIBILITY) { } else if (propertyKey == PropertyKey.TOOLBAR_SHADOW_VISIBILITY) {
view.setShadowVisibility(model.getToolbarShadowVisibility()); view.setShadowVisibility(model.getToolbarShadowVisibility());
} else if (propertyKey == PropertyKey.DEFAULT_TOOLBAR_ON_CLICK_LISTENER) {
view.setOnClickListener(model.getDefaultToolbarClickListener());
} else { } else {
assert false : "Unhandled property detected."; assert false : "Unhandled property detected.";
} }
......
...@@ -297,6 +297,14 @@ public class BottomSheetController implements ApplicationStatus.ActivityStateLis ...@@ -297,6 +297,14 @@ public class BottomSheetController implements ApplicationStatus.ActivityStateLis
} }
} }
/**
* Expand the {@link BottomSheet}. If there is no content in the sheet, this is a noop.
*/
public void expandSheet() {
if (mBottomSheet.getCurrentSheetContent() == null) return;
mBottomSheet.setSheetState(BottomSheet.SHEET_STATE_HALF, true);
}
@Override @Override
public void onActivityStateChange(Activity activity, int newState) { public void onActivityStateChange(Activity activity, int newState) {
if (newState == ActivityState.STARTED) { if (newState == ActivityState.STARTED) {
......
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