Bug 900128: Change aspect ratio of Bookmark thumbnails. [r=margaret]
authorSriram Ramasubramanian <sriram@mozilla.com>
Fri, 02 Aug 2013 10:03:21 -0700
changeset 143492 31027d675f80c44b4b4e20ad32309b9946717bd0
parent 143491 41e8b95f56679783cd32962e30b537e9ce2b6350
child 143493 b0e8ef08abae03a7a99b3199db198fe7b4f1bfcf
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)
reviewersmargaret
bugs900128
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 900128: Change aspect ratio of Bookmark thumbnails. [r=margaret]
mobile/android/base/ThumbnailHelper.java
mobile/android/base/home/TopBookmarksView.java
mobile/android/base/resources/values/attrs.xml
mobile/android/base/resources/values/styles.xml
--- a/mobile/android/base/ThumbnailHelper.java
+++ b/mobile/android/base/ThumbnailHelper.java
@@ -24,17 +24,17 @@ import java.util.concurrent.atomic.Atomi
  * completion of the current thumbnail the next one is automatically processed.
  * Changes to the thumbnail width are stashed in mPendingWidth and the change is
  * applied between thumbnail processing. This allows a single thumbnail buffer to
  * be used for all thumbnails.
  */
 public final class ThumbnailHelper {
     private static final String LOGTAG = "GeckoThumbnailHelper";
 
-    public static final float THUMBNAIL_ASPECT_RATIO = 0.714f;  // this is a 5:7 ratio (as per UX decision)
+    public static final float THUMBNAIL_ASPECT_RATIO = 0.571f;  // this is a 4:7 ratio (as per UX decision)
 
     // static singleton stuff
 
     private static ThumbnailHelper sInstance;
 
     public static synchronized ThumbnailHelper getInstance() {
         if (sInstance == null) {
             sInstance = new ThumbnailHelper();
--- a/mobile/android/base/home/TopBookmarksView.java
+++ b/mobile/android/base/home/TopBookmarksView.java
@@ -7,16 +7,17 @@ package org.mozilla.gecko.home;
 
 import org.mozilla.gecko.R;
 import org.mozilla.gecko.ThumbnailHelper;
 import org.mozilla.gecko.db.BrowserDB.TopSitesCursorWrapper;
 import org.mozilla.gecko.db.BrowserDB.URLColumns;
 import org.mozilla.gecko.home.HomePager.OnUrlOpenListener;
 
 import android.content.Context;
+import android.content.res.TypedArray;
 import android.database.Cursor;
 import android.text.TextUtils;
 import android.util.AttributeSet;
 import android.view.ContextMenu.ContextMenuInfo;
 import android.view.View;
 import android.widget.AbsListView;
 import android.widget.AdapterView;
 import android.widget.GridView;
@@ -34,16 +35,19 @@ public class TopBookmarksView extends Gr
     }
 
     // Max number of bookmarks that needs to be shown.
     private final int mMaxBookmarks;
 
     // Number of columns to show.
     private final int mNumColumns;
 
+    // Vertical spacing inbetween the rows.
+    private final int mVerticalSpacing;
+
     // On URL open listener.
     private OnUrlOpenListener mUrlOpenListener;
 
     // Pin bookmark listener.
     private OnPinBookmarkListener mPinBookmarkListener;
 
     // Context menu info.
     private TopBookmarksContextMenuInfo mContextMenuInfo;
@@ -56,16 +60,20 @@ public class TopBookmarksView extends Gr
         this(context, attrs, R.attr.topBookmarksViewStyle);
     }
 
     public TopBookmarksView(Context context, AttributeSet attrs, int defStyle) {
         super(context, attrs, defStyle);
         mMaxBookmarks = getResources().getInteger(R.integer.number_of_top_sites);
         mNumColumns = getResources().getInteger(R.integer.number_of_top_sites_cols);
         setNumColumns(mNumColumns);
+
+        TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.TopBookmarksView, defStyle, 0);
+        mVerticalSpacing = a.getDimensionPixelOffset(R.styleable.TopBookmarksView_android_verticalSpacing, 0x00);
+        a.recycle();
     }
 
     /**
      * {@inheritDoc}
      */
     @Override
     public void onAttachedToWindow() {
         super.onAttachedToWindow();
@@ -159,19 +167,20 @@ public class TopBookmarksView extends Gr
         }
 
         // Find the minimum of bookmarks we need to show, and the one given by the cursor.
         final int total = Math.min(count > 0 ? count : Integer.MAX_VALUE, mMaxBookmarks);
 
         // Number of rows required to show these bookmarks.
         final int rows = (int) Math.ceil((double) total / mNumColumns);
         final int childrenHeight = childHeight * rows;
+        final int totalVerticalSpacing = rows > 0 ? (rows - 1) * mVerticalSpacing : 0;
 
         // Total height of this view.
-        final int measuredHeight = childrenHeight + getPaddingTop() + getPaddingBottom();
+        final int measuredHeight = childrenHeight + getPaddingTop() + getPaddingBottom() + totalVerticalSpacing;
         setMeasuredDimension(measuredWidth, measuredHeight);
     }
 
     @Override
     public ContextMenuInfo getContextMenuInfo() {
         return mContextMenuInfo;
     }
 
--- a/mobile/android/base/resources/values/attrs.xml
+++ b/mobile/android/base/resources/values/attrs.xml
@@ -192,10 +192,14 @@
     <declare-styleable name="GeckoView">
         <attr name="url" format="string"/>
     </declare-styleable>
 
     <declare-styleable name="IconTabWidget">
         <attr name="android:layout"/>
     </declare-styleable>
 
+    <declare-styleable name="TopBookmarksView">
+        <attr name="android:verticalSpacing"/>
+    </declare-styleable>
+
 </resources>
 
--- a/mobile/android/base/resources/values/styles.xml
+++ b/mobile/android/base/resources/values/styles.xml
@@ -114,16 +114,17 @@
     <style name="Widget.BookmarkFolderView" parent="Widget.TwoLinePageRow.Title">
         <item name="android:paddingLeft">10dip</item>
         <item name="android:drawablePadding">10dip</item>
         <item name="android:drawableLeft">@drawable/bookmark_folder</item>
     </style>
 
     <style name="Widget.TopBookmarksView" parent="Widget.GridView">
         <item name="android:padding">7dp</item>
+        <item name="android:verticalSpacing">7dp</item>
     </style>
 
     <style name="Widget.TopBookmarkItemView">
       <item name="android:layout_width">fill_parent</item>
       <item name="android:layout_height">fill_parent</item>
       <item name="android:padding">5dip</item>
       <item name="android:orientation">vertical</item>
     </style>