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

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

Issue 1568813002: Let clients update icons for buttons on bottombar through service (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bottom_bar
Patch Set: tag->id Created 4 years, 11 months 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/customtabs/CustomTabActivity.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/customtabs/CustomTabActivity.java b/chrome/android/java/src/org/chromium/chrome/browser/customtabs/CustomTabActivity.java
index 92a1e00b886c454c480a911c9771a0e0ef1df837..eb650d2a30a283e88d7e8fe9f0c7669caeec29ec 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/customtabs/CustomTabActivity.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/customtabs/CustomTabActivity.java
@@ -246,14 +246,19 @@ public class CustomTabActivity extends ChromeActivity {
@Override
public boolean updateCustomButton(int id, Bitmap bitmap, String description) {
- List<CustomButtonParams> list = mIntentDataProvider.getAllCustomButtons();
- for (CustomButtonParams params : list) {
- if (params.getId() == id) {
- params.update(bitmap, description);
+ CustomButtonParams params = mIntentDataProvider.getButtonParamsForId(id);
+ if (params == null) return false;
+
+ params.update(bitmap, description);
+ if (params.showOnToolbar()) {
+ if (!CustomButtonParams.doesIconFitToolbar(CustomTabActivity.this, bitmap)) {
+ return false;
}
+ showCustomButtonOnToolbar();
+ } else {
+ updateBottomBarButton(params);
}
- // TODO(ianwen): support bottom bar here.
- return showCustomButtonOnToolbar();
+ return true;
}
};
DataUseTabUIManager.onCustomTabInitialNavigation(mainTab,
@@ -447,9 +452,9 @@ public class CustomTabActivity extends ChromeActivity {
/**
* Configures the custom button on toolbar. Does nothing if invalid data is provided by clients.
*/
- private boolean showCustomButtonOnToolbar() {
+ private void showCustomButtonOnToolbar() {
CustomButtonParams params = mIntentDataProvider.getCustomButtonOnToolbar();
- if (params == null) return false;
+ if (params == null) return;
getToolbarManager().setCustomActionButton(
params.getIcon(getResources()),
params.getDescription(),
@@ -461,7 +466,16 @@ public class CustomTabActivity extends ChromeActivity {
RecordUserAction.record("CustomTabsCustomActionButtonClick");
}
});
- return true;
+ }
+
+ /**
+ * Updates the button on the bottom bar that corresponds to the given {@link CustomButtonParams}
+ */
+ private void updateBottomBarButton(CustomButtonParams params) {
+ ViewGroup bottomBar = (ViewGroup) findViewById(R.id.bottombar);
+ ImageButton button = (ImageButton) bottomBar.findViewById(params.getId());
+ button.setContentDescription(params.getDescription());
+ button.setImageDrawable(params.getIcon(getResources()));
}
/**

Powered by Google App Engine
This is Rietveld 408576698