From ee318ef508820515f5ad773c66e182b8f2694370 Mon Sep 17 00:00:00 2001 From: Eric Kok Date: Mon, 27 Oct 2014 18:37:34 +0100 Subject: [PATCH] Added per-feed disabling of new RSS item checker. Fixes #136. --- .../core/app/settings/ApplicationSettings.java | 5 ++++- .../core/app/settings/RssfeedSetting.java | 8 +++++++- .../core/gui/settings/RssfeedSettingsActivity.java | 1 + .../transdroid/core/service/RssCheckerService.java | 5 +++++ app/src/main/res/values/strings.xml | 2 ++ app/src/main/res/xml/pref_rssfeed.xml | 14 ++++++++++---- 6 files changed, 29 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/org/transdroid/core/app/settings/ApplicationSettings.java b/app/src/main/java/org/transdroid/core/app/settings/ApplicationSettings.java index d174040a..3369b0ef 100644 --- a/app/src/main/java/org/transdroid/core/app/settings/ApplicationSettings.java +++ b/app/src/main/java/org/transdroid/core/app/settings/ApplicationSettings.java @@ -470,7 +470,8 @@ public class ApplicationSettings { return new RssfeedSetting(order, prefs.getString("rssfeed_name_" + 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), prefs.getString("rssfeed_lastvieweditemurl_" + order, null)); // @formatter:on @@ -492,6 +493,7 @@ public class ApplicationSettings { 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.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)); } @@ -499,6 +501,7 @@ public class ApplicationSettings { edit.remove("rssfeed_name_" + max); edit.remove("rssfeed_url_" + max); edit.remove("rssfeed_reqauth_" + max); + edit.remove("rssfeed_alarmnew_" + max); edit.remove("rssfeed_lastviewed_" + max); edit.commit(); diff --git a/app/src/main/java/org/transdroid/core/app/settings/RssfeedSetting.java b/app/src/main/java/org/transdroid/core/app/settings/RssfeedSetting.java index 4e61ebc7..82aa8fc8 100644 --- a/app/src/main/java/org/transdroid/core/app/settings/RssfeedSetting.java +++ b/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 url; private final boolean requiresAuth; + private final boolean alarm; private Date lastViewed; 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) { this.order = order; this.name = name; this.url = baseUrl; this.requiresAuth = needsAuth; + this.alarm = alarm; this.lastViewed = lastViewed; this.lastViewedItemUrl = lastViewedItemUrl; } @@ -71,6 +73,10 @@ public class RssfeedSetting implements SimpleListItem { 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 * settings were loaded from {@link ApplicationSettings}; instead the settings have to be manually loaded again diff --git a/app/src/main/java/org/transdroid/core/gui/settings/RssfeedSettingsActivity.java b/app/src/main/java/org/transdroid/core/gui/settings/RssfeedSettingsActivity.java index 22444793..59785028 100644 --- a/app/src/main/java/org/transdroid/core/gui/settings/RssfeedSettingsActivity.java +++ b/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()); initTextPreference("rssfeed_name"); initTextPreference("rssfeed_url"); + initBooleanPreference("rssfeed_alarmnew"); initBooleanPreference("rssfeed_reqauth"); // TODO: Replace this for cookies support like web searches diff --git a/app/src/main/java/org/transdroid/core/service/RssCheckerService.java b/app/src/main/java/org/transdroid/core/service/RssCheckerService.java index ec56b8b2..7517a3f9 100644 --- a/app/src/main/java/org/transdroid/core/service/RssCheckerService.java +++ b/app/src/main/java/org/transdroid/core/service/RssCheckerService.java @@ -75,6 +75,11 @@ public class RssCheckerService extends IntentService { for (RssfeedSetting feed : applicationSettings.getRssfeedSettings()) { 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() + ")"); RssParser parser = new RssParser(feed.getUrl()); parser.parse(); diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index a5f0b4b9..6da197eb 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -240,6 +240,8 @@ Feed URL Requires authentication Opens links in the webbrowser for user login + New item notification + Nofity when new torrents are released Server type IP or host name diff --git a/app/src/main/res/xml/pref_rssfeed.xml b/app/src/main/res/xml/pref_rssfeed.xml index c1d1f5c3..5e546cf8 100644 --- a/app/src/main/res/xml/pref_rssfeed.xml +++ b/app/src/main/res/xml/pref_rssfeed.xml @@ -16,22 +16,28 @@ along with Transdroid. If not, see . --> - + - + - + - + + +