diff options
author | Samuel Holland <samuel@sholland.org> | 2017-07-31 21:13:01 -0500 |
---|---|---|
committer | Samuel Holland <samuel@sholland.org> | 2017-07-31 21:13:01 -0500 |
commit | a1e334efa647d6f4aa2c5a818f92be9376219c73 (patch) | |
tree | 8d66c70af4417b4840a731f6beb9944d13edd4ed /app/src/main/java/com/wireguard/config | |
parent | 8623437185a7f6a982e9212a39dec3c836087d21 (diff) |
Profile: Track connection state
Observability is only enabled for isConnected because it is the only
mutable property.
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'app/src/main/java/com/wireguard/config')
-rw-r--r-- | app/src/main/java/com/wireguard/config/Profile.java | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/app/src/main/java/com/wireguard/config/Profile.java b/app/src/main/java/com/wireguard/config/Profile.java index 1670050c..e6506c45 100644 --- a/app/src/main/java/com/wireguard/config/Profile.java +++ b/app/src/main/java/com/wireguard/config/Profile.java @@ -1,9 +1,15 @@ package com.wireguard.config; +import android.databinding.BaseObservable; +import android.databinding.Bindable; +import android.databinding.Observable; import android.databinding.ObservableArrayList; import android.databinding.ObservableList; +import com.wireguard.android.BR; + import java.io.BufferedReader; +import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; @@ -13,12 +19,14 @@ import java.nio.charset.StandardCharsets; * Represents a wg-quick profile. */ -public class Profile { +public class Profile extends BaseObservable implements Observable { private final Interface iface = new Interface(); + private boolean isConnected; private final String name; private final ObservableList<Peer> peers = new ObservableArrayList<>(); public Profile(String name) { + super(); this.name = name; } @@ -26,6 +34,11 @@ public class Profile { return iface; } + @Bindable + public boolean getIsConnected() { + return isConnected; + } + public String getName() { return name; } @@ -55,6 +68,11 @@ public class Profile { } } + public void setIsConnected(boolean isConnected) { + this.isConnected = isConnected; + notifyPropertyChanged(BR.isConnected); + } + @Override public String toString() { StringBuilder sb = new StringBuilder().append(iface.toString()); |