Bug 1236431 - ToolbarDisplayLayout: Only show base domain. r=mcomella draft
authorSebastian Kaspari <s.kaspari@gmail.com>
Thu, 11 Feb 2016 15:54:11 +0100
changeset 331459 2c315e1c84416e77fd534f54eb9e5aa4e50fb8da
parent 331458 87e2044c27e7693b9c356e32f4f6d5e70de9d5ed
child 331460 5cf0a2dc496f67e000016a9f9a0094a7e1354122
push id10995
push users.kaspari@gmail.com
push dateWed, 17 Feb 2016 10:24:29 +0000
reviewersmcomella
bugs1236431
milestone47.0a1
Bug 1236431 - ToolbarDisplayLayout: Only show base domain. r=mcomella MozReview-Commit-ID: GwH3XDVim4F
mobile/android/base/java/org/mozilla/gecko/toolbar/ToolbarDisplayLayout.java
mobile/android/base/resources/values/colors.xml
--- a/mobile/android/base/java/org/mozilla/gecko/toolbar/ToolbarDisplayLayout.java
+++ b/mobile/android/base/java/org/mozilla/gecko/toolbar/ToolbarDisplayLayout.java
@@ -115,38 +115,30 @@ public class ToolbarDisplayLayout extend
     private static final int LEVEL_DEFAULT_GLOBE = 0;
     // Levels for displaying Mixed Content state icons.
     private static final int LEVEL_WARNING_MINOR = 3;
     private static final int LEVEL_LOCK_DISABLED = 4;
     // Levels for displaying Tracking Protection state icons.
     private static final int LEVEL_SHIELD_ENABLED = 5;
     private static final int LEVEL_SHIELD_DISABLED = 6;
 
-    private final ForegroundColorSpan mUrlColor;
     private final ForegroundColorSpan mBlockedColor;
-    private final ForegroundColorSpan mDomainColor;
-    private final ForegroundColorSpan mPrivateDomainColor;
 
     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();
 
-        final Resources res = getResources();
-
-        mUrlColor = new ForegroundColorSpan(ColorUtils.getColor(context, R.color.url_bar_urltext));
         mBlockedColor = new ForegroundColorSpan(ColorUtils.getColor(context, R.color.url_bar_blockedtext));
-        mDomainColor = new ForegroundColorSpan(ColorUtils.getColor(context, R.color.url_bar_domaintext));
-        mPrivateDomainColor = new ForegroundColorSpan(ColorUtils.getColor(context, R.color.url_bar_domaintext_private));
 
         mSiteSecurity = (ImageButton) findViewById(R.id.site_security);
 
         mSiteIdentityPopup = new SiteIdentityPopup(mActivity);
         mSiteIdentityPopup.setAnchor(this);
         mSiteIdentityPopup.setOnVisibilityChangeListener(mActivity);
 
         mStop = (ImageButton) findViewById(R.id.stop);
@@ -252,39 +244,30 @@ public class ToolbarDisplayLayout extend
 
             final SpannableStringBuilder builder = new SpannableStringBuilder(title);
             builder.setSpan(mBlockedColor, 0, title.length(), Spannable.SPAN_INCLUSIVE_INCLUSIVE);
 
             setTitle(builder);
             return;
         }
 
+        final String baseDomain = tab.getBaseDomain();
+
         String strippedURL = stripAboutReaderURL(url);
 
         if (mPrefs.shouldTrimUrls()) {
             strippedURL = StringUtils.stripCommonSubdomains(StringUtils.stripScheme(strippedURL));
         }
 
-        CharSequence title = strippedURL;
-
-        final String baseDomain = tab.getBaseDomain();
         if (!TextUtils.isEmpty(baseDomain)) {
-            final SpannableStringBuilder builder = new SpannableStringBuilder(title);
-
-            int index = title.toString().indexOf(baseDomain);
-            if (index > -1) {
-                builder.setSpan(mUrlColor, 0, title.length(), Spannable.SPAN_INCLUSIVE_INCLUSIVE);
-                builder.setSpan(tab.isPrivate() ? mPrivateDomainColor : mDomainColor,
-                                index, index + baseDomain.length(), Spannable.SPAN_INCLUSIVE_INCLUSIVE);
-
-                title = builder;
-            }
+            setTitle(baseDomain);
+            setContentDescription(strippedURL);
+        } else {
+            setTitle(strippedURL);
         }
-
-        setTitle(title);
     }
 
     private String stripAboutReaderURL(final String url) {
         if (!AboutPages.isAboutReader(url)) {
             return url;
         }
 
         return ReaderModeUtils.getUrlFromAboutReader(url);
--- a/mobile/android/base/resources/values/colors.xml
+++ b/mobile/android/base/resources/values/colors.xml
@@ -105,19 +105,16 @@
   <color name="url_bar_text_highlight_pb">#FFD06BFF</color>
   <color name="tab_row_pressed">#4D000000</color>
 
   <color name="textbox_background">#FFF</color>
   <color name="textbox_background_disabled">#DDD</color>
   <color name="textbox_stroke">#000</color>
   <color name="textbox_stroke_disabled">#666</color>
 
-  <color name="url_bar_urltext">#A6A6A6</color>
-  <color name="url_bar_domaintext">#000</color>
-  <color name="url_bar_domaintext_private">#FFF</color>
   <color name="url_bar_blockedtext">#b14646</color>
   <color name="url_bar_shadow">#12000000</color>
 
   <color name="home_button_bar_bg">#FFF5F7F9</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>