Add preferences

This commit is contained in:
Nathan Mascitelli 2020-02-07 10:55:13 -05:00
parent 39e0d20ae7
commit 1eaecf8358
5 changed files with 18 additions and 4 deletions

View File

@ -35,6 +35,12 @@
android:key="prefShowDownloadReport"
android:summary="@string/pref_showDownloadReport_sum"
android:title="@string/pref_showDownloadReport_title"/>
<SwitchPreference
android:defaultValue="false"
android:enabled="true"
android:key="prefShowAutoDownloadReport"
android:summary="@string/pref_showAutoDownloadReport_sum"
android:title="@string/pref_showAutoDownloadReport_title"/>
<Preference
android:key="prefProxy"
android:summary="@string/pref_proxy_sum"

View File

@ -60,6 +60,7 @@ public class UserPreferences {
public static final String PREF_COMPACT_NOTIFICATION_BUTTONS = "prefCompactNotificationButtons";
public static final String PREF_LOCKSCREEN_BACKGROUND = "prefLockscreenBackground";
private static final String PREF_SHOW_DOWNLOAD_REPORT = "prefShowDownloadReport";
private static final String PREF_SHOW_AUTO_DOWNLOAD_REPORT = "prefShowAutoDownloadReport";
public static final String PREF_BACK_BUTTON_BEHAVIOR = "prefBackButtonBehavior";
private static final String PREF_BACK_BUTTON_GO_TO_PAGE = "prefBackButtonGoToPage";
@ -292,6 +293,10 @@ public class UserPreferences {
return prefs.getBoolean(PREF_SHOW_DOWNLOAD_REPORT, true);
}
public static boolean showAutoDownloadReport() {
return prefs.getBoolean(PREF_SHOW_AUTO_DOWNLOAD_REPORT, false);
}
public static boolean enqueueDownloadedEpisodes() {
return prefs.getBoolean(PREF_ENQUEUE_DOWNLOADED, true);
}

View File

@ -205,9 +205,10 @@ public class DownloadService extends Service {
Log.d(TAG, "Service shutting down");
isRunning = false;
boolean showAutoDownloadReport = UserPreferences.showAutoDownloadReport();
if (ClientConfig.downloadServiceCallbacks.shouldCreateReport()
&& UserPreferences.showDownloadReport()) {
notificationManager.updateReport(reportQueue);
&& (UserPreferences.showDownloadReport() || showAutoDownloadReport)) {
notificationManager.updateReport(reportQueue, showAutoDownloadReport);
reportQueue.clear();
}

View File

@ -96,7 +96,7 @@ public class DownloadServiceNotification {
* user about the number of completed downloads. A report will only be
* created if there is at least one failed download excluding images
*/
public void updateReport(List<DownloadStatus> reportQueue) {
public void updateReport(List<DownloadStatus> reportQueue, boolean showAutoDownloadReport) {
// check if report should be created
boolean createReport = false;
int successfulDownloads = 0;
@ -110,7 +110,7 @@ public class DownloadServiceNotification {
} else if (!status.isCancelled()) {
failedDownloads++;
}
if (failedDownloads > 0 || status.isGeneratedBySystem() && status.getFeedfileType() == FeedMedia.FEEDFILETYPE_FEEDMEDIA) {
if (failedDownloads > 0 || showAutoDownloadReport && status.isGeneratedBySystem() && status.getFeedfileType() == FeedMedia.FEEDFILETYPE_FEEDMEDIA) {
createReport = true;
}
}

View File

@ -470,6 +470,8 @@
<string name="pref_lockscreen_background_sum">Set the lockscreen background to the current episode\'s image. As a side effect, this will also show the image in third party apps.</string>
<string name="pref_showDownloadReport_title">Show Download Report</string>
<string name="pref_showDownloadReport_sum">If downloads fail, generate a report that shows the details of the failure.</string>
<string name="pref_showAutoDownloadReport_title">Show Auto Download Report</string>
<string name="pref_showAutoDownloadReport_sum">Generate a report that shows the details of auto downloaded episodes.</string>
<string name="pref_expand_notify_unsupport_toast">Android versions before 4.1 do not support expanded notifications.</string>
<string name="pref_enqueue_location_title">Enqueue Location</string>
<string name="pref_enqueue_location_sum">Add episodes to: %1$s</string>