Bug 1332546 - Add SiteIdentityPopup to CustomTabsActivity r=sebastian
authorJulian_Chu <walkingice0204@gmail.com>
Fri, 10 Mar 2017 13:08:19 +0800
changeset 348317 1edd52437ecb2f6b64bcbdbae85b7faa79280a16
parent 348316 c9df402008ca91b48edcb5de1e8173f68c93108b
child 348318 312bdabd35b80e14c52893f72915531e334017a3
push id88187
push userarchaeopteryx@coole-files.de
push dateSat, 18 Mar 2017 15:27:00 +0000
treeherdermozilla-inbound@0b1d3324cffe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssebastian
bugs1332546
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 1332546 - Add SiteIdentityPopup to CustomTabsActivity r=sebastian Similiar to GeckoApp, once user click icon in ActionBar, it displays a popup menu for site identity. MozReview-Commit-ID: LpvhFjx2BSk
mobile/android/base/java/org/mozilla/gecko/customtabs/ActionBarPresenter.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
@@ -22,29 +22,31 @@ import android.view.Window;
 import android.view.WindowManager;
 import android.widget.ImageButton;
 import android.widget.TextView;
 
 import org.mozilla.gecko.R;
 import org.mozilla.gecko.SiteIdentity;
 import org.mozilla.gecko.Tab;
 import org.mozilla.gecko.toolbar.SecurityModeUtil;
+import org.mozilla.gecko.toolbar.SiteIdentityPopup;
 import org.mozilla.gecko.util.ColorUtil;
 
 /**
  * This class is used to maintain appearance of ActionBar of CustomTabsActivity, includes background
  * color, custom-view and so on.
  */
 public class ActionBarPresenter {
 
     @ColorInt
     private static final int DEFAULT_TEXT_PRIMARY_COLOR = 0xFFFFFFFF;
     private static final long CUSTOM_VIEW_UPDATE_DELAY = 1000;
 
     private final ActionBar mActionBar;
+    private final SiteIdentityPopup mIdentityPopup;
     private final ImageButton mIconView;
     private final TextView mTitleView;
     private final TextView mUrlView;
     private final Handler mHandler = new Handler();
 
     private Runnable mUpdateAction;
 
     @ColorInt
@@ -57,16 +59,25 @@ public class ActionBarPresenter {
 
         mActionBar.setCustomView(R.layout.customtabs_action_bar_custom_view);
         final View customView = mActionBar.getCustomView();
         mIconView = (ImageButton) customView.findViewById(R.id.custom_tabs_action_bar_icon);
         mTitleView = (TextView) customView.findViewById(R.id.custom_tabs_action_bar_title);
         mUrlView = (TextView) customView.findViewById(R.id.custom_tabs_action_bar_url);
 
         onThemeChanged(mActionBar.getThemedContext().getTheme());
+
+        mIdentityPopup = new SiteIdentityPopup(mActionBar.getThemedContext());
+        mIdentityPopup.setAnchor(customView);
+        mIconView.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                mIdentityPopup.show();
+            }
+        });
     }
 
     /**
      * To display Url in CustomView only and immediately.
      *
      * @param url Url String to display
      */
     public void displayUrlOnly(@NonNull final String url) {
@@ -126,16 +137,17 @@ public class ActionBarPresenter {
                                   @NonNull String url) {
         // update site-info icon
         if (identity == null) {
             mIconView.setVisibility(View.INVISIBLE);
         } else {
             final SecurityModeUtil.Mode mode = SecurityModeUtil.resolve(identity);
             mIconView.setVisibility(View.VISIBLE);
             mIconView.setImageLevel(mode.ordinal());
+            mIdentityPopup.setSiteIdentity(identity);
 
             if (mode == SecurityModeUtil.Mode.LOCK_SECURE) {
                 // Lock-Secure is special case. Keep its original green color.
                 DrawableCompat.setTintList(mIconView.getDrawable(), null);
             } else {
                 // Icon use same color as TextView.
                 DrawableCompat.setTint(mIconView.getDrawable(), mTextPrimaryColor);
             }
--- a/mobile/android/base/java/org/mozilla/gecko/toolbar/SiteIdentityPopup.java
+++ b/mobile/android/base/java/org/mozilla/gecko/toolbar/SiteIdentityPopup.java
@@ -453,17 +453,17 @@ public class SiteIdentityPopup extends A
         } else {
             config.setButton(mContext.getString(R.string.enable_protection), ButtonType.ENABLE.ordinal(), true);
         }
     }
 
     /*
      * @param identityData An object that holds the current tab's identity data.
      */
-    void setSiteIdentity(SiteIdentity siteIdentity) {
+    public void setSiteIdentity(SiteIdentity siteIdentity) {
         mSiteIdentity = siteIdentity;
     }
 
     @Override
     public void show() {
         if (mSiteIdentity == null) {
             Log.e(LOGTAG, "Can't show site identity popup for undefined state");
             return;