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 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>
|
||||
|
@@ -102,4 +102,7 @@
|
||||
<!-- Whether or not the camera lift trigger is available in the moves menu. -->
|
||||
<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>
|
||||
|
@@ -137,10 +137,11 @@ public class DashboardAdapter extends RecyclerView.Adapter<DashboardAdapter.Dash
|
||||
|
||||
public void setCategoriesAndSuggestions(List<DashboardCategory> categories,
|
||||
List<Tile> suggestions) {
|
||||
if (mDashboardFeatureProvider.shouldTintIcon()) {
|
||||
// TODO: Better place for tinting?
|
||||
final TypedArray a = mContext.obtainStyledAttributes(new int[]{
|
||||
android.R.attr.colorControlNormal});
|
||||
int tintColor = a.getColor(0, mContext.getColor(android.R.color.white));
|
||||
final int tintColor = a.getColor(0, mContext.getColor(R.color.fallback_tintColor));
|
||||
a.recycle();
|
||||
for (int i = 0; i < categories.size(); i++) {
|
||||
for (int j = 0; j < categories.get(i).tiles.size(); j++) {
|
||||
@@ -154,6 +155,7 @@ public class DashboardAdapter extends RecyclerView.Adapter<DashboardAdapter.Dash
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final DashboardData prevData = mDashboardData;
|
||||
mDashboardData = new DashboardData.Builder(prevData)
|
||||
|
@@ -55,6 +55,11 @@ public interface DashboardFeatureProvider {
|
||||
*/
|
||||
List<DashboardCategory> getAllCategories();
|
||||
|
||||
/**
|
||||
* Whether or not we should tint icons in setting pages.
|
||||
*/
|
||||
boolean shouldTintIcon();
|
||||
|
||||
/**
|
||||
* Returns an unique string key for the tile.
|
||||
*/
|
||||
|
@@ -97,6 +97,11 @@ public class DashboardFeatureProviderImpl implements DashboardFeatureProvider {
|
||||
return mCategoryManager.getCategories(mContext);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldTintIcon() {
|
||||
return mContext.getResources().getBoolean(R.bool.config_tintSettingIcon);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDashboardKeyForTile(Tile tile) {
|
||||
if (tile == null || tile.intent == null) {
|
||||
|
@@ -20,6 +20,7 @@ import android.app.Activity;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.drawable.Icon;
|
||||
import android.os.Bundle;
|
||||
@@ -364,4 +365,16 @@ public class DashboardFeatureProviderImplTest {
|
||||
public void testGetExtraIntentAction_shouldReturnNull() {
|
||||
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