Add flag to control whether or not we should tint icons

Fix: 34365726
Test: robotests
Change-Id: Ic08d8590c9867fb0383da03f05237f74644a77ff
This commit is contained in:
Fan Zhang
2017-04-28 09:11:28 -07:00
parent d0417e42f0
commit 0a257ee1ba
6 changed files with 43 additions and 13 deletions

View File

@@ -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>

View File

@@ -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>

View File

@@ -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)

View File

@@ -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.
*/

View File

@@ -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) {

View File

@@ -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();
}
}