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

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

Issue 2821973003: bluetooth: Add RSSI icon for bluetooth choosers. (Closed)
Patch Set: #757575 -> @color/google_grey_600 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
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);
« no previous file with comments | « chrome/android/java/res/drawable/ic_signal_cellular_4_bar.xml ('k') | chrome/android/java/strings/android_chrome_strings.grd » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698