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
<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"
<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"
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>
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">
-
- <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">
-
- <include layout="@layout/condition_header_icon" />
-
- </FrameLayout>
-
- <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"/>
-
- <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" />
-
- <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>
+ 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">
+
+ <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">
+
+ <include layout="@layout/condition_header_icon" />
+
+ </FrameLayout>
+
+ <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"/>
+
+ <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" />
+
+ <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>
<!-- 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>
</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">
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;
(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 -> {
}
}
- 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) {
} 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 ) {
@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);
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);
}
}
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.
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
@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};
}
@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);
//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);
}