Browse Source

When adding a Xirvik server using QR, use server name as settings name

pull/596/head
Eric Kok 4 years ago
parent
commit
10a31cc274
  1. 7
      app/src/main/java/org/transdroid/core/gui/settings/MainSettingsActivity.java
  2. 4
      app/src/main/java/org/transdroid/core/seedbox/XirvikDediSettings.java
  3. 4
      app/src/main/java/org/transdroid/core/seedbox/XirvikSemiSettings.java
  4. 4
      app/src/main/java/org/transdroid/core/seedbox/XirvikSharedSettings.java

7
app/src/main/java/org/transdroid/core/gui/settings/MainSettingsActivity.java

@ -294,6 +294,7 @@ public class MainSettingsActivity extends PreferenceCompatActivity { @@ -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 { @@ -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:

4
app/src/main/java/org/transdroid/core/seedbox/XirvikDediSettings.java

@ -98,7 +98,7 @@ public class XirvikDediSettings extends SeedboxSettingsImpl implements SeedboxSe @@ -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 @@ -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, "")

4
app/src/main/java/org/transdroid/core/seedbox/XirvikSemiSettings.java

@ -96,7 +96,7 @@ public class XirvikSemiSettings extends SeedboxSettingsImpl implements SeedboxSe @@ -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 @@ -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, "")

4
app/src/main/java/org/transdroid/core/seedbox/XirvikSharedSettings.java

@ -99,7 +99,7 @@ public class XirvikSharedSettings extends SeedboxSettingsImpl implements Seedbox @@ -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 @@ -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, "")

Loading…
Cancel
Save