Commit 22ad00a1 authored by Becky Zhou's avatar Becky Zhou Committed by Commit Bot

[EoC] Add alpha animation to menu button

Bug: 831782
Change-Id: I7558d68a41f30120b6c573b9752612215e35b115
Reviewed-on: https://chromium-review.googlesource.com/1031293Reviewed-by: default avatarTheresa <twellington@chromium.org>
Commit-Queue: Becky Zhou <huayinz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#554437}
parent cae49c8c
...@@ -239,6 +239,7 @@ class ContextualSuggestionsMediator ...@@ -239,6 +239,7 @@ class ContextualSuggestionsMediator
mModel.setClusterList(new ClusterList(Collections.emptyList())); mModel.setClusterList(new ClusterList(Collections.emptyList()));
mModel.setCloseButtonOnClickListener(null); mModel.setCloseButtonOnClickListener(null);
mModel.setMenuButtonVisibility(false); mModel.setMenuButtonVisibility(false);
mModel.setMenuButtonAlpha(0f);
mModel.setMenuButtonDelegate(null); mModel.setMenuButtonDelegate(null);
mModel.setDefaultToolbarClickListener(null); mModel.setDefaultToolbarClickListener(null);
mModel.setTitle(null); mModel.setTitle(null);
...@@ -266,6 +267,7 @@ class ContextualSuggestionsMediator ...@@ -266,6 +267,7 @@ class ContextualSuggestionsMediator
clearSuggestions(); clearSuggestions();
}); });
mModel.setMenuButtonVisibility(false); mModel.setMenuButtonVisibility(false);
mModel.setMenuButtonAlpha(0f);
mModel.setMenuButtonDelegate(this); mModel.setMenuButtonDelegate(this);
mModel.setDefaultToolbarClickListener(view -> mCoordinator.expandBottomSheet()); mModel.setDefaultToolbarClickListener(view -> mCoordinator.expandBottomSheet());
mModel.setTitle(title); mModel.setTitle(title);
...@@ -310,6 +312,11 @@ class ContextualSuggestionsMediator ...@@ -310,6 +312,11 @@ class ContextualSuggestionsMediator
public void onSheetClosed(int reason) { public void onSheetClosed(int reason) {
mModel.setMenuButtonVisibility(false); mModel.setMenuButtonVisibility(false);
} }
@Override
public void onTransitionPeekToHalf(float transitionFraction) {
mModel.setMenuButtonAlpha(transitionFraction);
}
}; };
mCoordinator.addBottomSheetObserver(mSheetObserver); mCoordinator.addBottomSheetObserver(mSheetObserver);
......
...@@ -23,6 +23,7 @@ class ContextualSuggestionsModel ...@@ -23,6 +23,7 @@ class ContextualSuggestionsModel
static class PropertyKey { static class PropertyKey {
static final PropertyKey CLOSE_BUTTON_ON_CLICK_LISTENER = new PropertyKey(); static final PropertyKey CLOSE_BUTTON_ON_CLICK_LISTENER = new PropertyKey();
static final PropertyKey MENU_BUTTON_VISIBILITY = new PropertyKey(); static final PropertyKey MENU_BUTTON_VISIBILITY = new PropertyKey();
static final PropertyKey MENU_BUTTON_ALPHA = new PropertyKey();
static final PropertyKey MENU_BUTTON_DELEGATE = new PropertyKey(); static final PropertyKey MENU_BUTTON_DELEGATE = 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();
...@@ -81,6 +82,7 @@ class ContextualSuggestionsModel ...@@ -81,6 +82,7 @@ class ContextualSuggestionsModel
ClusterListObservable mClusterListObservable = new ClusterListObservable(); ClusterListObservable mClusterListObservable = new ClusterListObservable();
private OnClickListener mCloseButtonOnClickListener; private OnClickListener mCloseButtonOnClickListener;
private boolean mMenuButtonVisibility; private boolean mMenuButtonVisibility;
private float mMenuButtonAlpha;
private ListMenuButton.Delegate mMenuButtonDelegate; private ListMenuButton.Delegate mMenuButtonDelegate;
private OnClickListener mDefaultToolbarOnClickListener; private OnClickListener mDefaultToolbarOnClickListener;
private String mTitle; private String mTitle;
...@@ -118,6 +120,17 @@ class ContextualSuggestionsModel ...@@ -118,6 +120,17 @@ class ContextualSuggestionsModel
return mMenuButtonVisibility; return mMenuButtonVisibility;
} }
/** @param alpha The opacity of the menu button. */
void setMenuButtonAlpha(float alpha) {
mMenuButtonAlpha = alpha;
notifyPropertyChanged(PropertyKey.MENU_BUTTON_ALPHA);
}
/** @return The opacity of the menu button. */
float getMenuButtonAlpha() {
return mMenuButtonAlpha;
}
/** @param delegate The delegate for handles actions for the menu. */ /** @param delegate The delegate for handles actions for the menu. */
void setMenuButtonDelegate(ListMenuButton.Delegate delegate) { void setMenuButtonDelegate(ListMenuButton.Delegate delegate) {
mMenuButtonDelegate = delegate; mMenuButtonDelegate = delegate;
......
...@@ -46,6 +46,10 @@ public class ToolbarView extends LinearLayout { ...@@ -46,6 +46,10 @@ public class ToolbarView extends LinearLayout {
mMenuButton.setVisibility(visible ? View.VISIBLE : View.GONE); mMenuButton.setVisibility(visible ? View.VISIBLE : View.GONE);
} }
void setMenuButtonAlpha(float alpha) {
mMenuButton.setAlpha(alpha);
}
void setTitle(String title) { void setTitle(String title) {
mTitle.setText(title); mTitle.setText(title);
} }
......
...@@ -19,6 +19,8 @@ class ToolbarViewBinder ...@@ -19,6 +19,8 @@ class ToolbarViewBinder
view.setCloseButtonOnClickListener(model.getCloseButtonOnClickListener()); view.setCloseButtonOnClickListener(model.getCloseButtonOnClickListener());
} else if (propertyKey == PropertyKey.MENU_BUTTON_VISIBILITY) { } else if (propertyKey == PropertyKey.MENU_BUTTON_VISIBILITY) {
view.setMenuButtonVisibility(model.getMenuButtonVisibility()); view.setMenuButtonVisibility(model.getMenuButtonVisibility());
} else if (propertyKey == PropertyKey.MENU_BUTTON_ALPHA) {
view.setMenuButtonAlpha(model.getMenuButtonAlpha());
} else if (propertyKey == PropertyKey.MENU_BUTTON_DELEGATE) { } else if (propertyKey == PropertyKey.MENU_BUTTON_DELEGATE) {
view.setMenuButtonDelegate(model.getMenuButtonDelegate()); view.setMenuButtonDelegate(model.getMenuButtonDelegate());
} else if (propertyKey == PropertyKey.TITLE) { } else if (propertyKey == PropertyKey.TITLE) {
......
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