Skip to content

Commit

Permalink
Bump version for 2.5.20 release
Browse files Browse the repository at this point in the history
  • Loading branch information
erickok committed Aug 16, 2021
1 parent 2e6d373 commit 29c3b3b
Show file tree
Hide file tree
Showing 11 changed files with 72 additions and 62 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ android {
defaultConfig {
minSdkVersion 15
targetSdkVersion 30
versionCode 239
versionName '2.5.19'
versionCode 240
versionName '2.5.20'

javaCompileOptions {
annotationProcessorOptions {
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@
android:name="org.transdroid.core.seedbox.DediseedboxSettingsActivity_"
android:theme="@style/TransdroidTheme.Settings" />
<activity
android:name="org.transdroid.core.seedbox.XirvikSharedSettingsActivity_"
android:name="org.transdroid.core.seedbox.XirvikSettingsActivity_"
android:theme="@style/TransdroidTheme.Settings" />
<activity
android:name="org.transdroid.core.seedbox.XirvikSemiSettingsActivity_"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package org.transdroid.core.app.settings;

import android.content.Context;
import android.net.Uri;
import android.text.TextUtils;

import org.transdroid.core.gui.lists.SimpleListItem;
Expand Down Expand Up @@ -124,12 +123,24 @@ public ServerSetting(int key, String name, Daemon type, String address, String l

@Override
public String getName() {
if (!TextUtils.isEmpty(name)) {
return name;
return ServerSetting.getServerName(name, address);
}

public static String getServerName(String giveName, String givenAddress) {
if (giveName != null && !giveName.isEmpty()) {
return giveName;
}
if (!TextUtils.isEmpty(address)) {
String host = Uri.parse(address).getHost();
return host == null ? DEFAULT_NAME : host;
if (givenAddress != null) {
int dot = givenAddress.lastIndexOf(".");
if (dot > 0) {
try {
Integer.parseInt(givenAddress.substring(dot));
// Last bit is numeric: looks like an IP, so better use the default fallback name
} catch (NumberFormatException e) {
// Not numeric, looks like a domain name we can use
return givenAddress;
}
}
}
return DEFAULT_NAME;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@
import org.transdroid.core.seedbox.SeedboxProvider;
import org.transdroid.core.seedbox.XirvikDediSettings;
import org.transdroid.core.seedbox.XirvikSemiSettings;
import org.transdroid.core.seedbox.XirvikSettingsActivity;
import org.transdroid.core.seedbox.XirvikSharedSettings;
import org.transdroid.core.seedbox.XirvikSharedSettingsActivity;

import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -128,7 +128,7 @@ public boolean onPreferenceClick(Preference preference) {
// Start the configuration activity for this specific chosen seedbox
if (which == 0)
ServerSettingsActivity_.intent(MainSettingsActivity.this).start();
else if (which == SeedboxProvider.values().length + 1)
else if (which == SeedboxProvider.activeProviders().length + 1)
BarcodeHelper.startBarcodeScanner(this, BarcodeHelper.ACTIVITY_BARCODE_ADDSERVER);
else
startActivity(SeedboxProvider.values()[which - 1].getSettings().getSettingsActivityIntent(MainSettingsActivity.this));
Expand Down Expand Up @@ -266,10 +266,10 @@ protected void navigateUp() {
protected Dialog onCreateDialog(int id) {
if (id == DIALOG_ADDSEEDBOX) {
// Open dialog to pick one of the supported seedbox providers (or a normal server)
String[] seedboxes = new String[SeedboxProvider.values().length + 2];
String[] seedboxes = new String[SeedboxProvider.activeProviders().length + 2];
seedboxes[0] = getString(R.string.pref_addserver_normal);
for (int i = 0; i < seedboxes.length - 2; i++) {
seedboxes[i + 1] = getString(R.string.pref_seedbox_addseedbox, SeedboxProvider.values()[i].getSettings().getName());
seedboxes[i + 1] = getString(R.string.pref_seedbox_addseedbox, SeedboxProvider.activeProviders()[i].getSettings().getName());
}
seedboxes[seedboxes.length - 1] = getString(R.string.pref_seedbox_xirvikviaqr);
return new AlertDialog.Builder(this).setItems(seedboxes, onAddSeedbox).create();
Expand All @@ -296,7 +296,7 @@ protected void onServerBarcodeScanHandled(String[] qrResult) {
final String token = qrResult[2];
final String name = server.replace(".xirvik.com", "");

new XirvikSharedSettingsActivity.RetrieveXirvikAutoConfTask(server, "", "", token) {
new XirvikSettingsActivity.RetrieveXirvikAutoConfTask(server, "", "", token) {
@Override
protected void onPostExecute(String result) {
if (result == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public SeedboxSettings getSettings() {
return new DediseedboxSettings();
}
},
XirvikShared {
Xirvik {
@Override
public SeedboxSettings getSettings() {
return new XirvikSharedSettings();
Expand All @@ -51,6 +51,10 @@ public SeedboxSettings getSettings() {
}
};

public static SeedboxProvider[] activeProviders() {
return new SeedboxProvider[]{SeedboxProvider.Dediseedbox, SeedboxProvider.Xirvik};
}

public abstract SeedboxSettings getSettings();

}
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public ServerSetting getServerSetting(SharedPreferences prefs, int orderOffset,
if (server == null) {
return null;
}
Daemon type = Daemon.fromCode(prefs.getString("seedbox_xirvikdedi_client_" + order, null));
Daemon type = Daemon.fromCode(prefs.getString("seedbox_xirvikdedi_client_" + order, Daemon.toCode(Daemon.rTorrent)));
String user = prefs.getString("seedbox_xirvikdedi_user_" + order, null);
String pass = prefs.getString("seedbox_xirvikdedi_pass_" + order, null);
String authToken = prefs.getString("seedbox_xirvikdedi_token_" + order, null);
Expand All @@ -62,7 +62,7 @@ public ServerSetting getServerSetting(SharedPreferences prefs, int orderOffset,
type != Daemon.uTorrent,
false,
null,
type == Daemon.Deluge ? "/deluge" : "/RPC2-aAoWTED8ngLqZyKnZ7FFEAgfz5lejcof",
type == Daemon.Deluge ? "/deluge" : null,
true,
user,
pass,
Expand Down Expand Up @@ -106,21 +106,21 @@ public void saveServerSetting(Context context, String server, String token, Stri
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);

// Check server already exists to replace token
for(int i = 0 ; i <= SeedboxProvider.XirvikDedi.getSettings().getMaxSeedboxOrder(PreferenceManager.getDefaultSharedPreferences(context)) ; i++) {
if(prefs.getString("seedbox_xirvikdedi_server_" + i, "").equals(server)) {
for (int i = 0; i <= SeedboxProvider.XirvikDedi.getSettings().getMaxSeedboxOrder(PreferenceManager.getDefaultSharedPreferences(context)); i++) {
if (prefs.getString("seedbox_xirvikdedi_server_" + i, "").equals(server)) {
key = i;
}
}

// Store new seedbox pref
prefs.edit()
.putString("seedbox_xirvikdedi_client_" + key, Daemon.toCode(Daemon.rTorrent))
.putString("seedbox_xirvikdedi_name_" + key, name)
.putString("seedbox_xirvikdedi_server_" + key, server)
.putString("seedbox_xirvikdedi_user_" + key, "")
.putString("seedbox_xirvikdedi_pass_" + key, "")
.putString("seedbox_xirvikdedi_token_" + key, token)
.apply();
.putString("seedbox_xirvikdedi_client_" + key, Daemon.toCode(Daemon.rTorrent))
.putString("seedbox_xirvikdedi_name_" + key, name)
.putString("seedbox_xirvikdedi_server_" + key, server)
.putString("seedbox_xirvikdedi_user_" + key, "")
.putString("seedbox_xirvikdedi_pass_" + key, "")
.putString("seedbox_xirvikdedi_token_" + key, token)
.apply();

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
*/
@EActivity
@OptionsMenu(resName = "activity_deleteableprefs")
public class XirvikSharedSettingsActivity extends KeyBoundPreferencesActivity {
public class XirvikSettingsActivity extends KeyBoundPreferencesActivity {

@Bean
protected Log log;
Expand All @@ -67,12 +67,11 @@ public void onCreate(Bundle savedInstanceState) {

// Load the raw preferences to show in this screen
init(R.xml.pref_seedbox_xirvikshared,
SeedboxProvider.XirvikShared.getSettings().getMaxSeedboxOrder(PreferenceManager.getDefaultSharedPreferences(this)));
SeedboxProvider.Xirvik.getSettings().getMaxSeedboxOrder(PreferenceManager.getDefaultSharedPreferences(this)));
initTextPreference("seedbox_xirvikshared_name");
initTextPreference("seedbox_xirvikshared_server");
initTextPreference("seedbox_xirvikshared_user");
initTextPreference("seedbox_xirvikshared_pass");
initTextPreference("seedbox_xirvikshared_rpc");
initBooleanPreference("seedbox_xirvikshared_alarmfinished", true);
initBooleanPreference("seedbox_xirvikshared_alarmnew", true);
excludeFilter = initTextPreference("seedbox_xirvikshared_alarmexclude");
Expand All @@ -82,7 +81,6 @@ public void onCreate(Bundle savedInstanceState) {

@Override
protected void onPreferencesChanged() {

// Show the exclude and the include filters if notifying
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
boolean alarmFinished = prefs.getBoolean("seedbox_xirvikshared_alarmfinished_" + key, true);
Expand All @@ -96,26 +94,28 @@ protected void onPreferencesChanged() {
String pass = prefs.getString("seedbox_xirvikshared_pass_" + key, null);
String token = prefs.getString("seedbox_xirvikshared_token_" + key, null);

new RetrieveXirvikAutoConfTask(server, user, pass, token) {
@Override
protected void onPostExecute(String result) {
storeScgiMountFolder(result);
}
}.execute();
boolean enteredServerName = server != null && !server.isEmpty();
boolean enteredUserCredentials = user != null && !user.isEmpty() && pass != null && !pass.isEmpty();
boolean hasToken = token != null && !token.isEmpty();
if (enteredServerName && (enteredUserCredentials || hasToken)) {
new RetrieveXirvikAutoConfTask(server, user, pass, token) {
@Override
protected void onPostExecute(String result) {
storeScgiMountFolder(result);
}
}.execute();
}

}

protected void storeScgiMountFolder(String result) {
Editor edit = PreferenceManager.getDefaultSharedPreferences(XirvikSharedSettingsActivity.this).edit();
EditTextPreference pref = (EditTextPreference) findPreference("seedbox_xirvikshared_rpc_" + key);
Editor edit = PreferenceManager.getDefaultSharedPreferences(XirvikSettingsActivity.this).edit();
if (result == null) {
log.d(this, "Could not retrieve the Xirvik shared seedbox RPC mount point setting");
SnackbarManager.show(Snackbar.with(this).text(R.string.pref_seedbox_xirviknofolder).colorResource(R.color.red));
edit.remove("seedbox_xirvikshared_rpc_" + key);
pref.setSummary("");
SnackbarManager.show(Snackbar.with(this).text(R.string.pref_seedbox_xirvikfolderfallback).colorResource(R.color.red));
edit.putString("seedbox_xirvikshared_rpc_" + key, null);
} else {
edit.putString("seedbox_xirvikshared_rpc_" + key, result);
pref.setSummary(result);
}
edit.apply();
}
Expand All @@ -129,7 +129,7 @@ protected void navigateUp() {
@OptionsItem(resName = "action_removesettings")
protected void removeSettings() {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
SeedboxProvider.XirvikShared.getSettings().removeServerSetting(prefs, key);
SeedboxProvider.Xirvik.getSettings().removeServerSetting(prefs, key);
finish();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class XirvikSharedSettings extends SeedboxSettingsImpl implements Seedbox

@Override
public String getName() {
return "Xirvik shared";
return "Xirvik";
}

@Override
Expand All @@ -45,7 +45,7 @@ public ServerSetting getServerSetting(SharedPreferences prefs, int orderOffset,
if (server == null) {
return null;
}
Daemon type = Daemon.fromCode(prefs.getString("seedbox_xirvikshared_client_" + order, null));
Daemon type = Daemon.fromCode(prefs.getString("seedbox_xirvikshared_client_" + order, Daemon.toCode(Daemon.rTorrent)));
String user = prefs.getString("seedbox_xirvikshared_user_" + order, null);
String pass = prefs.getString("seedbox_xirvikshared_pass_" + order, null);
String rpc = prefs.getString("seedbox_xirvikshared_rpc_" + order, null);
Expand Down Expand Up @@ -84,7 +84,7 @@ public ServerSetting getServerSetting(SharedPreferences prefs, int orderOffset,

@Override
public Intent getSettingsActivityIntent(Context context) {
return XirvikSharedSettingsActivity_.intent(context).get();
return XirvikSettingsActivity_.intent(context).get();
}

@Override
Expand All @@ -101,13 +101,13 @@ public void removeServerSetting(SharedPreferences prefs, int order) {

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;
int key = SeedboxProvider.Xirvik.getSettings().getMaxSeedboxOrder(PreferenceManager.getDefaultSharedPreferences(context)) + 1;

// Shared preferences
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);

// Check server already exists to replace token
for (int i = 0; i <= SeedboxProvider.XirvikShared.getSettings().getMaxSeedboxOrder(PreferenceManager.getDefaultSharedPreferences(context)); i++) {
for (int i = 0; i <= SeedboxProvider.Xirvik.getSettings().getMaxSeedboxOrder(PreferenceManager.getDefaultSharedPreferences(context)); i++) {
if (prefs.getString("seedbox_xirvikshared_server_" + i, "").equals(server)) {
key = i;
}
Expand Down
6 changes: 3 additions & 3 deletions app/src/main/java/org/transdroid/daemon/DaemonSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@
*/
package org.transdroid.daemon;

import org.transdroid.core.app.settings.ServerSetting;

/**
* A class that contains all the settings for a server daemon to connect.
*
* @author erickok
*/
public final class DaemonSettings {

private static final String DEFAULT_NAME = "Default";

final private String name;
final private Daemon type;
final private String address;
Expand Down Expand Up @@ -102,7 +102,7 @@ public DaemonSettings(String name, Daemon type, String address, int port, boolea
}

public String getName() {
return (name == null || name.equals("") ? DEFAULT_NAME : name);
return ServerSetting.getServerName(name, address);
}

public Daemon getType() {
Expand Down
6 changes: 3 additions & 3 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -379,12 +379,12 @@
<string name="pref_seedbox_client">Torrent client</string>
<string name="pref_seedbox_client_info">Client to connect to</string>
<string name="pref_seedbox_server">Server address</string>
<string name="pref_seedbox_xirvikviaqr">Add Xirvik server via QR</string>
<string name="pref_seedbox_xirvikscanerror">Not a valid Xirvik server QR code</string>
<string name="pref_seedbox_xirvikviaqr">Add Xirvik seedbox via QR</string>
<string name="pref_seedbox_xirvikscanerror">Not a valid Xirvik seedbox QR code</string>
<string name="pref_seedbox_xirvikhint">Like eplus001.xirvik.com</string>
<string name="pref_seedbox_xirvikhint2">Like semixl001a.xirvik.com</string>
<string name="pref_seedbox_xirvikhint3">Like desharedgbit001.xirvik.com</string>
<string name="pref_seedbox_xirviknofolder">Cannot retrieve the Xirvik SCGI folder setting; please try again later or correct your server address setting</string>
<string name="pref_seedbox_xirvikfolderfallback">Cannot retrieve the Xirvik SCGI folder setting; using /RPC2 as default</string>
<string name="pref_seedbox_dediseedboxhint">Like abcd123.dediseedbox.com</string>
<string-array name="pref_seedbox_xirvikclients" translatable="false">
<item>rTorrent</item>
Expand Down
11 changes: 3 additions & 8 deletions app/src/main/res/xml/pref_seedbox_xirvikshared.xml
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<?xml version="1.0" encoding="utf-8"?><!--
Copyright 2010-2018 Eric Kok et al.
Transdroid is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Transdroid is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Transdroid. If not, see <http://www.gnu.org/licenses/>.
-->
Expand Down Expand Up @@ -39,11 +39,6 @@
android:key="seedbox_xirvikshared_pass"
android:title="@string/pref_pass"
app:iconSpaceReserved="false" />
<EditTextPreference
android:enabled="false"
android:key="seedbox_xirvikshared_rpc"
android:title="@string/pref_folder"
app:iconSpaceReserved="false" />

<PreferenceScreen
android:title="@string/pref_optional"
Expand Down

0 comments on commit 29c3b3b

Please sign in to comment.