Browse Source

Added per-feed disabling of new RSS item checker. Fixes #136.

pull/177/head
Eric Kok 10 years ago
parent
commit
ee318ef508
  1. 5
      app/src/main/java/org/transdroid/core/app/settings/ApplicationSettings.java
  2. 8
      app/src/main/java/org/transdroid/core/app/settings/RssfeedSetting.java
  3. 1
      app/src/main/java/org/transdroid/core/gui/settings/RssfeedSettingsActivity.java
  4. 5
      app/src/main/java/org/transdroid/core/service/RssCheckerService.java
  5. 2
      app/src/main/res/values/strings.xml
  6. 14
      app/src/main/res/xml/pref_rssfeed.xml

5
app/src/main/java/org/transdroid/core/app/settings/ApplicationSettings.java

@ -470,7 +470,8 @@ public class ApplicationSettings {
return new RssfeedSetting(order, return new RssfeedSetting(order,
prefs.getString("rssfeed_name_" + order, null), prefs.getString("rssfeed_name_" + order, null),
prefs.getString("rssfeed_url_" + order, null), prefs.getString("rssfeed_url_" + order, null),
prefs.getBoolean("rssfeed_reqauth_" + order, false), prefs.getBoolean("rssfeed_reqauth_" + order, false),
prefs.getBoolean("rssfeed_alarmnew_" + order, true),
lastViewed == -1L ? null : new Date(lastViewed), lastViewed == -1L ? null : new Date(lastViewed),
prefs.getString("rssfeed_lastvieweditemurl_" + order, null)); prefs.getString("rssfeed_lastvieweditemurl_" + order, null));
// @formatter:on // @formatter:on
@ -492,6 +493,7 @@ public class ApplicationSettings {
edit.putString("rssfeed_name_" + i, prefs.getString("rssfeed_name_" + (i + 1), null)); edit.putString("rssfeed_name_" + i, prefs.getString("rssfeed_name_" + (i + 1), null));
edit.putString("rssfeed_url_" + i, prefs.getString("rssfeed_url_" + (i + 1), null)); edit.putString("rssfeed_url_" + i, prefs.getString("rssfeed_url_" + (i + 1), null));
edit.putBoolean("rssfeed_reqauth_" + i, prefs.getBoolean("rssfeed_reqauth_" + (i + 1), false)); edit.putBoolean("rssfeed_reqauth_" + i, prefs.getBoolean("rssfeed_reqauth_" + (i + 1), false));
edit.putBoolean("rssfeed_alarmnew_" + i, prefs.getBoolean("rssfeed_alarmnew_" + (i + 1), true));
edit.putLong("rssfeed_lastviewed_" + i, prefs.getLong("rssfeed_lastviewed_" + (i + 1), -1)); edit.putLong("rssfeed_lastviewed_" + i, prefs.getLong("rssfeed_lastviewed_" + (i + 1), -1));
} }
@ -499,6 +501,7 @@ public class ApplicationSettings {
edit.remove("rssfeed_name_" + max); edit.remove("rssfeed_name_" + max);
edit.remove("rssfeed_url_" + max); edit.remove("rssfeed_url_" + max);
edit.remove("rssfeed_reqauth_" + max); edit.remove("rssfeed_reqauth_" + max);
edit.remove("rssfeed_alarmnew_" + max);
edit.remove("rssfeed_lastviewed_" + max); edit.remove("rssfeed_lastviewed_" + max);
edit.commit(); edit.commit();

8
app/src/main/java/org/transdroid/core/app/settings/RssfeedSetting.java

@ -35,15 +35,17 @@ public class RssfeedSetting implements SimpleListItem {
private final String name; private final String name;
private final String url; private final String url;
private final boolean requiresAuth; private final boolean requiresAuth;
private final boolean alarm;
private Date lastViewed; private Date lastViewed;
private final String lastViewedItemUrl; private final String lastViewedItemUrl;
public RssfeedSetting(int order, String name, String baseUrl, boolean needsAuth, Date lastViewed, public RssfeedSetting(int order, String name, String baseUrl, boolean needsAuth, boolean alarm, Date lastViewed,
String lastViewedItemUrl) { String lastViewedItemUrl) {
this.order = order; this.order = order;
this.name = name; this.name = name;
this.url = baseUrl; this.url = baseUrl;
this.requiresAuth = needsAuth; this.requiresAuth = needsAuth;
this.alarm = alarm;
this.lastViewed = lastViewed; this.lastViewed = lastViewed;
this.lastViewedItemUrl = lastViewedItemUrl; this.lastViewedItemUrl = lastViewedItemUrl;
} }
@ -71,6 +73,10 @@ public class RssfeedSetting implements SimpleListItem {
return requiresAuth; return requiresAuth;
} }
public boolean shouldAlarmOnNewItems() {
return alarm;
}
/** /**
* Returns the date on which we last checked this feed. Note that this is NOT updated automatically after the * Returns the date on which we last checked this feed. Note that this is NOT updated automatically after the
* settings were loaded from {@link ApplicationSettings}; instead the settings have to be manually loaded again * settings were loaded from {@link ApplicationSettings}; instead the settings have to be manually loaded again

1
app/src/main/java/org/transdroid/core/gui/settings/RssfeedSettingsActivity.java

@ -52,6 +52,7 @@ public class RssfeedSettingsActivity extends KeyBoundPreferencesActivity {
init(R.xml.pref_rssfeed, ApplicationSettings_.getInstance_(this).getMaxRssfeed()); init(R.xml.pref_rssfeed, ApplicationSettings_.getInstance_(this).getMaxRssfeed());
initTextPreference("rssfeed_name"); initTextPreference("rssfeed_name");
initTextPreference("rssfeed_url"); initTextPreference("rssfeed_url");
initBooleanPreference("rssfeed_alarmnew");
initBooleanPreference("rssfeed_reqauth"); initBooleanPreference("rssfeed_reqauth");
// TODO: Replace this for cookies support like web searches // TODO: Replace this for cookies support like web searches

5
app/src/main/java/org/transdroid/core/service/RssCheckerService.java

@ -75,6 +75,11 @@ public class RssCheckerService extends IntentService {
for (RssfeedSetting feed : applicationSettings.getRssfeedSettings()) { for (RssfeedSetting feed : applicationSettings.getRssfeedSettings()) {
try { try {
if (!feed.shouldAlarmOnNewItems()) {
Log.d(this, "Skip checker for " + feed.getName() + " as alarms are disabled");
continue;
}
Log.d(this, "Try to parse " + feed.getName() + " (" + feed.getUrl() + ")"); Log.d(this, "Try to parse " + feed.getName() + " (" + feed.getUrl() + ")");
RssParser parser = new RssParser(feed.getUrl()); RssParser parser = new RssParser(feed.getUrl());
parser.parse(); parser.parse();

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

@ -240,6 +240,8 @@
<string name="pref_feedurl">Feed URL</string> <string name="pref_feedurl">Feed URL</string>
<string name="pref_reqauth">Requires authentication</string> <string name="pref_reqauth">Requires authentication</string>
<string name="pref_reqauth_info">Opens links in the webbrowser for user login</string> <string name="pref_reqauth_info">Opens links in the webbrowser for user login</string>
<string name="pref_alarmrssnew">New item notification</string>
<string name="pref_alarmrssnew_info">Nofity when new torrents are released</string>
<string name="pref_servertype">Server type</string> <string name="pref_servertype">Server type</string>
<string name="pref_address">IP or host name</string> <string name="pref_address">IP or host name</string>

14
app/src/main/res/xml/pref_rssfeed.xml

@ -16,22 +16,28 @@
along with Transdroid. If not, see <http://www.gnu.org/licenses/>. along with Transdroid. If not, see <http://www.gnu.org/licenses/>.
--> -->
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" > <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" >
<EditTextPreference <EditTextPreference
android:key="rssfeed_name" android:key="rssfeed_name"
android:title="@string/pref_name" android:title="@string/pref_name"
android:summary="@string/pref_name_optional" android:summary="@string/pref_name_optional"
android:inputType="textNoSuggestions" /> android:inputType="textNoSuggestions" />
<EditTextPreference <EditTextPreference
android:key="rssfeed_url" android:key="rssfeed_url"
android:title="@string/pref_feedurl" android:title="@string/pref_feedurl"
android:inputType="textUri" /> android:inputType="textUri" />
<CheckBoxPreference <CheckBoxPreference
android:key="rssfeed_reqauth" android:key="rssfeed_reqauth"
android:title="@string/pref_reqauth" android:title="@string/pref_reqauth"
android:summary="@string/pref_reqauth_info" android:summary="@string/pref_reqauth_info"
android:defaultValue="false" /> android:defaultValue="false" />
<CheckBoxPreference
android:key="rssfeed_alarmnew"
android:title="@string/pref_alarmrssnew"
android:summary="@string/pref_alarmrssnew_info"
android:defaultValue="true" />
</PreferenceScreen> </PreferenceScreen>

Loading…
Cancel
Save