Bug 885884: Pin bookmark dialog list shouldn't show bookmark icon, switch to tab. [r=lucasr]
authorSriram Ramasubramanian <sriram@mozilla.com>
Mon, 22 Jul 2013 12:49:39 -0700
changeset 143425 bd393061461ab1af9217eb8c0ddd320d1dcf075a
parent 143424 8e852b2a313a362dbdc2aa14dd1912ee474a334c
child 143426 9aca0034429f25379e83639cfb5a246173330468
push id25130
push userlrocha@mozilla.com
push dateWed, 21 Aug 2013 09:41:27 +0000
treeherdermozilla-central@b2486721572e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerslucasr
bugs885884
milestone25.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 885884: Pin bookmark dialog list shouldn't show bookmark icon, switch to tab. [r=lucasr]
mobile/android/base/home/PinBookmarkDialog.java
mobile/android/base/home/TwoLinePageRow.java
--- a/mobile/android/base/home/PinBookmarkDialog.java
+++ b/mobile/android/base/home/PinBookmarkDialog.java
@@ -160,16 +160,17 @@ class PinBookmarkDialog extends DialogFr
         public SearchAdapter(Context context) {
             super(context, null);
             mInflater = LayoutInflater.from(context);
         }
 
         @Override
         public void bindView(View view, Context context, Cursor cursor) {
             TwoLinePageRow row = (TwoLinePageRow) view;
+            row.setShowIcons(false);
             row.updateFromCursor(cursor);
         }
 
         @Override
         public View newView(Context context, Cursor cursor, ViewGroup parent) {
             return (TwoLinePageRow) mInflater.inflate(R.layout.home_item_row, parent, false);
         }
     }
--- a/mobile/android/base/home/TwoLinePageRow.java
+++ b/mobile/android/base/home/TwoLinePageRow.java
@@ -27,28 +27,30 @@ public class TwoLinePageRow extends Line
     private static final int NO_ICON = 0;
 
     private final TextView mTitle;
     private final TextView mUrl;
     private final FaviconView mFavicon;
 
     private int mUrlIconId;
     private int mBookmarkIconId;
+    private boolean mShowIcons;
 
     public TwoLinePageRow(Context context) {
         this(context, null);
     }
 
     public TwoLinePageRow(Context context, AttributeSet attrs) {
         super(context, attrs);
 
         setGravity(Gravity.CENTER_VERTICAL);
 
         mUrlIconId = NO_ICON;
         mBookmarkIconId = NO_ICON;
+        mShowIcons = true;
 
         LayoutInflater.from(context).inflate(R.layout.two_line_page_row, this);
         mTitle = (TextView) findViewById(R.id.title);
         mUrl = (TextView) findViewById(R.id.url);
         mFavicon = (FaviconView) findViewById(R.id.favicon);
     }
 
     private void setTitle(String title) {
@@ -80,38 +82,42 @@ public class TwoLinePageRow extends Line
         if (mBookmarkIconId == bookmarkIconId) {
             return;
         }
 
         mBookmarkIconId = bookmarkIconId;
         mUrl.setCompoundDrawablesWithIntrinsicBounds(mUrlIconId, 0, mBookmarkIconId, 0);
     }
 
+    public void setShowIcons(boolean showIcons) {
+        mShowIcons = showIcons;
+    }
+
     public void updateFromCursor(Cursor cursor) {
         if (cursor == null) {
             return;
         }
 
         int titleIndex = cursor.getColumnIndexOrThrow(URLColumns.TITLE);
         final String title = cursor.getString(titleIndex);
 
         int urlIndex = cursor.getColumnIndexOrThrow(URLColumns.URL);
         final String url = cursor.getString(urlIndex);
 
         // Use the URL instead of an empty title for consistency with the normal URL
         // bar view - this is the equivalent of getDisplayTitle() in Tab.java
         setTitle(TextUtils.isEmpty(title) ? url : title);
 
         // Update the url with "Switch to tab" if needed.
-        if (Tabs.getInstance().hasUrl(url)) {
+        if (!mShowIcons || !Tabs.getInstance().hasUrl(url)) {
+            setUrl(url);
+            setUrlIcon(NO_ICON);
+        } else {
             setUrl(R.string.switch_to_tab);
             setUrlIcon(R.drawable.ic_url_bar_tab);
-        } else {
-            setUrl(url);
-            setUrlIcon(NO_ICON);
         }
 
         int faviconIndex = cursor.getColumnIndex(URLColumns.FAVICON);
         if (faviconIndex != -1) {
             byte[] b = cursor.getBlob(faviconIndex);
 
             Bitmap favicon = null;
             if (b != null && b.length > 0) {
@@ -122,16 +128,21 @@ public class TwoLinePageRow extends Line
             }
 
             setFaviconWithUrl(favicon, url);
         } else {
             // If favicons is not on the cursor, try to fetch it from the memory cache
             setFaviconWithUrl(Favicons.getInstance().getFaviconFromMemCache(url), url);
         }
 
+        // Don't show bookmark/reading list icon, if not needed.
+        if (!mShowIcons) {
+            return;
+        }
+
         final int bookmarkIdIndex = cursor.getColumnIndex(Combined.BOOKMARK_ID);
         if (bookmarkIdIndex != -1) {
             final long bookmarkId = cursor.getLong(bookmarkIdIndex);
             final int displayIndex = cursor.getColumnIndex(Combined.DISPLAY);
 
             final int display;
             if (displayIndex != -1) {
                 display = cursor.getInt(displayIndex);