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

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

Issue 2271413002: bluetooth: Implement RSSI indicator on android (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bluetooth-impl-rssi-tx-power
Patch Set: Copyright and clean up Created 4 years, 3 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 c3bece95d76975a4215614bab331ec18decdc769..10e4c8a617cb65355bb3488365ad05823f716aed 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/BluetoothChooserDialog.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/BluetoothChooserDialog.java
@@ -10,7 +10,9 @@ import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
+import android.content.res.Resources;
import android.location.LocationManager;
+import android.support.graphics.drawable.VectorDrawableCompat;
import android.text.SpannableString;
import android.text.TextUtils;
import android.view.View;
@@ -63,6 +65,8 @@ public class BluetoothChooserDialog
// bluetooth devices. For valid values see SecurityStateModel::SecurityLevel.
int mSecurityLevel;
+ ItemChooserDialog.ItemChooserRowIcon[] mSignalStrengthLevelRowIcons;
+
// A pointer back to the native part of the implementation for this dialog.
long mNativeBluetoothChooserDialogPtr;
@@ -106,6 +110,38 @@ public class BluetoothChooserDialog
mOrigin = origin;
mSecurityLevel = securityLevel;
mNativeBluetoothChooserDialogPtr = nativeBluetoothChooserDialogPtr;
+ Resources resources = mActivity.getResources();
+ mSignalStrengthLevelRowIcons = new ItemChooserDialog.ItemChooserRowIcon[] {
+ new ItemChooserDialog.ItemChooserRowIcon(
+ VectorDrawableCompat.create(resources,
+ R.drawable.ic_signal_cellular_0_bar_grey600_24dp, null /* theme */),
Ian Wen 2016/09/26 18:12:48 Maybe remove /* */? This comment style is not comm
ortuno 2016/10/04 07:16:18 If it's OK with you I would rather keep this. Ther
+ VectorDrawableCompat.create(resources,
+ R.drawable.ic_signal_cellular_0_bar_white_24dp, null /* theme */),
+ resources.getQuantityString(R.plurals.signal_strength_level_n_bars, 0, 0)),
Ian Wen 2016/09/27 04:22:41 Thanks for making our product more accessible by a
ortuno 2016/10/04 07:16:18 As mentioned offline (I think?) the image adds mor
+ new ItemChooserDialog.ItemChooserRowIcon(
+ VectorDrawableCompat.create(resources,
+ R.drawable.ic_signal_cellular_1_bar_grey600_24dp, null /* theme */),
+ VectorDrawableCompat.create(resources,
+ R.drawable.ic_signal_cellular_1_bar_white_24dp, null /* theme */),
+ resources.getQuantityString(R.plurals.signal_strength_level_n_bars, 1, 1)),
+ new ItemChooserDialog.ItemChooserRowIcon(
+ VectorDrawableCompat.create(resources,
+ R.drawable.ic_signal_cellular_2_bar_grey600_24dp, null /* theme */),
+ VectorDrawableCompat.create(resources,
+ R.drawable.ic_signal_cellular_2_bar_white_24dp, null /* theme */),
+ resources.getQuantityString(R.plurals.signal_strength_level_n_bars, 2, 2)),
+ new ItemChooserDialog.ItemChooserRowIcon(
+ VectorDrawableCompat.create(resources,
+ R.drawable.ic_signal_cellular_3_bar_grey600_24dp, null /* theme */),
+ VectorDrawableCompat.create(resources,
+ R.drawable.ic_signal_cellular_3_bar_white_24dp, null /* theme */),
+ resources.getQuantityString(R.plurals.signal_strength_level_n_bars, 3, 3)),
+ new ItemChooserDialog.ItemChooserRowIcon(
+ VectorDrawableCompat.create(resources,
+ R.drawable.ic_signal_cellular_4_bar_grey600_24dp, null /* theme */),
+ VectorDrawableCompat.create(resources,
+ R.drawable.ic_signal_cellular_4_bar_white_24dp, null /* theme */),
+ resources.getQuantityString(R.plurals.signal_strength_level_n_bars, 4, 4))};
}
/**
@@ -156,13 +192,17 @@ public class BluetoothChooserDialog
ItemChooserDialog.ItemChooserLabels labels =
new ItemChooserDialog.ItemChooserLabels(title, searching, noneFound, statusActive,
statusIdleNoneFound, statusIdleSomeFound, positiveButton);
- mItemChooserDialog = new ItemChooserDialog(mActivity, this, labels);
+ mItemChooserDialog = new ItemChooserDialog(mActivity, this, labels, true /* usingIcon */);
mActivity.registerReceiver(mLocationModeBroadcastReceiver,
new IntentFilter(LocationManager.MODE_CHANGED_ACTION));
mIsLocationModeChangedReceiverRegistered = true;
}
+ ItemChooserDialog.ItemChooserRowIcon[] getSignalStrengthLevelRowIcons() {
+ return mSignalStrengthLevelRowIcons;
+ }
+
// Called to report the dialog's results back to native code.
private void finishDialog(int resultCode, String id) {
if (mIsLocationModeChangedReceiverRegistered) {
@@ -337,9 +377,15 @@ public class BluetoothChooserDialog
@VisibleForTesting
@CalledByNative
- void addOrUpdateDevice(String deviceId, String deviceName) {
- mItemChooserDialog.addOrUpdateItem(
- new ItemChooserDialog.ItemChooserRow(deviceId, deviceName));
+ void addOrUpdateDevice(String deviceId, String deviceName, int signalStrengthLevel) {
+ assert -1 <= signalStrengthLevel
+ && signalStrengthLevel < mSignalStrengthLevelRowIcons.length;
+ ItemChooserDialog.ItemChooserRowIcon signalStrengthLevelIcon = null;
+ if (signalStrengthLevel != -1) {
+ signalStrengthLevelIcon = mSignalStrengthLevelRowIcons[signalStrengthLevel];
+ }
+ mItemChooserDialog.addOrUpdateItem(new ItemChooserDialog.ItemChooserRow(
+ deviceId, deviceName, signalStrengthLevelIcon));
}
@VisibleForTesting

Powered by Google App Engine
This is Rietveld 408576698