Update spacing and background color for condition/suggestion.
- changed suggestion/condition and searchbox background color to #F2F2F2 - changed condition card background color to #F8F8F8 - removed Suggestion header - reduced space above condition header/footer by 9dp Fix: 63393599 Test: visual Change-Id: I4317781c93e23c6d019928b9fe9af16177f81c07 Merged-In: I268934e3a573b542480c0b21dbab68b7217295b5
This commit is contained in:
@@ -19,7 +19,7 @@
|
|||||||
android:id="@+id/content"
|
android:id="@+id/content"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:background="?android:attr/colorSecondary"
|
android:background="@color/condition_card_background"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
@@ -24,7 +24,7 @@
|
|||||||
<FrameLayout
|
<FrameLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:background="@color/material_grey_300">
|
android:background="@color/suggestion_condition_background">
|
||||||
<android.support.v7.widget.CardView
|
<android.support.v7.widget.CardView
|
||||||
android:id="@+id/search_bar"
|
android:id="@+id/search_bar"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
@@ -25,7 +25,7 @@
|
|||||||
<FrameLayout
|
<FrameLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:background="@color/material_grey_300">
|
android:background="@color/suggestion_condition_background">
|
||||||
<android.support.v7.widget.CardView
|
<android.support.v7.widget.CardView
|
||||||
android:id="@+id/search_bar"
|
android:id="@+id/search_bar"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
@@ -19,15 +19,16 @@
|
|||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
style="@style/SuggestionConditionStyle"
|
style="@style/SuggestionConditionStyle"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="56dp"
|
android:layout_height="44dp"
|
||||||
|
android:paddingTop="4dp"
|
||||||
|
android:paddingEnd="16dp"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
android:gravity="center|end">
|
android:gravity="end">
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/collapse_button"
|
android:id="@+id/collapse_button"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="wrap_content"
|
||||||
android:padding="16dp"
|
|
||||||
android:src="@drawable/ic_expand_less"/>
|
android:src="@drawable/ic_expand_less"/>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
@@ -15,11 +15,21 @@
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<RelativeLayout
|
<LinearLayout
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
style="@style/SuggestionConditionStyle"
|
style="@style/SuggestionConditionStyle"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="56dp"
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<Space
|
||||||
|
android:id="@+id/top_space"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="9dp"/>
|
||||||
|
|
||||||
|
<RelativeLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="35dp"
|
||||||
android:layout_centerHorizontal="true">
|
android:layout_centerHorizontal="true">
|
||||||
|
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
@@ -38,7 +48,9 @@
|
|||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_alignParentEnd="true"
|
android:layout_alignParentEnd="true"
|
||||||
android:padding="16dp"
|
android:paddingTop="4dp"
|
||||||
|
android:paddingStart="16dp"
|
||||||
|
android:paddingEnd="16dp"
|
||||||
android:src="@drawable/ic_expand_more"/>
|
android:src="@drawable/ic_expand_more"/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
@@ -74,3 +86,9 @@
|
|||||||
android:gravity="center_vertical"/>
|
android:gravity="center_vertical"/>
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
|
<Space
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="12dp"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
@@ -112,4 +112,8 @@
|
|||||||
|
|
||||||
<!-- The fallback color for tinting icons. Only used when colorControlNormal is unavailable -->
|
<!-- The fallback color for tinting icons. Only used when colorControlNormal is unavailable -->
|
||||||
<color name="fallback_tintColor">#89000000</color>
|
<color name="fallback_tintColor">#89000000</color>
|
||||||
|
|
||||||
|
<!-- Suggestion/condition colors -->
|
||||||
|
<color name="suggestion_condition_background">#f2f2f2</color>
|
||||||
|
<color name="condition_card_background">#f8f8f8</color>
|
||||||
</resources>
|
</resources>
|
||||||
|
@@ -456,7 +456,7 @@
|
|||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="SuggestionConditionStyle">
|
<style name="SuggestionConditionStyle">
|
||||||
<item name="android:background">@color/material_grey_300</item>
|
<item name="android:background">@color/suggestion_condition_background</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="TextAppearance.SearchBar" parent="@android:style/TextAppearance.Material.Widget.Toolbar.Subtitle">
|
<style name="TextAppearance.SearchBar" parent="@android:style/TextAppearance.Material.Widget.Toolbar.Subtitle">
|
||||||
|
@@ -34,6 +34,7 @@ import android.view.View;
|
|||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
|
import android.widget.Space;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
||||||
@@ -267,27 +268,9 @@ public class DashboardAdapter extends RecyclerView.Adapter<DashboardAdapter.Dash
|
|||||||
(SuggestionAndConditionContainerHolder) holder, position);
|
(SuggestionAndConditionContainerHolder) holder, position);
|
||||||
break;
|
break;
|
||||||
case R.layout.suggestion_condition_header:
|
case R.layout.suggestion_condition_header:
|
||||||
/* There are 2 different headers for the suggestions/conditions section. To minimize
|
|
||||||
visual animation when expanding and collapsing the suggestions/conditions, we are
|
|
||||||
using the same layout to represent the 2 headers:
|
|
||||||
1. Suggestion header - when there is any suggestion shown, the suggestion header
|
|
||||||
will be the first item on the section. It only has the text "Suggestion", and
|
|
||||||
do nothing when clicked. This header will not be shown when the section is
|
|
||||||
collapsed, in which case, the SuggestionCondition header will be
|
|
||||||
shown instead to show the summary info.
|
|
||||||
2. SuggestionCondition header - the header that shows the summary info for the
|
|
||||||
suggestion/condition that is currently hidden. It has the expand button to
|
|
||||||
expand the section. */
|
|
||||||
if (mDashboardData.getDisplayableSuggestionCount() > 0
|
|
||||||
&& position == SUGGESTION_CONDITION_HEADER_POSITION
|
|
||||||
&& mDashboardData.getSuggestionConditionMode()
|
|
||||||
!= DashboardData.HEADER_MODE_COLLAPSED) {
|
|
||||||
onBindSuggestionHeader((SuggestionAndConditionHeaderHolder) holder);
|
|
||||||
} else {
|
|
||||||
onBindSuggestionConditionHeader((SuggestionAndConditionHeaderHolder) holder,
|
onBindSuggestionConditionHeader((SuggestionAndConditionHeaderHolder) holder,
|
||||||
(SuggestionConditionHeaderData)
|
(SuggestionConditionHeaderData)
|
||||||
mDashboardData.getItemEntityByPosition(position));
|
mDashboardData.getItemEntityByPosition(position));
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case R.layout.suggestion_condition_footer:
|
case R.layout.suggestion_condition_footer:
|
||||||
holder.itemView.setOnClickListener(v -> {
|
holder.itemView.setOnClickListener(v -> {
|
||||||
@@ -374,17 +357,6 @@ public class DashboardAdapter extends RecyclerView.Adapter<DashboardAdapter.Dash
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onBindSuggestionHeader(final SuggestionAndConditionHeaderHolder holder) {
|
|
||||||
holder.title.setText(R.string.suggestions_title);
|
|
||||||
holder.title.setTextColor(Color.BLACK);
|
|
||||||
holder.icon.setVisibility(View.INVISIBLE);
|
|
||||||
holder.icons.removeAllViews();
|
|
||||||
holder.icons.setVisibility(View.INVISIBLE);
|
|
||||||
holder.summary.setVisibility(View.INVISIBLE);
|
|
||||||
holder.expandIndicator.setVisibility(View.INVISIBLE);
|
|
||||||
holder.itemView.setOnClickListener(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
void onBindSuggestionConditionHeader(final SuggestionAndConditionHeaderHolder holder,
|
void onBindSuggestionConditionHeader(final SuggestionAndConditionHeaderHolder holder,
|
||||||
SuggestionConditionHeaderData data) {
|
SuggestionConditionHeaderData data) {
|
||||||
@@ -444,8 +416,12 @@ public class DashboardAdapter extends RecyclerView.Adapter<DashboardAdapter.Dash
|
|||||||
} else {
|
} else {
|
||||||
holder.summary.setText(null);
|
holder.summary.setText(null);
|
||||||
}
|
}
|
||||||
holder.summary.setVisibility(View.VISIBLE);
|
|
||||||
holder.expandIndicator.setVisibility(View.VISIBLE);
|
if (curMode == DashboardData.HEADER_MODE_COLLAPSED) {
|
||||||
|
holder.topSpace.setVisibility(View.VISIBLE);
|
||||||
|
} else {
|
||||||
|
holder.topSpace.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
|
||||||
holder.itemView.setOnClickListener(v -> {
|
holder.itemView.setOnClickListener(v -> {
|
||||||
if (moreSuggestions ) {
|
if (moreSuggestions ) {
|
||||||
@@ -468,9 +444,9 @@ public class DashboardAdapter extends RecyclerView.Adapter<DashboardAdapter.Dash
|
|||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
void onBindConditionAndSuggestion(final SuggestionAndConditionContainerHolder holder,
|
void onBindConditionAndSuggestion(final SuggestionAndConditionContainerHolder holder,
|
||||||
int position) {
|
int position) {
|
||||||
// If there is suggestions to show, it will be at position 1
|
// If there is suggestions to show, it will be at position 0 as we don't show the suggestion
|
||||||
// position 0 is suggestion header.
|
// header anymore.
|
||||||
if (position == (SUGGESTION_CONDITION_HEADER_POSITION + 1)
|
if (position == (SUGGESTION_CONDITION_HEADER_POSITION)
|
||||||
&& mDashboardData.getSuggestions() != null) {
|
&& mDashboardData.getSuggestions() != null) {
|
||||||
mSuggestionAdapter = new SuggestionAdapter(mContext, (List<Tile>)
|
mSuggestionAdapter = new SuggestionAdapter(mContext, (List<Tile>)
|
||||||
mDashboardData.getItemEntityByPosition(position), mSuggestionsShownLogged);
|
mDashboardData.getItemEntityByPosition(position), mSuggestionsShownLogged);
|
||||||
@@ -572,11 +548,13 @@ public class DashboardAdapter extends RecyclerView.Adapter<DashboardAdapter.Dash
|
|||||||
public static class SuggestionAndConditionHeaderHolder extends DashboardItemHolder {
|
public static class SuggestionAndConditionHeaderHolder extends DashboardItemHolder {
|
||||||
public final LinearLayout icons;
|
public final LinearLayout icons;
|
||||||
public final ImageView expandIndicator;
|
public final ImageView expandIndicator;
|
||||||
|
public final Space topSpace;
|
||||||
|
|
||||||
public SuggestionAndConditionHeaderHolder(View itemView) {
|
public SuggestionAndConditionHeaderHolder(View itemView) {
|
||||||
super(itemView);
|
super(itemView);
|
||||||
icons = itemView.findViewById(id.additional_icons);
|
icons = itemView.findViewById(id.additional_icons);
|
||||||
expandIndicator = itemView.findViewById(id.expand_indicator);
|
expandIndicator = itemView.findViewById(id.expand_indicator);
|
||||||
|
topSpace = itemView.findViewById(id.top_space);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -228,12 +228,14 @@ public class DashboardData {
|
|||||||
hasSuggestions ? sizeOf(mSuggestions) - sizeOf(suggestions) : 0;
|
hasSuggestions ? sizeOf(mSuggestions) - sizeOf(suggestions) : 0;
|
||||||
|
|
||||||
resetCount();
|
resetCount();
|
||||||
/* Top suggestion/condition header. This will be present when there is any suggestion or
|
/* Top suggestion/condition header. This will be present when there is any suggestion
|
||||||
* condition to show, except in the case that there is only conditions to show and the
|
* and the mode is collapsed, or it only has conditions and the mode is not fully
|
||||||
* mode is fully expanded. */
|
* expanded. */
|
||||||
countItem(new SuggestionConditionHeaderData(conditions, hiddenSuggestion),
|
countItem(new SuggestionConditionHeaderData(conditions, hiddenSuggestion),
|
||||||
R.layout.suggestion_condition_header, hasSuggestions
|
R.layout.suggestion_condition_header,
|
||||||
|| hasConditions && mSuggestionConditionMode != HEADER_MODE_FULLY_EXPANDED,
|
hasSuggestions && mSuggestionConditionMode == HEADER_MODE_COLLAPSED
|
||||||
|
|| !hasSuggestions && hasConditions
|
||||||
|
&& mSuggestionConditionMode != HEADER_MODE_FULLY_EXPANDED,
|
||||||
NS_SUGGESTION_CONDITION);
|
NS_SUGGESTION_CONDITION);
|
||||||
|
|
||||||
/* Suggestion container. This is the card view that contains the list of suggestions.
|
/* Suggestion container. This is the card view that contains the list of suggestions.
|
||||||
|
@@ -386,7 +386,7 @@ public class DashboardAdapterTest {
|
|||||||
new DashboardAdapter.SuggestionAndConditionContainerHolder(itemView);
|
new DashboardAdapter.SuggestionAndConditionContainerHolder(itemView);
|
||||||
|
|
||||||
mDashboardAdapter.onBindConditionAndSuggestion(
|
mDashboardAdapter.onBindConditionAndSuggestion(
|
||||||
holder, DashboardAdapter.SUGGESTION_CONDITION_HEADER_POSITION + 1);
|
holder, DashboardAdapter.SUGGESTION_CONDITION_HEADER_POSITION);
|
||||||
|
|
||||||
verify(data).setAdapter(any(SuggestionAdapter.class));
|
verify(data).setAdapter(any(SuggestionAdapter.class));
|
||||||
// should not crash
|
// should not crash
|
||||||
|
@@ -112,10 +112,7 @@ public class DashboardDataTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testBuildItemsData_containsAllData() {
|
public void testBuildItemsData_containsAllData() {
|
||||||
final DashboardData.SuggestionConditionHeaderData data =
|
final Object[] expectedObjects = {
|
||||||
new DashboardData.SuggestionConditionHeaderData(
|
|
||||||
mDashboardDataWithOneConditions.getConditions(), 0);
|
|
||||||
final Object[] expectedObjects = {data,
|
|
||||||
mDashboardDataWithOneConditions.getSuggestions(),
|
mDashboardDataWithOneConditions.getSuggestions(),
|
||||||
mDashboardDataWithOneConditions.getConditions(),
|
mDashboardDataWithOneConditions.getConditions(),
|
||||||
null, mDashboardCategory, mTestCategoryTile};
|
null, mDashboardCategory, mTestCategoryTile};
|
||||||
@@ -186,17 +183,13 @@ public class DashboardDataTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDiffUtil_InsertOneCondition_ResultDataTwoChanged() {
|
public void testDiffUtil_InsertOneCondition_ResultDataOneChanged() {
|
||||||
//Build testResultData
|
//Build testResultData
|
||||||
final List<ListUpdateResult.ResultData> testResultData = new ArrayList<>();
|
final List<ListUpdateResult.ResultData> testResultData = new ArrayList<>();
|
||||||
// Item in position 1 is the header, which contains the number of conditions, changed from
|
// Item in position 2 is the condition container containing the list of conditions, which
|
||||||
// 1 to 2
|
|
||||||
testResultData.add(new ListUpdateResult.ResultData(
|
|
||||||
ListUpdateResult.ResultData.TYPE_OPERATION_CHANGE, 0, 1));
|
|
||||||
// Item in position 3 is the condition container containing the list of conditions, which
|
|
||||||
// gets 1 more item
|
// gets 1 more item
|
||||||
testResultData.add(new ListUpdateResult.ResultData(
|
testResultData.add(new ListUpdateResult.ResultData(
|
||||||
ListUpdateResult.ResultData.TYPE_OPERATION_CHANGE, 2, 1));
|
ListUpdateResult.ResultData.TYPE_OPERATION_CHANGE, 1, 1));
|
||||||
|
|
||||||
testDiffUtil(mDashboardDataWithOneConditions,
|
testDiffUtil(mDashboardDataWithOneConditions,
|
||||||
mDashboardDataWithTwoConditions, testResultData);
|
mDashboardDataWithTwoConditions, testResultData);
|
||||||
@@ -207,7 +200,7 @@ public class DashboardDataTest {
|
|||||||
//Build testResultData
|
//Build testResultData
|
||||||
final List<ListUpdateResult.ResultData> testResultData = new ArrayList<>();
|
final List<ListUpdateResult.ResultData> testResultData = new ArrayList<>();
|
||||||
testResultData.add(new ListUpdateResult.ResultData(
|
testResultData.add(new ListUpdateResult.ResultData(
|
||||||
ListUpdateResult.ResultData.TYPE_OPERATION_REMOVE, 0, 6));
|
ListUpdateResult.ResultData.TYPE_OPERATION_REMOVE, 0, 5));
|
||||||
|
|
||||||
testDiffUtil(mDashboardDataWithOneConditions, mDashboardDataWithNoItems, testResultData);
|
testDiffUtil(mDashboardDataWithOneConditions, mDashboardDataWithNoItems, testResultData);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user