Commit 19da8cbf authored by Pedro Amaral's avatar Pedro Amaral Committed by Commit Bot

Making Android View Visibility a boolean

The model properties should be agnostic to the view implementation.
ANDROID_VIEW_VISIBILITY was an int but that was view specific and really
all the mediator needs to interact with is whether or not the
Android View is visible.

Change-Id: I0daa79cc0d5a4a2a1a5c7b2443eee731525baa66
Reviewed-on: https://chromium-review.googlesource.com/1103545
Commit-Queue: Pedro Amaral <amaralp@chromium.org>
Reviewed-by: default avatarTed Choc <tedchoc@chromium.org>
Cr-Commit-Position: refs/heads/master@{#568111}
parent 627fd97a
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
package org.chromium.chrome.browser.toolbar; package org.chromium.chrome.browser.toolbar;
import android.content.res.Resources; import android.content.res.Resources;
import android.view.View;
import android.view.View.OnClickListener; import android.view.View.OnClickListener;
import android.view.View.OnTouchListener; import android.view.View.OnTouchListener;
...@@ -65,9 +64,9 @@ class BottomToolbarMediator implements FullscreenListener, OverviewModeObserver ...@@ -65,9 +64,9 @@ class BottomToolbarMediator implements FullscreenListener, OverviewModeObserver
public void onControlsOffsetChanged(float topOffset, float bottomOffset, boolean needsAnimate) { public void onControlsOffsetChanged(float topOffset, float bottomOffset, boolean needsAnimate) {
mModel.setValue(BottomToolbarModel.Y_OFFSET, (int) bottomOffset); mModel.setValue(BottomToolbarModel.Y_OFFSET, (int) bottomOffset);
if (bottomOffset > 0) { if (bottomOffset > 0) {
mModel.setValue(BottomToolbarModel.ANDROID_VIEW_VISIBILITY, View.INVISIBLE); mModel.setValue(BottomToolbarModel.ANDROID_VIEW_VISIBLE, false);
} else { } else {
mModel.setValue(BottomToolbarModel.ANDROID_VIEW_VISIBILITY, View.VISIBLE); mModel.setValue(BottomToolbarModel.ANDROID_VIEW_VISIBLE, true);
} }
} }
......
...@@ -17,8 +17,8 @@ public class BottomToolbarModel extends PropertyModel { ...@@ -17,8 +17,8 @@ public class BottomToolbarModel extends PropertyModel {
/** The Y offset of the view in px. */ /** The Y offset of the view in px. */
public static final IntPropertyKey Y_OFFSET = new IntPropertyKey(); public static final IntPropertyKey Y_OFFSET = new IntPropertyKey();
/** The visibility of the Android view version of the toolbar. */ /** Whether the Android view version of the toolbar is visible. */
public static final IntPropertyKey ANDROID_VIEW_VISIBILITY = new IntPropertyKey(); public static final BooleanPropertyKey ANDROID_VIEW_VISIBLE = new BooleanPropertyKey();
/** The click listener for the search accelerator. */ /** The click listener for the search accelerator. */
public static final ObjectPropertyKey<OnClickListener> SEARCH_ACCELERATOR_LISTENER = public static final ObjectPropertyKey<OnClickListener> SEARCH_ACCELERATOR_LISTENER =
...@@ -40,7 +40,7 @@ public class BottomToolbarModel extends PropertyModel { ...@@ -40,7 +40,7 @@ public class BottomToolbarModel extends PropertyModel {
/** Default constructor. */ /** Default constructor. */
public BottomToolbarModel() { public BottomToolbarModel() {
super(Y_OFFSET, ANDROID_VIEW_VISIBILITY, SEARCH_ACCELERATOR_LISTENER, HOME_BUTTON_LISTENER, super(Y_OFFSET, ANDROID_VIEW_VISIBLE, SEARCH_ACCELERATOR_LISTENER, HOME_BUTTON_LISTENER,
MENU_BUTTON_LISTENER, LAYOUT_MANAGER, SEARCH_ACCELERATOR_VISIBLE); MENU_BUTTON_LISTENER, LAYOUT_MANAGER, SEARCH_ACCELERATOR_VISIBLE);
} }
} }
...@@ -50,9 +50,10 @@ public class BottomToolbarViewBinder ...@@ -50,9 +50,10 @@ public class BottomToolbarViewBinder
if (BottomToolbarModel.Y_OFFSET == propertyKey) { if (BottomToolbarModel.Y_OFFSET == propertyKey) {
assert view.sceneLayer != null; assert view.sceneLayer != null;
view.sceneLayer.setYOffset(model.getValue(BottomToolbarModel.Y_OFFSET)); view.sceneLayer.setYOffset(model.getValue(BottomToolbarModel.Y_OFFSET));
} else if (BottomToolbarModel.ANDROID_VIEW_VISIBILITY == propertyKey) { } else if (BottomToolbarModel.ANDROID_VIEW_VISIBLE == propertyKey) {
view.toolbarRoot.setVisibility( view.toolbarRoot.setVisibility(model.getValue(BottomToolbarModel.ANDROID_VIEW_VISIBLE)
model.getValue(BottomToolbarModel.ANDROID_VIEW_VISIBILITY)); ? View.VISIBLE
: View.INVISIBLE);
} else if (BottomToolbarModel.SEARCH_ACCELERATOR_LISTENER == propertyKey) { } else if (BottomToolbarModel.SEARCH_ACCELERATOR_LISTENER == propertyKey) {
view.toolbarRoot.findViewById(R.id.search_button) view.toolbarRoot.findViewById(R.id.search_button)
.setOnClickListener( .setOnClickListener(
......
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