Eric Kok
4 years ago
28 changed files with 2 additions and 294 deletions
@ -1,95 +0,0 @@ |
|||||||
/* |
|
||||||
* 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/>.
|
|
||||||
*/ |
|
||||||
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 Seedstuff seedboxes. |
|
||||||
* |
|
||||||
* @author Eric Kok |
|
||||||
*/ |
|
||||||
public class SeedstuffSettings extends SeedboxSettingsImpl implements SeedboxSettings { |
|
||||||
|
|
||||||
@Override |
|
||||||
public String getName() { |
|
||||||
return "Seedstuff"; |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public ServerSetting getServerSetting(SharedPreferences prefs, int orderOffset, int order) { |
|
||||||
// @formatter:off
|
|
||||||
String server = prefs.getString("seedbox_seedstuff_server_" + order, null); |
|
||||||
if (server == null) { |
|
||||||
return null; |
|
||||||
} |
|
||||||
String user = prefs.getString("seedbox_seedstuff_user_" + order, null); |
|
||||||
String pass = prefs.getString("seedbox_seedstuff_pass_" + order, null); |
|
||||||
return new ServerSetting( |
|
||||||
orderOffset + order, |
|
||||||
prefs.getString("seedbox_seedstuff_name_" + order, null), |
|
||||||
Daemon.rTorrent, |
|
||||||
server, |
|
||||||
null, |
|
||||||
443, |
|
||||||
null, |
|
||||||
443, |
|
||||||
true, |
|
||||||
true, |
|
||||||
false, |
|
||||||
null, |
|
||||||
"/user/" + user, |
|
||||||
true, |
|
||||||
user, |
|
||||||
pass, |
|
||||||
null, |
|
||||||
OS.Linux, |
|
||||||
"/rtorrent/downloads", |
|
||||||
"ftp://" + user + "@" + server + ":32001/rtorrent/downloads", |
|
||||||
pass, |
|
||||||
6, |
|
||||||
prefs.getBoolean("seedbox_seedstuff_alarmfinished_" + order, true), |
|
||||||
prefs.getBoolean("seedbox_seedstuff_alarmnew_" + order, false), |
|
||||||
prefs.getString("seedbox_seedstuff_alarmexclude_" + order, null), |
|
||||||
prefs.getString("seedbox_seedstuff_alarminclude_" + order, null), |
|
||||||
true); |
|
||||||
// @formatter:on
|
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public Intent getSettingsActivityIntent(Context context) { |
|
||||||
return SeedstuffSettingsActivity_.intent(context).get(); |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public int getMaxSeedboxOrder(SharedPreferences prefs) { |
|
||||||
return getMaxSeedboxOrder(prefs, "seedbox_seedstuff_server_"); |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public void removeServerSetting(SharedPreferences prefs, int order) { |
|
||||||
removeServerSetting(prefs, "seedbox_seedstuff_server_", new String[]{"seedbox_seedstuff_name_", |
|
||||||
"seedbox_seedstuff_server_", "seedbox_seedstuff_user_", "seedbox_seedstuff_pass_"}, order); |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
@ -1,93 +0,0 @@ |
|||||||
/* |
|
||||||
* 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/>.
|
|
||||||
*/ |
|
||||||
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 androidx.preference.EditTextPreference; |
|
||||||
import androidx.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 Seedstuff 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 SeedstuffSettingsActivity extends KeyBoundPreferencesActivity { |
|
||||||
|
|
||||||
private EditTextPreference excludeFilter, includeFilter; |
|
||||||
|
|
||||||
@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_seedstuff, |
|
||||||
SeedboxProvider.Seedstuff.getSettings().getMaxSeedboxOrder( |
|
||||||
PreferenceManager.getDefaultSharedPreferences(this))); |
|
||||||
initTextPreference("seedbox_seedstuff_name"); |
|
||||||
initTextPreference("seedbox_seedstuff_server"); |
|
||||||
initTextPreference("seedbox_seedstuff_user"); |
|
||||||
initTextPreference("seedbox_seedstuff_pass"); |
|
||||||
initBooleanPreference("seedbox_seedstuff_alarmfinished", true); |
|
||||||
initBooleanPreference("seedbox_seedstuff_alarmnew", true); |
|
||||||
excludeFilter = initTextPreference("seedbox_seedstuff_alarmexclude"); |
|
||||||
includeFilter = initTextPreference("seedbox_seedstuff_alarminclude"); |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
@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.Seedstuff.getSettings().removeServerSetting(prefs, key); |
|
||||||
finish(); |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
protected void onPreferencesChanged() { |
|
||||||
|
|
||||||
// Show the exclude and the include filters if notifying
|
|
||||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); |
|
||||||
boolean alarmFinished = prefs.getBoolean("seedbox_seedstuff_alarmfinished_" + key, true); |
|
||||||
boolean alarmNew = prefs.getBoolean("seedbox_seedstuff_alarmnew_" + key, true); |
|
||||||
excludeFilter.setEnabled(alarmNew || alarmFinished); |
|
||||||
includeFilter.setEnabled(alarmNew || alarmFinished); |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
} |
|
@ -1,72 +0,0 @@ |
|||||||
<?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/>. |
|
||||||
--> |
|
||||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" |
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"> |
|
||||||
|
|
||||||
<EditTextPreference |
|
||||||
android:inputType="textNoSuggestions" |
|
||||||
android:key="seedbox_seedstuff_name" |
|
||||||
android:summary="@string/pref_name_optional" |
|
||||||
android:title="@string/pref_name" |
|
||||||
app:iconSpaceReserved="false" /> |
|
||||||
<EditTextPreference |
|
||||||
android:inputType="textUri" |
|
||||||
android:key="seedbox_seedstuff_server" |
|
||||||
android:summary="@string/pref_seedbox_seedstuffhint" |
|
||||||
android:title="@string/pref_seedbox_server" |
|
||||||
app:iconSpaceReserved="false" /> |
|
||||||
<EditTextPreference |
|
||||||
android:inputType="textNoSuggestions" |
|
||||||
android:key="seedbox_seedstuff_user" |
|
||||||
android:title="@string/pref_user" |
|
||||||
app:iconSpaceReserved="false" /> |
|
||||||
<EditTextPreference |
|
||||||
android:inputType="textPassword" |
|
||||||
android:key="seedbox_seedstuff_pass" |
|
||||||
android:title="@string/pref_pass" |
|
||||||
app:iconSpaceReserved="false" /> |
|
||||||
|
|
||||||
<PreferenceScreen |
|
||||||
android:title="@string/pref_optional" |
|
||||||
app:iconSpaceReserved="false"> |
|
||||||
<CheckBoxPreference |
|
||||||
android:defaultValue="true" |
|
||||||
android:key="seedbox_seedstuff_alarmfinished" |
|
||||||
android:summary="@string/pref_alarmdone_info" |
|
||||||
android:title="@string/pref_alarmdone" |
|
||||||
app:iconSpaceReserved="false" /> |
|
||||||
<CheckBoxPreference |
|
||||||
android:defaultValue="false" |
|
||||||
android:key="seedbox_seedstuff_alarmnew" |
|
||||||
android:summary="@string/pref_alarmnew_info" |
|
||||||
android:title="@string/pref_alarmnew" |
|
||||||
app:iconSpaceReserved="false" /> |
|
||||||
<EditTextPreference |
|
||||||
android:inputType="textFilter" |
|
||||||
android:key="seedbox_seedstuff_alarmexclude" |
|
||||||
android:summary="@string/pref_alarmexclude_info" |
|
||||||
android:title="@string/pref_alarmexclude" |
|
||||||
app:iconSpaceReserved="false" /> |
|
||||||
<EditTextPreference |
|
||||||
android:inputType="textFilter" |
|
||||||
android:key="seedbox_seedstuff_alarminclude" |
|
||||||
android:summary="@string/pref_alarminclude_info" |
|
||||||
android:title="@string/pref_alarminclude" |
|
||||||
app:iconSpaceReserved="false" /> |
|
||||||
</PreferenceScreen> |
|
||||||
|
|
||||||
</PreferenceScreen> |
|
Loading…
Reference in new issue