From 10a31cc27468b2b1b86d76d6d990ff90d15bcaea Mon Sep 17 00:00:00 2001 From: Eric Kok Date: Sun, 23 May 2021 10:18:31 +0200 Subject: [PATCH] When adding a Xirvik server using QR, use server name as settings name --- .../transdroid/core/gui/settings/MainSettingsActivity.java | 7 ++++--- .../org/transdroid/core/seedbox/XirvikDediSettings.java | 4 ++-- .../org/transdroid/core/seedbox/XirvikSemiSettings.java | 4 ++-- .../org/transdroid/core/seedbox/XirvikSharedSettings.java | 4 ++-- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/org/transdroid/core/gui/settings/MainSettingsActivity.java b/app/src/main/java/org/transdroid/core/gui/settings/MainSettingsActivity.java index 8c34c8c6..662524fc 100644 --- a/app/src/main/java/org/transdroid/core/gui/settings/MainSettingsActivity.java +++ b/app/src/main/java/org/transdroid/core/gui/settings/MainSettingsActivity.java @@ -294,6 +294,7 @@ public class MainSettingsActivity extends PreferenceCompatActivity { protected void onServerBarcodeScanHandled(String[] qrResult) { final String server = qrResult[0]; final String token = qrResult[2]; + final String name = server.replace(".xirvik.com", ""); new XirvikSharedSettingsActivity.RetrieveXirvikAutoConfTask(server, "", "", token) { @Override @@ -304,17 +305,17 @@ public class MainSettingsActivity extends PreferenceCompatActivity { switch (qrResult[1]) { case "P": XirvikDediSettings xirvikDediSettings = new XirvikDediSettings(); - xirvikDediSettings.saveServerSetting(getApplicationContext(), server, token); + xirvikDediSettings.saveServerSetting(getApplicationContext(), server, token, name); onResume(); break; case "N": XirvikSemiSettings xirvikSemiSettings = new XirvikSemiSettings(); - xirvikSemiSettings.saveServerSetting(getApplicationContext(), server, token); + xirvikSemiSettings.saveServerSetting(getApplicationContext(), server, token, name); onResume(); break; case "RG": XirvikSharedSettings xirvikSharedSettings = new XirvikSharedSettings(); - xirvikSharedSettings.saveServerSetting(getApplicationContext(), server, token, result); + xirvikSharedSettings.saveServerSetting(getApplicationContext(), server, token, result, name); onResume(); break; default: diff --git a/app/src/main/java/org/transdroid/core/seedbox/XirvikDediSettings.java b/app/src/main/java/org/transdroid/core/seedbox/XirvikDediSettings.java index e89927d7..55877e8d 100644 --- a/app/src/main/java/org/transdroid/core/seedbox/XirvikDediSettings.java +++ b/app/src/main/java/org/transdroid/core/seedbox/XirvikDediSettings.java @@ -98,7 +98,7 @@ public class XirvikDediSettings extends SeedboxSettingsImpl implements SeedboxSe "seedbox_xirvikdedi_pass_", "seedbox_xirvikdedi_token_"}, order); } - public void saveServerSetting(Context context, String server, String token) { + public void saveServerSetting(Context context, String server, String token, String name) { // Get server order int key = SeedboxProvider.XirvikDedi.getSettings().getMaxSeedboxOrder(PreferenceManager.getDefaultSharedPreferences(context)) + 1; @@ -115,7 +115,7 @@ public class XirvikDediSettings extends SeedboxSettingsImpl implements SeedboxSe // Store new seedbox pref prefs.edit() .putString("seedbox_xirvikdedi_client_" + key, Daemon.toCode(Daemon.rTorrent)) - .putString("seedbox_xirvikdedi_name" + key, "QR Server " + key) + .putString("seedbox_xirvikdedi_name_" + key, name) .putString("seedbox_xirvikdedi_server_" + key, server) .putString("seedbox_xirvikdedi_user_" + key, "") .putString("seedbox_xirvikdedi_pass_" + key, "") diff --git a/app/src/main/java/org/transdroid/core/seedbox/XirvikSemiSettings.java b/app/src/main/java/org/transdroid/core/seedbox/XirvikSemiSettings.java index e030d053..d0ab4dd6 100644 --- a/app/src/main/java/org/transdroid/core/seedbox/XirvikSemiSettings.java +++ b/app/src/main/java/org/transdroid/core/seedbox/XirvikSemiSettings.java @@ -96,7 +96,7 @@ public class XirvikSemiSettings extends SeedboxSettingsImpl implements SeedboxSe "seedbox_xirviksemi_server_", "seedbox_xirviksemi_user_", "seedbox_xirviksemi_pass_", "seedbox_xirviksemi_token_"}, order); } - public void saveServerSetting(Context context, String server, String token) { + public void saveServerSetting(Context context, String server, String token, String name) { // Get server order int key = SeedboxProvider.XirvikSemi.getSettings().getMaxSeedboxOrder(PreferenceManager.getDefaultSharedPreferences(context)) + 1; @@ -113,7 +113,7 @@ public class XirvikSemiSettings extends SeedboxSettingsImpl implements SeedboxSe // Store new seedbox pref prefs.edit() .putString("seedbox_xirviksemi_client_" + key, Daemon.toCode(Daemon.rTorrent)) - .putString("seedbox_xirviksemi_name" + key, "QR Server " + key) + .putString("seedbox_xirviksemi_name_" + key, name) .putString("seedbox_xirviksemi_server_" + key, server) .putString("seedbox_xirviksemi_user_" + key, "") .putString("seedbox_xirviksemi_pass_" + key, "") diff --git a/app/src/main/java/org/transdroid/core/seedbox/XirvikSharedSettings.java b/app/src/main/java/org/transdroid/core/seedbox/XirvikSharedSettings.java index f3e4afb9..3c92d18e 100644 --- a/app/src/main/java/org/transdroid/core/seedbox/XirvikSharedSettings.java +++ b/app/src/main/java/org/transdroid/core/seedbox/XirvikSharedSettings.java @@ -99,7 +99,7 @@ public class XirvikSharedSettings extends SeedboxSettingsImpl implements Seedbox "seedbox_xirvikshared_rpc_", "seedbox_xirvikshared_token_"}, order); } - public void saveServerSetting(final Context context, String server, String token, String rcp) { + public void saveServerSetting(final Context context, String server, String token, String rcp, String name) { // Get server order int key = SeedboxProvider.XirvikShared.getSettings().getMaxSeedboxOrder(PreferenceManager.getDefaultSharedPreferences(context)) + 1; @@ -116,7 +116,7 @@ public class XirvikSharedSettings extends SeedboxSettingsImpl implements Seedbox // Store new seedbox pref prefs.edit() .putString("seedbox_xirvikshared_client_" + key, Daemon.toCode(Daemon.rTorrent)) - .putString("seedbox_xirvikshared_name" + key, "QR Server " + key) + .putString("seedbox_xirvikshared_name" + key, name) .putString("seedbox_xirvikshared_server_" + key, server) .putString("seedbox_xirvikshared_user_" + key, "") .putString("seedbox_xirvikshared_pass_" + key, "")