Eric Kok
10 years ago
6 changed files with 210 additions and 0 deletions
@ -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); |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -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(); |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -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…
Reference in new issue