Bug 1116563 - Fall back to display URL if reading list item has no title. r=rnewman
authorMargaret Leibovic <margaret.leibovic@gmail.com>
Fri, 02 Jan 2015 15:21:07 -0800
changeset 222401 2eee3736551ac46c710ee187e0862d787bd91358
parent 222400 359db230dfb1d5272c3f17399dc4bdb48ec90f6a
child 222402 227dc63febd94321122c0bba29b07bd1d625e5df
push id28064
push usercbook@mozilla.com
push dateWed, 07 Jan 2015 13:13:08 +0000
treeherdermozilla-central@206205dd8bd1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrnewman
bugs1116563
milestone37.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 1116563 - Fall back to display URL if reading list item has no title. r=rnewman
mobile/android/base/home/ReadingListRow.java
--- a/mobile/android/base/home/ReadingListRow.java
+++ b/mobile/android/base/home/ReadingListRow.java
@@ -5,20 +5,22 @@
 
 package org.mozilla.gecko.home;
 
 import org.mozilla.gecko.R;
 import org.mozilla.gecko.Tab;
 import org.mozilla.gecko.Tabs;
 import org.mozilla.gecko.db.BrowserContract.ReadingListItems;
 import org.mozilla.gecko.home.TwoLinePageRow;
+import org.mozilla.gecko.util.StringUtils;
 
 import android.content.Context;
 import android.content.res.Resources;
 import android.database.Cursor;
+import android.text.TextUtils;
 import android.util.AttributeSet;
 import android.view.LayoutInflater;
 import android.widget.LinearLayout;
 import android.widget.TextView;
 
 public class ReadingListRow extends LinearLayout {
 
     private final Resources resources;
@@ -50,21 +52,23 @@ public class ReadingListRow extends Line
         readTime = (TextView) findViewById(R.id.read_time);
     }
 
     public void updateFromCursor(Cursor cursor) {
         if (cursor == null) {
             return;
         }
 
-        final int titleIndex = cursor.getColumnIndexOrThrow(ReadingListItems.TITLE);
-        title.setText(cursor.getString(titleIndex));
+        final String url = cursor.getString(cursor.getColumnIndexOrThrow(ReadingListItems.URL));
 
-        final int excerptIndex = cursor.getColumnIndexOrThrow(ReadingListItems.EXCERPT);
-        excerpt.setText(cursor.getString(excerptIndex));
+        final String titleText = cursor.getString(cursor.getColumnIndexOrThrow(ReadingListItems.TITLE));
+        title.setText(TextUtils.isEmpty(titleText) ? StringUtils.stripCommonSubdomains(StringUtils.stripScheme(url)) : titleText);
+
+        final String excerptText = cursor.getString(cursor.getColumnIndexOrThrow(ReadingListItems.EXCERPT));
+        excerpt.setText(TextUtils.isEmpty(excerptText) ? url : excerptText);
 
         /* Disabled until UX issues are fixed (see bug 1110461).
         final int lengthIndex = cursor.getColumnIndexOrThrow(ReadingListItems.LENGTH);
         final int minutes = getEstimatedReadTime(cursor.getInt(lengthIndex));
         if (minutes <= 60) {
             readTime.setText(resources.getString(R.string.reading_list_time_minutes, minutes));
         } else {
             readTime.setText(resources.getString(R.string.reading_list_time_over_an_hour));