From df868dfa77c8826e5b34940733bad7d50e0a3ca2 Mon Sep 17 00:00:00 2001 From: Eric Kok Date: Mon, 26 Apr 2021 23:05:41 +0200 Subject: [PATCH] Support for adding dedicated Xirvik servers by QR code --- .../gui/settings/MainSettingsActivity.java | 51 ++++++++++--------- .../settings/PreferenceCompatActivity.java | 3 ++ .../core/seedbox/XirvikDediSettings.java | 2 +- 3 files changed, 30 insertions(+), 26 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 33e9a55e..8c34c8c6 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,34 +294,35 @@ public class MainSettingsActivity extends PreferenceCompatActivity { protected void onServerBarcodeScanHandled(String[] qrResult) { final String server = qrResult[0]; final String token = qrResult[2]; - switch (qrResult[1]) { - case "P": - XirvikDediSettings xirvikDediSettings = new XirvikDediSettings(); - xirvikDediSettings.saveServerSetting(this, server, token); - onResume(); - break; - case "N": - XirvikSemiSettings xirvikSemiSettings = new XirvikSemiSettings(); - xirvikSemiSettings.saveServerSetting(this, server, token); - onResume(); - break; - case "RG": - new XirvikSharedSettingsActivity.RetrieveXirvikAutoConfTask(server, "", "", token) { - @Override - protected void onPostExecute(String result) { - if (result == null) { - log.d(MainSettingsActivity.this, "Could not retrieve the Xirvik shared seedbox RPC mount point setting"); - } + + new XirvikSharedSettingsActivity.RetrieveXirvikAutoConfTask(server, "", "", token) { + @Override + protected void onPostExecute(String result) { + if (result == null) { + log.d(MainSettingsActivity.this, "Could not retrieve the Xirvik shared seedbox RPC mount point setting"); + } + switch (qrResult[1]) { + case "P": + XirvikDediSettings xirvikDediSettings = new XirvikDediSettings(); + xirvikDediSettings.saveServerSetting(getApplicationContext(), server, token); + onResume(); + break; + case "N": + XirvikSemiSettings xirvikSemiSettings = new XirvikSemiSettings(); + xirvikSemiSettings.saveServerSetting(getApplicationContext(), server, token); + onResume(); + break; + case "RG": XirvikSharedSettings xirvikSharedSettings = new XirvikSharedSettings(); xirvikSharedSettings.saveServerSetting(getApplicationContext(), server, token, result); onResume(); - } - }.execute(); - break; - default: - SnackbarManager.show(Snackbar.with(this).text(R.string.pref_seedbox_xirvikscanerror).colorResource(R.color.red).type(SnackbarType.MULTI_LINE)); - break; - } + break; + default: + SnackbarManager.show(Snackbar.with(MainSettingsActivity.this).text(R.string.pref_seedbox_xirvikscanerror).colorResource(R.color.red).type(SnackbarType.MULTI_LINE)); + break; + } + } + }.execute(); } diff --git a/app/src/main/java/org/transdroid/core/gui/settings/PreferenceCompatActivity.java b/app/src/main/java/org/transdroid/core/gui/settings/PreferenceCompatActivity.java index 832c690a..95251ed6 100644 --- a/app/src/main/java/org/transdroid/core/gui/settings/PreferenceCompatActivity.java +++ b/app/src/main/java/org/transdroid/core/gui/settings/PreferenceCompatActivity.java @@ -43,6 +43,9 @@ public class PreferenceCompatActivity extends AppCompatActivity implements AppCo private int preferencesResId; + public RootPreferencesFragment() { + } + public RootPreferencesFragment(int preferencesResId) { this.preferencesResId = preferencesResId; } 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 3c82fd46..e89927d7 100644 --- a/app/src/main/java/org/transdroid/core/seedbox/XirvikDediSettings.java +++ b/app/src/main/java/org/transdroid/core/seedbox/XirvikDediSettings.java @@ -62,7 +62,7 @@ public class XirvikDediSettings extends SeedboxSettingsImpl implements SeedboxSe type != Daemon.uTorrent, false, null, - type == Daemon.Deluge ? "/deluge" : null, + type == Daemon.Deluge ? "/deluge" : "/RPC2-aAoWTED8ngLqZyKnZ7FFEAgfz5lejcof", true, user, pass,