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
--- 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();