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

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

Issue 1591053003: Fix to bottom bar behavior (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed test 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 162e346c6b09620d95174e451f0da0a6c09ad16b..e3a49c7d466e878b56a00d5b1898bb9e0e425c62 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
@@ -4,6 +4,8 @@
package org.chromium.chrome.browser.customtabs;
+import android.app.PendingIntent;
+import android.app.PendingIntent.CanceledException;
import android.content.Intent;
import android.graphics.Bitmap;
import android.net.Uri;
@@ -482,6 +484,7 @@ public class CustomTabActivity extends ChromeActivity {
* Inflates the bottom bar {@link ViewStub} and its shadow, and populates it with items.
*/
private void showBottomBarIfNecessary() {
+ // TODO (yusufo): Find a better place for the layout code here and in CustomButtonParams.
// TODO (ianwen): if button icon is too wide, show them in overflow menu instead. If button
// id is not specified, the overflow sequence should be toolbar -> bottom bar -> menu.
if (!mIntentDataProvider.shouldShowBottomBar()) return;
@@ -501,7 +504,24 @@ public class CustomTabActivity extends ChromeActivity {
List<CustomButtonParams> items = mIntentDataProvider.getCustomButtonsOnBottombar();
for (CustomButtonParams params : items) {
if (params.showOnToolbar()) continue;
- ImageButton button = params.buildBottomBarButton(this, bottomBar);
+ final PendingIntent pendingIntent = params.getPendingIntent();
+ OnClickListener clickListener = null;
+ if (pendingIntent != null) {
+ clickListener = new OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ Intent addedIntent = new Intent();
+ addedIntent.setData(Uri.parse(getActivityTab().getUrl()));
+ try {
+ pendingIntent.send(CustomTabActivity.this, 0, addedIntent, null, null);
+ } catch (CanceledException e) {
+ Log.e(TAG,
+ "CanceledException while sending pending intent in custom tab");
+ }
+ }
+ };
+ }
+ ImageButton button = params.buildBottomBarButton(this, bottomBar, clickListener);
bottomBar.addView(button);
}
}

Powered by Google App Engine
This is Rietveld 408576698