diff --git a/res/drawable-hdpi/ic_settings_bluetooth2_alpha.png b/res/drawable-hdpi/ic_settings_bluetooth2_alpha.png deleted file mode 100644 index 9dbc509d316..00000000000 Binary files a/res/drawable-hdpi/ic_settings_bluetooth2_alpha.png and /dev/null differ diff --git a/res/drawable-hdpi/ic_settings_bluetooth_alpha.png b/res/drawable-hdpi/ic_settings_bluetooth_alpha.png index a21982e9424..9dbc509d316 100644 Binary files a/res/drawable-hdpi/ic_settings_bluetooth_alpha.png and b/res/drawable-hdpi/ic_settings_bluetooth_alpha.png differ diff --git a/res/drawable-hdpi/ic_settings_wifi_alpha.png b/res/drawable-hdpi/ic_settings_wifi_alpha.png deleted file mode 100644 index a21982e9424..00000000000 Binary files a/res/drawable-hdpi/ic_settings_wifi_alpha.png and /dev/null differ diff --git a/res/drawable-mdpi/ic_settings_bluetooth2_alpha.png b/res/drawable-mdpi/ic_settings_bluetooth2_alpha.png deleted file mode 100644 index f51e5caa38a..00000000000 Binary files a/res/drawable-mdpi/ic_settings_bluetooth2_alpha.png and /dev/null differ diff --git a/res/drawable-mdpi/ic_settings_bluetooth_alpha.png b/res/drawable-mdpi/ic_settings_bluetooth_alpha.png index 31be00432cd..f51e5caa38a 100644 Binary files a/res/drawable-mdpi/ic_settings_bluetooth_alpha.png and b/res/drawable-mdpi/ic_settings_bluetooth_alpha.png differ diff --git a/res/drawable-mdpi/ic_settings_wifi_alpha.png b/res/drawable-mdpi/ic_settings_wifi_alpha.png deleted file mode 100644 index 31be00432cd..00000000000 Binary files a/res/drawable-mdpi/ic_settings_wifi_alpha.png and /dev/null differ diff --git a/res/drawable-xhdpi/ic_settings_bluetooth2_alpha.png b/res/drawable-xhdpi/ic_settings_bluetooth2_alpha.png deleted file mode 100644 index a3e09db2fa9..00000000000 Binary files a/res/drawable-xhdpi/ic_settings_bluetooth2_alpha.png and /dev/null differ diff --git a/res/drawable-xhdpi/ic_settings_bluetooth_alpha.png b/res/drawable-xhdpi/ic_settings_bluetooth_alpha.png index cee4e67ad6f..a3e09db2fa9 100644 Binary files a/res/drawable-xhdpi/ic_settings_bluetooth_alpha.png and b/res/drawable-xhdpi/ic_settings_bluetooth_alpha.png differ diff --git a/res/drawable-xhdpi/ic_settings_wifi_alpha.png b/res/drawable-xhdpi/ic_settings_wifi_alpha.png deleted file mode 100644 index cee4e67ad6f..00000000000 Binary files a/res/drawable-xhdpi/ic_settings_wifi_alpha.png and /dev/null differ diff --git a/res/drawable-xxhdpi/ic_settings_bluetooth2_alpha.png b/res/drawable-xxhdpi/ic_settings_bluetooth_alpha.png similarity index 100% rename from res/drawable-xxhdpi/ic_settings_bluetooth2_alpha.png rename to res/drawable-xxhdpi/ic_settings_bluetooth_alpha.png diff --git a/res/drawable-xxxhdpi/ic_settings_bluetooth2_alpha.png b/res/drawable-xxxhdpi/ic_settings_bluetooth_alpha.png similarity index 100% rename from res/drawable-xxxhdpi/ic_settings_bluetooth2_alpha.png rename to res/drawable-xxxhdpi/ic_settings_bluetooth_alpha.png diff --git a/res/drawable/ic_settings_bluetooth2.xml b/res/drawable/ic_settings_bluetooth2.xml deleted file mode 100644 index df0f866351d..00000000000 --- a/res/drawable/ic_settings_bluetooth2.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - diff --git a/res/drawable/ic_settings_wifi.xml b/res/drawable/ic_settings_wifi.xml deleted file mode 100644 index 9b58909047f..00000000000 --- a/res/drawable/ic_settings_wifi.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - diff --git a/res/xml/dashboard_categories.xml b/res/xml/dashboard_categories.xml index 5b8c243a33a..ebddd789ec0 100644 --- a/res/xml/dashboard_categories.xml +++ b/res/xml/dashboard_categories.xml @@ -36,7 +36,7 @@ android:id="@+id/bluetooth_settings" android:title="@string/bluetooth_settings_title" android:fragment="com.android.settings.bluetooth.BluetoothSettings" - android:icon="@drawable/ic_settings_bluetooth2" + android:icon="@drawable/ic_settings_bluetooth" /> diff --git a/src/com/android/settings/TintablePreference.java b/src/com/android/settings/TintablePreference.java new file mode 100644 index 00000000000..3c56b1e12c4 --- /dev/null +++ b/src/com/android/settings/TintablePreference.java @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2015 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; + +import android.content.Context; +import android.content.res.ColorStateList; +import android.preference.Preference; +import android.util.AttributeSet; +import android.view.View; +import android.widget.ImageView; + +public class TintablePreference extends Preference { + + private int mTintColor; + + public TintablePreference(Context context, AttributeSet attrs) { + super(context, attrs); + } + + public void setTint(int color) { + mTintColor = color; + notifyChanged(); + } + + @Override + protected void onBindView(View view) { + super.onBindView(view); + + if (mTintColor != 0) { + ((ImageView) view.findViewById(R.id.icon)).setImageTintList( + ColorStateList.valueOf(mTintColor)); + } + } +} diff --git a/src/com/android/settings/bluetooth/BluetoothDevicePreference.java b/src/com/android/settings/bluetooth/BluetoothDevicePreference.java index 7bdc1a69d0b..b36d2ea77f4 100644 --- a/src/com/android/settings/bluetooth/BluetoothDevicePreference.java +++ b/src/com/android/settings/bluetooth/BluetoothDevicePreference.java @@ -222,7 +222,7 @@ public final class BluetoothDevicePreference extends Preference implements data.className = BluetoothSettings.class.getName(); data.title = mCachedDevice.getName(); data.screenTitle = context.getResources().getString(R.string.bluetooth_settings); - data.iconResId = R.drawable.ic_settings_bluetooth2; + data.iconResId = R.drawable.ic_settings_bluetooth; data.enabled = true; Index.getInstance(context).updateFromSearchIndexableData(data); @@ -268,6 +268,6 @@ public final class BluetoothDevicePreference extends Preference implements return R.drawable.ic_bt_headset_hfp; } } - return R.drawable.ic_settings_bluetooth2; + return R.drawable.ic_settings_bluetooth; } } diff --git a/src/com/android/settings/bluetooth/BluetoothSettings.java b/src/com/android/settings/bluetooth/BluetoothSettings.java index cf06fe79ba4..4113b9ec23e 100755 --- a/src/com/android/settings/bluetooth/BluetoothSettings.java +++ b/src/com/android/settings/bluetooth/BluetoothSettings.java @@ -488,7 +488,7 @@ public final class BluetoothSettings extends DeviceListPreferenceFragment implem com.android.settings.bluetooth.Utils.updateSearchIndex(activity, BluetoothSettings.class.getName(), device.getName(), context.getResources().getString(R.string.bluetooth_settings), - R.drawable.ic_settings_bluetooth2, false); + R.drawable.ic_settings_bluetooth, false); } }); diff --git a/src/com/android/settings/fuelgauge/BatteryEntry.java b/src/com/android/settings/fuelgauge/BatteryEntry.java index be7c657001d..bfae5785bc9 100644 --- a/src/com/android/settings/fuelgauge/BatteryEntry.java +++ b/src/com/android/settings/fuelgauge/BatteryEntry.java @@ -146,7 +146,7 @@ public class BatteryEntry { break; case WIFI: name = context.getResources().getString(R.string.power_wifi); - iconId = R.drawable.ic_settings_wifi; + iconId = R.drawable.ic_settings_wireless; break; case BLUETOOTH: name = context.getResources().getString(R.string.power_bluetooth); diff --git a/src/com/android/settings/fuelgauge/PowerGaugePreference.java b/src/com/android/settings/fuelgauge/PowerGaugePreference.java index 97012e483ec..e80f4924227 100644 --- a/src/com/android/settings/fuelgauge/PowerGaugePreference.java +++ b/src/com/android/settings/fuelgauge/PowerGaugePreference.java @@ -25,13 +25,14 @@ import android.widget.ProgressBar; import android.widget.TextView; import com.android.settings.R; +import com.android.settings.TintablePreference; import com.android.settings.Utils; /** * Custom preference for displaying power consumption as a bar and an icon on * the left for the subsystem/app type. */ -public class PowerGaugePreference extends Preference { +public class PowerGaugePreference extends TintablePreference { private BatteryEntry mInfo; private int mProgress; private CharSequence mProgressText; @@ -39,7 +40,7 @@ public class PowerGaugePreference extends Preference { public PowerGaugePreference(Context context, Drawable icon, CharSequence contentDescription, BatteryEntry info) { - super(context); + super(context, null); setLayoutResource(R.layout.preference_app_percentage); setIcon(icon != null ? icon : new ColorDrawable(0)); mInfo = info; diff --git a/src/com/android/settings/fuelgauge/PowerUsageSummary.java b/src/com/android/settings/fuelgauge/PowerUsageSummary.java index 3576ee2475d..1fe59e909ab 100644 --- a/src/com/android/settings/fuelgauge/PowerUsageSummary.java +++ b/src/com/android/settings/fuelgauge/PowerUsageSummary.java @@ -28,6 +28,7 @@ import android.preference.Preference; import android.preference.PreferenceGroup; import android.preference.PreferenceScreen; import android.text.TextUtils; +import android.util.TypedValue; import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; @@ -35,12 +36,14 @@ import android.view.MenuItem; import com.android.internal.logging.MetricsLogger; import com.android.internal.os.BatterySipper; import com.android.internal.os.PowerProfile; +import com.android.internal.os.BatterySipper.DrainType; import com.android.settings.HelpUtils; import com.android.settings.R; import com.android.settings.Settings.HighPowerApplicationsActivity; import com.android.settings.SettingsActivity; import com.android.settings.applications.ManageApplications; +import java.util.ArrayList; import java.util.List; /** @@ -51,6 +54,8 @@ public class PowerUsageSummary extends PowerUsageBase { private static final boolean DEBUG = false; + private static final boolean USE_FAKE_DATA = false; + static final String TAG = "PowerUsageSummary"; private static final String KEY_APP_LIST = "app_list"; @@ -184,18 +189,25 @@ public class PowerUsageSummary extends PowerUsageBase { final BatteryStats stats = mStatsHelper.getStats(); final double averagePower = powerProfile.getAveragePower(PowerProfile.POWER_SCREEN_FULL); - if (averagePower >= MIN_AVERAGE_POWER_THRESHOLD_MILLI_AMP) { - final List usageList = mStatsHelper.getUsageList(); + TypedValue value = new TypedValue(); + getContext().getTheme().resolveAttribute(android.R.attr.colorControlNormal, value, true); + int colorControl = getContext().getColor(value.resourceId); - final int dischargeAmount = stats != null ? stats.getDischargeAmount(mStatsType) : 0; + if (averagePower >= MIN_AVERAGE_POWER_THRESHOLD_MILLI_AMP || USE_FAKE_DATA) { + final List usageList = USE_FAKE_DATA ? getFakeStats() + : mStatsHelper.getUsageList(); + + final int dischargeAmount = USE_FAKE_DATA ? 5000 + : stats != null ? stats.getDischargeAmount(mStatsType) : 0; final int numSippers = usageList.size(); for (int i = 0; i < numSippers; i++) { final BatterySipper sipper = usageList.get(i); if ((sipper.totalPowerMah * SECONDS_IN_HOUR) < MIN_POWER_THRESHOLD_MILLI_AMP) { continue; } + double totalPower = USE_FAKE_DATA ? 4000 : mStatsHelper.getTotalPower(); final double percentOfTotal = - ((sipper.totalPowerMah / mStatsHelper.getTotalPower()) * dischargeAmount); + ((sipper.totalPowerMah / totalPower) * dischargeAmount); if (((int) (percentOfTotal + .5)) < 1) { continue; } @@ -243,6 +255,9 @@ public class PowerUsageSummary extends PowerUsageBase { if (sipper.uidObj != null) { pref.setKey(Integer.toString(sipper.uidObj.getUid())); } + if (sipper.drainType != DrainType.APP && sipper.drainType != DrainType.USER) { + pref.setTint(colorControl); + } addedSome = true; mAppListGroup.addPreference(pref); if (mAppListGroup.getPreferenceCount() > (MAX_ITEMS_TO_LIST + 1)) { @@ -257,6 +272,19 @@ public class PowerUsageSummary extends PowerUsageBase { BatteryEntry.startRequestQueue(); } + private static List getFakeStats() { + ArrayList stats = new ArrayList<>(); + float use = 5; + for (DrainType type : DrainType.values()) { + if (type == DrainType.APP) { + continue; + } + stats.add(new BatterySipper(type, null, use)); + use += 5; + } + return stats; + } + Handler mHandler = new Handler() { @Override diff --git a/src/com/android/settings/search/SearchIndexableResources.java b/src/com/android/settings/search/SearchIndexableResources.java index 8aba2038331..6a324ac74df 100644 --- a/src/com/android/settings/search/SearchIndexableResources.java +++ b/src/com/android/settings/search/SearchIndexableResources.java @@ -91,7 +91,7 @@ public final class SearchIndexableResources { Ranking.getRankForClassName(BluetoothSettings.class.getName()), NO_DATA_RES_ID, BluetoothSettings.class.getName(), - R.drawable.ic_settings_bluetooth2)); + R.drawable.ic_settings_bluetooth)); sResMap.put(SimSettings.class.getName(), new SearchIndexableResource(