From 992fa86d529c59b8f665613dbf0602c8609b83f8 Mon Sep 17 00:00:00 2001 From: Maurice Lam Date: Fri, 9 Jun 2017 16:14:36 -0700 Subject: [PATCH] Tint suggestion icons If the suggestion is marked as isIconTintable, tint the icon with colorControlNormal. Test: cd tests/robotests && mma Bug: 62258845 Change-Id: I2a76181d9b8b4d9fbf496a8fc605cb762bba87c0 --- AndroidManifest.xml | 5 ++++ .../settings/dashboard/DashboardAdapter.java | 16 +++++----- .../dashboard/DashboardAdapterTest.java | 29 ++++++++++++++++--- 3 files changed, 39 insertions(+), 11 deletions(-) diff --git a/AndroidManifest.xml b/AndroidManifest.xml index b2a8dd12a75..2f42c8f5cbf 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -812,6 +812,7 @@ android:resource="@string/wallpaper_suggestion_summary" /> + + + + { @@ -445,7 +450,7 @@ public class DashboardAdapterTest { } @Test - public void testSuggestioDismissed_notOnlySuggestion_doNothing() { + public void testSuggestionDismissed_notOnlySuggestion_doNothing() { final DashboardAdapter adapter = spy(new DashboardAdapter(mContext, null, null)); adapter.setCategoriesAndSuggestions( new ArrayList<>(), makeSuggestions("pkg1", "pkg2", "pkg3")); @@ -459,7 +464,7 @@ public class DashboardAdapterTest { } @Test - public void testSuggestioDismissed_onlySuggestion_updateDashboardData() { + public void testSuggestionDismissed_onlySuggestion_updateDashboardData() { DashboardAdapter adapter = spy(new DashboardAdapter(mContext, null, null)); adapter.setCategoriesAndSuggestions(new ArrayList<>(), makeSuggestions("pkg1")); final DashboardData dashboardData = adapter.mDashboardData; @@ -471,6 +476,22 @@ public class DashboardAdapterTest { verify(adapter).notifyDashboardDataChanged(any()); } + @Test + public void testSetCategoriesAndSuggestions_iconTinted() { + TypedArray mockTypedArray = mock(TypedArray.class); + doReturn(mockTypedArray).when(mContext).obtainStyledAttributes(any(int[].class)); + doReturn(0x89000000).when(mockTypedArray).getColor(anyInt(), anyInt()); + + List packages = makeSuggestions("pkg1"); + Icon mockIcon = mock(Icon.class); + packages.get(0).isIconTintable = true; + packages.get(0).icon = mockIcon; + + mDashboardAdapter.setCategoriesAndSuggestions(Collections.emptyList(), packages); + + verify(mockIcon).setTint(eq(0x89000000)); + } + private List makeSuggestions(String... pkgNames) { final List suggestions = new ArrayList<>(); for (String pkgName : pkgNames) {