Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(471)

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/BluetoothChooserDialog.java

Issue 2823853004: DO NO SUMMIT: bluetooth: Use a LevelListDrawable instead of an array of drawables
Patch Set: Save icons level Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/android/java/src/org/chromium/chrome/browser/ItemChooserDialog.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/android/java/src/org/chromium/chrome/browser/BluetoothChooserDialog.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/BluetoothChooserDialog.java b/chrome/android/java/src/org/chromium/chrome/browser/BluetoothChooserDialog.java
index 58ac77967ca6b7afc8ccbfeb684878c2345970e9..b85833fef426e7bce63d6c6677c918ad6de5e248 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/BluetoothChooserDialog.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/BluetoothChooserDialog.java
@@ -13,6 +13,7 @@ import android.content.Intent;
import android.content.IntentFilter;
import android.content.res.Resources;
import android.graphics.drawable.Drawable;
+import android.graphics.drawable.LevelListDrawable;
import android.location.LocationManager;
import android.support.graphics.drawable.VectorDrawableCompat;
import android.support.v4.graphics.drawable.DrawableCompat;
@@ -77,7 +78,7 @@ public class BluetoothChooserDialog
@VisibleForTesting
String mConnectedIconDescription;
@VisibleForTesting
- Drawable[] mSignalStrengthLevelIcon;
+ LevelListDrawable mSignalStrengthLevelIcon;
// A pointer back to the native part of the implementation for this dialog.
long mNativeBluetoothChooserDialogPtr;
@@ -134,12 +135,17 @@ public class BluetoothChooserDialog
mConnectedIcon = getIconWithRowIconColorStateList(R.drawable.ic_bluetooth_connected);
mConnectedIconDescription = mActivity.getString(R.string.bluetooth_device_connected);
- mSignalStrengthLevelIcon = new Drawable[] {
- getIconWithRowIconColorStateList(R.drawable.ic_signal_cellular_0_bar),
- getIconWithRowIconColorStateList(R.drawable.ic_signal_cellular_1_bar),
- getIconWithRowIconColorStateList(R.drawable.ic_signal_cellular_2_bar),
- getIconWithRowIconColorStateList(R.drawable.ic_signal_cellular_3_bar),
- getIconWithRowIconColorStateList(R.drawable.ic_signal_cellular_4_bar)};
+ mSignalStrengthLevelIcon = new LevelListDrawable();
+ mSignalStrengthLevelIcon.addLevel(
+ 0, 0, getIconWithRowIconColorStateList(R.drawable.ic_signal_cellular_0_bar));
+ mSignalStrengthLevelIcon.addLevel(
+ 1, 1, getIconWithRowIconColorStateList(R.drawable.ic_signal_cellular_1_bar));
+ mSignalStrengthLevelIcon.addLevel(
+ 2, 2, getIconWithRowIconColorStateList(R.drawable.ic_signal_cellular_2_bar));
+ mSignalStrengthLevelIcon.addLevel(
+ 3, 3, getIconWithRowIconColorStateList(R.drawable.ic_signal_cellular_3_bar));
+ mSignalStrengthLevelIcon.addLevel(
+ 4, 4, getIconWithRowIconColorStateList(R.drawable.ic_signal_cellular_4_bar));
if (mAdapter == null) {
Log.i(TAG, "BluetoothChooserDialog: Default Bluetooth adapter not found.");
@@ -393,7 +399,8 @@ public class BluetoothChooserDialog
icon = mConnectedIcon.getConstantState().newDrawable();
iconDescription = mConnectedIconDescription;
} else if (signalStrengthLevel != -1) {
- icon = mSignalStrengthLevelIcon[signalStrengthLevel].getConstantState().newDrawable();
+ icon = mSignalStrengthLevelIcon.getConstantState().newDrawable();
ortuno 2017/04/26 01:06:45 This line makes the dialog pretty unusable. Since
+ icon.setLevel(signalStrengthLevel);
iconDescription = mActivity.getResources().getQuantityString(
R.plurals.signal_strength_level_n_bars, signalStrengthLevel,
signalStrengthLevel);
« no previous file with comments | « no previous file | chrome/android/java/src/org/chromium/chrome/browser/ItemChooserDialog.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698