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

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

Issue 2431243003: bluetooth: Show connected icon for connected devices. (Closed)
Patch Set: Rebase Created 4 years, 2 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 3d2289f72f0c2c0c2eab6654c7adfd8fb1cf3845..6836c8a356f3fa706bb70f93c591d6bb30a6921f 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/BluetoothChooserDialog.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/BluetoothChooserDialog.java
@@ -10,11 +10,17 @@ import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
+import android.content.res.ColorStateList;
+import android.content.res.Resources;
+import android.graphics.drawable.Drawable;
import android.location.LocationManager;
+import android.support.graphics.drawable.VectorDrawableCompat;
+import android.support.v4.graphics.drawable.DrawableCompat;
import android.text.SpannableString;
import android.text.TextUtils;
import android.view.View;
+import org.chromium.base.ApiCompatibilityUtils;
import org.chromium.base.VisibleForTesting;
import org.chromium.base.annotations.CalledByNative;
import org.chromium.chrome.R;
@@ -63,6 +69,11 @@ public class BluetoothChooserDialog
// bluetooth devices. For valid values see SecurityStateModel::SecurityLevel.
int mSecurityLevel;
+ @VisibleForTesting
+ Drawable mConnectedIcon;
+ @VisibleForTesting
+ String mConnectedIconDescription;
+
// A pointer back to the native part of the implementation for this dialog.
long mNativeBluetoothChooserDialogPtr;
@@ -106,6 +117,17 @@ public class BluetoothChooserDialog
mOrigin = origin;
mSecurityLevel = securityLevel;
mNativeBluetoothChooserDialogPtr = nativeBluetoothChooserDialogPtr;
+
+ Resources res = mActivity.getResources();
+
+ ColorStateList iconColorList =
+ ApiCompatibilityUtils.getColorStateList(res, R.color.item_chooser_row_icon_color);
+ mConnectedIcon = VectorDrawableCompat.create(mActivity.getResources(),
+ R.drawable.ic_bluetooth_connected_grey, mActivity.getTheme());
+
+ DrawableCompat.setTintList(mConnectedIcon, iconColorList);
+
+ mConnectedIconDescription = mActivity.getString(R.string.bluetooth_device_connected);
}
/**
@@ -337,8 +359,14 @@ public class BluetoothChooserDialog
@VisibleForTesting
@CalledByNative
- void addOrUpdateDevice(String deviceId, String deviceName) {
- mItemChooserDialog.addOrUpdateItem(deviceId, deviceName);
+ void addOrUpdateDevice(String deviceId, String deviceName, boolean isGATTConnected) {
+ Drawable icon = null;
+ String iconDescription = null;
+ // if (isGATTConnected) {
Ian Wen 2016/10/26 21:53:32 1. Please remove dead comments and merge #366-367
+ icon = mConnectedIcon.getConstantState().newDrawable();
+ iconDescription = mConnectedIconDescription;
+ // }
+ mItemChooserDialog.addOrUpdateItem(deviceId, deviceName, icon, iconDescription);
}
@VisibleForTesting

Powered by Google App Engine
This is Rietveld 408576698