Bug 942889 - Lists - Gallery layout. r=lucasr
authorSola Ogunsakin <oogunsakin@mozilla.com>
Fri, 31 Jan 2014 08:57:56 -0800
changeset 182361 c7d8358b2d27197bb803c8f50833d317e1c73ce7
parent 182360 cbcf7d2e9cb325c55cd45c4e7456c85a0d34f20d
child 182362 c8beb738fee76d937305c401f060ba37534287f8
push id3343
push userffxbld
push dateMon, 17 Mar 2014 21:55:32 +0000
treeherdermozilla-beta@2f7d3415f79f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerslucasr
bugs942889
milestone29.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 942889 - Lists - Gallery layout. r=lucasr
mobile/android/base/home/PanelGridItemView.java
mobile/android/base/home/PanelGridView.java
mobile/android/base/moz.build
mobile/android/base/resources/layout/panel_grid_item_view.xml
mobile/android/base/resources/values-v11/themes.xml
mobile/android/base/resources/values-xlarge-v11/dimens.xml
mobile/android/base/resources/values/attrs.xml
mobile/android/base/resources/values/colors.xml
mobile/android/base/resources/values/dimens.xml
mobile/android/base/resources/values/styles.xml
mobile/android/base/resources/values/themes.xml
mobile/android/base/widget/SquaredImageView.java
--- a/mobile/android/base/home/PanelGridItemView.java
+++ b/mobile/android/base/home/PanelGridItemView.java
@@ -32,21 +32,20 @@ public class PanelGridItemView extends F
 
     private final ImageView mThumbnailView;
 
     public PanelGridItemView(Context context) {
         this(context, null);
     }
 
     public PanelGridItemView(Context context, AttributeSet attrs) {
-        this(context, attrs, 0);
+        this(context, attrs, R.attr.panelGridItemViewStyle);
     }
 
     public PanelGridItemView(Context context, AttributeSet attrs, int defStyle) {
         super(context, attrs, defStyle);
 
         LayoutInflater.from(context).inflate(R.layout.panel_grid_item_view, this);
         mThumbnailView = (ImageView) findViewById(R.id.image);
-        mThumbnailView.setBackgroundColor(Color.rgb(255, 148, 0));
     }
 
     public void updateFromCursor(Cursor cursor) { }
 }
--- a/mobile/android/base/home/PanelGridView.java
+++ b/mobile/android/base/home/PanelGridView.java
@@ -18,17 +18,17 @@ import android.view.ViewGroup;
 import android.widget.GridView;
 
 public class PanelGridView extends GridView implements DatasetBacked {
     private static final String LOGTAG = "GeckoPanelGridView";
 
     private final PanelGridViewAdapter mAdapter;
 
     public PanelGridView(Context context, ViewConfig viewConfig) {
-        super(context, null, R.attr.homeGridViewStyle);
+        super(context, null, R.attr.panelGridViewStyle);
         mAdapter = new PanelGridViewAdapter(context);
         setAdapter(mAdapter);
         setNumColumns(AUTO_FIT);
     }
 
     @Override
     public void setDataset(Cursor cursor) {
         mAdapter.swapCursor(cursor);
--- a/mobile/android/base/moz.build
+++ b/mobile/android/base/moz.build
@@ -357,16 +357,17 @@ gbjar.sources += [
     'widget/DateTimePicker.java',
     'widget/Divider.java',
     'widget/DoorHanger.java',
     'widget/FaviconView.java',
     'widget/FlowLayout.java',
     'widget/GeckoActionProvider.java',
     'widget/GeckoPopupMenu.java',
     'widget/IconTabWidget.java',
+    'widget/SquaredImageView.java',
     'widget/TabRow.java',
     'widget/ThumbnailView.java',
     'widget/TwoWayView.java',
     'ZoomConstraints.java',
 ]
 gbjar.sources += [ thirdparty_source_dir + f for f in [
     'com/googlecode/eyesfree/braille/selfbraille/ISelfBrailleService.java',
     'com/googlecode/eyesfree/braille/selfbraille/SelfBrailleClient.java',
--- a/mobile/android/base/resources/layout/panel_grid_item_view.xml
+++ b/mobile/android/base/resources/layout/panel_grid_item_view.xml
@@ -1,14 +1,12 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!-- This Source Code Form is subject to the terms of the Mozilla Public
    - License, v. 2.0. If a copy of the MPL was not distributed with this
    - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
 
 <merge xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:gecko="http://schemas.android.com/apk/res-auto">
 
-    <ImageView android:id="@+id/image"
-               android:layout_width="fill_parent"
-               android:layout_height="80dp"
-               android:layout_marginRight="5dp" />
+    <org.mozilla.gecko.widget.SquaredImageView android:id="@+id/image"
+               style="@style/Widget.PanelGridItemImageView" />
 
 </merge>
--- a/mobile/android/base/resources/values-v11/themes.xml
+++ b/mobile/android/base/resources/values-v11/themes.xml
@@ -42,17 +42,18 @@
         <item name="menuItemActionBarStyle">@style/Widget.MenuItemActionBar</item>
         <item name="menuItemActionViewStyle">@style/Widget.MenuItemActionView</item>
         <item name="menuItemDefaultStyle">@style/Widget.MenuItemDefault</item>
         <item name="menuItemSecondaryActionBarStyle">@style/Widget.MenuItemSecondaryActionBar</item>
         <item name="menuItemShareActionButtonStyle">@style/Widget.MenuItemSecondaryActionBar</item>
         <item name="bookmarksListViewStyle">@style/Widget.BookmarksListView</item>
         <item name="topSitesGridItemViewStyle">@style/Widget.TopSitesGridItemView</item>
         <item name="topSitesGridViewStyle">@style/Widget.TopSitesGridView</item>
-        <item name="homeGridViewStyle">@style/Widget.HomeGridView</item>
+        <item name="panelGridViewStyle">@style/Widget.PanelGridView</item>
+        <item name="panelGridItemViewStyle">@style/Widget.PanelGridItemView</item>
         <item name="topSitesThumbnailViewStyle">@style/Widget.TopSitesThumbnailView</item>
         <item name="homeListViewStyle">@style/Widget.HomeListView</item>
         <item name="geckoMenuListViewStyle">@style/Widget.GeckoMenuListView</item>
         <item name="menuItemActionModeStyle">@style/GeckoActionBar.Button</item>
         <item name="android:actionModeStyle">@style/GeckoActionBar</item>
         <item name="android:actionButtonStyle">@style/GeckoActionBar.Button</item>
         <item name="android:actionModeCutDrawable">@drawable/ab_cut</item>
         <item name="android:actionModeCopyDrawable">@drawable/ab_copy</item>
--- a/mobile/android/base/resources/values-xlarge-v11/dimens.xml
+++ b/mobile/android/base/resources/values-xlarge-v11/dimens.xml
@@ -7,10 +7,11 @@
 
     <dimen name="browser_toolbar_height">56dp</dimen>
     <dimen name="remote_tab_child_row_height">56dp</dimen>
     <dimen name="remote_tab_group_row_height">34dp</dimen>
     <dimen name="tabs_counter_size">26sp</dimen>
     <dimen name="tabs_panel_indicator_width">60dp</dimen>
     <dimen name="tabs_panel_list_padding">8dip</dimen>
     <dimen name="history_tab_widget_width">270dp</dimen>
+    <dimen name="panel_grid_view_column_width">250dp</dimen>
 
 </resources>
--- a/mobile/android/base/resources/values/attrs.xml
+++ b/mobile/android/base/resources/values/attrs.xml
@@ -33,16 +33,22 @@
         <attr name="bookmarksListViewStyle" format="reference" />
 
         <!-- Default style for the TopSitesGridItemView -->
         <attr name="topSitesGridItemViewStyle" format="reference" />
 
         <!-- Default style for the HomeGridView -->
         <attr name="homeGridViewStyle" format="reference" />
 
+        <!-- Style for the PanelGridView -->
+        <attr name="panelGridViewStyle" format="reference" />
+
+        <!-- Default style for the PanelGridItemView -->
+        <attr name="panelGridItemViewStyle" format="reference" />
+
         <!-- Default style for the TopSitesGridView -->
         <attr name="topSitesGridViewStyle" format="reference" />
 
         <!-- Default style for the TopSitesThumbnailView -->
         <attr name="topSitesThumbnailViewStyle" format="reference" />
 
         <!-- Default style for the HomeListView -->
         <attr name="homeListViewStyle" format="reference" />
--- a/mobile/android/base/resources/values/colors.xml
+++ b/mobile/android/base/resources/values/colors.xml
@@ -85,10 +85,11 @@
   <color name="url_bar_urltext">#A6A6A6</color>
   <color name="url_bar_domaintext">#000</color>
   <color name="url_bar_domaintext_private">#FFF</color>
   <color name="url_bar_blockedtext">#b14646</color>
   <color name="url_bar_shadow">#12000000</color>
 
   <color name="home_last_tab_bar_bg">#FFF5F7F9</color>
 
+  <color name="panel_grid_item_image_background">#D1D9E1</color>
 </resources>
 
--- a/mobile/android/base/resources/values/dimens.xml
+++ b/mobile/android/base/resources/values/dimens.xml
@@ -96,9 +96,12 @@
     <dimen name="page_action_button_width">32dp</dimen>
 
     <!-- Banner -->
     <dimen name="home_banner_height">72dp</dimen>
 
     <!-- Icon Grid -->
     <dimen name="icongrid_columnwidth">128dp</dimen>
     <dimen name="icongrid_padding">16dp</dimen>
+
+    <!-- PanelGridView dimensions -->
+    <dimen name="panel_grid_view_column_width">180dp</dimen>
 </resources>
--- a/mobile/android/base/resources/values/styles.xml
+++ b/mobile/android/base/resources/values/styles.xml
@@ -140,16 +140,39 @@
 
     <style name="Widget.TopSitesGridItemView">
       <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>
 
+    <style name="Widget.PanelGridView" parent="Widget.GridView">
+        <item name="android:layout_width">fill_parent</item>
+        <item name="android:layout_height">fill_parent</item>
+        <item name="android:paddingTop">0dp</item>
+        <item name="android:stretchMode">columnWidth</item>
+        <item name="android:columnWidth">@dimen/panel_grid_view_column_width</item>
+        <item name="android:horizontalSpacing">2dp</item>
+        <item name="android:verticalSpacing">2dp</item>
+    </style>
+
+    <style name="Widget.PanelGridItemView">
+      <item name="android:layout_height">wrap_content</item>
+      <item name="android:layout_width">wrap_content</item>
+    </style>
+
+    <style name="Widget.PanelGridItemImageView">
+      <item name="android:layout_height">@dimen/panel_grid_view_column_width</item>
+      <item name="android:layout_width">fill_parent</item>
+      <item name="android:scaleType">centerCrop</item>
+      <item name="android:adjustViewBounds">true</item>
+      <item name="android:background">@color/panel_grid_item_image_background</item>
+    </style>
+
     <style name="Widget.BookmarkItemView" parent="Widget.TwoLineRow"/>
 
     <style name="Widget.BookmarksListView" parent="Widget.HomeListView"/>
 
     <style name="Widget.TopSitesThumbnailView">
       <item name="android:padding">0dip</item>
       <item name="android:scaleType">centerCrop</item>
     </style>
--- a/mobile/android/base/resources/values/themes.xml
+++ b/mobile/android/base/resources/values/themes.xml
@@ -75,17 +75,18 @@
         <item name="android:dropDownItemStyle">@style/Widget.DropDownItem</item>
         <item name="android:editTextStyle">@style/Widget.EditText</item>
         <item name="android:gridViewStyle">@style/Widget.GridView</item>
         <item name="android:textViewStyle">@style/Widget.TextView</item>
         <item name="android:spinnerStyle">@style/Widget.Spinner</item>
         <item name="bookmarksListViewStyle">@style/Widget.BookmarksListView</item>
         <item name="topSitesGridItemViewStyle">@style/Widget.TopSitesGridItemView</item>
         <item name="topSitesGridViewStyle">@style/Widget.TopSitesGridView</item>
-        <item name="homeGridViewStyle">@style/Widget.HomeGridView</item>
+        <item name="panelGridViewStyle">@style/Widget.PanelGridView</item>
+        <item name="panelGridItemViewStyle">@style/Widget.PanelGridItemView</item>
         <item name="topSitesThumbnailViewStyle">@style/Widget.TopSitesThumbnailView</item>
         <item name="homeListViewStyle">@style/Widget.HomeListView</item>
         <item name="geckoMenuListViewStyle">@style/Widget.GeckoMenuListView</item>
         <item name="menuItemDefaultStyle">@style/Widget.MenuItemDefault</item>
         <item name="menuItemActionBarStyle">@style/Widget.MenuItemActionBar</item>
         <item name="menuItemActionModeStyle">@style/GeckoActionBar.Button</item>
     </style>
 
new file mode 100644
--- /dev/null
+++ b/mobile/android/base/widget/SquaredImageView.java
@@ -0,0 +1,21 @@
+package org.mozilla.gecko.widget;
+
+import android.content.Context;
+import android.util.AttributeSet;
+import android.widget.ImageView;
+
+final class SquaredImageView extends ImageView {
+    public SquaredImageView(Context context) {
+        super(context);
+    }
+
+    public SquaredImageView(Context context, AttributeSet attrs) {
+        super(context, attrs);
+    }
+
+    @Override
+    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
+        super.onMeasure(widthMeasureSpec, heightMeasureSpec);
+        setMeasuredDimension(getMeasuredWidth(), getMeasuredWidth());
+    }
+}
\ No newline at end of file