diff options
author | Samuel Holland <samuel@sholland.org> | 2018-01-06 23:45:49 -0600 |
---|---|---|
committer | Samuel Holland <samuel@sholland.org> | 2018-01-06 23:45:49 -0600 |
commit | 5a2f692d7323f3bc7f5b2347fb8490be9057f302 (patch) | |
tree | 5b1d6d9a5157363fbb28ef4c9a771d03c3aef354 /app/src/main/java | |
parent | 536c6958fc1895638721befd0b70a3ff082bcc22 (diff) |
TunnelManager: Sort tunnels case-insensitively
The second comparator is required to allow multiple tunnels that differ
only in case.
Signed-off-by: Samuel Holland <samuel@sholland.org>
Diffstat (limited to 'app/src/main/java')
-rw-r--r-- | app/src/main/java/com/wireguard/android/model/TunnelManager.java | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/app/src/main/java/com/wireguard/android/model/TunnelManager.java b/app/src/main/java/com/wireguard/android/model/TunnelManager.java index 68bb541a..22bf1190 100644 --- a/app/src/main/java/com/wireguard/android/model/TunnelManager.java +++ b/app/src/main/java/com/wireguard/android/model/TunnelManager.java @@ -13,10 +13,12 @@ import com.wireguard.android.util.ObservableSortedKeyedArrayList; import com.wireguard.config.Config; import java.util.Collections; +import java.util.Comparator; import java.util.Set; import javax.inject.Inject; +import java9.util.Comparators; import java9.util.concurrent.CompletableFuture; import java9.util.concurrent.CompletionStage; import java9.util.stream.Collectors; @@ -30,6 +32,8 @@ import java9.util.stream.StreamSupport; public final class TunnelManager { public static final String KEY_PRIMARY_TUNNEL = "primary_config"; public static final String KEY_SELECTED_TUNNEL = "selected_tunnel"; + private static final Comparator<String> COMPARATOR = Comparators.<String>thenComparing( + String.CASE_INSENSITIVE_ORDER, Comparators.naturalOrder()); private static final String KEY_RESTORE_ON_BOOT = "restore_on_boot"; private static final String KEY_RUNNING_TUNNELS = "enabled_configs"; private static final String TAG = TunnelManager.class.getSimpleName(); @@ -38,7 +42,7 @@ public final class TunnelManager { private final ConfigStore configStore; private final SharedPreferences preferences; private final ObservableKeyedList<String, Tunnel> tunnels = - new ObservableSortedKeyedArrayList<>(); + new ObservableSortedKeyedArrayList<>(COMPARATOR); @Inject public TunnelManager(final Backend backend, final ConfigStore configStore, |