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);
}
@Override
- 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)) {
return;
}
- // 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.
*/
@UiThread
private boolean isTagSameAsStartTag(final View viewToCheck) {