Move the connected device to top in control center

What happens in reality is that devices are sorted according to their
connection status first, and then by name. So even if/when we support
multiple device connection, the order should remain sane.

This closes #842.
This commit is contained in:
Daniele Gobbetti 2018-02-19 18:27:48 +01:00
parent 7ec57fb81e
commit e7a1e1b8c3
4 changed files with 14 additions and 1 deletions

View File

@ -1,5 +1,8 @@
### Changelog
#### Version next
* Move the connected device to top in control center
#### Version 0.24.6
* Display the chat icon for notifications coming from Kontalk and Antox
* Pebble: Fix for background js which try to send floats (e.g. TrekVolle)

View File

@ -163,7 +163,10 @@ public class DeviceManager {
Collections.sort(deviceList, new Comparator<GBDevice>() {
@Override
public int compare(GBDevice lhs, GBDevice rhs) {
return Collator.getInstance().compare(lhs.getName(), rhs.getName());
if (rhs.getStateOrdinal() - lhs.getStateOrdinal() == 0) {
return Collator.getInstance().compare(lhs.getName(), rhs.getName());
}
return (rhs.getStateOrdinal() - lhs.getStateOrdinal());
}
});
notifyDevicesChanged();

View File

@ -252,6 +252,10 @@ public class GBDevice implements Parcelable {
return mState;
}
public int getStateOrdinal() {
return mState.ordinal();
}
public void setState(State state) {
mState = state;
if (state.ordinal() <= State.CONNECTED.ordinal()) {

View File

@ -1,5 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<changelog>
<release version="next">
<change>Move the connected device to top in control center</change>
</release>
<release version="0.24.6" versioncode="123">
<change>Display the chat icon for notifications coming from Kontalk and Antox</change>
<change>Pebble: Fix for background js which try to send floats (e.g. TrekVolle)</change>