Bug 1337771 - Let ActionButton works in some apps r=sebastian
authorJulian_Chu <walkingice0204@gmail.com>
Fri, 10 Feb 2017 15:47:56 +0800
changeset 342237 20d4be4ad46d65ac1890ac1eff6445df565a9918
parent 342236 ae2a6bd17689f6e8f536063c3aa691ffb3f64e42
child 342238 fc4ac23cf72b7042ce4df5a6d80287a0119c7290
push id31346
push userkwierso@gmail.com
push dateFri, 10 Feb 2017 22:33:24 +0000
treeherdermozilla-central@7b9d9e4a82a6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssebastian
bugs1337771
milestone54.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1337771 - Let ActionButton works in some apps r=sebastian If the intent from 3rd-party app doesn't have data url, directly call PendingIntent.send() will perform nothing. To use current url as polyfill to fix it. MozReview-Commit-ID: IIP7hGd1cBH
mobile/android/base/java/org/mozilla/gecko/customtabs/CustomTabsActivity.java
--- a/mobile/android/base/java/org/mozilla/gecko/customtabs/CustomTabsActivity.java
+++ b/mobile/android/base/java/org/mozilla/gecko/customtabs/CustomTabsActivity.java
@@ -8,16 +8,17 @@ package org.mozilla.gecko.customtabs;
 import android.app.PendingIntent;
 import android.content.Intent;
 import android.graphics.Bitmap;
 import android.graphics.Color;
 import android.graphics.drawable.BitmapDrawable;
 import android.net.Uri;
 import android.os.Build;
 import android.os.Bundle;
+import android.support.annotation.NonNull;
 import android.support.annotation.VisibleForTesting;
 import android.support.v4.view.MenuItemCompat;
 import android.support.v7.app.ActionBar;
 import android.support.v7.widget.Toolbar;
 import android.text.TextUtils;
 import android.util.Log;
 import android.view.Menu;
 import android.view.MenuItem;
@@ -265,17 +266,25 @@ public class CustomTabsActivity extends 
 
         final Window window = getWindow();
         if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
             window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
             window.setStatusBarColor(ColorUtil.darken(toolbarColor, 0.25));
         }
     }
 
+    private void performPendingIntent(@NonNull PendingIntent pendingIntent) {
+        // bug 1337771: If intent-creator haven't set data url, call send() directly won't work.
+        final Intent additional = new Intent();
+        final Tab tab = Tabs.getInstance().getSelectedTab();
+        additional.setData(Uri.parse(tab.getURL()));
+        try {
+            pendingIntent.send(this, 0, additional);
+        } catch (PendingIntent.CanceledException e) {
+            Log.w(LOGTAG, "Performing a canceled pending intent", e);
+        }
+    }
+
     private void onActionButtonClicked() {
         PendingIntent pendingIntent = IntentUtil.getActionButtonPendingIntent(getIntent());
-        try {
-            pendingIntent.send();
-        } catch (PendingIntent.CanceledException e) {
-            Log.w(LOGTAG, "Action Button clicked, but pending intent was canceled", e);
-        }
+        performPendingIntent(pendingIntent);
     }
 }