Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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 @@ -275,7 +275,14 @@ private boolean isValidPresharedKey(String key) {
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, R.string.advanced_presharedkey_saved_success, Toast.LENGTH_SHORT).show();
} catch (Exception e) {
Log.e(LOGTAG, "Failed to save pre-shared key", e);
Copy link
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, R.string.advanced_presharedkey_save_error + ": " + e.getMessage(), Toast.LENGTH_LONG).show();
}
}

private boolean hasPreSharedKey(Context context) {
Expand All @@ -301,4 +308,4 @@ private void shareLog() {
Log.e(LOGTAG, "failed to dump log", e);
}
}
}
}
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@
<string name="advanced_details">You will only communicate with peers that use the same key.</string>
<string name="advanced_hint">Add a pre-shared key</string>
<string name="advanced_save">Save</string>
<string name="advanced_presharedkey_saved_success">Pre-shared key saved successfully</string>
<string name="advanced_presharedkey_save_error">Failed to save pre-shared key</string>
<string name="advanced_tracelog">Enable trace log level.</string>
<string name="advanced_share_logs">Share logs</string>
<string name="advanced_rosenpass">Enable Rosenpass</string>
Expand Down
Loading