Add a generic blue background on some homepage tiles
If a homepage tile is injected from external packages, we can't control what their icons look like, so we put a generic blue circular background to make it consistent with the other icons. Change-Id: I2a935db37fff097ae15540262bff94efea55179a Fixes: 69314641 Test: robotests
This commit is contained in:
@@ -1661,7 +1661,7 @@
|
|||||||
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
|
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
|
||||||
<location
|
<location
|
||||||
file="res/drawable/ic_homepage_accessibility.xml"
|
file="res/drawable/ic_homepage_accessibility.xml"
|
||||||
line="24"
|
line="23"
|
||||||
column="17"/>
|
column="17"/>
|
||||||
</issue>
|
</issue>
|
||||||
|
|
||||||
@@ -1677,7 +1677,7 @@
|
|||||||
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
|
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
|
||||||
<location
|
<location
|
||||||
file="res/drawable/ic_homepage_accounts.xml"
|
file="res/drawable/ic_homepage_accounts.xml"
|
||||||
line="24"
|
line="23"
|
||||||
column="17"/>
|
column="17"/>
|
||||||
</issue>
|
</issue>
|
||||||
|
|
||||||
@@ -1693,7 +1693,7 @@
|
|||||||
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
|
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
|
||||||
<location
|
<location
|
||||||
file="res/drawable/ic_homepage_apps.xml"
|
file="res/drawable/ic_homepage_apps.xml"
|
||||||
line="24"
|
line="23"
|
||||||
column="17"/>
|
column="17"/>
|
||||||
</issue>
|
</issue>
|
||||||
|
|
||||||
@@ -1709,7 +1709,7 @@
|
|||||||
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
|
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
|
||||||
<location
|
<location
|
||||||
file="res/drawable/ic_homepage_battery.xml"
|
file="res/drawable/ic_homepage_battery.xml"
|
||||||
line="24"
|
line="23"
|
||||||
column="17"/>
|
column="17"/>
|
||||||
</issue>
|
</issue>
|
||||||
|
|
||||||
@@ -1725,7 +1725,7 @@
|
|||||||
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
|
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
|
||||||
<location
|
<location
|
||||||
file="res/drawable/ic_homepage_connected_device.xml"
|
file="res/drawable/ic_homepage_connected_device.xml"
|
||||||
line="24"
|
line="23"
|
||||||
column="17"/>
|
column="17"/>
|
||||||
</issue>
|
</issue>
|
||||||
|
|
||||||
@@ -1741,10 +1741,26 @@
|
|||||||
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
|
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
|
||||||
<location
|
<location
|
||||||
file="res/drawable/ic_homepage_display.xml"
|
file="res/drawable/ic_homepage_display.xml"
|
||||||
line="24"
|
line="23"
|
||||||
column="17"/>
|
column="17"/>
|
||||||
</issue>
|
</issue>
|
||||||
|
|
||||||
|
<issue
|
||||||
|
id="HardCodedColor"
|
||||||
|
severity="Error"
|
||||||
|
message="Avoid using hardcoded color"
|
||||||
|
category="Correctness"
|
||||||
|
priority="4"
|
||||||
|
summary="Using hardcoded color"
|
||||||
|
explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.
This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
|
||||||
|
errorLine1=" android:color="@color/homepage_generic_icon_background" />"
|
||||||
|
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
|
||||||
|
<location
|
||||||
|
file="res/drawable/ic_homepage_generic_background.xml"
|
||||||
|
line="20"
|
||||||
|
column="9"/>
|
||||||
|
</issue>
|
||||||
|
|
||||||
<issue
|
<issue
|
||||||
id="HardCodedColor"
|
id="HardCodedColor"
|
||||||
severity="Error"
|
severity="Error"
|
||||||
@@ -1757,7 +1773,7 @@
|
|||||||
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
|
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
|
||||||
<location
|
<location
|
||||||
file="res/drawable/ic_homepage_network.xml"
|
file="res/drawable/ic_homepage_network.xml"
|
||||||
line="24"
|
line="23"
|
||||||
column="17"/>
|
column="17"/>
|
||||||
</issue>
|
</issue>
|
||||||
|
|
||||||
@@ -1773,7 +1789,7 @@
|
|||||||
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
|
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
|
||||||
<location
|
<location
|
||||||
file="res/drawable/ic_homepage_security.xml"
|
file="res/drawable/ic_homepage_security.xml"
|
||||||
line="24"
|
line="23"
|
||||||
column="17"/>
|
column="17"/>
|
||||||
</issue>
|
</issue>
|
||||||
|
|
||||||
@@ -1789,7 +1805,7 @@
|
|||||||
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
|
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
|
||||||
<location
|
<location
|
||||||
file="res/drawable/ic_homepage_sound.xml"
|
file="res/drawable/ic_homepage_sound.xml"
|
||||||
line="24"
|
line="23"
|
||||||
column="17"/>
|
column="17"/>
|
||||||
</issue>
|
</issue>
|
||||||
|
|
||||||
@@ -1805,7 +1821,7 @@
|
|||||||
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
|
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
|
||||||
<location
|
<location
|
||||||
file="res/drawable/ic_homepage_storage.xml"
|
file="res/drawable/ic_homepage_storage.xml"
|
||||||
line="24"
|
line="23"
|
||||||
column="17"/>
|
column="17"/>
|
||||||
</issue>
|
</issue>
|
||||||
|
|
||||||
@@ -1821,7 +1837,7 @@
|
|||||||
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
|
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
|
||||||
<location
|
<location
|
||||||
file="res/drawable/ic_homepage_support.xml"
|
file="res/drawable/ic_homepage_support.xml"
|
||||||
line="24"
|
line="23"
|
||||||
column="17"/>
|
column="17"/>
|
||||||
</issue>
|
</issue>
|
||||||
|
|
||||||
@@ -1837,7 +1853,7 @@
|
|||||||
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
|
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
|
||||||
<location
|
<location
|
||||||
file="res/drawable/ic_homepage_system_dashboard.xml"
|
file="res/drawable/ic_homepage_system_dashboard.xml"
|
||||||
line="24"
|
line="23"
|
||||||
column="17"/>
|
column="17"/>
|
||||||
</issue>
|
</issue>
|
||||||
|
|
||||||
@@ -2557,7 +2573,7 @@
|
|||||||
errorLine2=" ~~~~~~~~~~~~~~~~~~~">
|
errorLine2=" ~~~~~~~~~~~~~~~~~~~">
|
||||||
<location
|
<location
|
||||||
file="res/values/strings.xml"
|
file="res/values/strings.xml"
|
||||||
line="5637"
|
line="5651"
|
||||||
column="36"/>
|
column="36"/>
|
||||||
</issue>
|
</issue>
|
||||||
|
|
||||||
@@ -2589,7 +2605,7 @@
|
|||||||
errorLine2=" ^">
|
errorLine2=" ^">
|
||||||
<location
|
<location
|
||||||
file="res/values/styles.xml"
|
file="res/values/styles.xml"
|
||||||
line="437"
|
line="442"
|
||||||
column="44"/>
|
column="44"/>
|
||||||
</issue>
|
</issue>
|
||||||
|
|
||||||
@@ -2605,7 +2621,7 @@
|
|||||||
errorLine2=" ^">
|
errorLine2=" ^">
|
||||||
<location
|
<location
|
||||||
file="res/values/styles.xml"
|
file="res/values/styles.xml"
|
||||||
line="443"
|
line="448"
|
||||||
column="44"/>
|
column="44"/>
|
||||||
</issue>
|
</issue>
|
||||||
|
|
||||||
@@ -2621,7 +2637,7 @@
|
|||||||
errorLine2=" ^">
|
errorLine2=" ^">
|
||||||
<location
|
<location
|
||||||
file="res/values/styles.xml"
|
file="res/values/styles.xml"
|
||||||
line="444"
|
line="449"
|
||||||
column="44"/>
|
column="44"/>
|
||||||
</issue>
|
</issue>
|
||||||
|
|
||||||
@@ -2637,7 +2653,7 @@
|
|||||||
errorLine2=" ^">
|
errorLine2=" ^">
|
||||||
<location
|
<location
|
||||||
file="res/values/styles.xml"
|
file="res/values/styles.xml"
|
||||||
line="467"
|
line="472"
|
||||||
column="41"/>
|
column="41"/>
|
||||||
</issue>
|
</issue>
|
||||||
|
|
||||||
|
@@ -18,8 +18,7 @@
|
|||||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
<item>
|
<item>
|
||||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
<shape android:shape="oval">
|
||||||
android:shape="oval">
|
|
||||||
<solid
|
<solid
|
||||||
android:color="@color/homepage_accessibility_background" />
|
android:color="@color/homepage_accessibility_background" />
|
||||||
<size
|
<size
|
||||||
|
@@ -18,8 +18,7 @@
|
|||||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
<item>
|
<item>
|
||||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
<shape android:shape="oval">
|
||||||
android:shape="oval">
|
|
||||||
<solid
|
<solid
|
||||||
android:color="@color/homepage_accounts_background" />
|
android:color="@color/homepage_accounts_background" />
|
||||||
<size
|
<size
|
||||||
|
@@ -18,8 +18,7 @@
|
|||||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
<item>
|
<item>
|
||||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
<shape android:shape="oval">
|
||||||
android:shape="oval">
|
|
||||||
<solid
|
<solid
|
||||||
android:color="@color/homepage_app_and_notification_background" />
|
android:color="@color/homepage_app_and_notification_background" />
|
||||||
<size
|
<size
|
||||||
|
@@ -18,8 +18,7 @@
|
|||||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
<item>
|
<item>
|
||||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
<shape android:shape="oval">
|
||||||
android:shape="oval">
|
|
||||||
<solid
|
<solid
|
||||||
android:color="@color/homepage_battery_background" />
|
android:color="@color/homepage_battery_background" />
|
||||||
<size
|
<size
|
||||||
|
@@ -18,8 +18,7 @@
|
|||||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
<item>
|
<item>
|
||||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
<shape android:shape="oval">
|
||||||
android:shape="oval">
|
|
||||||
<solid
|
<solid
|
||||||
android:color="@color/homepage_connected_device_background" />
|
android:color="@color/homepage_connected_device_background" />
|
||||||
<size
|
<size
|
||||||
|
@@ -18,8 +18,7 @@
|
|||||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
<item>
|
<item>
|
||||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
<shape android:shape="oval">
|
||||||
android:shape="oval">
|
|
||||||
<solid
|
<solid
|
||||||
android:color="@color/homepage_display_background" />
|
android:color="@color/homepage_display_background" />
|
||||||
<size
|
<size
|
||||||
|
24
res/drawable/ic_homepage_generic_background.xml
Normal file
24
res/drawable/ic_homepage_generic_background.xml
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!--
|
||||||
|
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.
|
||||||
|
-->
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:shape="oval">
|
||||||
|
<solid
|
||||||
|
android:color="@color/homepage_generic_icon_background" />
|
||||||
|
<size
|
||||||
|
android:width="@dimen/dashboard_tile_image_size"
|
||||||
|
android:height="@dimen/dashboard_tile_image_size" />
|
||||||
|
</shape>
|
@@ -18,8 +18,7 @@
|
|||||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
<item>
|
<item>
|
||||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
<shape android:shape="oval">
|
||||||
android:shape="oval">
|
|
||||||
<solid
|
<solid
|
||||||
android:color="@color/homepage_network_background" />
|
android:color="@color/homepage_network_background" />
|
||||||
<size
|
<size
|
||||||
|
@@ -18,8 +18,7 @@
|
|||||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
<item>
|
<item>
|
||||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
<shape android:shape="oval">
|
||||||
android:shape="oval">
|
|
||||||
<solid
|
<solid
|
||||||
android:color="@color/homepage_security_background" />
|
android:color="@color/homepage_security_background" />
|
||||||
<size
|
<size
|
||||||
|
@@ -18,8 +18,7 @@
|
|||||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
<item>
|
<item>
|
||||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
<shape android:shape="oval">
|
||||||
android:shape="oval">
|
|
||||||
<solid
|
<solid
|
||||||
android:color="@color/homepage_sound_background" />
|
android:color="@color/homepage_sound_background" />
|
||||||
<size
|
<size
|
||||||
|
@@ -18,8 +18,7 @@
|
|||||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
<item>
|
<item>
|
||||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
<shape android:shape="oval">
|
||||||
android:shape="oval">
|
|
||||||
<solid
|
<solid
|
||||||
android:color="@color/homepage_storage_background" />
|
android:color="@color/homepage_storage_background" />
|
||||||
<size
|
<size
|
||||||
|
@@ -18,8 +18,7 @@
|
|||||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
<item>
|
<item>
|
||||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
<shape android:shape="oval">
|
||||||
android:shape="oval">
|
|
||||||
<solid
|
<solid
|
||||||
android:color="@color/homepage_support_background" />
|
android:color="@color/homepage_support_background" />
|
||||||
<size
|
<size
|
||||||
|
@@ -18,8 +18,7 @@
|
|||||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
<item>
|
<item>
|
||||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
<shape android:shape="oval">
|
||||||
android:shape="oval">
|
|
||||||
<solid
|
<solid
|
||||||
android:color="@color/homepage_system_background" />
|
android:color="@color/homepage_system_background" />
|
||||||
<size
|
<size
|
||||||
|
@@ -17,7 +17,6 @@ package com.android.settings.dashboard;
|
|||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.res.TypedArray;
|
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.graphics.drawable.Icon;
|
import android.graphics.drawable.Icon;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
@@ -126,7 +125,6 @@ public class DashboardAdapterV2 extends RecyclerView.Adapter<DashboardAdapterV2.
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setCategory(DashboardCategory category) {
|
public void setCategory(DashboardCategory category) {
|
||||||
tintIcons(category);
|
|
||||||
final DashboardDataV2 prevData = mDashboardData;
|
final DashboardDataV2 prevData = mDashboardData;
|
||||||
Log.d(TAG, "adapter setCategory called");
|
Log.d(TAG, "adapter setCategory called");
|
||||||
mDashboardData = new DashboardDataV2.Builder(prevData)
|
mDashboardData = new DashboardDataV2.Builder(prevData)
|
||||||
@@ -194,7 +192,7 @@ public class DashboardAdapterV2 extends RecyclerView.Adapter<DashboardAdapterV2.
|
|||||||
switch (type) {
|
switch (type) {
|
||||||
case R.layout.dashboard_tile:
|
case R.layout.dashboard_tile:
|
||||||
final Tile tile = (Tile) mDashboardData.getItemEntityByPosition(position);
|
final Tile tile = (Tile) mDashboardData.getItemEntityByPosition(position);
|
||||||
onBindTile((DashboardItemHolder) holder, tile);
|
onBindTile(holder, tile);
|
||||||
holder.itemView.setTag(tile);
|
holder.itemView.setTag(tile);
|
||||||
holder.itemView.setOnClickListener(mTileClickListener);
|
holder.itemView.setOnClickListener(mTileClickListener);
|
||||||
break;
|
break;
|
||||||
@@ -318,8 +316,14 @@ public class DashboardAdapterV2 extends RecyclerView.Adapter<DashboardAdapterV2.
|
|||||||
holder.data.setLayoutManager(layoutManager);
|
holder.data.setLayoutManager(layoutManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onBindTile(DashboardItemHolder holder, Tile tile) {
|
@VisibleForTesting
|
||||||
holder.icon.setImageDrawable(mCache.getIcon(tile.icon));
|
void onBindTile(DashboardItemHolder holder, Tile tile) {
|
||||||
|
Drawable icon = mCache.getIcon(tile.icon);
|
||||||
|
if (!TextUtils.equals(tile.icon.getResPackage(), mContext.getPackageName())) {
|
||||||
|
icon = new RoundedHomepageIcon(mContext, icon);
|
||||||
|
mCache.updateIcon(tile.icon, icon);
|
||||||
|
}
|
||||||
|
holder.icon.setImageDrawable(icon);
|
||||||
holder.title.setText(tile.title);
|
holder.title.setText(tile.title);
|
||||||
if (!TextUtils.isEmpty(tile.summary)) {
|
if (!TextUtils.isEmpty(tile.summary)) {
|
||||||
holder.summary.setText(tile.summary);
|
holder.summary.setText(tile.summary);
|
||||||
@@ -329,25 +333,6 @@ public class DashboardAdapterV2 extends RecyclerView.Adapter<DashboardAdapterV2.
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void tintIcons(DashboardCategory category) {
|
|
||||||
if (!mDashboardFeatureProvider.shouldTintIcon()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// TODO: Better place for tinting?
|
|
||||||
final TypedArray a = mContext.obtainStyledAttributes(new int[]{
|
|
||||||
android.R.attr.colorControlNormal});
|
|
||||||
final int tintColor = a.getColor(0, mContext.getColor(R.color.fallback_tintColor));
|
|
||||||
a.recycle();
|
|
||||||
if (category != null) {
|
|
||||||
for (Tile tile : category.getTiles()) {
|
|
||||||
if (tile.isIconTintable) {
|
|
||||||
// If this drawable is tintable, tint it to match the color.
|
|
||||||
tile.icon.setTint(tintColor);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSaveInstanceState(Bundle outState) {
|
public void onSaveInstanceState(Bundle outState) {
|
||||||
final DashboardCategory category = mDashboardData.getCategory();
|
final DashboardCategory category = mDashboardData.getCategory();
|
||||||
@@ -392,10 +377,14 @@ public class DashboardAdapterV2 extends RecyclerView.Adapter<DashboardAdapterV2.
|
|||||||
Drawable drawable = mMap.get(icon);
|
Drawable drawable = mMap.get(icon);
|
||||||
if (drawable == null) {
|
if (drawable == null) {
|
||||||
drawable = icon.loadDrawable(mContext);
|
drawable = icon.loadDrawable(mContext);
|
||||||
mMap.put(icon, drawable);
|
updateIcon(icon, drawable);
|
||||||
}
|
}
|
||||||
return drawable;
|
return drawable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void updateIcon(Icon icon, Drawable drawable) {
|
||||||
|
mMap.put(icon, drawable);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class DashboardItemHolder extends RecyclerView.ViewHolder {
|
public static class DashboardItemHolder extends RecyclerView.ViewHolder {
|
||||||
|
@@ -56,7 +56,9 @@ public interface DashboardFeatureProvider {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether or not we should tint icons in setting pages.
|
* Whether or not we should tint icons in setting pages.
|
||||||
|
* @deprecated in favor of color icons in homepage
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
boolean shouldTintIcon();
|
boolean shouldTintIcon();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
36
src/com/android/settings/dashboard/RoundedHomepageIcon.java
Normal file
36
src/com/android/settings/dashboard/RoundedHomepageIcon.java
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
/*
|
||||||
|
* 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 android.content.Context;
|
||||||
|
import android.graphics.drawable.Drawable;
|
||||||
|
import android.graphics.drawable.LayerDrawable;
|
||||||
|
|
||||||
|
import com.android.settings.R;
|
||||||
|
|
||||||
|
public class RoundedHomepageIcon extends LayerDrawable {
|
||||||
|
|
||||||
|
public RoundedHomepageIcon(Context context, Drawable foreground) {
|
||||||
|
super(new Drawable[] {
|
||||||
|
context.getDrawable(R.drawable.ic_homepage_generic_background),
|
||||||
|
foreground
|
||||||
|
});
|
||||||
|
final int insetPx = context.getResources()
|
||||||
|
.getDimensionPixelSize(R.dimen.dashboard_tile_foreground_image_inset);
|
||||||
|
setLayerInset(1 /* index */, insetPx, insetPx, insetPx, insetPx);
|
||||||
|
}
|
||||||
|
}
|
@@ -16,11 +16,8 @@
|
|||||||
package com.android.settings.dashboard;
|
package com.android.settings.dashboard;
|
||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
import static org.mockito.ArgumentMatchers.anyInt;
|
|
||||||
import static org.mockito.ArgumentMatchers.eq;
|
import static org.mockito.ArgumentMatchers.eq;
|
||||||
import static org.mockito.Mockito.any;
|
import static org.mockito.Mockito.any;
|
||||||
import static org.mockito.Mockito.doReturn;
|
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.never;
|
import static org.mockito.Mockito.never;
|
||||||
import static org.mockito.Mockito.reset;
|
import static org.mockito.Mockito.reset;
|
||||||
@@ -31,11 +28,12 @@ import static org.mockito.Mockito.when;
|
|||||||
import android.app.PendingIntent;
|
import android.app.PendingIntent;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.content.res.TypedArray;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.graphics.drawable.Icon;
|
import android.graphics.drawable.Icon;
|
||||||
import android.service.settings.suggestions.Suggestion;
|
import android.service.settings.suggestions.Suggestion;
|
||||||
import android.support.v7.widget.RecyclerView;
|
import android.support.v7.widget.RecyclerView;
|
||||||
import android.util.DisplayMetrics;
|
import android.util.DisplayMetrics;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
@@ -47,7 +45,6 @@ import com.android.settings.dashboard.suggestions.SuggestionAdapterV2;
|
|||||||
import com.android.settings.testutils.FakeFeatureFactory;
|
import com.android.settings.testutils.FakeFeatureFactory;
|
||||||
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||||
import com.android.settings.testutils.shadow.SettingsShadowResources;
|
import com.android.settings.testutils.shadow.SettingsShadowResources;
|
||||||
import com.android.settingslib.drawer.DashboardCategory;
|
|
||||||
import com.android.settingslib.drawer.Tile;
|
import com.android.settingslib.drawer.Tile;
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
@@ -58,6 +55,7 @@ import org.mockito.Mock;
|
|||||||
import org.mockito.MockitoAnnotations;
|
import org.mockito.MockitoAnnotations;
|
||||||
import org.robolectric.RuntimeEnvironment;
|
import org.robolectric.RuntimeEnvironment;
|
||||||
import org.robolectric.annotation.Config;
|
import org.robolectric.annotation.Config;
|
||||||
|
import org.robolectric.util.ReflectionHelpers;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -105,7 +103,8 @@ public class DashboardAdapterV2Test {
|
|||||||
public void testSuggestionDismissed_notOnlySuggestion_updateSuggestionOnly() {
|
public void testSuggestionDismissed_notOnlySuggestion_updateSuggestionOnly() {
|
||||||
final DashboardAdapterV2 adapter =
|
final DashboardAdapterV2 adapter =
|
||||||
spy(new DashboardAdapterV2(mContext, null /* savedInstanceState */,
|
spy(new DashboardAdapterV2(mContext, null /* savedInstanceState */,
|
||||||
null /* conditions */, null /* suggestionControllerMixin */, null /* lifecycle */));
|
null /* conditions */, null /* suggestionControllerMixin */, null /*
|
||||||
|
lifecycle */));
|
||||||
final List<Suggestion> suggestions = makeSuggestionsV2("pkg1", "pkg2", "pkg3");
|
final List<Suggestion> suggestions = makeSuggestionsV2("pkg1", "pkg2", "pkg3");
|
||||||
adapter.setSuggestions(suggestions);
|
adapter.setSuggestions(suggestions);
|
||||||
|
|
||||||
@@ -143,7 +142,8 @@ public class DashboardAdapterV2Test {
|
|||||||
new DashboardAdapterV2.SuggestionContainerHolder(itemView);
|
new DashboardAdapterV2.SuggestionContainerHolder(itemView);
|
||||||
final List<Suggestion> suggestions = makeSuggestionsV2("pkg1", "pkg2", "pkg3", "pkg4");
|
final List<Suggestion> suggestions = makeSuggestionsV2("pkg1", "pkg2", "pkg3", "pkg4");
|
||||||
final DashboardAdapterV2 adapter = spy(new DashboardAdapterV2(mContext,
|
final DashboardAdapterV2 adapter = spy(new DashboardAdapterV2(mContext,
|
||||||
null /*savedInstance */, null /* conditions */, null /* suggestionControllerMixin */,
|
null /*savedInstance */, null /* conditions */,
|
||||||
|
null /* suggestionControllerMixin */,
|
||||||
null /* lifecycle */));
|
null /* lifecycle */));
|
||||||
adapter.setSuggestions(suggestions);
|
adapter.setSuggestions(suggestions);
|
||||||
adapter.onBindSuggestion(holder, 0);
|
adapter.onBindSuggestion(holder, 0);
|
||||||
@@ -160,7 +160,8 @@ public class DashboardAdapterV2Test {
|
|||||||
public void testSuggestionDismissed_onlySuggestion_updateDashboardData() {
|
public void testSuggestionDismissed_onlySuggestion_updateDashboardData() {
|
||||||
DashboardAdapterV2 adapter =
|
DashboardAdapterV2 adapter =
|
||||||
spy(new DashboardAdapterV2(mContext, null /* savedInstanceState */,
|
spy(new DashboardAdapterV2(mContext, null /* savedInstanceState */,
|
||||||
null /* conditions */, null /* suggestionControllerMixin */, null /* lifecycle */));
|
null /* conditions */, null /* suggestionControllerMixin */, null /*
|
||||||
|
lifecycle */));
|
||||||
final List<Suggestion> suggestions = makeSuggestionsV2("pkg1");
|
final List<Suggestion> suggestions = makeSuggestionsV2("pkg1");
|
||||||
adapter.setSuggestions(suggestions);
|
adapter.setSuggestions(suggestions);
|
||||||
final DashboardDataV2 dashboardData = adapter.mDashboardData;
|
final DashboardDataV2 dashboardData = adapter.mDashboardData;
|
||||||
@@ -172,24 +173,6 @@ public class DashboardAdapterV2Test {
|
|||||||
verify(adapter).notifyDashboardDataChanged(any());
|
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
|
@Test
|
||||||
public void testBindSuggestion_shouldSetSuggestionAdapterAndNoCrash() {
|
public void testBindSuggestion_shouldSetSuggestionAdapterAndNoCrash() {
|
||||||
mDashboardAdapter = new DashboardAdapterV2(mContext, null /* savedInstanceState */,
|
mDashboardAdapter = new DashboardAdapterV2(mContext, null /* savedInstanceState */,
|
||||||
@@ -245,6 +228,46 @@ public class DashboardAdapterV2Test {
|
|||||||
verify(summary).setText("4");
|
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<Suggestion> makeSuggestionsV2(String... pkgNames) {
|
private List<Suggestion> makeSuggestionsV2(String... pkgNames) {
|
||||||
final List<Suggestion> suggestions = new ArrayList<>();
|
final List<Suggestion> suggestions = new ArrayList<>();
|
||||||
for (String pkgName : pkgNames) {
|
for (String pkgName : pkgNames) {
|
||||||
|
@@ -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));
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user