android:resource="@string/wallpaper_suggestion_summary" />
<meta-data android:name="com.android.settings.dismiss"
android:value="3,7,30" />
+ <meta-data android:name="com.android.settings.icon_tintable" android:value="true" />
</activity>
<activity android:name=".support.NewDeviceIntroSuggestionActivity"
</intent-filter>
<meta-data android:name="com.android.settings.title"
android:resource="@string/vision_settings_suggestion_title" />
+ <meta-data android:name="com.android.settings.icon_tintable"
+ android:value="true" />
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
android:value="com.android.settings.accessibility.AccessibilitySettingsForSetupWizard" />
<meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
android:resource="@string/notification_suggestion_title" />
<meta-data android:name="com.android.settings.summary"
android:resource="@string/notification_suggestion_summary" />
+ <meta-data android:name="com.android.settings.icon_tintable" android:value="true" />
</activity>
<activity android:name=".notification.RedactionInterstitial"
android:resource="@string/suggested_lock_settings_title" />
<meta-data android:name="com.android.settings.summary"
android:resource="@string/suggested_lock_settings_summary" />
+ <meta-data android:name="com.android.settings.icon_tintable" android:value="true" />
</activity>
<activity android:name=".Settings$FingerprintEnrollSuggestionActivity"
*/
package com.android.settings.dashboard;
-import android.annotation.AttrRes;
import android.annotation.ColorInt;
import android.app.Activity;
import android.content.Context;
import com.android.settings.dashboard.conditional.Condition;
import com.android.settings.dashboard.conditional.ConditionAdapter;
import com.android.settings.dashboard.conditional.ConditionAdapterUtils;
-import com.android.settings.dashboard.conditional.FocusRecyclerView;
import com.android.settings.dashboard.suggestions.SuggestionAdapter;
import com.android.settings.dashboard.suggestions.SuggestionDismissController;
import com.android.settings.dashboard.suggestions.SuggestionFeatureProvider;
import com.android.settingslib.Utils;
import com.android.settingslib.drawer.DashboardCategory;
import com.android.settingslib.drawer.Tile;
-
import com.android.settingslib.suggestions.SuggestionParser;
+
import java.util.ArrayList;
import java.util.List;
for (int j = 0; j < categories.get(i).tiles.size(); j++) {
final Tile tile = categories.get(i).tiles.get(j);
- if (!mContext.getPackageName().equals(
- tile.intent.getComponent().getPackageName())) {
- // If this drawable is coming from outside Settings, tint it to match the
- // color.
+ if (tile.isIconTintable) {
+ // If this drawable is tintable, tint it to match the color.
tile.icon.setTint(tintColor);
}
}
}
+
+ for (Tile suggestion : suggestions) {
+ if (suggestion.isIconTintable) {
+ suggestion.icon.setTint(tintColor);
+ }
+ }
}
final DashboardData prevData = mDashboardData;
import static com.google.common.truth.Truth.assertThat;
+import static org.mockito.ArgumentMatchers.anyInt;
+import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.any;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
+import android.content.res.TypedArray;
import android.graphics.drawable.ColorDrawable;
+import android.graphics.drawable.Icon;
import android.view.ContextThemeWrapper;
import android.view.LayoutInflater;
import android.view.View;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.settings.R;
import com.android.settings.SettingsActivity;
-import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settings.TestConfig;
import com.android.settings.dashboard.conditional.Condition;
import com.android.settings.testutils.FakeFeatureFactory;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settings.testutils.shadow.SettingsShadowResources;
import com.android.settings.testutils.shadow.ShadowDynamicIndexableContentMonitor;
import com.android.settingslib.drawer.DashboardCategory;
import org.mockito.Captor;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
-import org.robolectric.annotation.Config;
import org.robolectric.RuntimeEnvironment;
+import org.robolectric.annotation.Config;
import org.robolectric.shadows.ShadowApplication;
import java.util.ArrayList;
MockitoAnnotations.initMocks(this);
FakeFeatureFactory.setupForTest(mContext);
mFactory = (FakeFeatureFactory) FakeFeatureFactory.getFactory(mContext);
+ when(mFactory.dashboardFeatureProvider.shouldTintIcon()).thenReturn(true);
when(mFactory.suggestionsFeatureProvider
.getSuggestionIdentifier(any(Context.class), any(Tile.class)))
.thenAnswer(invocation -> {
}
@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"));
}
@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;
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<Tile> 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<Tile> makeSuggestions(String... pkgNames) {
final List<Tile> suggestions = new ArrayList<>();
for (String pkgName : pkgNames) {