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

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

Issue 1557803002: [Custom Tabs] Implement Bottombar (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Simplify APIs 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 dfdb7f1ddd37b2aadd539cedf173b44a3c0713bb..aacb001d44e248c37be56fbc59575639aec06bbd 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
@@ -16,7 +16,9 @@ import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
+import android.view.ViewStub;
import android.view.Window;
+import android.widget.ImageButton;
import org.chromium.base.ApiCompatibilityUtils;
import org.chromium.base.Log;
@@ -46,6 +48,8 @@ import org.chromium.chrome.browser.tabmodel.TabModelSelectorImpl;
import org.chromium.chrome.browser.toolbar.ToolbarControlContainer;
import org.chromium.chrome.browser.util.ColorUtils;
import org.chromium.chrome.browser.util.IntentUtils;
+import org.chromium.chrome.browser.widget.FadingShadow;
+import org.chromium.chrome.browser.widget.FadingShadowView;
import org.chromium.chrome.browser.widget.findinpage.FindToolbarManager;
import org.chromium.components.dom_distiller.core.DomDistillerUrlUtils;
import org.chromium.content_public.browser.LoadUrlParams;
@@ -53,6 +57,8 @@ import org.chromium.content_public.browser.WebContents;
import org.chromium.content_public.common.Referrer;
import org.chromium.ui.base.PageTransition;
+import java.util.List;
+
/**
* The activity for custom tabs. It will be launched on top of a client's task.
*/
@@ -132,13 +138,13 @@ public class CustomTabActivity extends ChromeActivity {
* @param description The new content description for the action button.
* @return Whether the update is successful.
*/
- static boolean updateActionButton(IBinder session, Bitmap bitmap, String description) {
+ static boolean updateActionButton(IBinder session, int id, Bitmap bitmap, String description) {
ThreadUtils.assertOnUiThread();
// Do nothing if there is no activity or the activity does not belong to this session.
if (sActiveContentHandler == null || !sActiveContentHandler.getSession().equals(session)) {
return false;
}
- return sActiveContentHandler.updateActionButton(bitmap, description);
+ return sActiveContentHandler.updateActionButton(id, bitmap, description);
}
@Override
@@ -175,7 +181,7 @@ public class CustomTabActivity extends ChromeActivity {
setTabModelSelector(new TabModelSelectorImpl(this, 0, getWindowAndroid(), false));
getToolbarManager().setCloseButtonDrawable(mIntentDataProvider.getCloseButtonDrawable());
getToolbarManager().setShowTitle(mIntentDataProvider.getTitleVisibilityState()
- == CustomTabIntentDataProvider.SHOW_PAGE_TITLE);
+ == CustomTabsIntent.SHOW_PAGE_TITLE);
int toolbarColor = mIntentDataProvider.getToolbarColor();
getToolbarManager().updatePrimaryColor(toolbarColor);
if (toolbarColor != ApiCompatibilityUtils.getColor(
@@ -187,6 +193,7 @@ public class CustomTabActivity extends ChromeActivity {
// Setting task title and icon to be null will preserve the client app's title and icon.
ApiCompatibilityUtils.setTaskDescription(this, null, null, toolbarColor);
showActionButton();
+ showBottombarIfNecessary();
}
@Override
@@ -238,8 +245,14 @@ public class CustomTabActivity extends ChromeActivity {
}
@Override
- public boolean updateActionButton(Bitmap bitmap, String description) {
- mIntentDataProvider.getActionButtonParams().update(bitmap, description);
+ public boolean updateActionButton(int id, Bitmap bitmap, String description) {
+ List<ActionButtonParams> list = mIntentDataProvider.getAllActionButtons();
+ for (ActionButtonParams params : list) {
+ if (params.getId() == id) {
+ params.update(bitmap, description);
+ }
+ }
+ // TODO(ianwen): support bottombar here.
return showActionButton();
}
};
@@ -436,8 +449,8 @@ public class CustomTabActivity extends ChromeActivity {
* clients.
*/
private boolean showActionButton() {
- if (!mIntentDataProvider.shouldShowActionButton()) return false;
- ActionButtonParams params = mIntentDataProvider.getActionButtonParams();
+ ActionButtonParams params = mIntentDataProvider.getActionButtonOnToolbar();
+ if (params == null) return false;
getToolbarManager().setCustomActionButton(
params.getIcon(getResources()),
params.getDescription(),
@@ -452,6 +465,32 @@ public class CustomTabActivity extends ChromeActivity {
return true;
}
+ /**
+ * Inflates the bottom bar {@link ViewStub} and its shadow, and populates it with items.
+ */
+ private void showBottombarIfNecessary() {
+ if (!mIntentDataProvider.shouldShowBottomBar()) return;
+
+ ViewStub bottombarStub = ((ViewStub) findViewById(R.id.buttombar_stub));
+ bottombarStub.setLayoutResource(R.layout.custom_tabs_bottombar);
+ bottombarStub.inflate();
+
+ // Unlike others, this shadow docks itself at bottom and casts graphics upwards.
+ FadingShadowView shadow = (FadingShadowView) findViewById(R.id.bottombar_shadow);
+ shadow.setVisibility(View.VISIBLE);
+ shadow.init(ApiCompatibilityUtils.getColor(getResources(),
+ R.color.toolbar_shadow_color), FadingShadow.POSITION_BOTTOM);
+
+ ViewGroup bottomBar = (ViewGroup) findViewById(R.id.bottombar);
+ bottomBar.setBackgroundColor(mIntentDataProvider.getToolbarColor());
+ List<ActionButtonParams> items = mIntentDataProvider.getActionButtonsOnBottombar();
+ for (ActionButtonParams params : items) {
+ if (params.showOnToolbar()) continue;
+ ImageButton button = params.toBottomBarButton(this, bottomBar);
+ bottomBar.addView(button);
+ }
+ }
+
@Override
public boolean shouldShowAppMenu() {
return getActivityTab() != null && getToolbarManager().isInitialized();

Powered by Google App Engine
This is Rietveld 408576698