diff --git a/color-check-baseline.xml b/color-check-baseline.xml
index 066dab94ce2..f3050c48ec4 100644
--- a/color-check-baseline.xml
+++ b/color-check-baseline.xml
@@ -1661,7 +1661,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
@@ -1677,7 +1677,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
@@ -1693,7 +1693,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
@@ -1709,7 +1709,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
@@ -1725,7 +1725,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
@@ -1741,10 +1741,26 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
+
+
+
+
@@ -1773,7 +1789,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
@@ -1789,7 +1805,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
@@ -1805,7 +1821,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
@@ -1821,7 +1837,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
@@ -1837,7 +1853,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
@@ -2557,7 +2573,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~">
@@ -2589,7 +2605,7 @@
errorLine2=" ^">
@@ -2605,7 +2621,7 @@
errorLine2=" ^">
@@ -2621,7 +2637,7 @@
errorLine2=" ^">
@@ -2637,7 +2653,7 @@
errorLine2=" ^">
diff --git a/res/drawable/ic_homepage_accessibility.xml b/res/drawable/ic_homepage_accessibility.xml
index 6cfb124a717..07c9ef2ff84 100644
--- a/res/drawable/ic_homepage_accessibility.xml
+++ b/res/drawable/ic_homepage_accessibility.xml
@@ -18,8 +18,7 @@
-
-
+
-
-
+
-
-
+
-
-
+
-
-
+
-
-
+
+
+
+
+
+
\ No newline at end of file
diff --git a/res/drawable/ic_homepage_network.xml b/res/drawable/ic_homepage_network.xml
index c72e15256ba..5ed023ac3d4 100644
--- a/res/drawable/ic_homepage_network.xml
+++ b/res/drawable/ic_homepage_network.xml
@@ -18,8 +18,7 @@
-
-
+
-
-
+
-
-
+
-
-
+
-
-
+
-
-
+
data) {
@@ -126,7 +125,6 @@ public class DashboardAdapterV2 extends RecyclerView.Adapter {
mMetricsFeatureProvider.action(mContext,
- MetricsEvent.ACTION_SETTINGS_CONDITION_EXPAND, true);
+ MetricsEvent.ACTION_SETTINGS_CONDITION_EXPAND, true);
final DashboardDataV2 prevData = mDashboardData;
mDashboardData = new DashboardDataV2.Builder(prevData)
.setConditionExpanded(true).build();
@@ -294,8 +292,8 @@ public class DashboardAdapterV2 extends RecyclerView.Adapter) mDashboardData.getItemEntityByPosition(position),
- mDashboardData.isConditionExpanded());
+ (List) mDashboardData.getItemEntityByPosition(position),
+ mDashboardData.isConditionExpanded());
adapter.addDismissHandling(holder.data);
holder.data.setAdapter(adapter);
holder.data.setLayoutManager(new LinearLayoutManager(mContext));
@@ -306,10 +304,10 @@ public class DashboardAdapterV2 extends RecyclerView.Adapter suggestions =
- (List) mDashboardData.getItemEntityByPosition(position);
+ (List) mDashboardData.getItemEntityByPosition(position);
final int suggestionCount = suggestions.size();
if (suggestions != null && suggestionCount > 0) {
- holder.summary.setText(""+suggestionCount);
+ holder.summary.setText("" + suggestionCount);
mSuggestionAdapter.setSuggestions(suggestions);
holder.data.setAdapter(mSuggestionAdapter);
}
@@ -318,8 +316,14 @@ public class DashboardAdapterV2 extends RecyclerView.Adapter suggestions = makeSuggestionsV2("pkg1", "pkg2", "pkg3");
adapter.setSuggestions(suggestions);
@@ -143,8 +142,9 @@ public class DashboardAdapterV2Test {
new DashboardAdapterV2.SuggestionContainerHolder(itemView);
final List suggestions = makeSuggestionsV2("pkg1", "pkg2", "pkg3", "pkg4");
final DashboardAdapterV2 adapter = spy(new DashboardAdapterV2(mContext,
- null /*savedInstance */, null /* conditions */, null /* suggestionControllerMixin */,
- null /* lifecycle */));
+ null /*savedInstance */, null /* conditions */,
+ null /* suggestionControllerMixin */,
+ null /* lifecycle */));
adapter.setSuggestions(suggestions);
adapter.onBindSuggestion(holder, 0);
@@ -160,7 +160,8 @@ public class DashboardAdapterV2Test {
public void testSuggestionDismissed_onlySuggestion_updateDashboardData() {
DashboardAdapterV2 adapter =
spy(new DashboardAdapterV2(mContext, null /* savedInstanceState */,
- null /* conditions */, null /* suggestionControllerMixin */, null /* lifecycle */));
+ null /* conditions */, null /* suggestionControllerMixin */, null /*
+ lifecycle */));
final List suggestions = makeSuggestionsV2("pkg1");
adapter.setSuggestions(suggestions);
final DashboardDataV2 dashboardData = adapter.mDashboardData;
@@ -172,28 +173,10 @@ public class DashboardAdapterV2Test {
verify(adapter).notifyDashboardDataChanged(any());
}
- @Test
- public void testSetCategories_iconTinted() {
- TypedArray mockTypedArray = mock(TypedArray.class);
- doReturn(mockTypedArray).when(mContext).obtainStyledAttributes(any(int[].class));
- doReturn(0x89000000).when(mockTypedArray).getColor(anyInt(), anyInt());
-
- final DashboardCategory category = new DashboardCategory();
- final Icon mockIcon = mock(Icon.class);
- final Tile tile = new Tile();
- tile.isIconTintable = true;
- tile.icon = mockIcon;
- category.addTile(tile);
-
- mDashboardAdapter.setCategory(category);
-
- verify(mockIcon).setTint(eq(0x89000000));
- }
-
@Test
public void testBindSuggestion_shouldSetSuggestionAdapterAndNoCrash() {
mDashboardAdapter = new DashboardAdapterV2(mContext, null /* savedInstanceState */,
- null /* conditions */, null /* suggestionControllerMixin */, null /* lifecycle */);
+ null /* conditions */, null /* suggestionControllerMixin */, null /* lifecycle */);
final List suggestions = makeSuggestionsV2("pkg1");
mDashboardAdapter.setSuggestions(suggestions);
@@ -217,7 +200,7 @@ public class DashboardAdapterV2Test {
@Test
public void testBindSuggestion_shouldSetSummary() {
mDashboardAdapter = new DashboardAdapterV2(mContext, null /* savedInstanceState */,
- null /* conditions */, null /* suggestionControllerMixin */, null /* lifecycle */);
+ null /* conditions */, null /* suggestionControllerMixin */, null /* lifecycle */);
final List suggestions = makeSuggestionsV2("pkg1");
mDashboardAdapter.setSuggestions(suggestions);
@@ -231,7 +214,7 @@ public class DashboardAdapterV2Test {
final TextView summary = mock(TextView.class);
when(itemView.findViewById(android.R.id.summary)).thenReturn(summary);
final DashboardAdapterV2.SuggestionContainerHolder holder =
- new DashboardAdapterV2.SuggestionContainerHolder(itemView);
+ new DashboardAdapterV2.SuggestionContainerHolder(itemView);
mDashboardAdapter.onBindSuggestion(holder, 0);
@@ -245,6 +228,46 @@ public class DashboardAdapterV2Test {
verify(summary).setText("4");
}
+ @Test
+ public void onBindTile_internalTile_shouldNotUseGenericBackgroundIcon() {
+ final Context context = RuntimeEnvironment.application;
+ final View view = LayoutInflater.from(context).inflate(R.layout.dashboard_tile, null);
+ final DashboardAdapterV2.DashboardItemHolder holder =
+ new DashboardAdapterV2.DashboardItemHolder(view);
+ final Tile tile = new Tile();
+ tile.icon = Icon.createWithResource(context, R.drawable.ic_settings);
+ final DashboardAdapterV2.IconCache iconCache = mock(DashboardAdapterV2.IconCache.class);
+ when(iconCache.getIcon(tile.icon)).thenReturn(context.getDrawable(R.drawable.ic_settings));
+
+ mDashboardAdapter = new DashboardAdapterV2(context, null /* savedInstanceState */,
+ null /* conditions */, null /* suggestionControllerMixin */, null /* lifecycle */);
+ ReflectionHelpers.setField(mDashboardAdapter, "mCache", iconCache);
+ mDashboardAdapter.onBindTile(holder, tile);
+
+ verify(iconCache, never()).updateIcon(any(Icon.class), any(Drawable.class));
+ }
+
+ @Test
+ public void onBindTile_externalTile_shouldNotUseGenericBackgroundIcon() {
+ final Context context = RuntimeEnvironment.application;
+ final View view = LayoutInflater.from(context).inflate(R.layout.dashboard_tile, null);
+ final DashboardAdapterV2.DashboardItemHolder holder =
+ new DashboardAdapterV2.DashboardItemHolder(view);
+ final Tile tile = new Tile();
+ tile.icon = mock(Icon.class);
+ when(tile.icon.getResPackage()).thenReturn("another.package");
+
+ final DashboardAdapterV2.IconCache iconCache = mock(DashboardAdapterV2.IconCache.class);
+ when(iconCache.getIcon(tile.icon)).thenReturn(context.getDrawable(R.drawable.ic_settings));
+
+ mDashboardAdapter = new DashboardAdapterV2(context, null /* savedInstanceState */,
+ null /* conditions */, null /* suggestionControllerMixin */, null /* lifecycle */);
+ ReflectionHelpers.setField(mDashboardAdapter, "mCache", iconCache);
+ mDashboardAdapter.onBindTile(holder, tile);
+
+ verify(iconCache).updateIcon(eq(tile.icon), any(RoundedHomepageIcon.class));
+ }
+
private List makeSuggestionsV2(String... pkgNames) {
final List suggestions = new ArrayList<>();
for (String pkgName : pkgNames) {
diff --git a/tests/robotests/src/com/android/settings/dashboard/RoundedHomepageIconTest.java b/tests/robotests/src/com/android/settings/dashboard/RoundedHomepageIconTest.java
new file mode 100644
index 00000000000..4c62a6f6a62
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/dashboard/RoundedHomepageIconTest.java
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.dashboard;
+
+
+import static com.google.common.truth.Truth.assertThat;
+
+import android.content.Context;
+import android.graphics.Color;
+import android.graphics.drawable.ColorDrawable;
+
+import com.android.settings.R;
+import com.android.settings.TestConfig;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.annotation.Config;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+public class RoundedHomepageIconTest {
+
+ private Context mContext;
+
+ @Before
+ public void setUp() {
+ mContext = RuntimeEnvironment.application;
+ }
+
+ @Test
+ public void createIcon_shouldSetBackgroundAndInset() {
+ final RoundedHomepageIcon icon = new RoundedHomepageIcon(
+ mContext, new ColorDrawable(Color.BLACK));
+
+ assertThat(icon.getNumberOfLayers()).isEqualTo(2);
+ assertThat(icon.getDrawable(0))
+ .isEqualTo(mContext.getDrawable(R.drawable.ic_homepage_generic_background));
+ }
+}