Tunnel: Remove UNKNOWN state
It's never used. Signed-off-by: Samuel Holland <samuel@sholland.org>
This commit is contained in:
parent
11f851abf8
commit
0ab3e29432
@ -35,8 +35,6 @@ public final class WgQuickBackend implements Backend {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static State resolveState(final State currentState, State requestedState) {
|
private static State resolveState(final State currentState, State requestedState) {
|
||||||
if (requestedState == State.UNKNOWN)
|
|
||||||
throw new IllegalArgumentException("Requested unknown state");
|
|
||||||
if (requestedState == State.TOGGLE)
|
if (requestedState == State.TOGGLE)
|
||||||
requestedState = currentState == State.UP ? State.DOWN : State.UP;
|
requestedState = currentState == State.UP ? State.DOWN : State.UP;
|
||||||
return requestedState;
|
return requestedState;
|
||||||
|
@ -69,15 +69,11 @@ public class Tunnel extends BaseObservable implements Keyed<String> {
|
|||||||
|
|
||||||
@Bindable
|
@Bindable
|
||||||
public State getState() {
|
public State getState() {
|
||||||
if (state == State.UNKNOWN)
|
|
||||||
manager.getTunnelState(this).whenComplete(ExceptionLoggers.E);
|
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CompletionStage<State> getStateAsync() {
|
public CompletionStage<State> getStateAsync() {
|
||||||
if (state == State.UNKNOWN)
|
|
||||||
return manager.getTunnelState(this);
|
return manager.getTunnelState(this);
|
||||||
return CompletableFuture.completedFuture(state);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bindable
|
@Bindable
|
||||||
@ -133,7 +129,6 @@ public class Tunnel extends BaseObservable implements Keyed<String> {
|
|||||||
public enum State {
|
public enum State {
|
||||||
DOWN,
|
DOWN,
|
||||||
TOGGLE,
|
TOGGLE,
|
||||||
UNKNOWN,
|
|
||||||
UP
|
UP
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,7 +51,6 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_alignBaseline="@+id/interface_title"
|
android:layout_alignBaseline="@+id/interface_title"
|
||||||
android:layout_alignParentEnd="true"
|
android:layout_alignParentEnd="true"
|
||||||
android:enabled="@{tunnel.state != State.UNKNOWN}"
|
|
||||||
app:checked="@{tunnel.state == State.UP}"
|
app:checked="@{tunnel.state == State.UP}"
|
||||||
app:onBeforeCheckedChanged="@{() -> tunnel.setState(State.TOGGLE)}" />
|
app:onBeforeCheckedChanged="@{() -> tunnel.setState(State.TOGGLE)}" />
|
||||||
|
|
||||||
|
@ -46,7 +46,6 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_alignBaseline="@+id/tunnel_name"
|
android:layout_alignBaseline="@+id/tunnel_name"
|
||||||
android:layout_alignParentEnd="true"
|
android:layout_alignParentEnd="true"
|
||||||
android:enabled="@{item.state != State.UNKNOWN}"
|
|
||||||
app:checked="@{item.state == State.UP}"
|
app:checked="@{item.state == State.UP}"
|
||||||
app:onBeforeCheckedChanged="@{() -> item.setState(State.TOGGLE)}" />
|
app:onBeforeCheckedChanged="@{() -> item.setState(State.TOGGLE)}" />
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
Loading…
Reference in New Issue
Block a user