Loading res/layout/suggestion_tile.xml +2 −1 Original line number Diff line number Diff line Loading @@ -29,7 +29,8 @@ <LinearLayout android:layout_width="match_parent" android:layout_height="112dp" android:layout_height="wrap_content" android:minHeight="112dp" android:paddingBottom="8dp" android:orientation="vertical"> Loading res/layout/suggestion_tile_with_button.xml +2 −1 Original line number Diff line number Diff line Loading @@ -29,7 +29,8 @@ <LinearLayout android:layout_width="match_parent" android:layout_height="160dp" android:layout_height="wrap_content" android:minHeight="160dp" android:orientation="vertical"> <RelativeLayout Loading src/com/android/settings/dashboard/suggestions/SuggestionAdapter.java +1 −1 Original line number Diff line number Diff line Loading @@ -119,7 +119,7 @@ public class SuggestionAdapter extends RecyclerView.Adapter<DashboardItemHolder> } final Icon icon = suggestion.getIcon(); final Drawable drawable = mCache.getIcon(icon); if (drawable != null) { if (drawable != null && (suggestion.getFlags() & Suggestion.FLAG_ICON_TINTABLE) != 0) { drawable.setTint(Utils.getColorAccent(mContext)); } holder.icon.setImageDrawable(drawable); Loading tests/robotests/src/com/android/settings/dashboard/suggestions/SuggestionAdapterTest.java +29 −1 Original line number Diff line number Diff line Loading @@ -231,12 +231,40 @@ public class SuggestionAdapterTest { } @Test public void onBindViewHolder_shouldTintIcon() throws PendingIntent.CanceledException { public void onBindViewHolder_iconNotTintable_shouldNotTintIcon() throws PendingIntent.CanceledException { final Icon icon = mock(Icon.class); final Suggestion suggestion = new Suggestion.Builder("pkg1") .setPendingIntent(mock(PendingIntent.class)) .setIcon(icon) .build(); final List<Suggestion> suggestions = new ArrayList<>(); suggestions.add(suggestion); mSuggestionAdapter = new SuggestionAdapter(mActivity, mSuggestionControllerMixin, null /* savedInstanceState */, null /* callback */, null /* lifecycle */); mSuggestionAdapter.setSuggestions(suggestions); mSuggestionHolder = mSuggestionAdapter.onCreateViewHolder( new FrameLayout(RuntimeEnvironment.application), mSuggestionAdapter.getItemViewType(0)); IconCache cache = mock(IconCache.class); final Drawable drawable = mock(Drawable.class); when(cache.getIcon(icon)).thenReturn(drawable); ReflectionHelpers.setField(mSuggestionAdapter, "mCache", cache); mSuggestionAdapter.onBindViewHolder(mSuggestionHolder, 0); verify(drawable, never()).setTint(anyInt()); } @Test public void onBindViewHolder_iconTintable_shouldTintIcon() throws PendingIntent.CanceledException { final Icon icon = mock(Icon.class); final int FLAG_ICON_TINTABLE = 1 << 1; final Suggestion suggestion = new Suggestion.Builder("pkg1") .setPendingIntent(mock(PendingIntent.class)) .setIcon(icon) .setFlags(FLAG_ICON_TINTABLE) .build(); final List<Suggestion> suggestions = new ArrayList<>(); suggestions.add(suggestion); Loading Loading
res/layout/suggestion_tile.xml +2 −1 Original line number Diff line number Diff line Loading @@ -29,7 +29,8 @@ <LinearLayout android:layout_width="match_parent" android:layout_height="112dp" android:layout_height="wrap_content" android:minHeight="112dp" android:paddingBottom="8dp" android:orientation="vertical"> Loading
res/layout/suggestion_tile_with_button.xml +2 −1 Original line number Diff line number Diff line Loading @@ -29,7 +29,8 @@ <LinearLayout android:layout_width="match_parent" android:layout_height="160dp" android:layout_height="wrap_content" android:minHeight="160dp" android:orientation="vertical"> <RelativeLayout Loading
src/com/android/settings/dashboard/suggestions/SuggestionAdapter.java +1 −1 Original line number Diff line number Diff line Loading @@ -119,7 +119,7 @@ public class SuggestionAdapter extends RecyclerView.Adapter<DashboardItemHolder> } final Icon icon = suggestion.getIcon(); final Drawable drawable = mCache.getIcon(icon); if (drawable != null) { if (drawable != null && (suggestion.getFlags() & Suggestion.FLAG_ICON_TINTABLE) != 0) { drawable.setTint(Utils.getColorAccent(mContext)); } holder.icon.setImageDrawable(drawable); Loading
tests/robotests/src/com/android/settings/dashboard/suggestions/SuggestionAdapterTest.java +29 −1 Original line number Diff line number Diff line Loading @@ -231,12 +231,40 @@ public class SuggestionAdapterTest { } @Test public void onBindViewHolder_shouldTintIcon() throws PendingIntent.CanceledException { public void onBindViewHolder_iconNotTintable_shouldNotTintIcon() throws PendingIntent.CanceledException { final Icon icon = mock(Icon.class); final Suggestion suggestion = new Suggestion.Builder("pkg1") .setPendingIntent(mock(PendingIntent.class)) .setIcon(icon) .build(); final List<Suggestion> suggestions = new ArrayList<>(); suggestions.add(suggestion); mSuggestionAdapter = new SuggestionAdapter(mActivity, mSuggestionControllerMixin, null /* savedInstanceState */, null /* callback */, null /* lifecycle */); mSuggestionAdapter.setSuggestions(suggestions); mSuggestionHolder = mSuggestionAdapter.onCreateViewHolder( new FrameLayout(RuntimeEnvironment.application), mSuggestionAdapter.getItemViewType(0)); IconCache cache = mock(IconCache.class); final Drawable drawable = mock(Drawable.class); when(cache.getIcon(icon)).thenReturn(drawable); ReflectionHelpers.setField(mSuggestionAdapter, "mCache", cache); mSuggestionAdapter.onBindViewHolder(mSuggestionHolder, 0); verify(drawable, never()).setTint(anyInt()); } @Test public void onBindViewHolder_iconTintable_shouldTintIcon() throws PendingIntent.CanceledException { final Icon icon = mock(Icon.class); final int FLAG_ICON_TINTABLE = 1 << 1; final Suggestion suggestion = new Suggestion.Builder("pkg1") .setPendingIntent(mock(PendingIntent.class)) .setIcon(icon) .setFlags(FLAG_ICON_TINTABLE) .build(); final List<Suggestion> suggestions = new ArrayList<>(); suggestions.add(suggestion); Loading