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:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?android:attr/colorSecondary"
|
||||
android:background="@color/condition_card_background"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
|
@@ -24,7 +24,7 @@
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@color/material_grey_300">
|
||||
android:background="@color/suggestion_condition_background">
|
||||
<android.support.v7.widget.CardView
|
||||
android:id="@+id/search_bar"
|
||||
android:layout_width="match_parent"
|
||||
|
@@ -25,7 +25,7 @@
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@color/material_grey_300">
|
||||
android:background="@color/suggestion_condition_background">
|
||||
<android.support.v7.widget.CardView
|
||||
android:id="@+id/search_bar"
|
||||
android:layout_width="match_parent"
|
||||
|
@@ -19,15 +19,16 @@
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
style="@style/SuggestionConditionStyle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="56dp"
|
||||
android:layout_height="44dp"
|
||||
android:paddingTop="4dp"
|
||||
android:paddingEnd="16dp"
|
||||
android:orientation="horizontal"
|
||||
android:gravity="center|end">
|
||||
android:gravity="end">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/collapse_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:padding="16dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/ic_expand_less"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
@@ -15,62 +15,80 @@
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<RelativeLayout
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
style="@style/SuggestionConditionStyle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="56dp"
|
||||
android:layout_centerHorizontal="true">
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<FrameLayout
|
||||
android:id="@android:id/icon_frame"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="24dp"
|
||||
android:layout_centerVertical="true">
|
||||
<Space
|
||||
android:id="@+id/top_space"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="9dp"/>
|
||||
|
||||
<include layout="@layout/condition_header_icon" />
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="35dp"
|
||||
android:layout_centerHorizontal="true">
|
||||
|
||||
</FrameLayout>
|
||||
<FrameLayout
|
||||
android:id="@android:id/icon_frame"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="24dp"
|
||||
android:layout_centerVertical="true">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/expand_indicator"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:padding="16dp"
|
||||
android:src="@drawable/ic_expand_more"/>
|
||||
<include layout="@layout/condition_header_icon" />
|
||||
|
||||
<TextView
|
||||
android:id="@android:id/summary"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_toStartOf="@id/expand_indicator"
|
||||
android:layout_centerVertical="true"
|
||||
android:gravity="end"
|
||||
android:textAppearance="@style/TextAppearance.SuggestionTitle"
|
||||
android:textColor="?android:attr/colorAccent" />
|
||||
</FrameLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@android:id/title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_toEndOf="@android:id/icon_frame"
|
||||
android:layout_toStartOf="@android:id/summary"
|
||||
android:layout_centerVertical="true"
|
||||
android:singleLine="true"
|
||||
android:ellipsize="end"
|
||||
android:textAppearance="@style/TextAppearance.SuggestionTitle"
|
||||
android:textColor="?android:attr/colorAccent" />
|
||||
<ImageView
|
||||
android:id="@+id/expand_indicator"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:paddingTop="4dp"
|
||||
android:paddingStart="16dp"
|
||||
android:paddingEnd="16dp"
|
||||
android:src="@drawable/ic_expand_more"/>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/additional_icons"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_toStartOf="@android:id/summary"
|
||||
android:layout_toEndOf="@android:id/icon_frame"
|
||||
android:orientation="horizontal"
|
||||
android:gravity="center_vertical"/>
|
||||
<TextView
|
||||
android:id="@android:id/summary"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_toStartOf="@id/expand_indicator"
|
||||
android:layout_centerVertical="true"
|
||||
android:gravity="end"
|
||||
android:textAppearance="@style/TextAppearance.SuggestionTitle"
|
||||
android:textColor="?android:attr/colorAccent" />
|
||||
|
||||
</RelativeLayout>
|
||||
<TextView
|
||||
android:id="@android:id/title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_toEndOf="@android:id/icon_frame"
|
||||
android:layout_toStartOf="@android:id/summary"
|
||||
android:layout_centerVertical="true"
|
||||
android:singleLine="true"
|
||||
android:ellipsize="end"
|
||||
android:textAppearance="@style/TextAppearance.SuggestionTitle"
|
||||
android:textColor="?android:attr/colorAccent" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/additional_icons"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_toStartOf="@android:id/summary"
|
||||
android:layout_toEndOf="@android:id/icon_frame"
|
||||
android:orientation="horizontal"
|
||||
android:gravity="center_vertical"/>
|
||||
|
||||
</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 -->
|
||||
<color name="fallback_tintColor">#89000000</color>
|
||||
|
||||
<!-- Suggestion/condition colors -->
|
||||
<color name="suggestion_condition_background">#f2f2f2</color>
|
||||
<color name="condition_card_background">#f8f8f8</color>
|
||||
</resources>
|
||||
|
@@ -456,7 +456,7 @@
|
||||
</style>
|
||||
|
||||
<style name="SuggestionConditionStyle">
|
||||
<item name="android:background">@color/material_grey_300</item>
|
||||
<item name="android:background">@color/suggestion_condition_background</item>
|
||||
</style>
|
||||
|
||||
<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.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.Space;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
||||
@@ -267,27 +268,9 @@ public class DashboardAdapter extends RecyclerView.Adapter<DashboardAdapter.Dash
|
||||
(SuggestionAndConditionContainerHolder) holder, position);
|
||||
break;
|
||||
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)
|
||||
mDashboardData.getItemEntityByPosition(position));
|
||||
}
|
||||
mDashboardData.getItemEntityByPosition(position));
|
||||
break;
|
||||
case R.layout.suggestion_condition_footer:
|
||||
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
|
||||
void onBindSuggestionConditionHeader(final SuggestionAndConditionHeaderHolder holder,
|
||||
SuggestionConditionHeaderData data) {
|
||||
@@ -444,8 +416,12 @@ public class DashboardAdapter extends RecyclerView.Adapter<DashboardAdapter.Dash
|
||||
} else {
|
||||
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 -> {
|
||||
if (moreSuggestions ) {
|
||||
@@ -468,9 +444,9 @@ public class DashboardAdapter extends RecyclerView.Adapter<DashboardAdapter.Dash
|
||||
@VisibleForTesting
|
||||
void onBindConditionAndSuggestion(final SuggestionAndConditionContainerHolder holder,
|
||||
int position) {
|
||||
// If there is suggestions to show, it will be at position 1
|
||||
// position 0 is suggestion header.
|
||||
if (position == (SUGGESTION_CONDITION_HEADER_POSITION + 1)
|
||||
// If there is suggestions to show, it will be at position 0 as we don't show the suggestion
|
||||
// header anymore.
|
||||
if (position == (SUGGESTION_CONDITION_HEADER_POSITION)
|
||||
&& mDashboardData.getSuggestions() != null) {
|
||||
mSuggestionAdapter = new SuggestionAdapter(mContext, (List<Tile>)
|
||||
mDashboardData.getItemEntityByPosition(position), mSuggestionsShownLogged);
|
||||
@@ -572,11 +548,13 @@ public class DashboardAdapter extends RecyclerView.Adapter<DashboardAdapter.Dash
|
||||
public static class SuggestionAndConditionHeaderHolder extends DashboardItemHolder {
|
||||
public final LinearLayout icons;
|
||||
public final ImageView expandIndicator;
|
||||
public final Space topSpace;
|
||||
|
||||
public SuggestionAndConditionHeaderHolder(View itemView) {
|
||||
super(itemView);
|
||||
icons = itemView.findViewById(id.additional_icons);
|
||||
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;
|
||||
|
||||
resetCount();
|
||||
/* Top suggestion/condition header. This will be present when there is any suggestion or
|
||||
* condition to show, except in the case that there is only conditions to show and the
|
||||
* mode is fully expanded. */
|
||||
/* Top suggestion/condition header. This will be present when there is any suggestion
|
||||
* and the mode is collapsed, or it only has conditions and the mode is not fully
|
||||
* expanded. */
|
||||
countItem(new SuggestionConditionHeaderData(conditions, hiddenSuggestion),
|
||||
R.layout.suggestion_condition_header, hasSuggestions
|
||||
|| hasConditions && mSuggestionConditionMode != HEADER_MODE_FULLY_EXPANDED,
|
||||
R.layout.suggestion_condition_header,
|
||||
hasSuggestions && mSuggestionConditionMode == HEADER_MODE_COLLAPSED
|
||||
|| !hasSuggestions && hasConditions
|
||||
&& mSuggestionConditionMode != HEADER_MODE_FULLY_EXPANDED,
|
||||
NS_SUGGESTION_CONDITION);
|
||||
|
||||
/* Suggestion container. This is the card view that contains the list of suggestions.
|
||||
|
@@ -386,7 +386,7 @@ public class DashboardAdapterTest {
|
||||
new DashboardAdapter.SuggestionAndConditionContainerHolder(itemView);
|
||||
|
||||
mDashboardAdapter.onBindConditionAndSuggestion(
|
||||
holder, DashboardAdapter.SUGGESTION_CONDITION_HEADER_POSITION + 1);
|
||||
holder, DashboardAdapter.SUGGESTION_CONDITION_HEADER_POSITION);
|
||||
|
||||
verify(data).setAdapter(any(SuggestionAdapter.class));
|
||||
// should not crash
|
||||
|
@@ -112,10 +112,7 @@ public class DashboardDataTest {
|
||||
|
||||
@Test
|
||||
public void testBuildItemsData_containsAllData() {
|
||||
final DashboardData.SuggestionConditionHeaderData data =
|
||||
new DashboardData.SuggestionConditionHeaderData(
|
||||
mDashboardDataWithOneConditions.getConditions(), 0);
|
||||
final Object[] expectedObjects = {data,
|
||||
final Object[] expectedObjects = {
|
||||
mDashboardDataWithOneConditions.getSuggestions(),
|
||||
mDashboardDataWithOneConditions.getConditions(),
|
||||
null, mDashboardCategory, mTestCategoryTile};
|
||||
@@ -186,17 +183,13 @@ public class DashboardDataTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDiffUtil_InsertOneCondition_ResultDataTwoChanged() {
|
||||
public void testDiffUtil_InsertOneCondition_ResultDataOneChanged() {
|
||||
//Build testResultData
|
||||
final List<ListUpdateResult.ResultData> testResultData = new ArrayList<>();
|
||||
// Item in position 1 is the header, which contains the number of conditions, changed from
|
||||
// 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
|
||||
// Item in position 2 is the condition container containing the list of conditions, which
|
||||
// gets 1 more item
|
||||
testResultData.add(new ListUpdateResult.ResultData(
|
||||
ListUpdateResult.ResultData.TYPE_OPERATION_CHANGE, 2, 1));
|
||||
ListUpdateResult.ResultData.TYPE_OPERATION_CHANGE, 1, 1));
|
||||
|
||||
testDiffUtil(mDashboardDataWithOneConditions,
|
||||
mDashboardDataWithTwoConditions, testResultData);
|
||||
@@ -207,7 +200,7 @@ public class DashboardDataTest {
|
||||
//Build testResultData
|
||||
final List<ListUpdateResult.ResultData> testResultData = new ArrayList<>();
|
||||
testResultData.add(new ListUpdateResult.ResultData(
|
||||
ListUpdateResult.ResultData.TYPE_OPERATION_REMOVE, 0, 6));
|
||||
ListUpdateResult.ResultData.TYPE_OPERATION_REMOVE, 0, 5));
|
||||
|
||||
testDiffUtil(mDashboardDataWithOneConditions, mDashboardDataWithNoItems, testResultData);
|
||||
}
|
||||
|
Reference in New Issue
Block a user