mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-24 10:35:19 +00:00
parent
48efcaa785
commit
fa35814344
@ -5,15 +5,16 @@ import android.content.Context;
|
|||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
|
|
||||||
|
import org.thoughtcrime.securesms.permissions.Permissions;
|
||||||
import org.thoughtcrime.securesms.util.CharacterCalculator;
|
import org.thoughtcrime.securesms.util.CharacterCalculator;
|
||||||
import org.thoughtcrime.securesms.util.MmsCharacterCalculator;
|
import org.thoughtcrime.securesms.util.MmsCharacterCalculator;
|
||||||
import org.thoughtcrime.securesms.permissions.Permissions;
|
|
||||||
import org.thoughtcrime.securesms.util.PushCharacterCalculator;
|
import org.thoughtcrime.securesms.util.PushCharacterCalculator;
|
||||||
import org.thoughtcrime.securesms.util.SmsCharacterCalculator;
|
import org.thoughtcrime.securesms.util.SmsCharacterCalculator;
|
||||||
import org.thoughtcrime.securesms.util.dualsim.SubscriptionInfoCompat;
|
import org.thoughtcrime.securesms.util.dualsim.SubscriptionInfoCompat;
|
||||||
import org.thoughtcrime.securesms.util.dualsim.SubscriptionManagerCompat;
|
import org.thoughtcrime.securesms.util.dualsim.SubscriptionManagerCompat;
|
||||||
import org.whispersystems.libsignal.util.guava.Optional;
|
import org.whispersystems.libsignal.util.guava.Optional;
|
||||||
|
|
||||||
|
import java.util.Iterator;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -105,14 +106,18 @@ public class TransportOptions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void disableTransport(Type type) {
|
public void disableTransport(Type type) {
|
||||||
Optional<TransportOption> option = find(type);
|
TransportOption selected = selectedOption.orNull();
|
||||||
|
|
||||||
if (option.isPresent()) {
|
Iterator<TransportOption> iterator = enabledTransports.iterator();
|
||||||
enabledTransports.remove(option.get());
|
while (iterator.hasNext()) {
|
||||||
|
TransportOption option = iterator.next();
|
||||||
|
|
||||||
if (selectedOption.isPresent() && selectedOption.get().getType() == type) {
|
if (option.isType(type)) {
|
||||||
|
if (selected == option) {
|
||||||
setSelectedTransport(null);
|
setSelectedTransport(null);
|
||||||
}
|
}
|
||||||
|
iterator.remove();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -183,16 +188,6 @@ public class TransportOptions {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Optional<TransportOption> find(Type type) {
|
|
||||||
for (TransportOption option : enabledTransports) {
|
|
||||||
if (option.isType(type)) {
|
|
||||||
return Optional.of(option);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return Optional.absent();
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean isEnabled(TransportOption transportOption) {
|
private boolean isEnabled(TransportOption transportOption) {
|
||||||
for (TransportOption option : enabledTransports) {
|
for (TransportOption option : enabledTransports) {
|
||||||
if (option.equals(transportOption)) return true;
|
if (option.equals(transportOption)) return true;
|
||||||
|
Loading…
Reference in New Issue
Block a user