Browse Source

Added native support for Dediseebox seedboxes.

pull/256/head
Eric Kok 10 years ago
parent
commit
2a06c1ba56
  1. 1
      app/src/main/AndroidManifest.xml
  2. 91
      app/src/main/java/org/transdroid/core/seedbox/DediseedboxSettings.java
  3. 72
      app/src/main/java/org/transdroid/core/seedbox/DediseedboxSettingsActivity.java
  4. 6
      app/src/main/java/org/transdroid/core/seedbox/SeedboxProvider.java
  5. 1
      app/src/main/res/values/strings.xml
  6. 39
      app/src/main/res/xml/pref_seedbox_dediseedbox.xml

1
app/src/main/AndroidManifest.xml

@ -190,6 +190,7 @@
<activity android:name="org.transdroid.core.gui.navigation.DialogHelper_" /> <activity android:name="org.transdroid.core.gui.navigation.DialogHelper_" />
<!-- Seedbox settings --> <!-- Seedbox settings -->
<activity android:name="org.transdroid.core.seedbox.DediseedboxSettingsActivity_" />
<activity android:name="org.transdroid.core.seedbox.SeedstuffSettingsActivity_" /> <activity android:name="org.transdroid.core.seedbox.SeedstuffSettingsActivity_" />
<activity android:name="org.transdroid.core.seedbox.XirvikSharedSettingsActivity_" /> <activity android:name="org.transdroid.core.seedbox.XirvikSharedSettingsActivity_" />
<activity android:name="org.transdroid.core.seedbox.XirvikSemiSettingsActivity_" /> <activity android:name="org.transdroid.core.seedbox.XirvikSemiSettingsActivity_" />

91
app/src/main/java/org/transdroid/core/seedbox/DediseedboxSettings.java

@ -0,0 +1,91 @@
/*
* Copyright 2010-2013 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/>.
*/
package org.transdroid.core.seedbox;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import org.transdroid.core.app.settings.ServerSetting;
import org.transdroid.daemon.Daemon;
import org.transdroid.daemon.OS;
/**
* Implementation of {@link SeedboxSettings} for Dediseedbox seedboxes.
* @author Eric Kok
*/
public class DediseedboxSettings extends SeedboxSettingsImpl implements SeedboxSettings {
@Override
public String getName() {
return "Dediseedbox";
}
@Override
public ServerSetting getServerSetting(SharedPreferences prefs, int orderOffset, int order) {
// @formatter:off
String server = prefs.getString("seedbox_dediseedbox_server_" + order, null);
if (server == null) {
return null;
}
String user = prefs.getString("seedbox_dediseedbox_user_" + order, null);
String pass = prefs.getString("seedbox_dediseedbox_pass_" + order, null);
return new ServerSetting(
orderOffset + order,
prefs.getString("seedbox_dediseedbox_name_" + order, null),
Daemon.rTorrent,
server,
null,
443,
null,
443,
true,
false,
null,
"/rutorrent/plugins/httprpc/action.php",
true,
user,
pass,
null,
OS.Linux,
"/",
"ftp://" + user + "@" + server + "/",
pass,
6,
true,
true,
true);
// @formatter:on
}
@Override
public Intent getSettingsActivityIntent(Context context) {
return DediseedboxSettingsActivity_.intent(context).get();
}
@Override
public int getMaxSeedboxOrder(SharedPreferences prefs) {
return getMaxSeedboxOrder(prefs, "seedbox_dediseedbox_server_");
}
@Override
public void removeServerSetting(SharedPreferences prefs, int order) {
removeServerSetting(prefs, "seedbox_dediseedbox_server_", new String[] { "seedbox_dediseedbox_name_",
"seedbox_dediseedbox_server_", "seedbox_dediseedbox_user_", "seedbox_dediseedbox_pass_" }, order);
}
}

72
app/src/main/java/org/transdroid/core/seedbox/DediseedboxSettingsActivity.java

@ -0,0 +1,72 @@
/*
* Copyright 2010-2013 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/>.
*/
package org.transdroid.core.seedbox;
import android.annotation.TargetApi;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Build;
import android.os.Bundle;
import android.preference.PreferenceManager;
import org.androidannotations.annotations.EActivity;
import org.androidannotations.annotations.OptionsItem;
import org.androidannotations.annotations.OptionsMenu;
import org.transdroid.R;
import org.transdroid.core.gui.settings.KeyBoundPreferencesActivity;
import org.transdroid.core.gui.settings.MainSettingsActivity_;
/**
* Activity that allows for the configuration of a Dediseedbox seedbox. The key can be supplied to update an
* existing server setting instead of creating a new one.
* @author Eric Kok
*/
@EActivity
@OptionsMenu(resName = "activity_deleteableprefs")
public class DediseedboxSettingsActivity extends KeyBoundPreferencesActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
// Load the raw preferences to show in this screen
init(R.xml.pref_seedbox_dediseedbox,
SeedboxProvider.Dediseedbox.getSettings().getMaxSeedboxOrder(
PreferenceManager.getDefaultSharedPreferences(this)));
initTextPreference("seedbox_dediseedbox_name");
initTextPreference("seedbox_dediseedbox_server");
initTextPreference("seedbox_dediseedbox_user");
initTextPreference("seedbox_dediseedbox_pass");
}
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@OptionsItem(android.R.id.home)
protected void navigateUp() {
MainSettingsActivity_.intent(this).flags(Intent.FLAG_ACTIVITY_CLEAR_TOP).start();
}
@OptionsItem(resName = "action_removesettings")
protected void removeSettings() {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
SeedboxProvider.Dediseedbox.getSettings().removeServerSetting(prefs, key);
finish();
}
}

6
app/src/main/java/org/transdroid/core/seedbox/SeedboxProvider.java

@ -25,6 +25,12 @@ import org.transdroid.core.gui.settings.KeyBoundPreferencesActivity;
*/ */
public enum SeedboxProvider { public enum SeedboxProvider {
Dediseedbox {
@Override
public SeedboxSettings getSettings() {
return new DediseedboxSettings();
}
},
Seedstuff { Seedstuff {
@Override @Override
public SeedboxSettings getSettings() { public SeedboxSettings getSettings() {

1
app/src/main/res/values/strings.xml

@ -351,6 +351,7 @@
<string name="pref_seedbox_xirvikhint3">Like desharedgbit001.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_xirviknofolder">Cannot retrieve the Xirvik SCGI folder setting; please try again later or correct your server address setting</string>
<string name="pref_seedbox_seedstuffhint">Like 001.seedstuff.ca</string> <string name="pref_seedbox_seedstuffhint">Like 001.seedstuff.ca</string>
<string name="pref_seedbox_dediseedboxhint">Like abcd123.dediseedbox.com</string>
<string-array name="pref_seedbox_xirvikclients" translatable="false"> <string-array name="pref_seedbox_xirvikclients" translatable="false">
<item>rTorrent</item> <item>rTorrent</item>
<item>uTorrent</item> <item>uTorrent</item>

39
app/src/main/res/xml/pref_seedbox_dediseedbox.xml

@ -0,0 +1,39 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2010-2013 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/>.
-->
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" >
<EditTextPreference
android:key="seedbox_dediseedbox_name"
android:title="@string/pref_name"
android:summary="@string/pref_name_optional"
android:inputType="textNoSuggestions" />
<EditTextPreference
android:key="seedbox_dediseedbox_server"
android:title="@string/pref_seedbox_server"
android:summary="@string/pref_seedbox_dediseedboxhint"
android:inputType="textUri" />
<EditTextPreference
android:key="seedbox_dediseedbox_user"
android:title="@string/pref_user"
android:inputType="textNoSuggestions" />
<EditTextPreference
android:key="seedbox_dediseedbox_pass"
android:title="@string/pref_pass"
android:inputType="textPassword" />
</PreferenceScreen>
Loading…
Cancel
Save