Bug 1357781 - Enable function of edit site settings in SiteIdentity draft
authorJulian_Chu <walkingice0204@gmail.com>
Thu, 18 May 2017 16:38:01 +0800
changeset 580260 f7c8645affcd377f12b04fc4780bc88fda5b926e
parent 580040 baf05f61bc14fdf45511bc1165ce76daa08c5c0f
child 629221 7f1d13c2843e572ad451f21048b3087ba3842c61
push id59485
push userbmo:walkingice0204@gmail.com
push dateThu, 18 May 2017 09:00:39 +0000
bugs1357781
milestone55.0a1
Bug 1357781 - Enable function of edit site settings in SiteIdentity 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
@@ -79,16 +79,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
@@ -234,22 +234,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();