Browse Source

Added support for adding Xirvik and Seedstuff seedboxes with super simple settings.

pull/82/head
Eric Kok 11 years ago
parent
commit
18ad364d45
  1. BIN
      core/res/drawable-hdpi/ic_action_overflow.png
  2. BIN
      core/res/drawable-mdpi/ic_action_overflow.png
  3. BIN
      core/res/drawable-xhdpi/ic_action_overflow.png
  4. BIN
      core/res/drawable-xxhdpi/ic_action_overflow.png
  5. 16
      core/res/layout/pref_withoverflow.xml
  6. 2
      core/res/values-sw500dp/bools.xml
  7. 2
      core/res/values-v11/bools.xml
  8. 8
      core/res/values/bools.xml
  9. 21
      core/res/values/strings.xml
  10. 2
      core/res/xml/pref_main.xml
  11. 39
      core/res/xml/pref_seedbox_seedstuff.xml
  12. 45
      core/res/xml/pref_seedbox_xirvikdedi.xml
  13. 39
      core/res/xml/pref_seedbox_xirviksemi.xml
  14. 39
      core/res/xml/pref_seedbox_xirvikshared.xml
  15. 76
      core/src/org/transdroid/core/app/settings/ApplicationSettings.java
  16. 2
      core/src/org/transdroid/core/app/settings/SettingsPersistence.java
  17. 6
      core/src/org/transdroid/core/gui/TorrentsActivity.java
  18. 13
      core/src/org/transdroid/core/gui/navigation/NavigationHelper.java
  19. 77
      core/src/org/transdroid/core/gui/settings/MainSettingsActivity.java
  20. 117
      core/src/org/transdroid/core/gui/settings/OverflowPreference.java
  21. 2
      core/src/org/transdroid/core/gui/settings/ServerPreference.java
  22. 4
      core/src/org/transdroid/core/gui/settings/ServerSettingsActivity.java
  23. 10
      core/src/org/transdroid/core/gui/settings/SystemSettingsActivity.java
  24. 98
      core/src/org/transdroid/core/seedbox/SeedboxPreference.java
  25. 55
      core/src/org/transdroid/core/seedbox/SeedboxProvider.java
  26. 82
      core/src/org/transdroid/core/seedbox/SeedboxSettings.java
  27. 95
      core/src/org/transdroid/core/seedbox/SeedboxSettingsImpl.java
  28. 91
      core/src/org/transdroid/core/seedbox/SeedstuffSettings.java
  29. 71
      core/src/org/transdroid/core/seedbox/SeedstuffSettingsActivity.java
  30. 93
      core/src/org/transdroid/core/seedbox/XirvikDediSettings.java
  31. 72
      core/src/org/transdroid/core/seedbox/XirvikDediSettingsActivity.java
  32. 91
      core/src/org/transdroid/core/seedbox/XirvikSemiSettings.java
  33. 71
      core/src/org/transdroid/core/seedbox/XirvikSemiSettingsActivity.java
  34. 91
      core/src/org/transdroid/core/seedbox/XirvikSharedSettings.java
  35. 71
      core/src/org/transdroid/core/seedbox/XirvikSharedSettingsActivity.java
  36. 4
      core/src/org/transdroid/core/service/ControlService.java
  37. 2
      core/src/org/transdroid/core/service/ServerCheckerService.java
  38. 2
      core/src/org/transdroid/core/widget/ListWidgetConfigActivity.java
  39. 2
      core/src/org/transdroid/core/widget/ListWidgetProvider.java
  40. 6
      full/AndroidManifest.xml
  41. 27
      full/res/values/bools.xml
  42. 6
      lite/AndroidManifest.xml
  43. 27
      lite/res/values/bools.xml

BIN
core/res/drawable-hdpi/ic_action_overflow.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 342 B

BIN
core/res/drawable-mdpi/ic_action_overflow.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 216 B

BIN
core/res/drawable-xhdpi/ic_action_overflow.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 355 B

BIN
core/res/drawable-xxhdpi/ic_action_overflow.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 617 B

16
core/res/layout/pref_withoverflow.xml

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ImageButton
android:id="@+id/overflow_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right|center_vertical"
android:background="@drawable/abs__item_background_holo_light"
android:contentDescription="@string/pref_addseedbox"
android:padding="5dp"
android:src="@drawable/ic_action_overflow" />
</FrameLayout>

2
core/res/values-sw500dp/bools.xml

@ -16,6 +16,8 @@
along with Transdroid. If not, see <http://www.gnu.org/licenses/>. along with Transdroid. If not, see <http://www.gnu.org/licenses/>.
--> -->
<resources> <resources>
<!-- Used to determine if a device is 'small', i.e. a phone; for reference: a Nexus 7's smallest width is 533dip --> <!-- Used to determine if a device is 'small', i.e. a phone; for reference: a Nexus 7's smallest width is 533dip -->
<bool name="show_dialog_fullscreen">false</bool> <bool name="show_dialog_fullscreen">false</bool>
</resources> </resources>

2
core/res/values-v11/bools.xml

@ -16,6 +16,8 @@
along with Transdroid. If not, see <http://www.gnu.org/licenses/>. along with Transdroid. If not, see <http://www.gnu.org/licenses/>.
--> -->
<resources> <resources>
<!-- Used to enable the scrolling widget on Honeycomb (API 11) and higher only --> <!-- Used to enable the scrolling widget on Honeycomb (API 11) and higher only -->
<bool name="widget_available">true</bool> <bool name="widget_available">true</bool>
</resources> </resources>

8
core/res/values/bools.xml

@ -16,8 +16,16 @@
along with Transdroid. If not, see <http://www.gnu.org/licenses/>. along with Transdroid. If not, see <http://www.gnu.org/licenses/>.
--> -->
<resources> <resources>
<!-- Used to determine if a device is 'small', i.e. a phone; for reference: a Nexus 7's smallest width is 533dip --> <!-- Used to determine if a device is 'small', i.e. a phone; for reference: a Nexus 7's smallest width is 533dip -->
<bool name="show_dialog_fullscreen">true</bool> <bool name="show_dialog_fullscreen">true</bool>
<!-- Used to enable the scrolling widget on Honeycomb (API 11) and higher only --> <!-- Used to enable the scrolling widget on Honeycomb (API 11) and higher only -->
<bool name="widget_available">false</bool> <bool name="widget_available">false</bool>
<!-- Used to enable the search UI -->
<bool name="search_available">true</bool>
<!-- Used to enable the RSS UI and background service -->
<bool name="rss_available">true</bool>
<!-- Used to allow adding of seedboxes via easy server setup -->
<bool name="seedboxes_available">true</bool>
</resources> </resources>

21
core/res/values/strings.xml

@ -210,6 +210,7 @@
<string name="pref_servers">Servers</string> <string name="pref_servers">Servers</string>
<string name="pref_addserver">Add new server</string> <string name="pref_addserver">Add new server</string>
<string name="pref_addseedbox">Add seedbox</string>
<string name="pref_searchsites">Search sites</string> <string name="pref_searchsites">Search sites</string>
<string name="pref_setsearchsite">Set default site</string> <string name="pref_setsearchsite">Set default site</string>
<string name="pref_addwebsearch">Add web search site</string> <string name="pref_addwebsearch">Add web search site</string>
@ -298,6 +299,26 @@
<string name="pref_installhelp_info">Available at transdroid.org/download</string> <string name="pref_installhelp_info">Available at transdroid.org/download</string>
<string name="pref_changelog">Recent changes</string> <string name="pref_changelog">Recent changes</string>
<string name="pref_about">About %1$s</string> <string name="pref_about">About %1$s</string>
<string name="pref_seedbox_addseedbox">Add %1$s seedbox</string>
<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_xirvikhint">Like dedi001.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_seedstuffhint">Like 001.seedstuff.ca</string>
<string-array name="pref_seedbox_xirvikclients" translatable="false">
<item>rTorrent</item>
<item>uTorrent</item>
<item>Deluge</item>
</string-array>
<string-array name="pref_seedbox_xirviktypes" translatable="false">
<item>daemon_rtorrent</item>
<item>daemon_utorrent</item>
<item>daemon_deluge</item>
</string-array>
<string-array name="pref_daemon_types" translatable="false"> <string-array name="pref_daemon_types" translatable="false">
<item>BitComet</item> <item>BitComet</item>
<item>Bitflu 1.2+</item> <item>Bitflu 1.2+</item>

2
core/res/xml/pref_main.xml

@ -21,7 +21,7 @@
android:key="header_servers" android:key="header_servers"
android:title="@string/pref_servers" android:title="@string/pref_servers"
android:order="0"> android:order="0">
<Preference <org.transdroid.core.gui.settings.OverflowPreference
android:key="header_addserver" android:key="header_addserver"
android:title="@string/pref_addserver" android:title="@string/pref_addserver"
android:order="99" /> android:order="99" />

39
core/res/xml/pref_seedbox_seedstuff.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_seedstuff_name"
android:title="@string/pref_name"
android:summary="@string/pref_name_optional"
android:inputType="textNoSuggestions" />
<EditTextPreference
android:key="seedbox_seedstuff_server"
android:title="@string/pref_seedbox_server"
android:summary="@string/pref_seedbox_seedstuffhint"
android:inputType="textUri" />
<EditTextPreference
android:key="seedbox_seedstuff_user"
android:title="@string/pref_user"
android:inputType="textNoSuggestions" />
<EditTextPreference
android:key="seedbox_seedstuff_pass"
android:title="@string/pref_pass"
android:inputType="textPassword" />
</PreferenceScreen>

45
core/res/xml/pref_seedbox_xirvikdedi.xml

@ -0,0 +1,45 @@
<?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_xirvikdedi_name"
android:title="@string/pref_name"
android:summary="@string/pref_name_optional"
android:inputType="textNoSuggestions" />
<ListPreference
android:key="seedbox_xirvikdedi_client"
android:title="@string/pref_seedbox_client"
android:summary="@string/pref_seedbox_client_info"
android:entries="@array/pref_seedbox_xirvikclients"
android:entryValues="@array/pref_seedbox_xirviktypes" />
<EditTextPreference
android:key="seedbox_xirvikdedi_server"
android:title="@string/pref_seedbox_server"
android:summary="@string/pref_seedbox_xirvikhint"
android:inputType="textUri" />
<EditTextPreference
android:key="seedbox_xirvikdedi_user"
android:title="@string/pref_user"
android:inputType="textNoSuggestions" />
<EditTextPreference
android:key="seedbox_xirvikdedi_pass"
android:title="@string/pref_pass"
android:inputType="textPassword" />
</PreferenceScreen>

39
core/res/xml/pref_seedbox_xirviksemi.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_xirviksemi_name"
android:title="@string/pref_name"
android:summary="@string/pref_name_optional"
android:inputType="textNoSuggestions" />
<EditTextPreference
android:key="seedbox_xirviksemi_server"
android:title="@string/pref_seedbox_server"
android:summary="@string/pref_seedbox_xirvikhint2"
android:inputType="textUri" />
<EditTextPreference
android:key="seedbox_xirviksemi_user"
android:title="@string/pref_user"
android:inputType="textNoSuggestions" />
<EditTextPreference
android:key="seedbox_xirviksemi_pass"
android:title="@string/pref_pass"
android:inputType="textPassword" />
</PreferenceScreen>

39
core/res/xml/pref_seedbox_xirvikshared.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_xirviksemi_name"
android:title="@string/pref_name"
android:summary="@string/pref_name_optional"
android:inputType="textNoSuggestions" />
<EditTextPreference
android:key="seedbox_xirviksemi_server"
android:title="@string/pref_seedbox_server"
android:summary="@string/pref_seedbox_xirvikhint2"
android:inputType="textUri" />
<EditTextPreference
android:key="seedbox_xirviksemi_user"
android:title="@string/pref_user"
android:inputType="textNoSuggestions" />
<EditTextPreference
android:key="seedbox_xirviksemi_pass"
android:title="@string/pref_pass"
android:inputType="textPassword" />
</PreferenceScreen>

76
core/src/org/transdroid/core/app/settings/ApplicationSettings.java

@ -32,6 +32,7 @@ import org.transdroid.core.app.search.SearchHelper;
import org.transdroid.core.app.search.SearchSite; import org.transdroid.core.app.search.SearchSite;
import org.transdroid.core.gui.navigation.StatusType; import org.transdroid.core.gui.navigation.StatusType;
import org.transdroid.core.gui.search.SearchSetting; import org.transdroid.core.gui.search.SearchSetting;
import org.transdroid.core.seedbox.SeedboxProvider;
import org.transdroid.core.widget.ListWidgetConfig; import org.transdroid.core.widget.ListWidgetConfig;
import org.transdroid.daemon.Daemon; import org.transdroid.daemon.Daemon;
import org.transdroid.daemon.OS; import org.transdroid.daemon.OS;
@ -60,22 +61,69 @@ public class ApplicationSettings {
} }
/** /**
* Returns all available user-configured servers * Returns all available user-configured normal and seed servers
* @return A list of all stored server settings objects * @return A list of all stored server settings objects
*/ */
public List<ServerSetting> getServerSettings() { public List<ServerSetting> getAllServerSettings() {
List<ServerSetting> all = new ArrayList<ServerSetting>();
all.addAll(getNormalServerSettings());
for (SeedboxProvider provider : SeedboxProvider.values()) {
all.addAll(provider.getSettings().getAllServerSettings(prefs, all.size()));
}
return all;
}
/**
* Returns the order number/identifying key of the last server, normal or seedbox configured
* @return The zero-based order number (index) of the last stored server settings
*/
public int getMaxOfAllServers() {
int max = getMaxNormalServer();
for (SeedboxProvider provider : SeedboxProvider.values()) {
max += provider.getSettings().getMaxSeedboxOrder(prefs) + 1;
}
return max;
}
/**
* Returns the server settings for either a normal or a seedbox server as the user configured. WARNING: This method
* does not check if the settings actually exist and may reply on empty default if called for a non-existing server.
* @param order The order number/identifying key of the server's settings to retrieve, where the normal servers are
* first and the seedboxes are numbers thereafter onwards
* @return The server settings object, loaded from shared preferences
*/
public ServerSetting getServerSetting(int order) {
int max = getMaxNormalServer();
if (order <= max) {
return getNormalServerSetting(order);
}
for (SeedboxProvider provider : SeedboxProvider.values()) {
int offset = max;
max += provider.getSettings().getMaxSeedboxOrder(prefs) + 1;
if (order <= max) {
return provider.getSettings().getServerSetting(prefs, offset, order - offset - 1);
}
}
return null;
}
/**
* Returns all available normal, user-configured servers (so no seedbox settings)
* @return A list of all stored server settings objects
*/
public List<ServerSetting> getNormalServerSettings() {
List<ServerSetting> servers = new ArrayList<ServerSetting>(); List<ServerSetting> servers = new ArrayList<ServerSetting>();
for (int i = 0; i <= getMaxServer(); i++) { for (int i = 0; i <= getMaxNormalServer(); i++) {
servers.add(getServerSetting(i)); servers.add(getNormalServerSetting(i));
} }
return Collections.unmodifiableList(servers); return Collections.unmodifiableList(servers);
} }
/** /**
* Returns the order number/identifying key of the last server * Returns the order number/identifying key of the last normal server
* @return The zero-based order number (index) of the last stored server settings * @return The zero-based order number (index) of the last stored normal server settings
*/ */
public int getMaxServer() { public int getMaxNormalServer() {
for (int i = 0; true; i++) { for (int i = 0; true; i++) {
if (prefs.getString("server_type_" + i, null) == null) if (prefs.getString("server_type_" + i, null) == null)
return i - 1; return i - 1;
@ -83,12 +131,12 @@ public class ApplicationSettings {
} }
/** /**
* Returns the user-specified server settings for a specific server. WARNING: This method does not check if the * Returns the user-specified server settings for a normal (non-seedbox) server. WARNING: This method does not check
* settings actually exist and may rely on empty defaults if called not a non-existing server. * if the settings actually exist and may rely on empty defaults if called for a non-existing server.
* @param order The order number/identifying key of the settings to retrieve * @param order The order number/identifying key of the normal server's settings to retrieve
* @return The server settings object, loaded from shared preferences * @return The server settings object, loaded from shared preferences
*/ */
public ServerSetting getServerSetting(int order) { public ServerSetting getNormalServerSetting(int order) {
// @formatter:off // @formatter:off
Daemon type = Daemon.fromCode(prefs.getString("server_type_" + order, null)); Daemon type = Daemon.fromCode(prefs.getString("server_type_" + order, null));
boolean ssl = prefs.getBoolean("server_sslenabled_" + order, false); boolean ssl = prefs.getBoolean("server_sslenabled_" + order, false);
@ -132,13 +180,13 @@ public class ApplicationSettings {
* servers will be updated accordingly. * servers will be updated accordingly.
* @param order The identifying order number/key of the settings to remove * @param order The identifying order number/key of the settings to remove
*/ */
public void removeServerSettings(int order) { public void removeNormalServerSettings(int order) {
if (prefs.getString("server_type_" + order, null) == null) if (prefs.getString("server_type_" + order, null) == null)
return; // The settings that were requested to be removed do not exist return; // The settings that were requested to be removed do not exist
// Copy all settings higher than the supplied order number to the previous spot // Copy all settings higher than the supplied order number to the previous spot
Editor edit = prefs.edit(); Editor edit = prefs.edit();
int max = getMaxServer(); int max = getMaxNormalServer();
for (int i = order; i < max; i++) { for (int i = order; i < max; i++) {
edit.putString("server_name_" + i, prefs.getString("server_name_" + (i + 1), null)); edit.putString("server_name_" + i, prefs.getString("server_name_" + (i + 1), null));
edit.putString("server_type_" + i, prefs.getString("server_type_" + (i + 1), null)); edit.putString("server_type_" + i, prefs.getString("server_type_" + (i + 1), null));
@ -197,7 +245,7 @@ public class ApplicationSettings {
* servers exist * servers exist
*/ */
public ServerSetting getLastUsedServer() { public ServerSetting getLastUsedServer() {
int max = getMaxServer(); // Zero-based index, so with max == 0 there is 1 server int max = getMaxOfAllServers(); // Zero-based index, so with max == 0 there is 1 server
if (max < 0) { if (max < 0) {
// No servers configured // No servers configured
return null; return null;

2
core/src/org/transdroid/core/app/settings/SettingsPersistence.java

@ -73,7 +73,7 @@ public class SettingsPersistence {
JSONArray servers = json.getJSONArray("servers"); JSONArray servers = json.getJSONArray("servers");
for (int i = 0; i < servers.length(); i++) { for (int i = 0; i < servers.length(); i++) {
JSONObject server = servers.getJSONObject(i); JSONObject server = servers.getJSONObject(i);
String postfix = Integer.toString(applicationSettings.getMaxServer() + 1 + i); String postfix = Integer.toString(applicationSettings.getMaxOfAllServers() + 1 + i);
if (server.has("name")) if (server.has("name"))
editor.putString("server_name_" + postfix, server.getString("name")); editor.putString("server_name_" + postfix, server.getString("name"));

6
core/src/org/transdroid/core/gui/TorrentsActivity.java

@ -194,7 +194,7 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi
getSupportActionBar().setCustomView(serverStatusView); getSupportActionBar().setCustomView(serverStatusView);
navigationSpinnerAdapter = FilterListDropDownAdapter_.getInstance_(this); navigationSpinnerAdapter = FilterListDropDownAdapter_.getInstance_(this);
// Servers are always added to the action bar spinner // Servers are always added to the action bar spinner
navigationSpinnerAdapter.updateServers(applicationSettings.getServerSettings()); navigationSpinnerAdapter.updateServers(applicationSettings.getAllServerSettings());
// Check if there was room for a dedicated filter list (i.e. on tablets) // Check if there was room for a dedicated filter list (i.e. on tablets)
if (filtersList != null) { if (filtersList != null) {
@ -231,7 +231,7 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi
&& getIntent().getExtras() == null && getIntent().hasExtra(ListWidgetProvider.EXTRA_SERVER)) { && getIntent().getExtras() == null && getIntent().hasExtra(ListWidgetProvider.EXTRA_SERVER)) {
// A server settings order ID was provided in this org.transdroid.START_SERVER action intent // A server settings order ID was provided in this org.transdroid.START_SERVER action intent
int serverId = getIntent().getExtras().getInt(ListWidgetProvider.EXTRA_SERVER); int serverId = getIntent().getExtras().getInt(ListWidgetProvider.EXTRA_SERVER);
if (serverId < 0 || serverId > applicationSettings.getMaxServer()) { if (serverId < 0 || serverId > applicationSettings.getMaxOfAllServers()) {
Log.e(this, "Tried to start with " + ListWidgetProvider.EXTRA_SERVER + " intent but " + serverId Log.e(this, "Tried to start with " + ListWidgetProvider.EXTRA_SERVER + " intent but " + serverId
+ " is not an existing server order id"); + " is not an existing server order id");
} else { } else {
@ -275,7 +275,7 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi
super.onResume(); super.onResume();
// Refresh server settings // Refresh server settings
navigationSpinnerAdapter.updateServers(applicationSettings.getServerSettings()); navigationSpinnerAdapter.updateServers(applicationSettings.getAllServerSettings());
ServerSetting lastUsed = applicationSettings.getLastUsedServer(); ServerSetting lastUsed = applicationSettings.getLastUsedServer();
if (lastUsed == null) { if (lastUsed == null) {
// Still no settings // Still no settings

13
core/src/org/transdroid/core/gui/navigation/NavigationHelper.java

@ -141,7 +141,7 @@ public class NavigationHelper {
* @return True if search is enabled, false otherwise * @return True if search is enabled, false otherwise
*/ */
public boolean enableSearchUi() { public boolean enableSearchUi() {
return !context.getPackageName().equals("org.transdroid.lite"); return context.getResources().getBoolean(R.bool.search_available);
} }
/** /**
@ -150,7 +150,16 @@ public class NavigationHelper {
* @return True if search is enabled, false otherwise * @return True if search is enabled, false otherwise
*/ */
public boolean enableRssUi() { public boolean enableRssUi() {
return !context.getPackageName().equals("org.transdroid.lite"); return context.getResources().getBoolean(R.bool.rss_available);
}
/**
* Returns whether any seedbox-related components should be shown in the interface; specifically the option to add
* server settings via easy seedbox-specific screens.
* @return True if seedbox settings should be shown, false otherwise
*/
public boolean enableSeedboxes() {
return context.getResources().getBoolean(R.bool.seedboxes_available);
} }
/** /**

77
core/src/org/transdroid/core/gui/settings/MainSettingsActivity.java

@ -31,17 +31,27 @@ import org.transdroid.core.app.settings.ServerSetting;
import org.transdroid.core.app.settings.WebsearchSetting; import org.transdroid.core.app.settings.WebsearchSetting;
import org.transdroid.core.gui.*; import org.transdroid.core.gui.*;
import org.transdroid.core.gui.navigation.NavigationHelper; import org.transdroid.core.gui.navigation.NavigationHelper;
import org.transdroid.core.gui.settings.OverflowPreference.OnOverflowClicked;
import org.transdroid.core.gui.settings.RssfeedPreference.OnRssfeedClickedListener; import org.transdroid.core.gui.settings.RssfeedPreference.OnRssfeedClickedListener;
import org.transdroid.core.gui.settings.ServerPreference.OnServerClickedListener; import org.transdroid.core.gui.settings.ServerPreference.OnServerClickedListener;
import org.transdroid.core.gui.settings.WebsearchPreference.OnWebsearchClickedListener; import org.transdroid.core.gui.settings.WebsearchPreference.OnWebsearchClickedListener;
import org.transdroid.core.seedbox.SeedboxPreference;
import org.transdroid.core.seedbox.SeedboxPreference.OnSeedboxClickedListener;
import org.transdroid.core.seedbox.SeedboxProvider;
import android.annotation.TargetApi; import android.annotation.TargetApi;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.preference.ListPreference; import android.preference.ListPreference;
import android.preference.Preference; import android.preference.Preference;
import android.preference.Preference.OnPreferenceClickListener; import android.preference.Preference.OnPreferenceClickListener;
import android.view.View;
import com.actionbarsherlock.app.SherlockPreferenceActivity; import com.actionbarsherlock.app.SherlockPreferenceActivity;
@ -53,12 +63,15 @@ import com.actionbarsherlock.app.SherlockPreferenceActivity;
@EActivity @EActivity
public class MainSettingsActivity extends SherlockPreferenceActivity { public class MainSettingsActivity extends SherlockPreferenceActivity {
protected static final int DIALOG_ADDSEEDBOX = 0;
@Bean @Bean
protected NavigationHelper navigationHelper; protected NavigationHelper navigationHelper;
@Bean @Bean
protected ApplicationSettings applicationSettings; protected ApplicationSettings applicationSettings;
@Bean @Bean
protected SearchHelper searchHelper; protected SearchHelper searchHelper;
protected SharedPreferences prefs;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
@ -73,6 +86,7 @@ public class MainSettingsActivity extends SherlockPreferenceActivity {
getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayHomeAsUpEnabled(true);
prefs = getPreferenceManager().getSharedPreferences();
if (getPreferenceScreen() != null) if (getPreferenceScreen() != null)
getPreferenceScreen().removeAll(); getPreferenceScreen().removeAll();
@ -81,7 +95,12 @@ public class MainSettingsActivity extends SherlockPreferenceActivity {
// Load the preference menu and attach actions // Load the preference menu and attach actions
addPreferencesFromResource(R.xml.pref_main); addPreferencesFromResource(R.xml.pref_main);
findPreference("header_addserver").setOnPreferenceClickListener(onAddServer); OverflowPreference addServerPrefernce = (OverflowPreference) findPreference("header_addserver");
addServerPrefernce.setOnPreferenceClickListener(onAddServer);
if (navigationHelper.enableSeedboxes())
addServerPrefernce.setOnOverflowClickedListener(onOverflowClicked);
else
addServerPrefernce.hideOverflowButton();
if (enableSearchUi) if (enableSearchUi)
findPreference("header_addwebsearch").setOnPreferenceClickListener(onAddWebsearch); findPreference("header_addwebsearch").setOnPreferenceClickListener(onAddWebsearch);
if (enableRssUi) if (enableRssUi)
@ -90,12 +109,25 @@ public class MainSettingsActivity extends SherlockPreferenceActivity {
findPreference("header_system").setOnPreferenceClickListener(onSystemSettings); findPreference("header_system").setOnPreferenceClickListener(onSystemSettings);
// Add existing servers // Add existing servers
List<ServerSetting> servers = applicationSettings.getServerSettings(); List<ServerSetting> servers = applicationSettings.getNormalServerSettings();
for (ServerSetting serverSetting : servers) { for (ServerSetting serverSetting : servers) {
getPreferenceScreen().addPreference( getPreferenceScreen().addPreference(
new ServerPreference(this).setServerSetting(serverSetting).setOnServerClickedListener( new ServerPreference(this).setServerSetting(serverSetting).setOnServerClickedListener(
onServerClicked)); onServerClicked));
} }
// Add seedboxes; serversOffset keeps an int to have all ServerSettings with unique ids, seedboxOffset is unique
// only per seedbox type
int orderOffset = servers.size();
for (SeedboxProvider provider : SeedboxProvider.values()) {
int seedboxOffset = 0;
for (ServerSetting seedbox : provider.getSettings().getAllServerSettings(prefs, orderOffset)) {
getPreferenceScreen().addPreference(
new SeedboxPreference(this).setProvider(provider).setServerSetting(seedbox)
.setOnSeedboxClickedListener(onSeedboxClicked, seedboxOffset));
orderOffset++;
seedboxOffset++;
}
}
// Add existing RSS feeds // Add existing RSS feeds
if (!enableRssUi) { if (!enableRssUi) {
@ -166,6 +198,14 @@ public class MainSettingsActivity extends SherlockPreferenceActivity {
} }
}; };
private OnOverflowClicked onOverflowClicked = new OnOverflowClicked() {
@SuppressWarnings("deprecation")
@Override
public void onOverflowClicked(View overflowButton) {
showDialog(DIALOG_ADDSEEDBOX);
}
};
private OnPreferenceClickListener onAddWebsearch = new OnPreferenceClickListener() { private OnPreferenceClickListener onAddWebsearch = new OnPreferenceClickListener() {
@Override @Override
public boolean onPreferenceClick(Preference preference) { public boolean onPreferenceClick(Preference preference) {
@ -205,6 +245,16 @@ public class MainSettingsActivity extends SherlockPreferenceActivity {
} }
}; };
private OnSeedboxClickedListener onSeedboxClicked = new OnSeedboxClickedListener() {
@Override
public void onSeedboxClicked(ServerSetting serverSetting, SeedboxProvider provider, int seedboxOffset) {
// NOTE: The seedboxOffset is the seedbox type-unique order that we need to supply uin the Extras bundle to
// edit this specific seedbox
startActivity(provider.getSettings().getSettingsActivityIntent(MainSettingsActivity.this)
.putExtra("key", seedboxOffset));
}
};
private OnWebsearchClickedListener onWebsearchClicked = new OnWebsearchClickedListener() { private OnWebsearchClickedListener onWebsearchClicked = new OnWebsearchClickedListener() {
@Override @Override
public void onWebsearchClicked(WebsearchSetting websearchSetting) { public void onWebsearchClicked(WebsearchSetting websearchSetting) {
@ -219,4 +269,27 @@ public class MainSettingsActivity extends SherlockPreferenceActivity {
} }
}; };
protected Dialog onCreateDialog(int id) {
switch (id) {
case DIALOG_ADDSEEDBOX:
// Open dialog to pick one of the supported seedbox providers
String[] seedboxes = new String[SeedboxProvider.values().length];
for (int i = 0; i < seedboxes.length; i++) {
seedboxes[i] = getString(R.string.pref_seedbox_addseedbox, SeedboxProvider.values()[i].getSettings()
.getName());
}
return new AlertDialog.Builder(this).setItems(seedboxes, onAddSeedbox).create();
}
return null;
}
private OnClickListener onAddSeedbox = new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// Start the configuration activity for this specific chosen seedbox
startActivity(SeedboxProvider.values()[which].getSettings().getSettingsActivityIntent(
MainSettingsActivity.this));
}
};
} }

117
core/src/org/transdroid/core/gui/settings/OverflowPreference.java

@ -0,0 +1,117 @@
package org.transdroid.core.gui.settings;
import org.transdroid.core.R;
import android.content.Context;
import android.preference.Preference;
import android.util.AttributeSet;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.ImageButton;
/**
* A {@link Preference} item that shows an extra overflow button at the right side of the screen. The action attached to
* this button is set using {@link #setOnOverflowClickedListener(OnOverflowClicked)}. Normal clicks on this preference
* are handled in the standard way.
* @author Eric Kok
*/
public class OverflowPreference extends Preference {
private OnPreferenceClickListener onPreferenceClickListener = null;
private OnOverflowClicked onOverflowClickedListener = null;
private ImageButton overflowButton = null;
public OverflowPreference(Context context) {
super(context);
init();
}
public OverflowPreference(Context context, AttributeSet attrs) {
super(context, attrs);
init();
}
public OverflowPreference(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
init();
}
@Override
protected View onCreateView(ViewGroup parent) {
View layout = super.onCreateView(parent);
// Since the Preference layout is now created, we can attach the proper click listeners
layout.setClickable(true);
layout.setFocusable(true);
// When setting the background drawable the padding on this Preference layout disappears, so add it again
int bottom = layout.getPaddingBottom();
int top = layout.getPaddingTop();
int right = layout.getPaddingRight();
int left = layout.getPaddingLeft();
layout.setBackgroundResource(R.drawable.abs__item_background_holo_light);
layout.setPadding(left, top, right, bottom);
layout.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (onPreferenceClickListener != null)
onPreferenceClickListener.onPreferenceClick(OverflowPreference.this);
}
});
overflowButton = (ImageButton) layout.findViewById(R.id.overflow_button);
overflowButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (onOverflowClickedListener != null)
onOverflowClickedListener.onOverflowClicked(v);
}
});
return layout;
}
public void init() {
// Load an overflow-style image button as custom widget in the right of this Preference layout
setWidgetLayoutResource(R.layout.pref_withoverflow);
}
/**
* Hides the overflow button (on the right side of the Preference) from the UI.
*/
public void hideOverflowButton() {
if (overflowButton != null) {
overflowButton.setVisibility(View.GONE);
}
}
/**
* Shows (after hiding it) the overflow button (on the right side of the Preference) in the UI.
*/
public void showOverflowButton() {
if (overflowButton != null) {
overflowButton.setVisibility(View.VISIBLE);
}
}
@Override
public void setOnPreferenceClickListener(OnPreferenceClickListener onPreferenceClickListener) {
// Instead of the build-in list item click behaviour, we have to manually assign the click listener to this
// Preference item, as we stole the focus behaviour when we added a Button to the Preference layout
this.onPreferenceClickListener = onPreferenceClickListener;
}
/**
* Registers the listener for clicks on the overflow button contained in this preference.
* @param onOverflowClickedListener The overflow button click listener
*/
public void setOnOverflowClickedListener(OnOverflowClicked onOverflowClickedListener) {
this.onOverflowClickedListener = onOverflowClickedListener;
}
/**
* An interface to be implemented by any activity (or otherwise) that wants to handle events when the contained
* overflow button is clicked.
*/
public interface OnOverflowClicked {
public void onOverflowClicked(View overflowButton);
}
}

2
core/src/org/transdroid/core/gui/settings/ServerPreference.java

@ -29,7 +29,7 @@ public class ServerPreference extends Preference {
private static final int ORDER_START = 1; private static final int ORDER_START = 1;
private ServerSetting serverSetting; protected ServerSetting serverSetting;
private OnServerClickedListener onServerClickedListener = null; private OnServerClickedListener onServerClickedListener = null;
public ServerPreference(Context context) { public ServerPreference(Context context) {

4
core/src/org/transdroid/core/gui/settings/ServerSettingsActivity.java

@ -49,7 +49,7 @@ public class ServerSettingsActivity extends KeyBoundPreferencesActivity {
getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayHomeAsUpEnabled(true);
// Load the raw preferences to show in this screen // Load the raw preferences to show in this screen
init(R.xml.pref_server, ApplicationSettings_.getInstance_(this).getMaxServer()); init(R.xml.pref_server, ApplicationSettings_.getInstance_(this).getMaxOfAllServers());
initTextPreference("server_name"); initTextPreference("server_name");
initListPreference("server_type"); initListPreference("server_type");
initTextPreference("server_address"); initTextPreference("server_address");
@ -84,7 +84,7 @@ public class ServerSettingsActivity extends KeyBoundPreferencesActivity {
@OptionsItem(resName = "action_removesettings") @OptionsItem(resName = "action_removesettings")
protected void removeSettings() { protected void removeSettings() {
ApplicationSettings_.getInstance_(this).removeServerSettings(key); ApplicationSettings_.getInstance_(this).removeNormalServerSettings(key);
finish(); finish();
} }

10
core/src/org/transdroid/core/gui/settings/SystemSettingsActivity.java

@ -183,7 +183,10 @@ public class SystemSettingsActivity extends SherlockPreferenceActivity {
// @formatter:off // @formatter:off
return new AlertDialog.Builder(this) return new AlertDialog.Builder(this)
.setMessage( .setMessage(
getString(R.string.pref_import_dialog, getString(R.string.app_name), SettingsPersistence.DEFAULT_SETTINGS_FILE.toString())) getString(
R.string.pref_import_dialog,
getString(R.string.app_name),
SettingsPersistence.DEFAULT_SETTINGS_FILE.toString()))
.setPositiveButton(android.R.string.ok, importSettings) .setPositiveButton(android.R.string.ok, importSettings)
.setNegativeButton(android.R.string.cancel, null).create(); .setNegativeButton(android.R.string.cancel, null).create();
// @formatter:on // @formatter:on
@ -191,7 +194,10 @@ public class SystemSettingsActivity extends SherlockPreferenceActivity {
// @formatter:off // @formatter:off
return new AlertDialog.Builder(this) return new AlertDialog.Builder(this)
.setMessage( .setMessage(
getString(R.string.pref_export_dialog, getString(R.string.app_name), SettingsPersistence.DEFAULT_SETTINGS_FILE.toString())) getString(
R.string.pref_export_dialog,
getString(R.string.app_name),
SettingsPersistence.DEFAULT_SETTINGS_FILE.toString()))
.setPositiveButton(android.R.string.ok, exportSettings) .setPositiveButton(android.R.string.ok, exportSettings)
.setNegativeButton(android.R.string.cancel, null).create(); .setNegativeButton(android.R.string.cancel, null).create();
// @formatter:on // @formatter:on

98
core/src/org/transdroid/core/seedbox/SeedboxPreference.java

@ -0,0 +1,98 @@
/*
* 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 org.transdroid.core.app.settings.ServerSetting;
import org.transdroid.core.gui.settings.ServerPreference;
import android.content.Context;
import android.preference.Preference;
/**
* Represents a {@link ServerSetting} in a preferences screen, as constructed for a specific {@link SeedboxProvider}.
* @author Eric Kok
*/
public class SeedboxPreference extends ServerPreference {
private SeedboxProvider provider = null;
private OnSeedboxClickedListener onSeedboxClickedListener = null;
private int onSeedboxClickedListenerOffset = 0;
public SeedboxPreference(Context context) {
super(context);
setOnPreferenceClickListener(onSeedboxPreferenceClicked);
}
/**
* Set the seedbox provider that this server settings object is constructed for.
* @param provider The seedbox provider type
* @return Itself, for method chaining
*/
public SeedboxPreference setProvider(SeedboxProvider provider) {
this.provider = provider;
setSummary(provider.getSettings().getName());
return this;
}
/**
* Set the server settings object that is bound to this preference item. This seedbox=specific implementation does
* not show the human readable server connection string, but the seedbox provider name.
* @param serverSetting The server settings
* @return Itself, for method chaining
*/
public SeedboxPreference setServerSetting(ServerSetting serverSetting) {
super.setServerSetting(serverSetting);
if (this.provider != null)
setSummary(provider.getSettings().getName());
return this;
}
/**
* Returns the seedbox provider for which this server is constructed.
* @return The seedbox provider type of this server
*/
public SeedboxProvider getSeedboxProvider() {
return provider;
}
private OnPreferenceClickListener onSeedboxPreferenceClicked = new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
if (onSeedboxClickedListener != null)
onSeedboxClickedListener.onSeedboxClicked(serverSetting, provider, onSeedboxClickedListenerOffset);
return true;
}
};
/**
* Set a listener that will be notified of click events on this preference
* @param onSeedboxClickedListener The click listener to register
* @return Itself, for method chaining
*/
public ServerPreference setOnSeedboxClickedListener(OnSeedboxClickedListener onSeedboxClickedListener,
int seedboxOffset) {
this.onSeedboxClickedListener = onSeedboxClickedListener;
this.onSeedboxClickedListenerOffset = seedboxOffset;
return this;
}
public interface OnSeedboxClickedListener {
public void onSeedboxClicked(ServerSetting serverSetting, SeedboxProvider provider,
int onSeedboxClickedListenerOffset);
}
}

55
core/src/org/transdroid/core/seedbox/SeedboxProvider.java

@ -0,0 +1,55 @@
/*
* 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 org.transdroid.core.gui.settings.KeyBoundPreferencesActivity;
/**
* Enumeration of all available seedbox types. Every type needs a {@link SeedboxSettings} implementation to access and
* modify settings, which includes a {@link KeyBoundPreferencesActivity} to allow a user to configure the settings.
* @author Eric Kok
*/
public enum SeedboxProvider {
Seedstuff {
@Override
public SeedboxSettings getSettings() {
return new SeedstuffSettings();
}
},
XirvikShared {
@Override
public SeedboxSettings getSettings() {
return new XirvikSharedSettings();
}
},
XirvikSemi {
@Override
public SeedboxSettings getSettings() {
return new XirvikSemiSettings();
}
},
XirvikDedi {
@Override
public SeedboxSettings getSettings() {
return new XirvikDediSettings();
}
};
public abstract SeedboxSettings getSettings();
}

82
core/src/org/transdroid/core/seedbox/SeedboxSettings.java

@ -0,0 +1,82 @@
/*
* 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 java.util.List;
import org.transdroid.core.app.settings.ServerSetting;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
/**
* Interface to implement by any seedbox type (as appears in the {@link SeedboxProvider} enum) to access and modify
* seedbox settings for a certain seedbox provider.
* @author Eric Kok
*/
public interface SeedboxSettings {
/**
* Should return the name of the seedbox (and perhaps the seedbox type)
* @return A human-readable name of this seedbox provider
*/
public String getName();
/**
* Should return the order number of the last specified seedbox of this type (regardless of other seedbox types).
* @param prefs The shared preferences to load the settings from
* @return The order number (id) of the last configured seedbox, or -1 if none are configured.
*/
public int getMaxSeedboxOrder(SharedPreferences prefs);
/**
* Should return a {@link ServerSetting} object that can connect to the seedbox as identified by the given seedbox
* provider-unique order.
* @param prefs The shared preferences to load the settings from
* @param orderOffset An offset integer to add to the normal order number to assign a app-unique server id to this
* seedbox
* @param order The seedbox provider-specific order id referring to the specific seedbox to load settings for
* @return A server settings object corresponding to the user's seedbox settings for the specified order id
*/
public ServerSetting getServerSetting(SharedPreferences prefs, int orderOffset, int order);
/**
* Should return a list of all the {@link ServerSetting}s available for this seedbox type.
* @param prefs The shared preferences to load the settings from
* @param orderOffset An offset integer to add to the normal order number to assign a app-unique server id to this
* seedbox
* @return A list of all server settings objects that are stored for this seedbox type
*/
public List<ServerSetting> getAllServerSettings(SharedPreferences prefs, int orderOffset);
/**
* Should remove the settings of a specific seedbox specification as identified by its seedbox provider-unique order
* number.
* @param prefs The shared preferences to remove the settings from
* @param order The id referring to a specific seedbox order number within this type of seedbox
*/
public void removeServerSetting(SharedPreferences prefs, int order);
/**
* The settings activity in which the user can supply and edit its settings for this specific seedbox type.
* @param context The activity context from where the settings activity will be started
* @return An already prepared intent that points to the settings activity for this specific type of seedbox
*/
public Intent getSettingsActivityIntent(Context context);
}

95
core/src/org/transdroid/core/seedbox/SeedboxSettingsImpl.java

@ -0,0 +1,95 @@
/*
* 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 java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.transdroid.core.app.settings.ServerSetting;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
/**
* Abstract class that acts as a helper for actual {@link SeedboxSettings} implementations by implementing some
* functions (partially) to do away with boileplate code.
* @author Eric Kok
*/
public abstract class SeedboxSettingsImpl implements SeedboxSettings {
/**
* Helper method to look up the seedbox type-unique order number of the last configured seedbox.
* @param prefs The shared preferences object to remove settings from
* @param uniqueKeyBase The base of the key that is used as identifying (unique) key, for example
* 'seedbox_myseedbox_name_'
* @return The order number of the configured seedbox, or 01 if no seedbox is configured of this type
*/
public int getMaxSeedboxOrder(SharedPreferences prefs, String uniqueKeyBase) {
for (int i = 0; true; i++) {
if (prefs.getString(uniqueKeyBase + i, null) == null) {
return i - 1;
}
}
}
/**
* Helper method to remove some seedbox setting as identified by the order number.
* @param prefs The shared preferences object to remove settings from
* @param uniqueKeyBase The base of the key that is used as identifying (unique) key, for example
* 'seedbox_myseedbox_name_'
* @param removeKeyBases The keys of the stored preferences to remove, for example new String[] {
* 'seedbox_myseedbox_name_', 'seedbox_myseedbox_address_' }
* @param order The seedbox-unique order number (id) of the seedbox settings to remove
*/
public void removeServerSetting(SharedPreferences prefs, String uniqueKeyBase, String[] removeKeyBases, int order) {
if (prefs.getString(uniqueKeyBase + order, null) == null)
return;
Editor edit = prefs.edit();
int max = getMaxSeedboxOrder(prefs, uniqueKeyBase);
// Move all settings 'higher' than the one to be removed 'down' one place
for (int i = order; i < max; i++) {
for (String keyBase : removeKeyBases) {
edit.putString(keyBase + i, prefs.getString(keyBase + (i + 1), null));
}
}
// Remove the last seedbox settings, of which we are now sure are no longer required
for (String keyBase : removeKeyBases) {
edit.remove(keyBase + max);
}
edit.commit();
}
/**
* Helper method to provide server settings for every configured seedbox of this type.
* @param prefs The shared preferences object to remove settings from
* @param orderOffset The offset to use when assigning unique ids to the server settings object (added to the
* seedbox-unique internal order number)
*/
public List<ServerSetting> getAllServerSettings(SharedPreferences prefs, int orderOffset) {
List<ServerSetting> servers = new ArrayList<ServerSetting>();
for (int i = 0; true; i++) {
ServerSetting settings = getServerSetting(prefs, orderOffset, i);
if (settings != null)
servers.add(settings);
else
break;
}
return Collections.unmodifiableList(servers);
}
}

91
core/src/org/transdroid/core/seedbox/SeedstuffSettings.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 org.transdroid.core.app.settings.ServerSetting;
import org.transdroid.daemon.Daemon;
import org.transdroid.daemon.OS;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
/**
* 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,
null,
"/user/" + user,
true,
user,
pass,
null,
OS.Linux,
"/rtorrent/downloads",
"ftp://" + user + "@" + server + ":32001/rtorrent/downloads",
pass,
6,
true,
true,
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);
}
}

71
core/src/org/transdroid/core/seedbox/SeedstuffSettingsActivity.java

@ -0,0 +1,71 @@
/*
* 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 org.androidannotations.annotations.EActivity;
import org.androidannotations.annotations.OptionsItem;
import org.androidannotations.annotations.OptionsMenu;
import org.transdroid.core.R;
import org.transdroid.core.gui.settings.*;
import android.annotation.TargetApi;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Build;
import android.os.Bundle;
import android.preference.PreferenceManager;
/**
* 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 {
@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");
}
@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();
}
}

93
core/src/org/transdroid/core/seedbox/XirvikDediSettings.java

@ -0,0 +1,93 @@
/*
* 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 org.transdroid.core.app.settings.ServerSetting;
import org.transdroid.daemon.Daemon;
import org.transdroid.daemon.OS;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
/**
* Implementation of {@link SeedboxSettings} for the Xirvik dedicated seedbox.
* @author Eric Kok
*/
public class XirvikDediSettings extends SeedboxSettingsImpl implements SeedboxSettings {
@Override
public String getName() {
return "Xirvik dedicated";
}
@Override
public ServerSetting getServerSetting(SharedPreferences prefs, int orderOffset, int order) {
// @formatter:off
String server = prefs.getString("seedbox_xirvikdedi_server_" + order, null);
if (server == null) {
return null;
}
Daemon type = Daemon.fromCode(prefs.getString("seedbox_xirvikdedi_client_" + order, null));
String user = prefs.getString("seedbox_xirvikdedi_user_" + order, null);
String pass = prefs.getString("seedbox_xirvikdedi_pass_" + order, null);
return new ServerSetting(
orderOffset + order,
prefs.getString("seedbox_xirvikdedi_name_" + order, null),
type,
server,
null,
0,
null,
type == Daemon.uTorrent? 5010: 443,
type == Daemon.uTorrent? false: true,
type == Daemon.uTorrent? false: true,
null,
type == Daemon.Deluge? "/deluge": null,
true,
user,
pass,
type == Daemon.Deluge? "deluge": null,
OS.Linux,
type == Daemon.uTorrent? "/downloads": null,
"ftp://" + user + "@" + server + "/downloads",
pass,
6,
true,
true,
true);
// @formatter:on
}
@Override
public Intent getSettingsActivityIntent(Context context) {
return XirvikDediSettingsActivity_.intent(context).get();
}
@Override
public int getMaxSeedboxOrder(SharedPreferences prefs) {
return getMaxSeedboxOrder(prefs, "seedbox_xirvikdedi_server_");
}
@Override
public void removeServerSetting(SharedPreferences prefs, int order) {
removeServerSetting(prefs, "seedbox_xirvikdedi_server_", new String[] { "seedbox_xirvikdedi_name_",
"seedbox_xirvikdedi_server_", "seedbox_xirvikdedi_client_", "seedbox_xirvikdedi_user_",
"seedbox_xirvikdedi_pass_" }, order);
}
}

72
core/src/org/transdroid/core/seedbox/XirvikDediSettingsActivity.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 org.androidannotations.annotations.EActivity;
import org.androidannotations.annotations.OptionsItem;
import org.androidannotations.annotations.OptionsMenu;
import org.transdroid.core.R;
import org.transdroid.core.gui.settings.*;
import android.annotation.TargetApi;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Build;
import android.os.Bundle;
import android.preference.PreferenceManager;
/**
* Activity that allows for the configuration of a Xirvik dedicated 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 XirvikDediSettingsActivity 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_xirvikdedi,
SeedboxProvider.XirvikDedi.getSettings().getMaxSeedboxOrder(
PreferenceManager.getDefaultSharedPreferences(this)));
initTextPreference("seedbox_xirvikdedi_name");
initListPreference("seedbox_xirvikdedi_client");
initTextPreference("seedbox_xirvikdedi_server");
initTextPreference("seedbox_xirvikdedi_user");
initTextPreference("seedbox_xirvikdedi_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.XirvikDedi.getSettings().removeServerSetting(prefs, key);
finish();
}
}

91
core/src/org/transdroid/core/seedbox/XirvikSemiSettings.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 org.transdroid.core.app.settings.ServerSetting;
import org.transdroid.daemon.Daemon;
import org.transdroid.daemon.OS;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
/**
* Implementation of {@link SeedboxSettings} for a Xirvik semi-dedicated seedbox.
* @author Eric Kok
*/
public class XirvikSemiSettings extends SeedboxSettingsImpl implements SeedboxSettings {
@Override
public String getName() {
return "Xirvik semi-dedi";
}
@Override
public ServerSetting getServerSetting(SharedPreferences prefs, int orderOffset, int order) {
// @formatter:off
String server = prefs.getString("seedbox_xirviksemi_server_" + order, null);
if (server == null) {
return null;
}
String user = prefs.getString("seedbox_xirviksemi_user_" + order, null);
String pass = prefs.getString("seedbox_xirviksemi_pass_" + order, null);
return new ServerSetting(
orderOffset + order,
prefs.getString("seedbox_xirviksemi_name_" + order, null),
Daemon.rTorrent,
server,
null,
0,
null,
443,
true,
true,
null,
"/RPC2",
true,
user,
pass,
null,
OS.Linux,
null,
"ftp://" + user + "@" + server + "/downloads",
pass,
6,
true,
true,
true);
// @formatter:on
}
@Override
public Intent getSettingsActivityIntent(Context context) {
return XirvikSemiSettingsActivity_.intent(context).get();
}
@Override
public int getMaxSeedboxOrder(SharedPreferences prefs) {
return getMaxSeedboxOrder(prefs, "seedbox_xirviksemi_server_");
}
@Override
public void removeServerSetting(SharedPreferences prefs, int order) {
removeServerSetting(prefs, "seedbox_xirviksemi_server_", new String[] { "seedbox_xirviksemi_name_",
"seedbox_xirviksemi_server_", "seedbox_xirviksemi_user_", "seedbox_xirviksemi_pass_" }, order);
}
}

71
core/src/org/transdroid/core/seedbox/XirvikSemiSettingsActivity.java

@ -0,0 +1,71 @@
/*
* 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 org.androidannotations.annotations.EActivity;
import org.androidannotations.annotations.OptionsItem;
import org.androidannotations.annotations.OptionsMenu;
import org.transdroid.core.R;
import org.transdroid.core.gui.settings.*;
import android.annotation.TargetApi;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Build;
import android.os.Bundle;
import android.preference.PreferenceManager;
/**
* Activity that allows for the configuration of a Xirvik semi-dedicated 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 XirvikSemiSettingsActivity 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_xirviksemi,
SeedboxProvider.XirvikSemi.getSettings().getMaxSeedboxOrder(
PreferenceManager.getDefaultSharedPreferences(this)));
initTextPreference("seedbox_xirviksemi_name");
initTextPreference("seedbox_xirviksemi_server");
initTextPreference("seedbox_xirviksemi_user");
initTextPreference("seedbox_xirviksemi_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.XirvikSemi.getSettings().removeServerSetting(prefs, key);
finish();
}
}

91
core/src/org/transdroid/core/seedbox/XirvikSharedSettings.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 org.transdroid.core.app.settings.ServerSetting;
import org.transdroid.daemon.Daemon;
import org.transdroid.daemon.OS;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
/**
* Implementation of {@link SeedboxSettings} for a Xirvik shared seedbox.
* @author Eric Kok
*/
public class XirvikSharedSettings extends SeedboxSettingsImpl implements SeedboxSettings {
@Override
public String getName() {
return "Xirvik shared";
}
@Override
public ServerSetting getServerSetting(SharedPreferences prefs, int orderOffset, int order) {
// @formatter:off
String server = prefs.getString("seedbox_xirvikshared_server_" + order, null);
if (server == null) {
return null;
}
String user = prefs.getString("seedbox_xirvikshared_user_" + order, null);
String pass = prefs.getString("seedbox_xirvikshared_pass_" + order, null);
return new ServerSetting(
orderOffset + order,
prefs.getString("seedbox_xirvikshared_name_" + order, null),
Daemon.rTorrent,
server,
null,
0,
null,
443,
true,
true,
null,
"/RPC2",
true,
user,
pass,
null,
OS.Linux,
null,
"ftp://" + user + "@" + server + "/downloads",
pass,
6,
true,
true,
true);
// @formatter:on
}
@Override
public Intent getSettingsActivityIntent(Context context) {
return XirvikSharedSettingsActivity_.intent(context).get();
}
@Override
public int getMaxSeedboxOrder(SharedPreferences prefs) {
return getMaxSeedboxOrder(prefs, "seedbox_xirvikshared_server_");
}
@Override
public void removeServerSetting(SharedPreferences prefs, int order) {
removeServerSetting(prefs, "seedbox_xirvikshared_server_", new String[] { "seedbox_xirvikshared_name_",
"seedbox_xirvikshared_server_", "seedbox_xirvikshared_user_", "seedbox_xirvikshared_pass_" }, order);
}
}

71
core/src/org/transdroid/core/seedbox/XirvikSharedSettingsActivity.java

@ -0,0 +1,71 @@
/*
* 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 org.androidannotations.annotations.EActivity;
import org.androidannotations.annotations.OptionsItem;
import org.androidannotations.annotations.OptionsMenu;
import org.transdroid.core.R;
import org.transdroid.core.gui.settings.*;
import android.annotation.TargetApi;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Build;
import android.os.Bundle;
import android.preference.PreferenceManager;
/**
* Activity that allows for the configuration of a Xirvik shared 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 XirvikSharedSettingsActivity 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_xirvikshared,
SeedboxProvider.XirvikShared.getSettings().getMaxSeedboxOrder(
PreferenceManager.getDefaultSharedPreferences(this)));
initTextPreference("seedbox_xirvikshared_name");
initTextPreference("seedbox_xirvikshared_server");
initTextPreference("seedbox_xirvikshared_user");
initTextPreference("seedbox_xirvikshared_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.XirvikShared.getSettings().removeServerSetting(prefs, key);
finish();
}
}

4
core/src/org/transdroid/core/service/ControlService.java

@ -57,7 +57,7 @@ public class ControlService extends IntentService {
// See if the supplied server id is pointing to a valid server // See if the supplied server id is pointing to a valid server
int serverId = intent.getIntExtra(EXTRA_DAEMON, -1); int serverId = intent.getIntExtra(EXTRA_DAEMON, -1);
if (serverId < 0 || serverId > applicationSettings.getMaxServer()) { if (serverId < 0 || serverId > applicationSettings.getMaxOfAllServers()) {
// This server does not exist (any more) or no valid EXTRA_DAEMON value was supplied // This server does not exist (any more) or no valid EXTRA_DAEMON value was supplied
Log.e(this, "The control service can be started with a DAEMON extra zero-based server id, but the" Log.e(this, "The control service can be started with a DAEMON extra zero-based server id, but the"
+ "supplied id was invalid or no longer points to an existing server."); + "supplied id was invalid or no longer points to an existing server.");
@ -77,7 +77,7 @@ public class ControlService extends IntentService {
return; return;
} }
int serverId = config.getServerId(); int serverId = config.getServerId();
if (serverId < 0 || serverId > applicationSettings.getMaxServer()) { if (serverId < 0 || serverId > applicationSettings.getMaxOfAllServers()) {
Log.e(this, "The home screen widget points to a server that no longer exists."); Log.e(this, "The home screen widget points to a server that no longer exists.");
return; return;
} }

2
core/src/org/transdroid/core/service/ServerCheckerService.java

@ -75,7 +75,7 @@ public class ServerCheckerService extends IntentService {
} }
int notifyBase = 10000; int notifyBase = 10000;
for (ServerSetting server : applicationSettings.getServerSettings()) { for (ServerSetting server : applicationSettings.getAllServerSettings()) {
// No need to check if the server is not properly configured or none of the two types of notifications are // No need to check if the server is not properly configured or none of the two types of notifications are
// enabled by the user for this specific server // enabled by the user for this specific server

2
core/src/org/transdroid/core/widget/ListWidgetConfigActivity.java

@ -121,7 +121,7 @@ public class ListWidgetConfigActivity extends SherlockActivity {
sortOrders.add(new SortByListItem(this, order)); sortOrders.add(new SortByListItem(this, order));
} }
serverSpinner.setAdapter(new SimpleListItemSpinnerAdapter<ServerSetting>(this, 0, applicationSettings serverSpinner.setAdapter(new SimpleListItemSpinnerAdapter<ServerSetting>(this, 0, applicationSettings
.getServerSettings())); .getAllServerSettings()));
filterSpinner.setAdapter(new SimpleListItemSpinnerAdapter<StatusTypeFilter>(this, 0, StatusType filterSpinner.setAdapter(new SimpleListItemSpinnerAdapter<StatusTypeFilter>(this, 0, StatusType
.getAllStatusTypes(this))); .getAllStatusTypes(this)));
sortSpinner.setAdapter(new SimpleListItemSpinnerAdapter<SortByListItem>(this, 0, sortOrders)); sortSpinner.setAdapter(new SimpleListItemSpinnerAdapter<SortByListItem>(this, 0, sortOrders));

2
core/src/org/transdroid/core/widget/ListWidgetProvider.java

@ -110,7 +110,7 @@ public class ListWidgetProvider extends AppWidgetProvider {
if (context == null || config == null) if (context == null || config == null)
return null; return null;
ApplicationSettings appSettings = ApplicationSettings_.getInstance_(context); ApplicationSettings appSettings = ApplicationSettings_.getInstance_(context);
if (config.getServerId() < 0 || config.getServerId() > appSettings.getMaxServer()) { if (config.getServerId() < 0 || config.getServerId() > appSettings.getMaxOfAllServers()) {
Log.e(context, "Tried to set up widget " + appWidgetId + " but the bound server ID " + config.getServerId() Log.e(context, "Tried to set up widget " + appWidgetId + " but the bound server ID " + config.getServerId()
+ " no longer exists."); + " no longer exists.");
return null; return null;

6
full/AndroidManifest.xml

@ -192,6 +192,12 @@
<activity android:name="org.transdroid.core.gui.settings.SystemSettingsActivity_" /> <activity android:name="org.transdroid.core.gui.settings.SystemSettingsActivity_" />
<activity android:name="org.transdroid.core.gui.navigation.DialogHelper_" /> <activity android:name="org.transdroid.core.gui.navigation.DialogHelper_" />
<!-- Seedbox settings -->
<activity android:name="org.transdroid.core.seedbox.SeedstuffSettingsActivity_" />
<activity android:name="org.transdroid.core.seedbox.XirvikSharedSettingsActivity_" />
<activity android:name="org.transdroid.core.seedbox.XirvikSemiDediSettingsActivity_" />
<activity android:name="org.transdroid.core.seedbox.XirvikDediSettingsActivity_" />
<!-- Search --> <!-- Search -->
<activity <activity
android:name="org.transdroid.core.gui.search.SearchActivity_" android:name="org.transdroid.core.gui.search.SearchActivity_"

27
full/res/values/bools.xml

@ -0,0 +1,27 @@
<?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/>.
-->
<resources>
<!-- Used to enable the search UI -->
<bool name="search_available">true</bool>
<!-- Used to enable the RSS UI and background service -->
<bool name="rss_available">true</bool>
<!-- Used to allow adding of seedboxes via easy server setup -->
<bool name="seedboxes_available">true</bool>
</resources>

6
lite/AndroidManifest.xml

@ -183,6 +183,12 @@
<activity android:name="org.transdroid.core.gui.settings.SystemSettingsActivity_" /> <activity android:name="org.transdroid.core.gui.settings.SystemSettingsActivity_" />
<activity android:name="org.transdroid.core.gui.navigation.DialogHelper_" /> <activity android:name="org.transdroid.core.gui.navigation.DialogHelper_" />
<!-- Seedbox settings -->
<activity android:name="org.transdroid.core.seedbox.SeedstuffSettingsActivity_" />
<activity android:name="org.transdroid.core.seedbox.XirvikSharedSettingsActivity_" />
<activity android:name="org.transdroid.core.seedbox.XirvikSemiDediSettingsActivity_" />
<activity android:name="org.transdroid.core.seedbox.XirvikDediSettingsActivity_" />
<!-- Background service --> <!-- Background service -->
<service android:name="org.transdroid.core.service.ServerCheckerService_" /> <service android:name="org.transdroid.core.service.ServerCheckerService_" />
<service android:name="org.transdroid.core.service.AppUpdateService_" /> <service android:name="org.transdroid.core.service.AppUpdateService_" />

27
lite/res/values/bools.xml

@ -0,0 +1,27 @@
<?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/>.
-->
<resources>
<!-- Used to enable the search UI -->
<bool name="search_available">false</bool>
<!-- Used to enable the RSS UI and background service -->
<bool name="rss_available">false</bool>
<!-- Used to allow adding of seedboxes via easy server setup -->
<bool name="seedboxes_available">true</bool>
</resources>
Loading…
Cancel
Save