Bug 1377294 - ToolbarDisplay layout color span supports Pirvate mode r=jwu
authorJulian_Chu <walkingice0204@gmail.com>
Thu, 22 Jun 2017 14:12:39 +0800
changeset 604298 8122909722c4887a54150902dbfc162335e69a55
parent 604297 3de22a3d12a97fa86b29ee3c5732f155ff53a363
child 604299 e3c44cc06506d23affe0e5e139fce87a73a8d65d
push id67025
push userbmo:emilio+bugs@crisal.io
push dateWed, 05 Jul 2017 18:45:23 +0000
reviewersjwu
bugs1377294
milestone56.0a1
Bug 1377294 - ToolbarDisplay layout color span supports Pirvate mode r=jwu In ToolbarDisplayLayout we use color span for Title, Domain...etc. In Photon-flavor we use use different color in priavte mode. In Australis-flavor, normal-mode and private-mode refers to same color, so user should not aware anything different. MozReview-Commit-ID: 30cGivl9oOz
mobile/android/app/src/australis/res/values/colors.xml
mobile/android/app/src/photon/res/values/colors.xml
mobile/android/base/java/org/mozilla/gecko/toolbar/ToolbarDisplayLayout.java
--- a/mobile/android/app/src/australis/res/values/colors.xml
+++ b/mobile/android/app/src/australis/res/values/colors.xml
@@ -103,16 +103,19 @@
   <color name="url_bar_text_highlight_pb">#FFD06BFF</color>
   <color name="tab_row_pressed">#4D000000</color>
 
   <color name="url_bar_urltext">#AFB1B3</color>
   <color name="url_bar_urltext_private">#777777</color>
   <color name="url_bar_domaintext">#363B40</color>
   <color name="url_bar_domaintext_private">#FFFFFF</color>
   <color name="url_bar_blockedtext">#b14646</color>
+  <color name="url_bar_blockedtext_private">@color/url_bar_blockedtext</color>
+  <color name="url_bar_certificate_owner">@color/affirmative_green</color>
+  <color name="url_bar_certificate_owner_private">@color/affirmative_green</color>
   <color name="url_bar_shadow">#12000000</color>
 
   <color name="panel_image_item_background">#D1D9E1</color>
   <color name="panel_icon_item_title_background">#32000000</color>
   <color name="panel_tab_text_normal">#FFBFBFBF</color>
 
   <!-- Remote tabs setup -->
   <color name="remote_tabs_setup_button_background_hit">#D95300</color>
--- a/mobile/android/app/src/photon/res/values/colors.xml
+++ b/mobile/android/app/src/photon/res/values/colors.xml
@@ -184,17 +184,22 @@
     <color name="validation_message_text">#ffffff</color>
     <color name="url_bar_text_highlight_pb">#FFD06BFF</color>
     <color name="tab_row_pressed">#4D000000</color>
 
     <color name="url_bar_urltext">#AFB1B3</color>
     <color name="url_bar_urltext_private">#777777</color>
     <color name="url_bar_domaintext">#363B40</color>
     <color name="url_bar_domaintext_private">#FFFFFF</color>
-    <color name="url_bar_blockedtext">#b14646</color>
+    <color name="url_bar_blockedtext">@color/photon_url_bar_blocked</color>
+    <color name="url_bar_blockedtext_private">@color/photon_url_bar_blocked_private</color>
+    <color name="url_bar_certificate_owner">@color/photon_url_bar_certificate_owner</color>
+    <color name="url_bar_certificate_owner_private">
+        @color/photon_url_bar_certificate_owner_private
+    </color>
     <color name="url_bar_shadow">#12000000</color>
 
     <color name="panel_image_item_background">#D1D9E1</color>
     <color name="panel_icon_item_title_background">#32000000</color>
     <color name="panel_tab_text_normal">#FFBFBFBF</color>
 
     <!-- Remote tabs setup -->
     <color name="remote_tabs_setup_button_background_hit">#D95300</color>
--- a/mobile/android/base/java/org/mozilla/gecko/toolbar/ToolbarDisplayLayout.java
+++ b/mobile/android/base/java/org/mozilla/gecko/toolbar/ToolbarDisplayLayout.java
@@ -125,37 +125,41 @@ public class ToolbarDisplayLayout extend
     private static final int LEVEL_SHIELD_ENABLED = 5;
     private static final int LEVEL_SHIELD_DISABLED = 6;
     // Icon used for about:home
     private static final int LEVEL_SEARCH_ICON = 999;
 
     private final ForegroundColorSpan mUrlColorSpan;
     private final ForegroundColorSpan mPrivateUrlColorSpan;
     private final ForegroundColorSpan mBlockedColorSpan;
+    private final ForegroundColorSpan mPrivateBlockedColorSpan;
     private final ForegroundColorSpan mDomainColorSpan;
     private final ForegroundColorSpan mPrivateDomainColorSpan;
     private final ForegroundColorSpan mCertificateOwnerColorSpan;
+    private final ForegroundColorSpan mPrivateCertificateOwnerColorSpan;
 
     public ToolbarDisplayLayout(Context context, AttributeSet attrs) {
         super(context, attrs);
         setOrientation(HORIZONTAL);
 
         mActivity = (BrowserApp) context;
 
         LayoutInflater.from(context).inflate(R.layout.toolbar_display_layout, this);
 
         mTitle = (ThemedTextView) findViewById(R.id.url_bar_title);
         mTitlePadding = mTitle.getPaddingRight();
 
         mUrlColorSpan = new ForegroundColorSpan(ContextCompat.getColor(context, R.color.url_bar_urltext));
         mPrivateUrlColorSpan = new ForegroundColorSpan(ContextCompat.getColor(context, R.color.url_bar_urltext_private));
         mBlockedColorSpan = new ForegroundColorSpan(ContextCompat.getColor(context, R.color.url_bar_blockedtext));
+        mPrivateBlockedColorSpan = new ForegroundColorSpan(ContextCompat.getColor(context, R.color.url_bar_blockedtext_private));
         mDomainColorSpan = new ForegroundColorSpan(ContextCompat.getColor(context, R.color.url_bar_domaintext));
         mPrivateDomainColorSpan = new ForegroundColorSpan(ContextCompat.getColor(context, R.color.url_bar_domaintext_private));
-        mCertificateOwnerColorSpan = new ForegroundColorSpan(ContextCompat.getColor(context, R.color.affirmative_green));
+        mCertificateOwnerColorSpan = new ForegroundColorSpan(ContextCompat.getColor(context, R.color.url_bar_certificate_owner));
+        mPrivateCertificateOwnerColorSpan = new ForegroundColorSpan(ContextCompat.getColor(context, R.color.url_bar_certificate_owner_private));
 
         mSiteSecurity = (ThemedImageButton) findViewById(R.id.site_security);
 
         mSiteIdentityPopup = new SiteIdentityPopup(mActivity);
         mSiteIdentityPopup.setAnchor(this);
         mSiteIdentityPopup.setOnVisibilityChangeListener(mActivity);
 
         mStop = (ImageButton) findViewById(R.id.stop);
@@ -280,17 +284,20 @@ public class ToolbarDisplayLayout extend
             return;
         }
 
         // Show the about:blocked page title in red, regardless of prefs
         if (tab.getErrorType() == Tab.ErrorType.BLOCKED) {
             final String title = tab.getDisplayTitle();
 
             final SpannableStringBuilder builder = new SpannableStringBuilder(title);
-            builder.setSpan(mBlockedColorSpan, 0, title.length(), Spannable.SPAN_INCLUSIVE_INCLUSIVE);
+            final ForegroundColorSpan fgColorSpan = tab.isPrivate()
+                    ? mPrivateBlockedColorSpan
+                    : mBlockedColorSpan;
+            builder.setSpan(fgColorSpan, 0, title.length(), Spannable.SPAN_INCLUSIVE_INCLUSIVE);
 
             setTitle(builder);
             setContentDescription(null);
             return;
         }
 
         final String baseDomain = tab.getBaseDomain();
 
@@ -310,38 +317,41 @@ public class ToolbarDisplayLayout extend
         // This value is not visible to screen readers but we rely on it when running UI tests. Screen
         // readers will instead focus BrowserToolbar and read the "base domain" from there. UI tests
         // will read the content description to obtain the full URL for performing assertions.
         setContentDescription(strippedURL);
 
         final SiteIdentity siteIdentity = tab.getSiteIdentity();
         if (siteIdentity.hasOwner() && SwitchBoard.isInExperiment(mActivity, Experiments.URLBAR_SHOW_EV_CERT_OWNER)) {
             // Show Owner of EV certificate as title
-            updateTitleFromSiteIdentity(siteIdentity);
+            updateTitleFromSiteIdentity(siteIdentity, tab.isPrivate());
         } else if (isHttpOrHttps && !HardwareUtils.isTablet() && !TextUtils.isEmpty(baseDomain)
                 && SwitchBoard.isInExperiment(mActivity, Experiments.URLBAR_SHOW_ORIGIN_ONLY)) {
             // Show just the base domain as title
             setTitle(baseDomain);
         } else {
             // Display full URL with base domain highlighted as title
             updateAndColorTitleFromFullURL(strippedURL, baseDomain, tab.isPrivate());
         }
     }
 
-    private void updateTitleFromSiteIdentity(SiteIdentity siteIdentity) {
+    private void updateTitleFromSiteIdentity(SiteIdentity siteIdentity, boolean isPrivate) {
         final String title;
 
         if (siteIdentity.hasCountry()) {
             title = String.format("%s (%s)", siteIdentity.getOwner(), siteIdentity.getCountry());
         } else {
             title = siteIdentity.getOwner();
         }
 
         final SpannableString spannable = new SpannableString(title);
-        spannable.setSpan(mCertificateOwnerColorSpan, 0, title.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
+        final ForegroundColorSpan colorSpan = isPrivate
+                ? mPrivateCertificateOwnerColorSpan
+                : mCertificateOwnerColorSpan;
+        spannable.setSpan(colorSpan, 0, title.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
 
         setTitle(spannable);
     }
 
     private void updateAndColorTitleFromFullURL(String url, String baseDomain, boolean isPrivate) {
         if (TextUtils.isEmpty(baseDomain)) {
             setTitle(url);
             return;