Bug 1357781 - Enable function of edit site settings in SiteIdentity r=sebastian
authorJulian_Chu <walkingice0204@gmail.com>
Thu, 18 May 2017 16:38:01 +0800
changeset 359821 45eb05278a0fc5d7eb94eea2846813763366db5c
parent 359820 7010b10abac2f3919f3e09356d34782899268f2f
child 359822 3bce1540107cb517e3f9f0a19cc08562edfd0076
push id31859
push userihsiao@mozilla.com
push dateMon, 22 May 2017 03:28:26 +0000
treeherdermozilla-central@367944041b55 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssebastian
bugs1357781
milestone55.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 1357781 - Enable function of edit site settings in SiteIdentity r=sebastian The SiteIdentityPopup has a clickable-text to show a dialog to edit permission for the browsring-site. Its visibility is decided by message from EventDispatcher("Permission:CheckResult"). Now register listener by visibility of ActionBar.(or Activity, actually). MozReview-Commit-ID: CUU1gCKqh02
mobile/android/base/java/org/mozilla/gecko/customtabs/ActionBarPresenter.java
mobile/android/base/java/org/mozilla/gecko/customtabs/CustomTabsActivity.java
mobile/android/base/java/org/mozilla/gecko/toolbar/SiteIdentityPopup.java
--- a/mobile/android/base/java/org/mozilla/gecko/customtabs/ActionBarPresenter.java
+++ b/mobile/android/base/java/org/mozilla/gecko/customtabs/ActionBarPresenter.java
@@ -82,16 +82,32 @@ public class ActionBarPresenter {
                 mIdentityPopup.show();
             }
         });
 
         initIndicator();
     }
 
     /**
+     * Called when ActionBar is to start interacting with user. Usually this method is called from
+     * Activity.onResume.
+     */
+    public void onResume() {
+        mIdentityPopup.registerListeners();
+    }
+
+    /**
+     * Called when ActionBar is going to background, but has not yet been killed. Usually this method
+     * is called from Activity.onPause.
+     */
+    public void onPause() {
+        mIdentityPopup.unregisterListeners();
+    }
+
+    /**
      * To display Url in CustomView only and immediately.
      *
      * @param url Url String to display
      */
     public void displayUrlOnly(@NonNull final String url) {
         updateCustomView(null, null, url);
     }
 
--- a/mobile/android/base/java/org/mozilla/gecko/customtabs/CustomTabsActivity.java
+++ b/mobile/android/base/java/org/mozilla/gecko/customtabs/CustomTabsActivity.java
@@ -226,22 +226,24 @@ public class CustomTabsActivity extends 
 
         updateMenuItemForward();
     }
 
     @Override
     public void onResume() {
         super.onResume();
         mLayerView.getDynamicToolbarAnimator().setPinned(true, PinReason.CUSTOM_TAB);
+        actionBarPresenter.onResume();
     }
 
     @Override
     public void onPause() {
         super.onPause();
         mLayerView.getDynamicToolbarAnimator().setPinned(false, PinReason.CUSTOM_TAB);
+        actionBarPresenter.onPause();
     }
 
     // Usually should use onCreateOptionsMenu() to initialize menu items. But GeckoApp overwrite
     // it to support custom menu(Bug 739412). Then the parameter *menu* in this.onCreateOptionsMenu()
     // and this.onPrepareOptionsMenu() are different instances - GeckoApp.onCreatePanelMenu() changed it.
     // CustomTabsActivity only use standard menu in ActionBar, so initialize menu here.
     @Override
     public boolean onCreatePanelMenu(final int id, final Menu menu) {
--- a/mobile/android/base/java/org/mozilla/gecko/toolbar/SiteIdentityPopup.java
+++ b/mobile/android/base/java/org/mozilla/gecko/toolbar/SiteIdentityPopup.java
@@ -92,17 +92,17 @@ public class SiteIdentityPopup extends A
     public SiteIdentityPopup(Context context) {
         super(context);
 
         mResources = mContext.getResources();
 
         mContentButtonClickListener = new ContentNotificationButtonListener();
     }
 
-    void registerListeners() {
+    public void registerListeners() {
         EventDispatcher.getInstance().registerUiThreadListener(this,
                 "Doorhanger:Logins",
                 "Permissions:CheckResult");
     }
 
     @Override
     protected void init() {
         super.init();
@@ -535,17 +535,17 @@ public class SiteIdentityPopup extends A
         if (lastVisibleDoorHanger != null) {
             lastVisibleDoorHanger.hideDivider();
         }
     }
 
     void destroy() {
     }
 
-    void unregisterListeners() {
+    public void unregisterListeners() {
         EventDispatcher.getInstance().unregisterUiThreadListener(this,
                 "Doorhanger:Logins",
                 "Permissions:CheckResult");
     }
 
     @Override
     public void dismiss() {
         super.dismiss();