Chromium Code Reviews| 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..63a2f80d53a10df76fe42dcc6c0a17a9332d7814 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; |
|
Ted C
2017/03/03 00:56:19
any reason these aren't private?
ortuno
2017/03/03 22:08:22
They were being used in tests but not anymore. Cha
Ted C
2017/03/04 00:08:46
If they need to be exposed for testing, they shoul
|
| + 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( |
|
Ted C
2017/03/03 00:56:19
tints work on vectors now?
ortuno
2017/03/03 22:08:22
They don't? I was assuming they did since they wer
Ted C
2017/03/04 00:08:46
If you have a K device it would be good to verify
ortuno
2017/03/08 06:57:37
tldr; It works! Huzzah!
Web Bluetooth only works
|
| + 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( |
| + selected, 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 |