Commit 10eff100 authored by Pedro Amaral's avatar Pedro Amaral Committed by Commit Bot

Adding upload badge to bottom toolbar

Bug: 852116
Change-Id: I558bbb8cbb2cfc614d6953ec2778e9802de26430
Reviewed-on: https://chromium-review.googlesource.com/1094325
Commit-Queue: Pedro Amaral <amaralp@chromium.org>
Reviewed-by: default avatarTed Choc <tedchoc@chromium.org>
Reviewed-by: default avatarMatthew Jones <mdjones@chromium.org>
Cr-Commit-Position: refs/heads/master@{#568176}
parent 6b67a403
......@@ -74,13 +74,7 @@
android:layout_height="1dp"
android:layout_weight="1" />
<org.chromium.chrome.browser.widget.TintedImageButton
android:id="@+id/menu_button"
style="@style/ToolbarMenuButtonPhone"
android:src="@drawable/ic_more_vert_black_24dp"
android:layout_gravity="center"
android:contentDescription="@string/accessibility_toolbar_btn_menu"
app:chrometint="@color/dark_mode_tint" />
<include layout="@layout/menu_button"/>
<Space
android:layout_width="0dp"
......
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2018 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file. -->
<merge
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/menu_button_wrapper">
<org.chromium.chrome.browser.widget.TintedImageButton
android:id="@+id/menu_button"
style="@style/ToolbarMenuButtonPhone"
android:src="@drawable/ic_more_vert_black_24dp"
android:contentDescription="@string/accessibility_toolbar_btn_menu"
android:layout_gravity="center"
app:chrometint="@color/dark_mode_tint" />
<ImageView
android:id="@+id/menu_badge"
style="@style/ToolbarMenuButtonPhone"
android:src="@drawable/badge_update_dark"
android:contentDescription="@null"
android:importantForAccessibility="no"
android:layout_gravity="center"
android:visibility="invisible" />
</FrameLayout>
</merge>
......@@ -59,26 +59,8 @@
android:layout_gravity="top"
android:contentDescription="@string/accessibility_toolbar_btn_tabswitcher_toggle_default" />
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/menu_button_wrapper">
<include layout="@layout/menu_button"/>
<org.chromium.chrome.browser.widget.TintedImageButton
android:id="@+id/menu_button"
style="@style/ToolbarMenuButtonPhone"
android:src="@drawable/ic_more_vert_black_24dp"
android:contentDescription="@string/accessibility_toolbar_btn_menu"
app:chrometint="@color/dark_mode_tint" />
<ImageView
android:id="@+id/menu_badge"
style="@style/ToolbarMenuButtonPhone"
android:src="@drawable/badge_update_dark"
android:contentDescription="@null"
android:importantForAccessibility="no"
android:visibility="invisible" />
</FrameLayout>
</LinearLayout>
</merge>
......@@ -581,7 +581,7 @@ public abstract class ChromeActivity extends AsyncInitializationActivity
if (isVisible && !isInOverviewMode()) {
// The app menu badge should be removed the first time the menu is opened.
if (mToolbarManager.getToolbar().isShowingAppMenuUpdateBadge()) {
mToolbarManager.getToolbar().removeAppMenuUpdateBadge(true);
mToolbarManager.removeAppMenuUpdateBadge(true);
mCompositorViewHolder.requestRender();
}
}
......@@ -2039,10 +2039,10 @@ public abstract class ChromeActivity extends AsyncInitializationActivity
*/
public void onCheckForUpdate(boolean updateAvailable) {
if (UpdateMenuItemHelper.getInstance().shouldShowToolbarBadge(this)) {
mToolbarManager.getToolbar().showAppMenuUpdateBadge();
mToolbarManager.showAppMenuUpdateBadge();
mCompositorViewHolder.requestRender();
} else {
mToolbarManager.getToolbar().removeAppMenuUpdateBadge(false);
mToolbarManager.removeAppMenuUpdateBadge(false);
}
}
......
......@@ -104,6 +104,27 @@ public class BottomToolbarController {
mResourceId, mViewResourceAdapter);
}
/**
* Show the update badge over the bottom toolbar's app menu.
*/
public void showAppMenuUpdateBadge() {
mMediator.setUpdateBadgeVisibility(true);
}
/**
* Remove the update badge.
*/
public void removeAppMenuUpdateBadge() {
mMediator.setUpdateBadgeVisibility(false);
}
/**
* @return Whether the update badge is showing.
*/
public boolean isShowingAppMenuUpdateBadge() {
return mMediator.isShowingAppMenuUpdateBadge();
}
/**
* Clean up any state when the bottom toolbar is destroyed.
*/
......
......@@ -107,4 +107,12 @@ class BottomToolbarMediator implements FullscreenListener, OverviewModeObserver
mOverviewModeBehavior = overviewModeBehavior;
mOverviewModeBehavior.addOverviewModeObserver(this);
}
public void setUpdateBadgeVisibility(boolean visible) {
mModel.setValue(BottomToolbarModel.UPDATE_BADGE_VISIBLE, visible);
}
public boolean isShowingAppMenuUpdateBadge() {
return mModel.getValue(BottomToolbarModel.UPDATE_BADGE_VISIBLE);
}
}
......@@ -38,9 +38,13 @@ public class BottomToolbarModel extends PropertyModel {
/** Whether or not the search accelerator is visible. */
public static final BooleanPropertyKey SEARCH_ACCELERATOR_VISIBLE = new BooleanPropertyKey();
/** Whether or not the update badge is visible. */
public static final BooleanPropertyKey UPDATE_BADGE_VISIBLE = new BooleanPropertyKey();
/** Default constructor. */
public BottomToolbarModel() {
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,
UPDATE_BADGE_VISIBLE);
}
}
......@@ -75,6 +75,11 @@ public class BottomToolbarViewBinder
.setVisibility(model.getValue(BottomToolbarModel.SEARCH_ACCELERATOR_VISIBLE)
? View.VISIBLE
: View.INVISIBLE);
} else if (BottomToolbarModel.UPDATE_BADGE_VISIBLE == propertyKey) {
view.toolbarRoot.findViewById(R.id.menu_badge)
.setVisibility(model.getValue(BottomToolbarModel.UPDATE_BADGE_VISIBLE)
? View.VISIBLE
: View.GONE);
} else {
assert false : "Unhandled property detected in BottomToolbarViewBinder!";
}
......
......@@ -721,6 +721,40 @@ public class ToolbarManager implements ToolbarTabController, UrlFocusChangeListe
mInitializedWithNative = true;
}
/**
* Show the update badge in both the top and bottom toolbar.
* TODO(amaralp): Only the top or bottom menu should be visible.
*/
public void showAppMenuUpdateBadge() {
mToolbar.showAppMenuUpdateBadge();
if (mBottomToolbarController != null) {
mBottomToolbarController.showAppMenuUpdateBadge();
}
}
/**
* Remove the update badge in both the top and bottom toolbar.
* TODO(amaralp): Only the top or bottom menu should be visible.
*/
public void removeAppMenuUpdateBadge(boolean animate) {
mToolbar.removeAppMenuUpdateBadge(animate);
if (mBottomToolbarController != null) {
mBottomToolbarController.removeAppMenuUpdateBadge();
}
}
/**
* @return Whether the badge is showing (either in the top or bottom toolbar).
* TODO(amaralp): Only the top or bottom menu should be visible.
*/
public boolean isShowingAppMenuUpdateBadge() {
if (mBottomToolbarController != null
&& mBottomToolbarController.isShowingAppMenuUpdateBadge()) {
return true;
}
return mToolbar.isShowingAppMenuUpdateBadge();
}
/**
* @return The bookmarks bridge.
*/
......
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