Merge "Sort Bluetooth devices in quick settings by name"
This commit is contained in:
@@ -37,7 +37,7 @@ public interface BluetoothController {
|
||||
void onBluetoothPairedDevicesChanged();
|
||||
}
|
||||
|
||||
public static final class PairedDevice {
|
||||
public static final class PairedDevice implements Comparable<PairedDevice> {
|
||||
public static int STATE_DISCONNECTED = 0;
|
||||
public static int STATE_CONNECTING = 1;
|
||||
public static int STATE_CONNECTED = 2;
|
||||
@@ -55,5 +55,9 @@ public interface BluetoothController {
|
||||
if (state == STATE_DISCONNECTING) return "STATE_DISCONNECTING";
|
||||
return "UNKNOWN";
|
||||
}
|
||||
|
||||
public int compareTo(PairedDevice another) {
|
||||
return name.compareTo(another.name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,7 +45,6 @@ import android.os.Looper;
|
||||
import android.os.Message;
|
||||
import android.os.ParcelUuid;
|
||||
import android.util.ArrayMap;
|
||||
import android.util.ArraySet;
|
||||
import android.util.Log;
|
||||
import android.util.SparseArray;
|
||||
|
||||
@@ -55,6 +54,7 @@ import java.io.FileDescriptor;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
|
||||
public class BluetoothControllerImpl implements BluetoothController {
|
||||
private static final String TAG = "BluetoothController";
|
||||
@@ -194,8 +194,8 @@ public class BluetoothControllerImpl implements BluetoothController {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArraySet<PairedDevice> getPairedDevices() {
|
||||
final ArraySet<PairedDevice> rt = new ArraySet<>();
|
||||
public Set<PairedDevice> getPairedDevices() {
|
||||
final Set<PairedDevice> rt = new TreeSet<>();
|
||||
for (int i = 0; i < mDeviceInfo.size(); i++) {
|
||||
final BluetoothDevice device = mDeviceInfo.keyAt(i);
|
||||
final DeviceInfo info = mDeviceInfo.valueAt(i);
|
||||
|
||||
Reference in New Issue
Block a user