diff options
-rw-r--r-- | app/src/main/java/com/wireguard/config/Interface.java | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/app/src/main/java/com/wireguard/config/Interface.java b/app/src/main/java/com/wireguard/config/Interface.java index d583f37b..6116a4a7 100644 --- a/app/src/main/java/com/wireguard/config/Interface.java +++ b/app/src/main/java/com/wireguard/config/Interface.java @@ -90,10 +90,14 @@ public class Interface extends BaseObservable implements Observable { } public void setPrivateKey(String privateKey) { - // Avoid exceptions from Keypair while the user is typing. - if (privateKey.length() != KeyEncoding.KEY_LENGTH_BASE64) - return; - keypair = new Keypair(privateKey); + if (privateKey != null && !privateKey.isEmpty()) { + // Avoid exceptions from Keypair while the user is typing. + if (privateKey.length() != KeyEncoding.KEY_LENGTH_BASE64) + return; + keypair = new Keypair(privateKey); + } else { + keypair = null; + } notifyPropertyChanged(BR.privateKey); notifyPropertyChanged(BR.publicKey); } |