Bug 1220928 - Add dividers. draft
authorChenxia Liu <liuche@mozilla.com>
Wed, 09 Mar 2016 17:49:08 -0800
changeset 338843 f4ea24d5e83ae98c0ab2ba8452362256aad4a86f
parent 338842 ddf1088494f20fbe56ab448a237997ea820a3518
child 515865 1a59edae9bafaca8b1d3b41568a7bae135b7e5c1
push id12587
push usercliu@mozilla.com
push dateThu, 10 Mar 2016 01:56:14 +0000
bugs1220928
milestone48.0a1
Bug 1220928 - Add dividers. MozReview-Commit-ID: KYzvrB1YEsA
mobile/android/base/java/org/mozilla/gecko/home/CombinedHistoryPanel.java
mobile/android/base/java/org/mozilla/gecko/home/SearchEngineBar.java
mobile/android/base/resources/values-v11/styles.xml
mobile/android/base/resources/values/dimens.xml
mobile/android/base/resources/values/styles.xml
--- a/mobile/android/base/java/org/mozilla/gecko/home/CombinedHistoryPanel.java
+++ b/mobile/android/base/java/org/mozilla/gecko/home/CombinedHistoryPanel.java
@@ -7,32 +7,35 @@ package org.mozilla.gecko.home;
 
 import android.app.AlertDialog;
 import android.content.ContentResolver;
 import android.content.Context;
 import android.content.DialogInterface;
 import android.database.Cursor;
 import android.os.Bundle;
 import android.support.v4.content.Loader;
+import android.support.v7.widget.DefaultItemAnimator;
+import android.support.v7.widget.RecyclerView;
 import android.util.Log;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
 import android.widget.Button;
 import org.json.JSONException;
 import org.json.JSONObject;
 import org.json.JSONArray;
 import org.mozilla.gecko.GeckoAppShell;
 import org.mozilla.gecko.GeckoEvent;
 import org.mozilla.gecko.GeckoProfile;
 import org.mozilla.gecko.R;
 import org.mozilla.gecko.Telemetry;
 import org.mozilla.gecko.TelemetryContract;
 import org.mozilla.gecko.db.BrowserDB;
 import org.mozilla.gecko.db.RemoteClient;
+import org.mozilla.gecko.widget.DividerItemDecoration;
 
 import java.util.Iterator;
 import java.util.List;
 
 public class CombinedHistoryPanel extends HomeFragment {
     private static final String LOGTAG = "GeckoCombinedHistoryPnl";
     private final int LOADER_ID_HISTORY = 0;
     private final int LOADER_ID_REMOTE = 1;
@@ -59,16 +62,18 @@ public class CombinedHistoryPanel extend
 
     @Override
     public void onViewCreated(View view, Bundle savedInstanceState) {
         super.onViewCreated(view, savedInstanceState);
 
         mRecyclerView = (CombinedHistoryRecyclerView) view.findViewById(R.id.combined_recycler_view);
         mAdapter = new CombinedHistoryAdapter();
         mRecyclerView.setAdapter(mAdapter);
+        mRecyclerView.setItemAnimator(new DefaultItemAnimator());
+        mRecyclerView.addItemDecoration(new DividerItemDecoration(getContext()));
         mRecyclerView.setOnHistoryClickedListener(mUrlOpenListener);
         mRecyclerView.setOnPanelLevelChangeListener(new OnLevelChangeListener());
 //            mRangeList = (HomeListView) view.findViewById(R.id.range_list);
 //            mList.setTag(HomePager.LIST_TAG_HISTORY);
         mPanelFooterButton = (Button) view.findViewById(R.id.clear_history_button);
         mPanelFooterButton.setOnClickListener(new OnFooterButtonClickListener());
         // TODO: Check if history is empty
         mPanelFooterButton.setVisibility(View.VISIBLE);
--- a/mobile/android/base/java/org/mozilla/gecko/home/SearchEngineBar.java
+++ b/mobile/android/base/java/org/mozilla/gecko/home/SearchEngineBar.java
@@ -27,17 +27,16 @@ import org.mozilla.gecko.widget.Recycler
 import java.util.List;
 
 public class SearchEngineBar extends RecyclerView
         implements RecyclerViewClickSupport.OnItemClickListener {
     private static final String LOGTAG = SearchEngineBar.class.getSimpleName();
 
     private static final float ICON_CONTAINER_MIN_WIDTH_DP = 72;
     private static final float LABEL_CONTAINER_WIDTH_DP = 48;
-    private static final float DIVIDER_HEIGHT_DP = 1;
 
     public interface OnSearchBarClickListener {
         void onSearchBarClickListener(SearchEngine searchEngine);
     }
 
     private final SearchEngineAdapter mAdapter;
     private final LinearLayoutManager mLayoutManager;
     private final Paint mDividerPaint;
@@ -53,18 +52,17 @@ public class SearchEngineBar extends Rec
 
         mDividerPaint = new Paint();
         mDividerPaint.setColor(ContextCompat.getColor(context, R.color.toolbar_divider_grey));
         mDividerPaint.setStyle(Paint.Style.FILL_AND_STROKE);
 
         final DisplayMetrics displayMetrics = getResources().getDisplayMetrics();
         mMinIconContainerWidth = TypedValue.applyDimension(
                 TypedValue.COMPLEX_UNIT_DIP, ICON_CONTAINER_MIN_WIDTH_DP, displayMetrics);
-        mDividerHeight = TypedValue.applyDimension(
-                TypedValue.COMPLEX_UNIT_DIP, DIVIDER_HEIGHT_DP, displayMetrics);
+        mDividerHeight = context.getResources().getDimension(R.dimen.page_row_divider_height);
         mLabelContainerWidth = Math.round(TypedValue.applyDimension(
                 TypedValue.COMPLEX_UNIT_DIP, LABEL_CONTAINER_WIDTH_DP, displayMetrics));
 
         mIconContainerWidth = Math.round(mMinIconContainerWidth);
 
         mAdapter = new SearchEngineAdapter(context);
         mAdapter.setIconContainerWidth(mIconContainerWidth);
         mLayoutManager = new LinearLayoutManager(context);
--- a/mobile/android/base/resources/values-v11/styles.xml
+++ b/mobile/android/base/resources/values-v11/styles.xml
@@ -56,17 +56,17 @@
     <style name="ActionBar.TabsLayout">
          <item name="android:visibility">gone</item>
     </style>
 
     <!-- DropDown List View -->
     <style name="DropDownListView" parent="@android:style/Widget.Holo.ListView.DropDown">
          <item name="android:listSelector">@drawable/action_bar_button</item>
          <item name="android:divider">@color/toolbar_divider_grey</item>
-         <item name="android:dividerHeight">1dp</item>
+         <item name="android:dividerHeight">@dimen/page_row_divider_height</item>
     </style>
 
     <!-- Spinner DropDown Item -->
     <style name="Widget.DropDownItem.Spinner" parent="@android:style/Widget.Holo.Light.DropDownItem.Spinner">
          <item name="android:textColor">#FF000000</item>
     </style>
 
     <style name="Widget.Spinner" parent="android:style/Widget.Holo.Light.Spinner">
--- a/mobile/android/base/resources/values/dimens.xml
+++ b/mobile/android/base/resources/values/dimens.xml
@@ -81,16 +81,17 @@
 
     <dimen name="page_row_edge_padding">16dp</dimen>
 
     <!-- Regular page row on about:home -->
     <dimen name="page_row_height">64dp</dimen>
 
     <!-- Group/heading page row on about:home -->
     <dimen name="page_group_height">56dp</dimen>
+    <dimen name="page_row_divider_height">1dp</dimen>
 
     <!-- Reading list row on about:home -->
     <dimen name="reading_list_row_height">128dp</dimen>
     <dimen name="reading_list_row_padding_right">10dp</dimen>
 
     <!-- Remote Tabs static view top padding. Less in landscape on phones. -->
     <dimen name="home_remote_tabs_top_padding">48dp</dimen>
 
--- a/mobile/android/base/resources/values/styles.xml
+++ b/mobile/android/base/resources/values/styles.xml
@@ -41,17 +41,17 @@
     </style>
 
     <style name="Widget.TextView" parent="Widget.BaseTextView">
         <item name="android:textAppearance">@style/TextAppearance.Widget.TextView</item>
     </style>
 
     <style name="Widget.ListView" parent="Widget.BaseListView">
         <item name="android:divider">@color/toolbar_divider_grey</item>
-        <item name="android:dividerHeight">1dp</item>
+        <item name="android:dividerHeight">@dimen/page_row_divider_height</item>
         <item name="android:cacheColorHint">@android:color/transparent</item>
         <item name="android:listSelector">@drawable/action_bar_button</item>
     </style>
 
     <style name="Widget.ExpandableListView" parent="Widget.ListView">
         <item name="android:groupIndicator">@android:color/transparent</item>
     </style>