Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a8f45e63 authored by Mathias Jeppsson's avatar Mathias Jeppsson Committed by Johan Redestig
Browse files

Sort Bluetooth devices in quick settings by name

To avoid Bluetooth devices moving randomly in list, sorting by name.

Change-Id: I4f8e9f98fa29f9670678a3bb6051a6fcf7ae0b9d
parent 540e1f8c
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -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);
        }
    }
}
+3 −3
Original line number Diff line number Diff line
@@ -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);