Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(67)

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/ChromeActivity.java

Issue 1505913003: Add update menu item and app menu icon badge (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rearrange field_trial.. again to facilitate command line testing Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/android/java/src/org/chromium/chrome/browser/ChromeActivity.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/ChromeActivity.java b/chrome/android/java/src/org/chromium/chrome/browser/ChromeActivity.java
index ebeaa204310acaa03315acf923299d2d42d859a5..b29f2dc4611996a8a4defa1a088f566ccc53fa3c 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/ChromeActivity.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/ChromeActivity.java
@@ -94,6 +94,7 @@ import org.chromium.chrome.browser.net.spdyproxy.DataReductionProxySettings;
import org.chromium.chrome.browser.nfc.BeamController;
import org.chromium.chrome.browser.nfc.BeamProvider;
import org.chromium.chrome.browser.offlinepages.OfflinePageUtils;
+import org.chromium.chrome.browser.omaha.UpdateMenuItemHelper;
import org.chromium.chrome.browser.pageinfo.WebsiteSettingsPopup;
import org.chromium.chrome.browser.partnercustomizations.PartnerBrowserCustomizations;
import org.chromium.chrome.browser.preferences.ChromePreferenceManager;
@@ -373,6 +374,11 @@ public abstract class ChromeActivity extends AsyncInitializationActivity
public void onMenuVisibilityChanged(boolean isVisible) {
if (!isVisible) {
mAppMenuPropertiesDelegate.onMenuDismissed();
+ MenuItem updateMenuItem = mAppMenuHandler.getAppMenu().getMenu().findItem(
+ R.id.update_menu_id);
+ if (updateMenuItem != null && updateMenuItem.isVisible()) {
+ UpdateMenuItemHelper.getInstance().onMenuDismissed();
+ }
}
}
});
@@ -554,6 +560,7 @@ public abstract class ChromeActivity extends AsyncInitializationActivity
@Override
public void onStartWithNative() {
super.onStartWithNative();
+ UpdateMenuItemHelper.getInstance().onStart();
getChromeApplication().onStartWithNative();
FeatureUtilities.setDocumentModeEnabled(FeatureUtilities.isDocumentMode(this));
WarmupManager.getInstance().clearWebContentsIfNecessary();
@@ -693,6 +700,7 @@ public abstract class ChromeActivity extends AsyncInitializationActivity
});
getChromeApplication().getUpdateInfoBarHelper().checkForUpdateOnBackgroundThread(this);
+ UpdateMenuItemHelper.getInstance().checkForUpdateOnBackgroundThread(this);
removeSnapshotDatabase();
if (mToolbarManager != null) {
@@ -1364,6 +1372,19 @@ public abstract class ChromeActivity extends AsyncInitializationActivity
}
/**
+ * Callback after UpdateMenuItemHelper#checkForUpdateOnBackgroundThread is complete.
+ * @param updateAvailable Whether an update is available.
+ */
+ public void onCheckForUpdate(boolean updateAvailable) {
+ if (UpdateMenuItemHelper.getInstance().shouldShowToolbarBadge(this)) {
+ mToolbarManager.getToolbar().showAppMenuUpdateBadge();
+ mCompositorViewHolder.requestRender();
+ } else {
+ mToolbarManager.getToolbar().removeAppMenuUpdateBadge();
+ }
+ }
+
+ /**
* Handles menu item selection and keyboard shortcuts.
*
* @param id The ID of the selected menu item (defined in main_menu.xml) or
@@ -1379,6 +1400,11 @@ public abstract class ChromeActivity extends AsyncInitializationActivity
showAppMenuForKeyboardEvent();
}
+ if (id == R.id.update_menu_id) {
+ UpdateMenuItemHelper.getInstance().onMenuItemClicked(this);
+ return true;
+ }
+
// All the code below assumes currentTab is not null, so return early if it is null.
final Tab currentTab = getActivityTab();
if (currentTab == null) {
« no previous file with comments | « chrome/android/java/res/values/dimens.xml ('k') | chrome/android/java/src/org/chromium/chrome/browser/ChromeSwitches.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698