Bug 1388724 - 3. Add DoorHangerPopup to custom tabs and PWA; r?droeh draft
authorJim Chen <nchen@mozilla.com>
Thu, 17 Aug 2017 20:21:31 -0400
changeset 648584 38e44a6566c8355c09cfc6b4bca83a71c1a9372f
parent 648583 2f507a10e524f80e6173d75e105b0141b0c73f43
child 648585 78bdc01e103006b2c2d4f28ea6799d03aeb721fb
push id74801
push userbmo:nchen@mozilla.com
push dateFri, 18 Aug 2017 00:24:19 +0000
reviewersdroeh
bugs1388724
milestone57.0a1
Bug 1388724 - 3. Add DoorHangerPopup to custom tabs and PWA; r?droeh Add a DoorHangerPopup to CustomTabsActivity and WebAppActivity, so we can show doorhangers for custom tabs and PWA. MozReview-Commit-ID: L34Ow7yeZWV
mobile/android/base/java/org/mozilla/gecko/customtabs/CustomTabsActivity.java
mobile/android/base/java/org/mozilla/gecko/webapps/WebAppActivity.java
--- a/mobile/android/base/java/org/mozilla/gecko/customtabs/CustomTabsActivity.java
+++ b/mobile/android/base/java/org/mozilla/gecko/customtabs/CustomTabsActivity.java
@@ -26,16 +26,17 @@ import android.text.TextUtils;
 import android.util.Log;
 import android.view.Menu;
 import android.view.MenuInflater;
 import android.view.MenuItem;
 import android.view.View;
 import android.widget.ProgressBar;
 
 import org.mozilla.gecko.ActivityHandlerHelper;
+import org.mozilla.gecko.DoorHangerPopup;
 import org.mozilla.gecko.EventDispatcher;
 import org.mozilla.gecko.GeckoView;
 import org.mozilla.gecko.GeckoViewSettings;
 import org.mozilla.gecko.R;
 import org.mozilla.gecko.SnackbarBuilder;
 import org.mozilla.gecko.Telemetry;
 import org.mozilla.gecko.TelemetryContract;
 import org.mozilla.gecko.menu.GeckoMenu;
@@ -66,16 +67,17 @@ public class CustomTabsActivity extends 
     private ProgressBar mProgressView;
     // A state to indicate whether this activity is finishing with customize animation
     private boolean usingCustomAnimation = false;
 
     private MenuItem menuItemControl;
 
     private GeckoView mGeckoView;
     private PromptService mPromptService;
+    private DoorHangerPopup mDoorHangerPopup;
 
     private boolean mCanGoBack = false;
     private boolean mCanGoForward = false;
     private boolean mCanStop = false;
     private String mCurrentUrl;
     private String mCurrentTitle;
     private SecurityInformation mSecurityInformation = null;
 
@@ -103,30 +105,32 @@ public class CustomTabsActivity extends 
 
         mGeckoView = (GeckoView) findViewById(R.id.gecko_view);
 
         mGeckoView.setNavigationListener(this);
         mGeckoView.setProgressListener(this);
         mGeckoView.setContentListener(this);
 
         mPromptService = new PromptService(this, mGeckoView.getEventDispatcher());
+        mDoorHangerPopup = new DoorHangerPopup(this, mGeckoView.getEventDispatcher());
 
         final GeckoViewSettings settings = mGeckoView.getSettings();
         settings.setBoolean(GeckoViewSettings.USE_MULTIPROCESS, false);
 
         if (intent != null && !TextUtils.isEmpty(intent.getDataString())) {
             mGeckoView.loadUri(intent.getDataString());
         } else {
             Log.w(LOGTAG, "No intend found for custom tab");
             finish();
         }
     }
 
     @Override
     public void onDestroy() {
+        mDoorHangerPopup.destroy();
         mPromptService.destroy();
 
         super.onDestroy();
     }
 
     @Override
     protected void onActivityResult(int requestCode, int resultCode, Intent data) {
         if (!ActivityHandlerHelper.handleActivityResult(requestCode, resultCode, data)) {
--- a/mobile/android/base/java/org/mozilla/gecko/webapps/WebAppActivity.java
+++ b/mobile/android/base/java/org/mozilla/gecko/webapps/WebAppActivity.java
@@ -26,16 +26,17 @@ import android.view.Window;
 import android.view.WindowManager;
 import android.widget.TextView;
 
 import org.json.JSONObject;
 import org.json.JSONException;
 
 import org.mozilla.gecko.ActivityHandlerHelper;
 import org.mozilla.gecko.AppConstants;
+import org.mozilla.gecko.DoorHangerPopup;
 import org.mozilla.gecko.GeckoAppShell;
 import org.mozilla.gecko.GeckoView;
 import org.mozilla.gecko.GeckoViewSettings;
 import org.mozilla.gecko.icons.decoders.FaviconDecoder;
 import org.mozilla.gecko.icons.decoders.LoadFaviconResult;
 import org.mozilla.gecko.prompts.PromptService;
 import org.mozilla.gecko.R;
 import org.mozilla.gecko.util.ColorUtil;
@@ -46,16 +47,17 @@ public class WebAppActivity extends AppC
     private static final String LOGTAG = "WebAppActivity";
 
     public static final String MANIFEST_PATH = "MANIFEST_PATH";
     private static final String SAVED_INTENT = "savedIntent";
 
     private TextView mUrlView;
     private GeckoView mGeckoView;
     private PromptService mPromptService;
+    private DoorHangerPopup mDoorHangerPopup;
 
     private Uri mScope;
 
     @Override
     public void onCreate(Bundle savedInstanceState) {
         if ((getIntent().getFlags() & Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY) != 0 &&
             savedInstanceState != null) {
             // Even though we're a single task activity, Android's task switcher has the
@@ -85,31 +87,34 @@ public class WebAppActivity extends AppC
         final View customView = actionBar.getCustomView();
         mUrlView = (TextView) customView.findViewById(R.id.webapps_action_bar_url);
 
         mGeckoView = (GeckoView) findViewById(R.id.gecko_view);
 
         mGeckoView.setNavigationListener(this);
 
         mPromptService = new PromptService(this, mGeckoView.getEventDispatcher());
+        mDoorHangerPopup = new DoorHangerPopup(this, mGeckoView.getEventDispatcher());
 
         final GeckoViewSettings settings = mGeckoView.getSettings();
         settings.setBoolean(GeckoViewSettings.USE_MULTIPROCESS, false);
 
         final Uri u = getIntent().getData();
         if (u != null) {
             mGeckoView.loadUri(u.toString());
         }
 
         loadManifest(getIntent().getStringExtra(MANIFEST_PATH));
     }
 
     @Override
     public void onDestroy() {
+        mDoorHangerPopup.destroy();
         mPromptService.destroy();
+
         super.onDestroy();
     }
 
     @Override
     public void onActivityResult(int requestCode, int resultCode, Intent data) {
         if (!ActivityHandlerHelper.handleActivityResult(requestCode, resultCode, data)) {
             super.onActivityResult(requestCode, resultCode, data);
         }