Add flag to control whether or not we should tint icons
Fix: 34365726 Test: robotests Change-Id: Ic08d8590c9867fb0383da03f05237f74644a77ff
This commit is contained in:
@@ -113,4 +113,6 @@
|
|||||||
<!-- Color for preference icons on the Wifi Network Details page -->
|
<!-- Color for preference icons on the Wifi Network Details page -->
|
||||||
<color name="wifi_details_icon_color">#8A000000</color>
|
<color name="wifi_details_icon_color">#8A000000</color>
|
||||||
|
|
||||||
|
<!-- The fallback color for tinting icons. Only used when colorControlNormal is unavailable -->
|
||||||
|
<color name="fallback_tintColor">#89000000</color>
|
||||||
</resources>
|
</resources>
|
||||||
|
@@ -102,4 +102,7 @@
|
|||||||
<!-- Whether or not the camera lift trigger is available in the moves menu. -->
|
<!-- Whether or not the camera lift trigger is available in the moves menu. -->
|
||||||
<bool name="config_cameraLiftTriggerAvailable">false</bool>
|
<bool name="config_cameraLiftTriggerAvailable">false</bool>
|
||||||
|
|
||||||
|
<!-- Whether or not we should tint the icon color on setting pages. -->
|
||||||
|
<bool name="config_tintSettingIcon">true</bool>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
@@ -137,20 +137,22 @@ public class DashboardAdapter extends RecyclerView.Adapter<DashboardAdapter.Dash
|
|||||||
|
|
||||||
public void setCategoriesAndSuggestions(List<DashboardCategory> categories,
|
public void setCategoriesAndSuggestions(List<DashboardCategory> categories,
|
||||||
List<Tile> suggestions) {
|
List<Tile> suggestions) {
|
||||||
// TODO: Better place for tinting?
|
if (mDashboardFeatureProvider.shouldTintIcon()) {
|
||||||
final TypedArray a = mContext.obtainStyledAttributes(new int[]{
|
// TODO: Better place for tinting?
|
||||||
android.R.attr.colorControlNormal});
|
final TypedArray a = mContext.obtainStyledAttributes(new int[]{
|
||||||
int tintColor = a.getColor(0, mContext.getColor(android.R.color.white));
|
android.R.attr.colorControlNormal});
|
||||||
a.recycle();
|
final int tintColor = a.getColor(0, mContext.getColor(R.color.fallback_tintColor));
|
||||||
for (int i = 0; i < categories.size(); i++) {
|
a.recycle();
|
||||||
for (int j = 0; j < categories.get(i).tiles.size(); j++) {
|
for (int i = 0; i < categories.size(); i++) {
|
||||||
final Tile tile = categories.get(i).tiles.get(j);
|
for (int j = 0; j < categories.get(i).tiles.size(); j++) {
|
||||||
|
final Tile tile = categories.get(i).tiles.get(j);
|
||||||
|
|
||||||
if (!mContext.getPackageName().equals(
|
if (!mContext.getPackageName().equals(
|
||||||
tile.intent.getComponent().getPackageName())) {
|
tile.intent.getComponent().getPackageName())) {
|
||||||
// If this drawable is coming from outside Settings, tint it to match the
|
// If this drawable is coming from outside Settings, tint it to match the
|
||||||
// color.
|
// color.
|
||||||
tile.icon.setTint(tintColor);
|
tile.icon.setTint(tintColor);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -55,6 +55,11 @@ public interface DashboardFeatureProvider {
|
|||||||
*/
|
*/
|
||||||
List<DashboardCategory> getAllCategories();
|
List<DashboardCategory> getAllCategories();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether or not we should tint icons in setting pages.
|
||||||
|
*/
|
||||||
|
boolean shouldTintIcon();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an unique string key for the tile.
|
* Returns an unique string key for the tile.
|
||||||
*/
|
*/
|
||||||
|
@@ -97,6 +97,11 @@ public class DashboardFeatureProviderImpl implements DashboardFeatureProvider {
|
|||||||
return mCategoryManager.getCategories(mContext);
|
return mCategoryManager.getCategories(mContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean shouldTintIcon() {
|
||||||
|
return mContext.getResources().getBoolean(R.bool.config_tintSettingIcon);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getDashboardKeyForTile(Tile tile) {
|
public String getDashboardKeyForTile(Tile tile) {
|
||||||
if (tile == null || tile.intent == null) {
|
if (tile == null || tile.intent == null) {
|
||||||
|
@@ -20,6 +20,7 @@ import android.app.Activity;
|
|||||||
import android.content.ComponentName;
|
import android.content.ComponentName;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.content.res.Resources;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.graphics.drawable.Icon;
|
import android.graphics.drawable.Icon;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
@@ -364,4 +365,16 @@ public class DashboardFeatureProviderImplTest {
|
|||||||
public void testGetExtraIntentAction_shouldReturnNull() {
|
public void testGetExtraIntentAction_shouldReturnNull() {
|
||||||
assertThat(mImpl.getExtraIntentAction()).isNull();
|
assertThat(mImpl.getExtraIntentAction()).isNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testShouldTintIcon_shouldReturnValueFromResource() {
|
||||||
|
final Resources res = mActivity.getApplicationContext().getResources();
|
||||||
|
when(res.getBoolean(R.bool.config_tintSettingIcon))
|
||||||
|
.thenReturn(false);
|
||||||
|
assertThat(mImpl.shouldTintIcon()).isFalse();
|
||||||
|
|
||||||
|
when(res.getBoolean(R.bool.config_tintSettingIcon))
|
||||||
|
.thenReturn(true);
|
||||||
|
assertThat(mImpl.shouldTintIcon()).isTrue();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user