| 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 cbbcd4b35319ae9aa253ec097daa451bcd8bbcbb..396f50e94a7c9f1049e79a0f743889aac1d8d802 100644
|
| --- a/chrome/android/java/src/org/chromium/chrome/browser/BluetoothChooserDialog.java
|
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/BluetoothChooserDialog.java
|
| @@ -11,11 +11,16 @@ import android.content.BroadcastReceiver;
|
| import android.content.Context;
|
| import android.content.Intent;
|
| import android.content.IntentFilter;
|
| +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.Log;
|
| import org.chromium.base.VisibleForTesting;
|
| import org.chromium.base.annotations.CalledByNative;
|
| @@ -67,6 +72,10 @@ public class BluetoothChooserDialog
|
| // bluetooth devices. For valid values see SecurityStateModel::SecurityLevel.
|
| int mSecurityLevel;
|
|
|
| + Drawable mConnectedIcon;
|
| + Drawable mConnectedSelectedIcon;
|
| + String mConnectedIconDescription;
|
| +
|
| // A pointer back to the native part of the implementation for this dialog.
|
| long mNativeBluetoothChooserDialogPtr;
|
|
|
| @@ -117,6 +126,17 @@ public class BluetoothChooserDialog
|
| mSecurityLevel = securityLevel;
|
| mNativeBluetoothChooserDialogPtr = nativeBluetoothChooserDialogPtr;
|
| mAdapter = BluetoothAdapter.getDefaultAdapter();
|
| +
|
| + Resources res = mActivity.getResources();
|
| +
|
| + // Initialize icons.
|
| + mConnectedIcon = VectorDrawableCompat.create(
|
| + res, R.drawable.ic_bluetooth_connected, mActivity.getTheme());
|
| + DrawableCompat.setTint(
|
| + mConnectedIcon, ApiCompatibilityUtils.getColor(res, R.color.google_grey_600));
|
| + mConnectedSelectedIcon = getSelectedIcon(res, mConnectedIcon);
|
| + mConnectedIconDescription = mActivity.getString(R.string.bluetooth_device_connected);
|
| +
|
| if (mAdapter == null) {
|
| Log.i(TAG, "BluetoothChooserDialog: Default Bluetooth adapter not found.");
|
| }
|
| @@ -353,10 +373,29 @@ public class BluetoothChooserDialog
|
| return dialog;
|
| }
|
|
|
| + private Drawable getSelectedIcon(Resources res, Drawable drawable) {
|
| + Drawable selected = DrawableCompat.wrap(drawable.getConstantState().newDrawable());
|
| + selected.mutate();
|
| + DrawableCompat.setTint(
|
| + mConnectedIcon, ApiCompatibilityUtils.getColor(res, android.R.color.white));
|
| + return selected;
|
| + }
|
| +
|
| + @VisibleForTesting
|
| + ItemChooserDialog.ItemChooserRowIcon createConnectedRowIcon() {
|
| + return new ItemChooserDialog.ItemChooserRowIcon(
|
| + mConnectedIcon, mConnectedSelectedIcon, mConnectedIconDescription);
|
| + }
|
| +
|
| @VisibleForTesting
|
| @CalledByNative
|
| - void addOrUpdateDevice(String deviceId, String deviceName) {
|
| - mItemChooserDialog.addOrUpdateItem(deviceId, deviceName);
|
| + void addOrUpdateDevice(String deviceId, String deviceName, boolean isGATTConnected) {
|
| + ItemChooserDialog.ItemChooserRowIcon icon = null;
|
| + if (isGATTConnected) {
|
| + icon = createConnectedRowIcon();
|
| + }
|
| +
|
| + mItemChooserDialog.addOrUpdateItem(deviceId, deviceName, icon);
|
| }
|
|
|
| @VisibleForTesting
|
|
|