From 0c83f03f37486ac3034ffc31ee2f2d88fc1bb7db Mon Sep 17 00:00:00 2001
From: nev-al <149487875+nev-al@users.noreply.github.com>
Date: Sun, 7 Sep 2025 17:08:53 +0300
Subject: [PATCH 1/3] fix: (AdvancedFragment.java) save pre-shared key
correctly
---
.../client/ui/advanced/AdvancedFragment.java | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/app/src/main/java/io/netbird/client/ui/advanced/AdvancedFragment.java b/app/src/main/java/io/netbird/client/ui/advanced/AdvancedFragment.java
index 5e4a96b..4955c2c 100644
--- a/app/src/main/java/io/netbird/client/ui/advanced/AdvancedFragment.java
+++ b/app/src/main/java/io/netbird/client/ui/advanced/AdvancedFragment.java
@@ -238,13 +238,20 @@ private boolean isValidPresharedKey(String key) {
String base64Pattern = "^[A-Za-z0-9+/=]{32,64}$";
return key.matches(base64Pattern);
}
-
+
private void setPreSharedKey(String key, Context context) {
String configFilePath = Preferences.configFile(context);
io.netbird.gomobile.android.Preferences preferences = new io.netbird.gomobile.android.Preferences(configFilePath);
- preferences.setPreSharedKey(key);
+ try {
+ preferences.setPreSharedKey(key);
+ preferences.commit();
+ Toast.makeText(context, "Pre-shared key saved successfully", Toast.LENGTH_SHORT).show();
+ } catch (Exception e) {
+ Log.e(LOGTAG, "Failed to save pre-shared key", e);
+ Toast.makeText(context, "Error saving key: " + e.getMessage(), Toast.LENGTH_LONG).show();
+ }
}
-
+
private boolean hasPreSharedKey(Context context) {
String configFilePath = Preferences.configFile(context);
io.netbird.gomobile.android.Preferences preferences = new io.netbird.gomobile.android.Preferences(configFilePath);
@@ -268,4 +275,4 @@ private void shareLog() {
Log.e(LOGTAG, "failed to dump log", e);
}
}
-}
\ No newline at end of file
+}
From 4ea9c1d108a8ac43d968bc9b37d5527cc439573d Mon Sep 17 00:00:00 2001
From: nev-al <149487875+nev-al@users.noreply.github.com>
Date: Sat, 13 Sep 2025 13:11:48 +0300
Subject: [PATCH 2/3] Add preshared key save feedback
---
app/src/main/res/values/strings.xml | 2 ++
1 file changed, 2 insertions(+)
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index c6687ff..65ae49f 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -71,6 +71,8 @@
You will only communicate with peers that use the same key.
Add a pre-shared key
Save
+ Pre-shared key saved successfully
+ Failed to save pre-shared key
Enable trace log level.
Share logs
Enable Rosenpass
From 6548cd9acfddcde6df9c43c610c9b78107fb82dc Mon Sep 17 00:00:00 2001
From: nev-al <149487875+nev-al@users.noreply.github.com>
Date: Sat, 13 Sep 2025 13:18:10 +0300
Subject: [PATCH 3/3] Save preshared key correctly
---
.../io/netbird/client/ui/advanced/AdvancedFragment.java | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/app/src/main/java/io/netbird/client/ui/advanced/AdvancedFragment.java b/app/src/main/java/io/netbird/client/ui/advanced/AdvancedFragment.java
index e095479..5afcc47 100644
--- a/app/src/main/java/io/netbird/client/ui/advanced/AdvancedFragment.java
+++ b/app/src/main/java/io/netbird/client/ui/advanced/AdvancedFragment.java
@@ -271,20 +271,20 @@ private boolean isValidPresharedKey(String key) {
String base64Pattern = "^[A-Za-z0-9+/=]{32,64}$";
return key.matches(base64Pattern);
}
-
+
private void setPreSharedKey(String key, Context context) {
String configFilePath = Preferences.configFile(context);
io.netbird.gomobile.android.Preferences preferences = new io.netbird.gomobile.android.Preferences(configFilePath);
try {
preferences.setPreSharedKey(key);
preferences.commit();
- Toast.makeText(context, "Pre-shared key saved successfully", Toast.LENGTH_SHORT).show();
+ Toast.makeText(context, R.string.advanced_presharedkey_saved_success, Toast.LENGTH_SHORT).show();
} catch (Exception e) {
Log.e(LOGTAG, "Failed to save pre-shared key", e);
- Toast.makeText(context, "Error saving key: " + e.getMessage(), Toast.LENGTH_LONG).show();
+ Toast.makeText(context, R.string.advanced_presharedkey_save_error + ": " + e.getMessage(), Toast.LENGTH_LONG).show();
}
}
-
+
private boolean hasPreSharedKey(Context context) {
String configFilePath = Preferences.configFile(context);
io.netbird.gomobile.android.Preferences preferences = new io.netbird.gomobile.android.Preferences(configFilePath);