+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2014 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@+id/category"
- android:layout_width="match_parent"
- android:layout_height="@dimen/dashboard_category_height"
- android:orientation="vertical"
- android:paddingBottom="8dip">
-
- <TextView android:id="@android:id/title"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:paddingStart="@dimen/dashboard_category_title_margin_start"
- android:singleLine="true"
- android:ellipsize="marquee"
- android:gravity="center_vertical"
- android:textAppearance="@style/TextAppearance.CategoryTitle"
- android:textAlignment="viewStart"
- />
-
-</LinearLayout>
<!-- Dashboard category layout height -->
<dimen name="dashboard_category_height">48dp</dimen>
- <!-- Dashboard category title margin start -->
- <dimen name="dashboard_category_title_margin_start">16dp</dimen>
-
<!-- Dashboard tile minimum height -->
<dimen name="dashboard_tile_minimum_height">72dp</dimen>
case R.layout.dashboard_header_spacer:
onBindHeaderSpacer(holder, position);
break;
- case R.layout.dashboard_category:
- onBindCategory(holder,
- (DashboardCategory) mDashboardData.getItemEntityByPosition(position));
- break;
case R.layout.dashboard_tile:
final Tile tile = (Tile) mDashboardData.getItemEntityByPosition(position);
onBindTile(holder, tile);
import android.annotation.IntDef;
import android.graphics.drawable.Icon;
import android.support.annotation.Nullable;
-import android.support.annotation.VisibleForTesting;
import android.support.v7.util.DiffUtil;
import android.text.TextUtils;
tile.remoteViews != null
? R.layout.suggestion_tile_card
: R.layout.suggestion_tile,
- Objects.hash(tile.title),
- false));
+ Objects.hash(tile.title)));
}
mId++;
}
resetCount();
for (int i = 0; mCategories != null && i < mCategories.size(); i++) {
DashboardCategory category = mCategories.get(i);
- countItem(category, R.layout.dashboard_category,
- !TextUtils.isEmpty(category.title), NS_ITEMS);
for (int j = 0; j < category.tiles.size(); j++) {
Tile tile = category.tiles.get(j);
countItem(tile, R.layout.dashboard_tile, true, NS_ITEMS);
*/
private static class Item {
// valid types in field type
- private static final int TYPE_DASHBOARD_CATEGORY = R.layout.dashboard_category;
private static final int TYPE_DASHBOARD_TILE = R.layout.dashboard_tile;
@Deprecated
private static final int TYPE_SUGGESTION_HEADER = R.layout.suggestion_header;
R.layout.suggestion_condition_footer;
private static final int TYPE_DASHBOARD_SPACER = R.layout.dashboard_spacer;
- @IntDef({TYPE_DASHBOARD_CATEGORY, TYPE_DASHBOARD_TILE, TYPE_SUGGESTION_HEADER,
+ @IntDef({TYPE_DASHBOARD_TILE, TYPE_SUGGESTION_HEADER,
TYPE_SUGGESTION_TILE, TYPE_SUGGESTION_CONDITION_CONTAINER,
TYPE_SUGGESTION_CONDITION_HEADER, TYPE_CONDITION_CARD,
TYPE_SUGGESTION_CONDITION_FOOTER, TYPE_DASHBOARD_SPACER})
public @interface ItemTypes{}
/**
- * The main data object in item, usually is a {@link Tile}, {@link Condition} or
- * {@link DashboardCategory} object. This object can also be null when the
+ * The main data object in item, usually is a {@link Tile}, {@link Condition}
+ * object. This object can also be null when the
* item is an divider line. Please refer to {@link #buildItemsData()} for
* detail usage of the Item.
*/
}
switch (type) {
- case TYPE_DASHBOARD_CATEGORY:
- // Only check title for dashboard category
- return TextUtils.equals(((DashboardCategory) entity).title,
- ((DashboardCategory) targetItem.entity).title);
case TYPE_DASHBOARD_TILE:
final Tile localTile = (Tile) entity;
final Tile targetTile = (Tile) targetItem.entity;
import android.support.v7.widget.RecyclerView.ViewHolder;
import android.util.TypedValue;
import android.view.View;
+
import com.android.settings.R;
public class DashboardDecorator extends RecyclerView.ItemDecoration {
for (int i = 1; i < childCount; i++) {
final View child = parent.getChildAt(i);
final ViewHolder holder = parent.getChildViewHolder(child);
- if (holder.getItemViewType() == R.layout.dashboard_category) {
- if (parent.getChildViewHolder(parent.getChildAt(i - 1)).getItemViewType()
- != R.layout.dashboard_tile) {
- continue;
- }
- } else if (holder.getItemViewType() != R.layout.condition_card) {
+ if (holder.getItemViewType() != R.layout.condition_card) {
continue;
}
import android.support.annotation.NonNull;
import android.support.v7.util.DiffUtil;
import android.support.v7.util.ListUpdateCallback;
+
import com.android.settings.TestConfig;
import com.android.settings.dashboard.conditional.AirplaneModeCondition;
import com.android.settings.dashboard.conditional.Condition;
import com.android.settingslib.drawer.DashboardCategory;
import com.android.settingslib.drawer.Tile;
+
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
public void testBuildItemsData_containsAllData() {
final DashboardData.SuggestionConditionHeaderData data =
new DashboardData.SuggestionConditionHeaderData(
- mDashboardDataWithOneConditions.getConditions(), 0);
+ mDashboardDataWithOneConditions.getConditions(), 0);
final Object[] expectedObjects = {null, data,
- mDashboardDataWithOneConditions.getSuggestions(),
- mDashboardDataWithOneConditions.getConditions(),
- null, mDashboardCategory, mTestCategoryTile};
+ mDashboardDataWithOneConditions.getSuggestions(),
+ mDashboardDataWithOneConditions.getConditions(),
+ null, mTestCategoryTile};
final int expectedSize = expectedObjects.length;
- assertThat(mDashboardDataWithOneConditions.getItemList().size())
- .isEqualTo(expectedSize);
+ assertThat(mDashboardDataWithOneConditions.getItemList()).hasSize(expectedSize);
+
for (int i = 0; i < expectedSize; i++) {
final Object item = mDashboardDataWithOneConditions.getItemEntityByPosition(i);
if (item instanceof DashboardData.SuggestionHeaderData
//Build testResultData
final List<ListUpdateResult.ResultData> testResultData = new ArrayList<>();
testResultData.add(new ListUpdateResult.ResultData(
- ListUpdateResult.ResultData.TYPE_OPERATION_REMOVE, 1, 6));
+ ListUpdateResult.ResultData.TYPE_OPERATION_REMOVE, 1, 5));
testDiffUtil(mDashboardDataWithOneConditions, mDashboardDataWithNoItems, testResultData);
}