Bug 701330 - Show star on "History" tab rows that are bookmarks (r=margaret)
authorLucas Rocha <lucasr@mozilla.com>
Tue, 24 Apr 2012 18:59:30 -0400
changeset 92254 e36768ec309ba53de9d1cefbf304bfdc885bc285
parent 92253 ecb25f038e120e136ee3726ed2723b5e36457a45
child 92255 1e2e0e7972a5ff4e463ef7920cb03b454373b2aa
push id8629
push userlrocha@mozilla.com
push dateTue, 24 Apr 2012 22:59:57 +0000
treeherdermozilla-inbound@e36768ec309b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmargaret
bugs701330
milestone14.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 701330 - Show star on "History" tab rows that are bookmarks (r=margaret)
mobile/android/base/AwesomeBarTabs.java
mobile/android/base/db/LocalBrowserDB.java
--- a/mobile/android/base/AwesomeBarTabs.java
+++ b/mobile/android/base/AwesomeBarTabs.java
@@ -142,16 +142,17 @@ public class AwesomeBarTabs extends TabH
 
             if (convertView == null) {
                 convertView = mInflater.inflate(R.layout.awesomebar_row, null);
 
                 viewHolder = new ViewHolder();
                 viewHolder.titleView = (TextView) convertView.findViewById(R.id.title);
                 viewHolder.urlView = (TextView) convertView.findViewById(R.id.url);
                 viewHolder.faviconView = (ImageView) convertView.findViewById(R.id.favicon);
+                viewHolder.starView = (ImageView) convertView.findViewById(R.id.bookmark_star);
 
                 convertView.setTag(viewHolder);
             } else {
                 viewHolder = (ViewHolder) convertView.getTag();
             }
 
             @SuppressWarnings("unchecked")
             Map<String,Object> historyItem =
@@ -170,16 +171,23 @@ public class AwesomeBarTabs extends TabH
 
             if (b == null) {
                 viewHolder.faviconView.setImageDrawable(null);
             } else {
                 Bitmap bitmap = BitmapFactory.decodeByteArray(b, 0, b.length);
                 viewHolder.faviconView.setImageBitmap(bitmap);
             }
 
+            Long bookmarkId = (Long) historyItem.get(Combined.BOOKMARK_ID);
+
+            // The bookmark id will be 0 (null in database) when the url
+            // is not a bookmark.
+            int visibility = (bookmarkId == 0 ? View.GONE : View.VISIBLE);
+            viewHolder.starView.setVisibility(visibility);
+
             return convertView;
         }
     }
 
     private class BookmarksListAdapter extends SimpleCursorAdapter {
         private static final int VIEW_TYPE_ITEM = 0;
         private static final int VIEW_TYPE_FOLDER = 1;
         private static final int VIEW_TYPE_COUNT = 2;
@@ -476,28 +484,31 @@ public class AwesomeBarTabs extends TabH
         }
 
         public Map<String,Object> createHistoryItem(Cursor cursor) {
             Map<String,Object> historyItem = new HashMap<String,Object>();
 
             String url = cursor.getString(cursor.getColumnIndexOrThrow(URLColumns.URL));
             String title = cursor.getString(cursor.getColumnIndexOrThrow(URLColumns.TITLE));
             byte[] favicon = cursor.getBlob(cursor.getColumnIndexOrThrow(URLColumns.FAVICON));
+            Long bookmarkId = cursor.getLong(cursor.getColumnIndexOrThrow(Combined.BOOKMARK_ID));
 
             // 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
             if (title == null || title.length() == 0)
                 title = url;
 
             historyItem.put(URLColumns.URL, url);
             historyItem.put(URLColumns.TITLE, title);
 
             if (favicon != null)
                 historyItem.put(URLColumns.FAVICON, favicon);
 
+            historyItem.put(Combined.BOOKMARK_ID, bookmarkId);
+
             return historyItem;
         }
 
         public Map<String,String> createGroupItem(HistorySection section) {
             Map<String,String> groupItem = new HashMap<String,String>();
 
             groupItem.put(URLColumns.TITLE, getSectionName(section));
 
--- a/mobile/android/base/db/LocalBrowserDB.java
+++ b/mobile/android/base/db/LocalBrowserDB.java
@@ -265,23 +265,24 @@ public class LocalBrowserDB implements B
                             History.VISITS + " > 0",
                             null,
                             null);
 
         return new LocalDBCursor(c);
     }
 
     public Cursor getRecentHistory(ContentResolver cr, int limit) {
-        Cursor c = cr.query(historyUriWithLimit(limit),
-                            new String[] { History._ID,
-                                           History.URL,
-                                           History.TITLE,
-                                           History.FAVICON,
-                                           History.DATE_LAST_VISITED,
-                                           History.VISITS },
+        Cursor c = cr.query(combinedUriWithLimit(limit),
+                            new String[] { Combined._ID,
+                                           Combined.BOOKMARK_ID,
+                                           Combined.URL,
+                                           Combined.TITLE,
+                                           Combined.FAVICON,
+                                           Combined.DATE_LAST_VISITED,
+                                           Combined.VISITS },
                             History.DATE_LAST_VISITED + " > 0",
                             null,
                             History.DATE_LAST_VISITED + " DESC");
 
         return new LocalDBCursor(c);
     }
 
     public void clearHistory(ContentResolver cr) {