Bug 1393577: Change highlight domain title to subdomain.domain. r=liuche draft
authorMichael Comella <michael.l.comella@gmail.com>
Fri, 08 Sep 2017 14:43:40 -0700
changeset 661701 165b72395a28f745c9a4e4b82d72299e648615ed
parent 660845 3c96d611ebd67fc219d22bcb476a72412c76f6c7
child 661702 1c5f7dc4aec2b91a2929d24d5cdaf587a3715623
push id78854
push usermichael.l.comella@gmail.com
push dateFri, 08 Sep 2017 21:46:17 +0000
Bug 1393577: Change highlight domain title to subdomain.domain. r=liuche We strip common subdomains from subdomain.domain because things like "m.youtube" and "www.mozilla" look really bad. MozReview-Commit-ID: wmWdcL8p8C
--- a/mobile/android/base/java/org/mozilla/gecko/activitystream/homepanel/stream/WebpageItemRow.java
+++ b/mobile/android/base/java/org/mozilla/gecko/activitystream/homepanel/stream/WebpageItemRow.java
@@ -14,16 +14,17 @@ import android.view.ViewGroup;
 import android.widget.ImageView;
 import android.widget.TextView;
 import org.mozilla.gecko.R;
 import org.mozilla.gecko.activitystream.ActivityStreamTelemetry;
 import org.mozilla.gecko.activitystream.Utils;
 import org.mozilla.gecko.activitystream.homepanel.StreamHighlightItemRowContextMenuListener;
 import org.mozilla.gecko.activitystream.homepanel.model.WebpageRowModel;
 import org.mozilla.gecko.util.DrawableUtil;
+import org.mozilla.gecko.util.StringUtils;
 import org.mozilla.gecko.util.TouchTargetUtil;
 import org.mozilla.gecko.util.URIUtils;
 import org.mozilla.gecko.util.ViewUtil;
 import java.lang.ref.WeakReference;
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.util.UUID;
@@ -139,36 +140,36 @@ public class WebpageItemRow extends Stre
     /** Updates the text of the given view to the host second level domain. */
     private static class UpdatePageDomainAsyncTask extends URIUtils.GetFormattedDomainAsyncTask {
         private static final int VIEW_TAG_ID = R.id.page; // same as the view.
         private final WeakReference<TextView> pageDomainViewWeakReference;
         private final UUID viewTagAtStart;
         UpdatePageDomainAsyncTask(final Context contextReference, final URI uri, final TextView pageDomainView) {
-            super(contextReference, uri, false, 0); // hostSLD.
+            super(contextReference, uri, false, 1); // subdomain.domain.
             this.pageDomainViewWeakReference = new WeakReference<>(pageDomainView);
             // See isTagSameAsStartTag for details.
             viewTagAtStart = UUID.randomUUID();
             pageDomainView.setTag(VIEW_TAG_ID, viewTagAtStart);
-        protected void onPostExecute(final String hostSLD) {
-            super.onPostExecute(hostSLD);
+        protected void onPostExecute(final String domainTitle) {
+            super.onPostExecute(domainTitle);
             final TextView viewToUpdate = pageDomainViewWeakReference.get();
             if (viewToUpdate == null || !isTagSameAsStartTag(viewToUpdate)) {
-            // hostSLD will be the empty String if the host cannot be determined. This is fine: it's very unlikely
+            // The title will be the empty String if the host cannot be determined. This is fine: it's very unlikely
             // and the page title will be URL if there's an error there so we wouldn't want to write the URL again here.
-            viewToUpdate.setText(hostSLD);
+            viewToUpdate.setText(StringUtils.stripCommonSubdomains(domainTitle));
          * Returns true if the tag on the given view matches the tag from the constructor. We do this to ensure
          * the View we're making this request for hasn't been re-used by the time this request completes.
         private boolean isTagSameAsStartTag(final View viewToCheck) {