diff --git a/res/drawable/selectable_card.xml b/res/drawable/selectable_card.xml
new file mode 100644
index 00000000000..554b9f6778c
--- /dev/null
+++ b/res/drawable/selectable_card.xml
@@ -0,0 +1,21 @@
+
+
+
+
+
+
diff --git a/res/layout/dashboard.xml b/res/layout/dashboard.xml
index 0563fc00c3b..ae5be68dd30 100644
--- a/res/layout/dashboard.xml
+++ b/res/layout/dashboard.xml
@@ -14,24 +14,13 @@
limitations under the License.
-->
-
-
-
-
-
+ android:paddingStart="@dimen/dashboard_padding_start"
+ android:paddingEnd="@dimen/dashboard_padding_end"
+ android:paddingTop="@dimen/dashboard_padding_top"
+ android:paddingBottom="@dimen/dashboard_padding_bottom"
+ android:clipToPadding="false" />
diff --git a/res/layout/dashboard_category.xml b/res/layout/dashboard_category.xml
index bee063e6eb3..9109440431e 100644
--- a/res/layout/dashboard_category.xml
+++ b/res/layout/dashboard_category.xml
@@ -21,11 +21,16 @@
android:paddingStart="@dimen/dashboard_category_padding_start"
android:paddingEnd="@dimen/dashboard_category_padding_end"
android:orientation="vertical"
+ android:paddingBottom="8dip"
android:background="@color/card_background"
- android:layout_marginBottom="8dip"
- android:elevation="@dimen/dashboard_category_elevation">
+ android:elevation="@dimen/dashboard_category_elevation" >
-
+
+
-
-
diff --git a/res/layout/dashboard_spacer.xml b/res/layout/dashboard_spacer.xml
new file mode 100644
index 00000000000..d7d9717b3d6
--- /dev/null
+++ b/res/layout/dashboard_spacer.xml
@@ -0,0 +1,19 @@
+
+
+
+
diff --git a/res/layout/dashboard_tile.xml b/res/layout/dashboard_tile.xml
index aa1d00e1414..d1625c7e68c 100644
--- a/res/layout/dashboard_tile.xml
+++ b/res/layout/dashboard_tile.xml
@@ -19,10 +19,13 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
- android:minHeight="@dimen/dashboard_tile_minimum_height">
+ android:minHeight="@dimen/dashboard_tile_minimum_height"
+ android:clickable="true"
+ android:background="@drawable/selectable_card"
+ android:elevation="@dimen/dashboard_category_elevation" >
-
-
-
-
-
\ No newline at end of file
+
diff --git a/res/layout/see_all.xml b/res/layout/see_all.xml
new file mode 100644
index 00000000000..fff4d076ad7
--- /dev/null
+++ b/res/layout/see_all.xml
@@ -0,0 +1,65 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/res/values/strings.xml b/res/values/strings.xml
index df4d7a4dda6..f9a8feeb2b0 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -6989,4 +6989,9 @@
Custom (%d)
+
+
+ See all
+
+ See less
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 8b400efbec3..87e51031ab8 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -299,7 +299,7 @@
diff --git a/src/com/android/settings/dashboard/DashboardSummary.java b/src/com/android/settings/dashboard/DashboardSummary.java
index a771400f5b5..c376d20ccaa 100644
--- a/src/com/android/settings/dashboard/DashboardSummary.java
+++ b/src/com/android/settings/dashboard/DashboardSummary.java
@@ -20,11 +20,11 @@ import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
-import android.content.res.Resources;
-import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
+import android.support.v7.widget.LinearLayoutManager;
+import android.support.v7.widget.RecyclerView;
import android.text.TextUtils;
import android.util.Log;
import android.util.TypedValue;
@@ -35,43 +35,39 @@ import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
-
import com.android.internal.logging.MetricsLogger;
+import com.android.internal.util.ArrayUtils;
import com.android.settings.HelpUtils;
import com.android.settings.InstrumentedFragment;
import com.android.settings.R;
+import com.android.settings.Settings;
import com.android.settings.SettingsActivity;
import com.android.settingslib.drawer.DashboardCategory;
import com.android.settingslib.drawer.DashboardTile;
+import java.util.ArrayList;
import java.util.List;
public class DashboardSummary extends InstrumentedFragment {
- private static final String LOG_TAG = "DashboardSummary";
+ private static final boolean DEBUG = true;
+ private static final String TAG = "DashboardSummary";
- private LayoutInflater mLayoutInflater;
- private ViewGroup mDashboard;
-
- private static final int MSG_REBUILD_UI = 1;
- private Handler mHandler = new Handler() {
- @Override
- public void handleMessage(Message msg) {
- switch (msg.what) {
- case MSG_REBUILD_UI: {
- final Context context = getActivity();
- rebuildUI(context);
- } break;
- }
- }
+ public static final String[] INITIAL_ITEMS = new String[] {
+ Settings.WifiSettingsActivity.class.getName(),
+ Settings.DataUsageSummaryActivity.class.getName(),
+ Settings.PowerUsageSummaryActivity.class.getName(),
+ Settings.ManageApplicationsActivity.class.getName(),
+ Settings.StorageSettingsActivity.class.getName(),
+ Settings.DisplaySettingsActivity.class.getName(),
+ Settings.NotificationSettingsActivity.class.getName(),
};
- private class HomePackageReceiver extends BroadcastReceiver {
- @Override
- public void onReceive(Context context, Intent intent) {
- rebuildUI(context);
- }
- }
- private HomePackageReceiver mHomePackageReceiver = new HomePackageReceiver();
+ private static final int MSG_REBUILD_UI = 1;
+
+ private final HomePackageReceiver mHomePackageReceiver = new HomePackageReceiver();
+
+ private RecyclerView mDashboard;
+ private DashboardAdapter mAdapter;
@Override
protected int getMetricsCategory() {
@@ -117,95 +113,33 @@ public class DashboardSummary extends InstrumentedFragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
+ return inflater.inflate(R.layout.dashboard, container, false);
+ }
- mLayoutInflater = inflater;
+ @Override
+ public void onViewCreated(View view, Bundle bundle) {
+ mDashboard = (RecyclerView) view.findViewById(R.id.dashboard_container);
+ LinearLayoutManager llm = new LinearLayoutManager(getContext());
+ llm.setOrientation(LinearLayoutManager.VERTICAL);
+ mDashboard.setLayoutManager(llm);
+ mDashboard.setHasFixedSize(true);
- final View rootView = inflater.inflate(R.layout.dashboard, container, false);
- mDashboard = (ViewGroup) rootView.findViewById(R.id.dashboard_container);
-
- return rootView;
+ rebuildUI(getContext());
}
private void rebuildUI(Context context) {
if (!isAdded()) {
- Log.w(LOG_TAG, "Cannot build the DashboardSummary UI yet as the Fragment is not added");
+ Log.w(TAG, "Cannot build the DashboardSummary UI yet as the Fragment is not added");
return;
}
long start = System.currentTimeMillis();
- final Resources res = getResources();
+ mAdapter = new DashboardAdapter(getContext(),
+ ((SettingsActivity) getActivity()).getDashboardCategories(true));
+ mDashboard.setAdapter(mAdapter);
- mDashboard.removeAllViews();
-
- List categories =
- ((SettingsActivity) context).getDashboardCategories(true);
-
- final int count = categories.size();
-
- for (int n = 0; n < count; n++) {
- DashboardCategory category = categories.get(n);
-
- View categoryView = mLayoutInflater.inflate(R.layout.dashboard_category, mDashboard,
- false);
-
- TextView categoryLabel = (TextView) categoryView.findViewById(R.id.category_title);
- categoryLabel.setText(category.title);
-
- ViewGroup categoryContent =
- (ViewGroup) categoryView.findViewById(R.id.category_content);
-
- final int tilesCount = category.getTilesCount();
- for (int i = 0; i < tilesCount; i++) {
- DashboardTile tile = category.getTile(i);
-
- DashboardTileView tileView = new DashboardTileView(context);
- updateTileView(context, res, tile, tileView.getImageView(),
- tileView.getTitleTextView(), tileView.getStatusTextView());
-
- tileView.setTile(tile);
-
- categoryContent.addView(tileView);
- }
-
- // Add the category
- mDashboard.addView(categoryView);
- }
long delta = System.currentTimeMillis() - start;
- Log.d(LOG_TAG, "rebuildUI took: " + delta + " ms");
- }
-
- private void updateTileView(Context context, Resources res, DashboardTile tile,
- ImageView tileIcon, TextView tileTextView, TextView statusTextView) {
-
- if (tile.icon != null) {
- if (!TextUtils.isEmpty(tile.icon.getResPackage())) {
- Drawable drawable = tile.icon.loadDrawable(context);
- if (!tile.icon.getResPackage().equals(context.getPackageName())
- && drawable != null) {
- // If this drawable is coming from outside Settings, tint it to match the color.
- TypedValue tintColor = new TypedValue();
- context.getTheme().resolveAttribute(com.android.internal.R.attr.colorAccent,
- tintColor, true);
- drawable.setTint(tintColor.data);
- }
- tileIcon.setImageDrawable(drawable);
- } else {
- tileIcon.setImageIcon(tile.icon);
- }
- } else {
- tileIcon.setImageDrawable(null);
- tileIcon.setBackground(null);
- }
-
- tileTextView.setText(tile.title);
-
- CharSequence summary = tile.summary;
- if (!TextUtils.isEmpty(summary)) {
- statusTextView.setVisibility(View.VISIBLE);
- statusTextView.setText(summary);
- } else {
- statusTextView.setVisibility(View.GONE);
- }
+ Log.d(TAG, "rebuildUI took: " + delta + " ms");
}
private void sendRebuildUI() {
@@ -213,4 +147,178 @@ public class DashboardSummary extends InstrumentedFragment {
mHandler.sendEmptyMessage(MSG_REBUILD_UI);
}
}
+
+ private Handler mHandler = new Handler() {
+ @Override
+ public void handleMessage(Message msg) {
+ switch (msg.what) {
+ case MSG_REBUILD_UI: {
+ final Context context = getActivity();
+ rebuildUI(context);
+ } break;
+ }
+ }
+ };
+
+ private class HomePackageReceiver extends BroadcastReceiver {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ rebuildUI(context);
+ }
+ }
+
+ private static class DashboardItemHolder extends RecyclerView.ViewHolder {
+ private final ImageView icon;
+ private final TextView title;
+ private final TextView summary;
+
+ public DashboardItemHolder(View itemView) {
+ super(itemView);
+ icon = (ImageView) itemView.findViewById(android.R.id.icon);
+ title = (TextView) itemView.findViewById(android.R.id.title);
+ summary = (TextView) itemView.findViewById(android.R.id.summary);
+ }
+ }
+
+ private static class DashboardAdapter extends RecyclerView.Adapter {
+
+ private final List