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 13b491ae759cf2d9710fb10a694b6714954c3586..58ac77967ca6b7afc8ccbfeb684878c2345970e9 100644 |
--- a/chrome/android/java/src/org/chromium/chrome/browser/BluetoothChooserDialog.java |
+++ b/chrome/android/java/src/org/chromium/chrome/browser/BluetoothChooserDialog.java |
@@ -76,6 +76,8 @@ public class BluetoothChooserDialog |
Drawable mConnectedIcon; |
@VisibleForTesting |
String mConnectedIconDescription; |
+ @VisibleForTesting |
+ Drawable[] mSignalStrengthLevelIcon; |
// A pointer back to the native part of the implementation for this dialog. |
long mNativeBluetoothChooserDialogPtr; |
@@ -128,16 +130,17 @@ public class BluetoothChooserDialog |
mNativeBluetoothChooserDialogPtr = nativeBluetoothChooserDialogPtr; |
mAdapter = BluetoothAdapter.getDefaultAdapter(); |
- Resources res = mActivity.getResources(); |
- |
// Initialize icons. |
- mConnectedIcon = VectorDrawableCompat.create( |
- res, R.drawable.ic_bluetooth_connected, mActivity.getTheme()); |
- DrawableCompat.setTintList(mConnectedIcon, |
- ApiCompatibilityUtils.getColorStateList(res, R.color.item_chooser_row_icon_color)); |
- |
+ 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)}; |
+ |
if (mAdapter == null) { |
Log.i(TAG, "BluetoothChooserDialog: Default Bluetooth adapter not found."); |
} |
@@ -147,6 +150,15 @@ public class BluetoothChooserDialog |
new BluetoothClickableSpan(LinkType.ADAPTER_OFF_HELP, mActivity))); |
} |
+ private Drawable getIconWithRowIconColorStateList(int icon) { |
+ Resources res = mActivity.getResources(); |
+ |
+ Drawable drawable = VectorDrawableCompat.create(res, icon, mActivity.getTheme()); |
+ DrawableCompat.setTintList(drawable, |
+ ApiCompatibilityUtils.getColorStateList(res, R.color.item_chooser_row_icon_color)); |
+ return drawable; |
+ } |
+ |
/** |
* Show the BluetoothChooserDialog. |
*/ |
@@ -373,12 +385,18 @@ public class BluetoothChooserDialog |
@VisibleForTesting |
@CalledByNative |
- void addOrUpdateDevice(String deviceId, String deviceName, boolean isGATTConnected) { |
+ void addOrUpdateDevice( |
+ String deviceId, String deviceName, boolean isGATTConnected, int signalStrengthLevel) { |
Drawable icon = null; |
String iconDescription = null; |
if (isGATTConnected) { |
icon = mConnectedIcon.getConstantState().newDrawable(); |
iconDescription = mConnectedIconDescription; |
+ } else if (signalStrengthLevel != -1) { |
+ icon = mSignalStrengthLevelIcon[signalStrengthLevel].getConstantState().newDrawable(); |
+ iconDescription = mActivity.getResources().getQuantityString( |
+ R.plurals.signal_strength_level_n_bars, signalStrengthLevel, |
+ signalStrengthLevel); |
} |
mItemChooserDialog.addOrUpdateItem(deviceId, deviceName, icon, iconDescription); |