Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please move the string to strings.xml value file

} catch (Exception e) {
Log.e(LOGTAG, "Failed to save pre-shared key", e);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please move the string to strings.xml value file

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);
Expand All @@ -268,4 +275,4 @@ private void shareLog() {
Log.e(LOGTAG, "failed to dump log", e);
}
}
}
}
Loading