Bug 701330 - Show star on "Top Sites" tab rows that are bookmarks (r=margaret)
authorLucas Rocha <lucasr@mozilla.com>
Tue, 24 Apr 2012 18:59:09 -0400
changeset 92253 ecb25f038e120e136ee3726ed2723b5e36457a45
parent 92252 08008f60f4e5433ebfc2dd8e89464ea5e3365e0a
child 92254 e36768ec309ba53de9d1cefbf304bfdc885bc285
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 "Top Sites" tab rows that are bookmarks (r=margaret)
mobile/android/base/AwesomeBarTabs.java
mobile/android/base/Makefile.in
mobile/android/base/db/LocalBrowserDB.java
mobile/android/base/resources/drawable-hdpi/ic_awesomebar_star.png
mobile/android/base/resources/drawable-xhdpi-v11/ic_awesomebar_star.png
mobile/android/base/resources/drawable/ic_awesomebar_star.png
mobile/android/base/resources/layout/awesomebar_row.xml
--- a/mobile/android/base/AwesomeBarTabs.java
+++ b/mobile/android/base/AwesomeBarTabs.java
@@ -77,16 +77,17 @@ import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
 
 import org.json.JSONArray;
 import org.json.JSONException;
 import org.json.JSONObject;
 
 import org.mozilla.gecko.db.BrowserContract.Bookmarks;
+import org.mozilla.gecko.db.BrowserContract.Combined;
 import org.mozilla.gecko.db.BrowserDB;
 import org.mozilla.gecko.db.BrowserDB.URLColumns;
 
 public class AwesomeBarTabs extends TabHost {
     private static final String LOGTAG = "GeckoAwesomeBarTabs";
 
     private static final String ALL_PAGES_TAB = "all";
     private static final String BOOKMARKS_TAB = "bookmarks";
@@ -117,16 +118,17 @@ public class AwesomeBarTabs extends TabH
         public void onUrlOpen(String url);
         public void onSearch(String engine);
     }
 
     private class ViewHolder {
         public TextView titleView;
         public TextView urlView;
         public ImageView faviconView;
+        public ImageView starView;
     }
 
     private class HistoryListAdapter extends SimpleExpandableListAdapter {
         public HistoryListAdapter(Context context, List<? extends Map<String, ?>> groupData,
                 int groupLayout, String[] groupFrom, int[] groupTo,
                 List<? extends List<? extends Map<String, ?>>> childData) {
 
             super(context, groupData, groupLayout, groupFrom, groupTo,
@@ -639,31 +641,33 @@ 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();
             }
 
             final int resultCount = super.getCount();
             if (position < resultCount) {
                 Cursor cursor = getCursor();
                 if (!cursor.moveToPosition(position))
                     throw new IllegalStateException("Couldn't move cursor to position " + position);
 
                 updateTitle(viewHolder.titleView, cursor);
                 updateUrl(viewHolder.urlView, cursor);
                 updateFavicon(viewHolder.faviconView, cursor);
+                updateBookmarkStar(viewHolder.starView, cursor);
             } else {
                 bindSearchEngineView(position - resultCount, viewHolder);
             }
 
             return convertView;
         }
 
         private Drawable getDrawableFromDataURI(String dataURI) {
@@ -692,16 +696,17 @@ public class AwesomeBarTabs extends TabH
                 Log.e(LOGTAG, "error getting json arguments");
                 return;
             }
 
             viewHolder.titleView.setText(name);
             viewHolder.urlView.setText(searchText);
             Drawable drawable = getDrawableFromDataURI(iconURI);
             viewHolder.faviconView.setImageDrawable(drawable);
+            viewHolder.starView.setVisibility(View.GONE);
         }
     };
 
     public AwesomeBarTabs(Context context, AttributeSet attrs) {
         super(context, attrs);
 
         Log.d(LOGTAG, "Creating AwesomeBarTabs");
 
@@ -943,16 +948,26 @@ public class AwesomeBarTabs extends TabH
 
     private void updateUrl(TextView urlView, Cursor cursor) {
         int urlIndex = cursor.getColumnIndexOrThrow(URLColumns.URL);
         String url = cursor.getString(urlIndex);
 
         urlView.setText(url);
     }
 
+    private void updateBookmarkStar(ImageView starView, Cursor cursor) {
+        int bookmarkIdIndex = cursor.getColumnIndexOrThrow(Combined.BOOKMARK_ID);
+        long id = cursor.getLong(bookmarkIdIndex);
+
+        // The bookmark id will be 0 (null in database) when the url
+        // is not a bookmark.
+        int visibility = (id == 0 ? View.GONE : View.VISIBLE);
+        starView.setVisibility(visibility);
+    }
+
     public void setOnUrlOpenListener(OnUrlOpenListener listener) {
         mUrlOpenListener = listener;
     }
 
     public void destroy() {
         Cursor allPagesCursor = mAllPagesCursorAdapter.getCursor();
         if (allPagesCursor != null)
             allPagesCursor.close();
--- a/mobile/android/base/Makefile.in
+++ b/mobile/android/base/Makefile.in
@@ -335,16 +335,17 @@ RES_DRAWABLE_BASE = \
   res/drawable/abouthome_sync_bg.9.png \
   res/drawable/abouthome_sync_pressed_bg.9.png \
   res/drawable/abouthome_thumbnail.png \
   res/drawable/awesomebar_tab.9.png \
   res/drawable/awesomebar_tab_pressed.9.png \
   res/drawable/ic_addons_empty.png \
   res/drawable/ic_awesomebar_go.png \
   res/drawable/ic_awesomebar_search.png \
+  res/drawable/ic_awesomebar_star.png \
   res/drawable/ic_menu_bookmark_add.png \
   res/drawable/ic_menu_bookmark_remove.png \
   res/drawable/ic_menu_find_in_page.png \
   res/drawable/ic_menu_reload.png \
   res/drawable/ic_menu_save_as_pdf.png \
   res/drawable/ic_menu_share.png \
   res/drawable/ic_menu_forward.png \
   res/drawable/tab_new.png \
@@ -391,16 +392,17 @@ RES_DRAWABLE_HDPI = \
   res/drawable-hdpi/abouthome_sync_pressed_bg.9.png \
   res/drawable-hdpi/abouthome_thumbnail.png \
   res/drawable-hdpi/address_bar_bg_shadow.png \
   res/drawable-hdpi/awesomebar_tab.9.png \
   res/drawable-hdpi/awesomebar_tab_pressed.9.png \
   res/drawable-hdpi/ic_addons_empty.png \
   res/drawable-hdpi/ic_awesomebar_go.png \
   res/drawable-hdpi/ic_awesomebar_search.png \
+  res/drawable-hdpi/ic_awesomebar_star.png \
   res/drawable-hdpi/ic_menu_bookmark_add.png \
   res/drawable-hdpi/ic_menu_bookmark_remove.png \
   res/drawable-hdpi/ic_menu_find_in_page.png \
   res/drawable-hdpi/ic_menu_reload.png \
   res/drawable-hdpi/ic_menu_save_as_pdf.png \
   res/drawable-hdpi/ic_menu_share.png \
   res/drawable-hdpi/ic_menu_forward.png \
   res/drawable-hdpi/tab_new.png \
@@ -459,16 +461,17 @@ RES_DRAWABLE_XHDPI_V11 = \
   res/drawable-xhdpi-v11/abouthome_sync_pressed_bg.9.png \
   res/drawable-xhdpi-v11/abouthome_thumbnail.png \
   res/drawable-xhdpi-v11/address_bar_bg_shadow.png \
   res/drawable-xhdpi-v11/awesomebar_tab.9.png \
   res/drawable-xhdpi-v11/awesomebar_tab_pressed.9.png \
   res/drawable-xhdpi-v11/ic_addons_empty.png \
   res/drawable-xhdpi-v11/ic_awesomebar_go.png \
   res/drawable-xhdpi-v11/ic_awesomebar_search.png \
+  res/drawable-xhdpi-v11/ic_awesomebar_star.png \
   res/drawable-xhdpi-v11/ic_menu_bookmark_add.png \
   res/drawable-xhdpi-v11/ic_menu_bookmark_remove.png \
   res/drawable-xhdpi-v11/ic_menu_find_in_page.png \
   res/drawable-xhdpi-v11/ic_menu_reload.png \
   res/drawable-xhdpi-v11/ic_menu_save_as_pdf.png \
   res/drawable-xhdpi-v11/ic_menu_share.png \
   res/drawable-xhdpi-v11/tab_new.png \
   res/drawable-xhdpi-v11/tab_close.png \
--- a/mobile/android/base/db/LocalBrowserDB.java
+++ b/mobile/android/base/db/LocalBrowserDB.java
@@ -179,17 +179,18 @@ public class LocalBrowserDB implements B
         return new LocalDBCursor(c);
     }
 
     public Cursor filter(ContentResolver cr, CharSequence constraint, int limit) {
         return filterAllSites(cr,
                               new String[] { Combined._ID,
                                              Combined.URL,
                                              Combined.TITLE,
-                                             Combined.FAVICON },
+                                             Combined.FAVICON,
+                                             Combined.BOOKMARK_ID },
                               constraint,
                               limit,
                               null);
     }
 
     public Cursor getTopSites(ContentResolver cr, int limit) {
         return filterAllSites(cr,
                               new String[] { Combined._ID,
new file mode 100644
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..7848ddbf1e9fd0396b5ecbd3239e82da9bb53306
GIT binary patch
literal 789
zc$@(h1M2*VP)<h;3K|Lk000e1NJLTq000#L000#T1^@s6sTZY|0000PbVXQnQ*UN;
zcVTj606}DLVr3vnZDD6+Qe|Oed2z{QJOBU!w@E}nRCwB?R7*=6Q4~J&t}(HRl}c^Z
z*jS5H0>wo)rKkZnr9z>L3Q`eDe}tRTh58S=Euyp)3WCsXYS4<%)}2j!KPK@}O)w9W
zG?SUh-08WEii%C59{4zO&pr2>@0|MpD8fwb$756Xhp8_npD9SFeC0JQyCO<fr>3R?
zqR8E0O4_se*06<04L#E>^5BGQ2&gx7^~I%>n#nOyRdrdCpbE$zlu!z)3cn>usAFs$
z+J%(rYUY(BuvMTZsAQm?jxql7LQ2i#lts@(Wr0my2a-A_!wNdFhJ`ETPR8~~Ig`|k
zf8l|1Gy%gk;`kn-0Vx|HyWaptR0MqwL*!&}LInVSO#`lM87USph#uy^G#0>!`5AL>
z#0T8fCNObB3I3R*51=Bqo~K3u`6Yzq03{gXu}%9ver;g}T(#wJexv(@n+MSo(Y0Wd
z;XZp8l_#yP`wp962V%fw5ZH(W+q(t_xY&MXer$X((b0C>?XdB7><e53@@6#X=^E}|
z-;57&^nAw?s(;M8oaktAx*b;j+=}ImSkTiw(kE{v25Dco!;3?SN5@wZPg`r;_EN5B
z;=oos=;;~llecq(rw_ljv6C8H4@PFez_}tp^N$l!<4<pCLrs|-01GhEg%1E{fm}YE
zxU#27!77=~BP9im&*kU4rsmJ*JRwA3Sv<w02vSxALd-17vL(!ekJ&RHl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a-^ZnHZxezRMOkvQyQzy0RD<$G_2DeonEmkAgdfMuRUpQ?QmvQ35PVR49{S7!_o
zr<(_Jrek6EA<;fT`n@!WZR|oyf`aclcM)zfji{zxwD%X614Hp>Mv}&(Pw8E-5~7G;
zBl@$I*k1(F=fMxXfeLBA13fy2OiYug1jVzEK^CEtLP#Rf+O-UBz6R$m*gzdf)@ke|
z=G10ahf;}CF!qoi3P5Sk>Yu<EJp%+&PlPSETQwJ#zL*ya$Hvo^NJIEK7({{fK=)`b
z?7+60cIoQ#d*;t|cXe^O(V3b&I+jV2SxLnIV9jo>ox46i_qnnDjH${DSniQEdVJrF
z>Z{B58Kb28ETte%PA%N3ecyaa8lS0;*P^qleEpTpjSSZ!pM5==s5F|Rxf2H|9DN*t
zN68sT52{@3$4B2~S}`XK>JT0YLq9rP;X8S3%ZSt33R??h`<<?@l#ZOur1)OV6TX{A
zz+XUi^_7cng6nz*nj7l(eEG-9oyXsn+itj`g|{D6&&<t?6fR93o^V}%n1u20s$7VR
y;@b&&jS)T&D%2M{eSHPS38#1Z?{)u=00RKB$q1}GYwHdG0000<MNUMnLSTYe0~dS%
--- a/mobile/android/base/resources/layout/awesomebar_row.xml
+++ b/mobile/android/base/resources/layout/awesomebar_row.xml
@@ -8,30 +8,43 @@
                android:layout_width="32dip"
                android:layout_height="32dip"
                android:layout_marginRight="10dip"
                android:layout_centerVertical="true"
                android:minWidth="32dip"
                android:minHeight="32dip"
                android:scaleType="fitCenter"/>
 
+    <ImageView android:id="@+id/bookmark_star"
+               android:layout_width="wrap_content"
+               android:layout_height="wrap_content"
+               android:layout_marginLeft="10dip"
+               android:layout_centerVertical="true"
+               android:layout_alignParentRight="true"
+               android:visibility="gone"
+               android:minHeight="32dip"
+               android:src="@drawable/ic_awesomebar_star"
+               android:scaleType="fitStart"/>
+
     <TextView android:id="@+id/title"
               android:layout_width="wrap_content"
               android:layout_height="wrap_content"
               android:textAppearance="?android:attr/textAppearanceMedium"
               android:textColor="?android:attr/textColorPrimary"
               android:layout_toRightOf="@id/favicon"
+              android:layout_toLeftOf="@id/bookmark_star"
               android:singleLine="true"
               android:ellipsize="middle"/>
 
     <TextView android:id="@+id/url"
               android:layout_width="wrap_content"
               android:layout_height="wrap_content"
               android:textAppearance="?android:attr/textAppearanceSmall"
               android:textColor="?android:attr/textColorSecondary"
               android:layout_marginTop="2dip"
               android:layout_below="@id/title"
               android:layout_alignLeft="@id/title"
+              android:layout_toLeftOf="@id/bookmark_star"
               android:includeFontPadding="false"
               android:singleLine="true"
               android:ellipsize="middle"/>
 
 </RelativeLayout>