From 18ad364d457d8bcf7740fcb973b223795cd0df39 Mon Sep 17 00:00:00 2001 From: Eric Kok Date: Thu, 28 Nov 2013 10:46:08 +0100 Subject: [PATCH] Added support for adding Xirvik and Seedstuff seedboxes with super simple settings. --- core/res/drawable-hdpi/ic_action_overflow.png | Bin 0 -> 342 bytes core/res/drawable-mdpi/ic_action_overflow.png | Bin 0 -> 216 bytes .../res/drawable-xhdpi/ic_action_overflow.png | Bin 0 -> 355 bytes .../drawable-xxhdpi/ic_action_overflow.png | Bin 0 -> 617 bytes core/res/layout/pref_withoverflow.xml | 16 +++ core/res/values-sw500dp/bools.xml | 4 +- core/res/values-v11/bools.xml | 4 +- core/res/values/bools.xml | 10 +- core/res/values/strings.xml | 21 ++++ core/res/xml/pref_main.xml | 2 +- core/res/xml/pref_seedbox_seedstuff.xml | 39 ++++++ core/res/xml/pref_seedbox_xirvikdedi.xml | 45 +++++++ core/res/xml/pref_seedbox_xirviksemi.xml | 39 ++++++ core/res/xml/pref_seedbox_xirvikshared.xml | 39 ++++++ .../app/settings/ApplicationSettings.java | 76 +++++++++--- .../app/settings/SettingsPersistence.java | 2 +- .../transdroid/core/gui/TorrentsActivity.java | 6 +- .../core/gui/navigation/NavigationHelper.java | 13 +- .../gui/settings/MainSettingsActivity.java | 77 +++++++++++- .../core/gui/settings/OverflowPreference.java | 117 ++++++++++++++++++ .../core/gui/settings/ServerPreference.java | 2 +- .../gui/settings/ServerSettingsActivity.java | 4 +- .../gui/settings/SystemSettingsActivity.java | 10 +- .../core/seedbox/SeedboxPreference.java | 98 +++++++++++++++ .../core/seedbox/SeedboxProvider.java | 55 ++++++++ .../core/seedbox/SeedboxSettings.java | 82 ++++++++++++ .../core/seedbox/SeedboxSettingsImpl.java | 95 ++++++++++++++ .../core/seedbox/SeedstuffSettings.java | 91 ++++++++++++++ .../seedbox/SeedstuffSettingsActivity.java | 71 +++++++++++ .../core/seedbox/XirvikDediSettings.java | 93 ++++++++++++++ .../seedbox/XirvikDediSettingsActivity.java | 72 +++++++++++ .../core/seedbox/XirvikSemiSettings.java | 91 ++++++++++++++ .../seedbox/XirvikSemiSettingsActivity.java | 71 +++++++++++ .../core/seedbox/XirvikSharedSettings.java | 91 ++++++++++++++ .../seedbox/XirvikSharedSettingsActivity.java | 71 +++++++++++ .../core/service/ControlService.java | 4 +- .../core/service/ServerCheckerService.java | 2 +- .../core/widget/ListWidgetConfigActivity.java | 2 +- .../core/widget/ListWidgetProvider.java | 2 +- full/AndroidManifest.xml | 6 + full/res/values/bools.xml | 27 ++++ lite/AndroidManifest.xml | 6 + lite/res/values/bools.xml | 27 ++++ 43 files changed, 1547 insertions(+), 36 deletions(-) create mode 100755 core/res/drawable-hdpi/ic_action_overflow.png create mode 100755 core/res/drawable-mdpi/ic_action_overflow.png create mode 100755 core/res/drawable-xhdpi/ic_action_overflow.png create mode 100755 core/res/drawable-xxhdpi/ic_action_overflow.png create mode 100644 core/res/layout/pref_withoverflow.xml create mode 100644 core/res/xml/pref_seedbox_seedstuff.xml create mode 100644 core/res/xml/pref_seedbox_xirvikdedi.xml create mode 100644 core/res/xml/pref_seedbox_xirviksemi.xml create mode 100644 core/res/xml/pref_seedbox_xirvikshared.xml create mode 100644 core/src/org/transdroid/core/gui/settings/OverflowPreference.java create mode 100644 core/src/org/transdroid/core/seedbox/SeedboxPreference.java create mode 100644 core/src/org/transdroid/core/seedbox/SeedboxProvider.java create mode 100644 core/src/org/transdroid/core/seedbox/SeedboxSettings.java create mode 100644 core/src/org/transdroid/core/seedbox/SeedboxSettingsImpl.java create mode 100644 core/src/org/transdroid/core/seedbox/SeedstuffSettings.java create mode 100644 core/src/org/transdroid/core/seedbox/SeedstuffSettingsActivity.java create mode 100644 core/src/org/transdroid/core/seedbox/XirvikDediSettings.java create mode 100644 core/src/org/transdroid/core/seedbox/XirvikDediSettingsActivity.java create mode 100644 core/src/org/transdroid/core/seedbox/XirvikSemiSettings.java create mode 100644 core/src/org/transdroid/core/seedbox/XirvikSemiSettingsActivity.java create mode 100644 core/src/org/transdroid/core/seedbox/XirvikSharedSettings.java create mode 100644 core/src/org/transdroid/core/seedbox/XirvikSharedSettingsActivity.java create mode 100644 full/res/values/bools.xml create mode 100644 lite/res/values/bools.xml diff --git a/core/res/drawable-hdpi/ic_action_overflow.png b/core/res/drawable-hdpi/ic_action_overflow.png new file mode 100755 index 0000000000000000000000000000000000000000..a074c10d05c6d899bbbde731fb5473e24d6c3448 GIT binary patch literal 342 zcmV-c0jd6pP)~5+$zEa2WS0eCh2jzeq2r8fm1qBQrmjmA<%sFqcKQZLJq?FcS>0b>f4uHT8{bvTq z69_CtKn^ryKoM#&AR1!h8eL$2WC(f1EwpbTa$_mQfl}Z+eMG>c60?Tl0Itz3Ku-jO$pPaXP=pjAuL4Gd=GY$^J#M&050U<#XDLHm3Y@2p2zXRt)=(V4 zS7Hp%0|WR2GjJ?LibX*0fY%{8ps$2CD@L6n^sf=>gILdS{fT$r9!$>rI3+@*z**~AJSs73Y87gIG5Y}hDgXcg07*qoM6N<$f|uTcod5s; literal 0 HcmV?d00001 diff --git a/core/res/drawable-mdpi/ic_action_overflow.png b/core/res/drawable-mdpi/ic_action_overflow.png new file mode 100755 index 0000000000000000000000000000000000000000..b6d614fcaf9c09be7b183a030a3ebbbb10b3e1fa GIT binary patch literal 216 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=ffJ`JOJ0ArbD$DG~_>EDn4#?y*WR zVL8Fq`2YX^*G$3&{838#&YU>$qjgG)Zzr=DgD#ULlcWlRY(eD}MrAdYu1331m(RKU z2D~;4yg4Q$aoTN7dEUfW&agpd23tvs*(_(H#=wGJk>e9(nH<=ArZF#8JizFa};-(qhim7_wlrZ6wQ`Z2@OK*A|ui`6o(K!>ti57FC=Z9P^D3{@YZ6nEH#R|1{N N;OXk;vd$@?2>?H}N00yj literal 0 HcmV?d00001 diff --git a/core/res/drawable-xhdpi/ic_action_overflow.png b/core/res/drawable-xhdpi/ic_action_overflow.png new file mode 100755 index 0000000000000000000000000000000000000000..7be3c2a4f1d0b81421e8501a11ae24979859d7ff GIT binary patch literal 355 zcmeAS@N?(olHy`uVBq!ia0vp^4j|0I1|(Ny7T#lEVAS$-aSW-5dpm2R;2{GZ*T<8R z1+A>2)E1<%swJ=k(JLMYU(cfoA|-CZ1y&`~=Kj|ITE3*F{^T#uQz~_$AD_=xU|{Vq zcHr#bZcy{!3}AZ11H?=x>{+wcRx8)OR`?g^RcTeA=uyQf!I*yf$BPrcl34D@>=0mK za{BUjqXcUJ(-($W3d#QFD7zxy*T*G!!YoG o$L@>D;vyHCzfMd#rTu_AqjRZaLwZ;`Fz^^WUHx3vIVCg!0Pv)U0RR91 literal 0 HcmV?d00001 diff --git a/core/res/drawable-xxhdpi/ic_action_overflow.png b/core/res/drawable-xxhdpi/ic_action_overflow.png new file mode 100755 index 0000000000000000000000000000000000000000..a0cb8a4182ccd233621c13bdd0ff6f9b5e84821c GIT binary patch literal 617 zcmeAS@N?(olHy`uVBq!ia0vp^2_VeD1|%QND7Ro>U^4J@aSW-5dpl=iu9KsH%g!5u zJEIi~ncp>@2(>5_PTAtX$`{jJtaSW-_meXo)>fG&Rv$aQryZ$Y&^LN zhE29@8-w;eI~hh><<~4sYbt&huzcxRBh0bk(c8m<7mPRgDIDn9&hPGU{)AN{PKDt@ z8`f|Cd}sgC-NM&@nSZGU+rzX*r0F3C$D#e9$_$K&Ob@Hfz|^l)vjuvm_KU3E?in}# ztMM0;%4=0Qs*HC;6aQ+MJiIe)(vtYQ91abw4EGtu)>LUQm4r?6WQo}DY9Ysk$VfH8 zgoCTvl^oJjXSy`7u9oX!m^(F92(IwtR2Cc2#@llRjn~irW&O*l_(E-(Bx9by${Lm> zC;op`LUsqpIZ}*r*A^CT@+}O!*A~X@)^O~kSu2Bdl&%D$l=^KErksqe2`m|Na)LQF zEWFwzxB#e9@c>?hstxU>H(uBk7=#}=^hvOx!Jx6gR+mdKI;Vst0GjmhsQ>@~ literal 0 HcmV?d00001 diff --git a/core/res/layout/pref_withoverflow.xml b/core/res/layout/pref_withoverflow.xml new file mode 100644 index 00000000..867c44c8 --- /dev/null +++ b/core/res/layout/pref_withoverflow.xml @@ -0,0 +1,16 @@ + + + + + + \ No newline at end of file diff --git a/core/res/values-sw500dp/bools.xml b/core/res/values-sw500dp/bools.xml index 3a2b3761..22e6baef 100644 --- a/core/res/values-sw500dp/bools.xml +++ b/core/res/values-sw500dp/bools.xml @@ -16,6 +16,8 @@ along with Transdroid. If not, see . --> + false - + + \ No newline at end of file diff --git a/core/res/values-v11/bools.xml b/core/res/values-v11/bools.xml index 2ea1c4b9..5ba39a6b 100644 --- a/core/res/values-v11/bools.xml +++ b/core/res/values-v11/bools.xml @@ -16,6 +16,8 @@ along with Transdroid. If not, see . --> + true - + + \ No newline at end of file diff --git a/core/res/values/bools.xml b/core/res/values/bools.xml index a79e6d70..9629ade3 100644 --- a/core/res/values/bools.xml +++ b/core/res/values/bools.xml @@ -16,8 +16,16 @@ along with Transdroid. If not, see . --> + true false - + + true + + true + + true + + \ No newline at end of file diff --git a/core/res/values/strings.xml b/core/res/values/strings.xml index 71eb29ef..a718d164 100644 --- a/core/res/values/strings.xml +++ b/core/res/values/strings.xml @@ -210,6 +210,7 @@ Servers Add new server + Add seedbox Search sites Set default site Add web search site @@ -298,6 +299,26 @@ Available at transdroid.org/download Recent changes About %1$s + + Add %1$s seedbox + Torrent client + Client to connect to + Server address + Like dedi001.xirvik.com + Like semixl001a.xirvik.com + Like desharedgbit001.xirvik.com + Like 001.seedstuff.ca + + rTorrent + uTorrent + Deluge + + + daemon_rtorrent + daemon_utorrent + daemon_deluge + + BitComet Bitflu 1.2+ diff --git a/core/res/xml/pref_main.xml b/core/res/xml/pref_main.xml index f8a5df82..b28de47a 100644 --- a/core/res/xml/pref_main.xml +++ b/core/res/xml/pref_main.xml @@ -21,7 +21,7 @@ android:key="header_servers" android:title="@string/pref_servers" android:order="0"> - diff --git a/core/res/xml/pref_seedbox_seedstuff.xml b/core/res/xml/pref_seedbox_seedstuff.xml new file mode 100644 index 00000000..84c0e150 --- /dev/null +++ b/core/res/xml/pref_seedbox_seedstuff.xml @@ -0,0 +1,39 @@ + + + + + + + + + + diff --git a/core/res/xml/pref_seedbox_xirvikdedi.xml b/core/res/xml/pref_seedbox_xirvikdedi.xml new file mode 100644 index 00000000..eb70295d --- /dev/null +++ b/core/res/xml/pref_seedbox_xirvikdedi.xml @@ -0,0 +1,45 @@ + + + + + + + + + + + diff --git a/core/res/xml/pref_seedbox_xirviksemi.xml b/core/res/xml/pref_seedbox_xirviksemi.xml new file mode 100644 index 00000000..ec59651b --- /dev/null +++ b/core/res/xml/pref_seedbox_xirviksemi.xml @@ -0,0 +1,39 @@ + + + + + + + + + + diff --git a/core/res/xml/pref_seedbox_xirvikshared.xml b/core/res/xml/pref_seedbox_xirvikshared.xml new file mode 100644 index 00000000..ec59651b --- /dev/null +++ b/core/res/xml/pref_seedbox_xirvikshared.xml @@ -0,0 +1,39 @@ + + + + + + + + + + diff --git a/core/src/org/transdroid/core/app/settings/ApplicationSettings.java b/core/src/org/transdroid/core/app/settings/ApplicationSettings.java index 2a1239c2..0ce6eaa8 100644 --- a/core/src/org/transdroid/core/app/settings/ApplicationSettings.java +++ b/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.gui.navigation.StatusType; import org.transdroid.core.gui.search.SearchSetting; +import org.transdroid.core.seedbox.SeedboxProvider; import org.transdroid.core.widget.ListWidgetConfig; import org.transdroid.daemon.Daemon; 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 */ - public List getServerSettings() { + public List getAllServerSettings() { + List all = new ArrayList(); + 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 getNormalServerSettings() { List servers = new ArrayList(); - for (int i = 0; i <= getMaxServer(); i++) { - servers.add(getServerSetting(i)); + for (int i = 0; i <= getMaxNormalServer(); i++) { + servers.add(getNormalServerSetting(i)); } return Collections.unmodifiableList(servers); } /** - * Returns the order number/identifying key of the last server - * @return The zero-based order number (index) of the last stored server settings + * Returns the order number/identifying key of the last normal server + * @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++) { if (prefs.getString("server_type_" + i, null) == null) 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 - * settings actually exist and may rely on empty defaults if called not a non-existing server. - * @param order The order number/identifying key of the settings to retrieve + * Returns the user-specified server settings for a normal (non-seedbox) server. WARNING: This method does not check + * 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 normal server's settings to retrieve * @return The server settings object, loaded from shared preferences */ - public ServerSetting getServerSetting(int order) { + public ServerSetting getNormalServerSetting(int order) { // @formatter:off Daemon type = Daemon.fromCode(prefs.getString("server_type_" + order, null)); boolean ssl = prefs.getBoolean("server_sslenabled_" + order, false); @@ -132,13 +180,13 @@ public class ApplicationSettings { * servers will be updated accordingly. * @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) 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 Editor edit = prefs.edit(); - int max = getMaxServer(); + int max = getMaxNormalServer(); for (int i = order; i < max; i++) { edit.putString("server_name_" + i, prefs.getString("server_name_" + (i + 1), null)); edit.putString("server_type_" + i, prefs.getString("server_type_" + (i + 1), null)); @@ -197,7 +245,7 @@ public class ApplicationSettings { * servers exist */ 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) { // No servers configured return null; diff --git a/core/src/org/transdroid/core/app/settings/SettingsPersistence.java b/core/src/org/transdroid/core/app/settings/SettingsPersistence.java index 1c875293..a57b1f72 100644 --- a/core/src/org/transdroid/core/app/settings/SettingsPersistence.java +++ b/core/src/org/transdroid/core/app/settings/SettingsPersistence.java @@ -73,7 +73,7 @@ public class SettingsPersistence { JSONArray servers = json.getJSONArray("servers"); for (int i = 0; i < servers.length(); 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")) editor.putString("server_name_" + postfix, server.getString("name")); diff --git a/core/src/org/transdroid/core/gui/TorrentsActivity.java b/core/src/org/transdroid/core/gui/TorrentsActivity.java index 77ccdb8b..ff9ad8d3 100644 --- a/core/src/org/transdroid/core/gui/TorrentsActivity.java +++ b/core/src/org/transdroid/core/gui/TorrentsActivity.java @@ -194,7 +194,7 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi getSupportActionBar().setCustomView(serverStatusView); navigationSpinnerAdapter = FilterListDropDownAdapter_.getInstance_(this); // 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) if (filtersList != null) { @@ -231,7 +231,7 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi && getIntent().getExtras() == null && getIntent().hasExtra(ListWidgetProvider.EXTRA_SERVER)) { // A server settings order ID was provided in this org.transdroid.START_SERVER action intent 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 + " is not an existing server order id"); } else { @@ -275,7 +275,7 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi super.onResume(); // Refresh server settings - navigationSpinnerAdapter.updateServers(applicationSettings.getServerSettings()); + navigationSpinnerAdapter.updateServers(applicationSettings.getAllServerSettings()); ServerSetting lastUsed = applicationSettings.getLastUsedServer(); if (lastUsed == null) { // Still no settings diff --git a/core/src/org/transdroid/core/gui/navigation/NavigationHelper.java b/core/src/org/transdroid/core/gui/navigation/NavigationHelper.java index a36221bf..ec82c317 100644 --- a/core/src/org/transdroid/core/gui/navigation/NavigationHelper.java +++ b/core/src/org/transdroid/core/gui/navigation/NavigationHelper.java @@ -141,7 +141,7 @@ public class NavigationHelper { * @return True if search is enabled, false otherwise */ 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 */ 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); } /** diff --git a/core/src/org/transdroid/core/gui/settings/MainSettingsActivity.java b/core/src/org/transdroid/core/gui/settings/MainSettingsActivity.java index 7e4ad600..f5a4dfc5 100644 --- a/core/src/org/transdroid/core/gui/settings/MainSettingsActivity.java +++ b/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.gui.*; 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.ServerPreference.OnServerClickedListener; 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.app.AlertDialog; +import android.app.Dialog; +import android.content.DialogInterface; +import android.content.DialogInterface.OnClickListener; import android.content.Intent; +import android.content.SharedPreferences; import android.os.Build; import android.os.Bundle; import android.preference.ListPreference; import android.preference.Preference; import android.preference.Preference.OnPreferenceClickListener; +import android.view.View; import com.actionbarsherlock.app.SherlockPreferenceActivity; @@ -53,12 +63,15 @@ import com.actionbarsherlock.app.SherlockPreferenceActivity; @EActivity public class MainSettingsActivity extends SherlockPreferenceActivity { + protected static final int DIALOG_ADDSEEDBOX = 0; + @Bean protected NavigationHelper navigationHelper; @Bean protected ApplicationSettings applicationSettings; @Bean protected SearchHelper searchHelper; + protected SharedPreferences prefs; @Override protected void onCreate(Bundle savedInstanceState) { @@ -73,6 +86,7 @@ public class MainSettingsActivity extends SherlockPreferenceActivity { getSupportActionBar().setDisplayHomeAsUpEnabled(true); + prefs = getPreferenceManager().getSharedPreferences(); if (getPreferenceScreen() != null) getPreferenceScreen().removeAll(); @@ -81,7 +95,12 @@ public class MainSettingsActivity extends SherlockPreferenceActivity { // Load the preference menu and attach actions 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) findPreference("header_addwebsearch").setOnPreferenceClickListener(onAddWebsearch); if (enableRssUi) @@ -90,12 +109,25 @@ public class MainSettingsActivity extends SherlockPreferenceActivity { findPreference("header_system").setOnPreferenceClickListener(onSystemSettings); // Add existing servers - List servers = applicationSettings.getServerSettings(); + List servers = applicationSettings.getNormalServerSettings(); for (ServerSetting serverSetting : servers) { getPreferenceScreen().addPreference( new ServerPreference(this).setServerSetting(serverSetting).setOnServerClickedListener( 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 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() { @Override 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() { @Override 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)); + } + }; + } diff --git a/core/src/org/transdroid/core/gui/settings/OverflowPreference.java b/core/src/org/transdroid/core/gui/settings/OverflowPreference.java new file mode 100644 index 00000000..6e996672 --- /dev/null +++ b/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); + } + +} diff --git a/core/src/org/transdroid/core/gui/settings/ServerPreference.java b/core/src/org/transdroid/core/gui/settings/ServerPreference.java index fa109915..9f57dc78 100644 --- a/core/src/org/transdroid/core/gui/settings/ServerPreference.java +++ b/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 ServerSetting serverSetting; + protected ServerSetting serverSetting; private OnServerClickedListener onServerClickedListener = null; public ServerPreference(Context context) { diff --git a/core/src/org/transdroid/core/gui/settings/ServerSettingsActivity.java b/core/src/org/transdroid/core/gui/settings/ServerSettingsActivity.java index 4641464e..304c90fd 100644 --- a/core/src/org/transdroid/core/gui/settings/ServerSettingsActivity.java +++ b/core/src/org/transdroid/core/gui/settings/ServerSettingsActivity.java @@ -49,7 +49,7 @@ public class ServerSettingsActivity extends KeyBoundPreferencesActivity { getSupportActionBar().setDisplayHomeAsUpEnabled(true); // 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"); initListPreference("server_type"); initTextPreference("server_address"); @@ -84,7 +84,7 @@ public class ServerSettingsActivity extends KeyBoundPreferencesActivity { @OptionsItem(resName = "action_removesettings") protected void removeSettings() { - ApplicationSettings_.getInstance_(this).removeServerSettings(key); + ApplicationSettings_.getInstance_(this).removeNormalServerSettings(key); finish(); } diff --git a/core/src/org/transdroid/core/gui/settings/SystemSettingsActivity.java b/core/src/org/transdroid/core/gui/settings/SystemSettingsActivity.java index cae772ef..d77bcca9 100644 --- a/core/src/org/transdroid/core/gui/settings/SystemSettingsActivity.java +++ b/core/src/org/transdroid/core/gui/settings/SystemSettingsActivity.java @@ -183,7 +183,10 @@ public class SystemSettingsActivity extends SherlockPreferenceActivity { // @formatter:off return new AlertDialog.Builder(this) .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) .setNegativeButton(android.R.string.cancel, null).create(); // @formatter:on @@ -191,7 +194,10 @@ public class SystemSettingsActivity extends SherlockPreferenceActivity { // @formatter:off return new AlertDialog.Builder(this) .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) .setNegativeButton(android.R.string.cancel, null).create(); // @formatter:on diff --git a/core/src/org/transdroid/core/seedbox/SeedboxPreference.java b/core/src/org/transdroid/core/seedbox/SeedboxPreference.java new file mode 100644 index 00000000..038ec509 --- /dev/null +++ b/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 . + */ +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); + } + +} diff --git a/core/src/org/transdroid/core/seedbox/SeedboxProvider.java b/core/src/org/transdroid/core/seedbox/SeedboxProvider.java new file mode 100644 index 00000000..cd3fb83e --- /dev/null +++ b/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 . + */ +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(); + +} diff --git a/core/src/org/transdroid/core/seedbox/SeedboxSettings.java b/core/src/org/transdroid/core/seedbox/SeedboxSettings.java new file mode 100644 index 00000000..e943e03f --- /dev/null +++ b/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 . + */ +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 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); + +} diff --git a/core/src/org/transdroid/core/seedbox/SeedboxSettingsImpl.java b/core/src/org/transdroid/core/seedbox/SeedboxSettingsImpl.java new file mode 100644 index 00000000..3ddf8764 --- /dev/null +++ b/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 . + */ +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 getAllServerSettings(SharedPreferences prefs, int orderOffset) { + List servers = new ArrayList(); + for (int i = 0; true; i++) { + ServerSetting settings = getServerSetting(prefs, orderOffset, i); + if (settings != null) + servers.add(settings); + else + break; + } + return Collections.unmodifiableList(servers); + } + +} diff --git a/core/src/org/transdroid/core/seedbox/SeedstuffSettings.java b/core/src/org/transdroid/core/seedbox/SeedstuffSettings.java new file mode 100644 index 00000000..319b63a3 --- /dev/null +++ b/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 . + */ +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); + } + +} diff --git a/core/src/org/transdroid/core/seedbox/SeedstuffSettingsActivity.java b/core/src/org/transdroid/core/seedbox/SeedstuffSettingsActivity.java new file mode 100644 index 00000000..ba580bc0 --- /dev/null +++ b/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 . + */ +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(); + } + +} diff --git a/core/src/org/transdroid/core/seedbox/XirvikDediSettings.java b/core/src/org/transdroid/core/seedbox/XirvikDediSettings.java new file mode 100644 index 00000000..0f9787ee --- /dev/null +++ b/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 . + */ +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); + } + +} diff --git a/core/src/org/transdroid/core/seedbox/XirvikDediSettingsActivity.java b/core/src/org/transdroid/core/seedbox/XirvikDediSettingsActivity.java new file mode 100644 index 00000000..f8336ec0 --- /dev/null +++ b/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 . + */ +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(); + } + +} diff --git a/core/src/org/transdroid/core/seedbox/XirvikSemiSettings.java b/core/src/org/transdroid/core/seedbox/XirvikSemiSettings.java new file mode 100644 index 00000000..7de3d8e2 --- /dev/null +++ b/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 . + */ +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); + } + +} diff --git a/core/src/org/transdroid/core/seedbox/XirvikSemiSettingsActivity.java b/core/src/org/transdroid/core/seedbox/XirvikSemiSettingsActivity.java new file mode 100644 index 00000000..e8badbb9 --- /dev/null +++ b/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 . + */ +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(); + } + +} diff --git a/core/src/org/transdroid/core/seedbox/XirvikSharedSettings.java b/core/src/org/transdroid/core/seedbox/XirvikSharedSettings.java new file mode 100644 index 00000000..d172ee16 --- /dev/null +++ b/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 . + */ +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); + } + +} diff --git a/core/src/org/transdroid/core/seedbox/XirvikSharedSettingsActivity.java b/core/src/org/transdroid/core/seedbox/XirvikSharedSettingsActivity.java new file mode 100644 index 00000000..90affa9f --- /dev/null +++ b/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 . + */ +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(); + } + +} diff --git a/core/src/org/transdroid/core/service/ControlService.java b/core/src/org/transdroid/core/service/ControlService.java index 57c5376e..4a038dae 100644 --- a/core/src/org/transdroid/core/service/ControlService.java +++ b/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 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 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."); @@ -77,7 +77,7 @@ public class ControlService extends IntentService { return; } 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."); return; } diff --git a/core/src/org/transdroid/core/service/ServerCheckerService.java b/core/src/org/transdroid/core/service/ServerCheckerService.java index 0a35b48e..8e9b5746 100644 --- a/core/src/org/transdroid/core/service/ServerCheckerService.java +++ b/core/src/org/transdroid/core/service/ServerCheckerService.java @@ -75,7 +75,7 @@ public class ServerCheckerService extends IntentService { } 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 // enabled by the user for this specific server diff --git a/core/src/org/transdroid/core/widget/ListWidgetConfigActivity.java b/core/src/org/transdroid/core/widget/ListWidgetConfigActivity.java index 9015d1a1..bfd0f8a7 100644 --- a/core/src/org/transdroid/core/widget/ListWidgetConfigActivity.java +++ b/core/src/org/transdroid/core/widget/ListWidgetConfigActivity.java @@ -121,7 +121,7 @@ public class ListWidgetConfigActivity extends SherlockActivity { sortOrders.add(new SortByListItem(this, order)); } serverSpinner.setAdapter(new SimpleListItemSpinnerAdapter(this, 0, applicationSettings - .getServerSettings())); + .getAllServerSettings())); filterSpinner.setAdapter(new SimpleListItemSpinnerAdapter(this, 0, StatusType .getAllStatusTypes(this))); sortSpinner.setAdapter(new SimpleListItemSpinnerAdapter(this, 0, sortOrders)); diff --git a/core/src/org/transdroid/core/widget/ListWidgetProvider.java b/core/src/org/transdroid/core/widget/ListWidgetProvider.java index e3cd0242..89fd7d56 100644 --- a/core/src/org/transdroid/core/widget/ListWidgetProvider.java +++ b/core/src/org/transdroid/core/widget/ListWidgetProvider.java @@ -110,7 +110,7 @@ public class ListWidgetProvider extends AppWidgetProvider { if (context == null || config == null) return null; 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() + " no longer exists."); return null; diff --git a/full/AndroidManifest.xml b/full/AndroidManifest.xml index 26b62da5..63183c3c 100644 --- a/full/AndroidManifest.xml +++ b/full/AndroidManifest.xml @@ -192,6 +192,12 @@ + + + + + + + + + + + true + + true + + true + + \ No newline at end of file diff --git a/lite/AndroidManifest.xml b/lite/AndroidManifest.xml index a64f4e43..940e300c 100644 --- a/lite/AndroidManifest.xml +++ b/lite/AndroidManifest.xml @@ -183,6 +183,12 @@ + + + + + + diff --git a/lite/res/values/bools.xml b/lite/res/values/bools.xml new file mode 100644 index 00000000..df85c6ba --- /dev/null +++ b/lite/res/values/bools.xml @@ -0,0 +1,27 @@ + + + + + + false + + false + + true + + \ No newline at end of file