Reduce max suggestion to show to 2.

- since we now either have 1 or 2 suggestions, putting most layout
configuration in the xml instead of dynamically setting it in code.
- remove the suggestion header
- vertical center align the suggestion title text for 2 cards to make
the card with single line looks better.
- tint all suggestions icons.

Change-Id: I0130f15d530264e164e5afd7c091f165a4a6adc2
Fixes: 70573674
Fixes: 73293989
Fixes: 64986736
Test: visual and make RunSettingsRoboTests
This commit is contained in:
Doris Ling
2018-02-23 14:59:41 -08:00
parent 46d6ecc2b1
commit 7d59c441b8
11 changed files with 106 additions and 197 deletions

View File

@@ -138,31 +138,6 @@ public class DashboardAdapterTest {
verify(adapter, never()).notifyDashboardDataChanged(any());
}
@Test
public void testSuggestionDismissed_moreThanTwoSuggestions_shouldNotCrash() {
final RecyclerView data = new RecyclerView(RuntimeEnvironment.application);
final View itemView = mock(View.class);
when(itemView.findViewById(R.id.suggestion_list)).thenReturn(data);
when(itemView.findViewById(android.R.id.summary)).thenReturn(mock(TextView.class));
when(itemView.findViewById(android.R.id.title)).thenReturn(mock(TextView.class));
final DashboardAdapter.SuggestionContainerHolder holder =
new DashboardAdapter.SuggestionContainerHolder(itemView);
final List<Suggestion> suggestions = makeSuggestionsV2("pkg1", "pkg2", "pkg3", "pkg4");
final DashboardAdapter adapter = spy(new DashboardAdapter(mContext,
null /*savedInstance */, null /* conditions */,
null /* suggestionControllerMixin */,
null /* lifecycle */));
adapter.setSuggestions(suggestions);
adapter.onBindSuggestion(holder, 0);
adapter.onSuggestionClosed(suggestions.get(1));
// verify operations that access the lists will not cause ConcurrentModificationException
assertThat(holder.data.getAdapter().getItemCount()).isEqualTo(3);
adapter.setSuggestions(suggestions);
// should not crash
}
@Test
public void testSuggestionDismissed_onlySuggestion_updateDashboardData() {
DashboardAdapter adapter =
@@ -205,38 +180,6 @@ public class DashboardAdapterTest {
// should not crash
}
@Test
public void testBindSuggestion_shouldSetSummary() {
mDashboardAdapter = new DashboardAdapter(mContext, null /* savedInstanceState */,
null /* conditions */, null /* suggestionControllerMixin */, null /* lifecycle */);
final List<Suggestion> suggestions = makeSuggestionsV2("pkg1");
mDashboardAdapter.setSuggestions(suggestions);
final RecyclerView data = mock(RecyclerView.class);
when(data.getResources()).thenReturn(mResources);
when(data.getContext()).thenReturn(mContext);
when(mResources.getDisplayMetrics()).thenReturn(mock(DisplayMetrics.class));
final View itemView = mock(View.class);
when(itemView.findViewById(R.id.suggestion_list)).thenReturn(data);
final TextView summary = mock(TextView.class);
when(itemView.findViewById(android.R.id.summary)).thenReturn(summary);
when(itemView.findViewById(android.R.id.title)).thenReturn(mock(TextView.class));
final DashboardAdapter.SuggestionContainerHolder holder =
new DashboardAdapter.SuggestionContainerHolder(itemView);
mDashboardAdapter.onBindSuggestion(holder, 0);
verify(summary).setText("1");
suggestions.addAll(makeSuggestionsV2("pkg2", "pkg3", "pkg4"));
mDashboardAdapter.setSuggestions(suggestions);
mDashboardAdapter.onBindSuggestion(holder, 0);
verify(summary).setText("4");
}
@Test
public void onBindTile_internalTile_shouldNotUseGenericBackgroundIcon() {
final Context context = RuntimeEnvironment.application;