From 1a89f35f2d83267fa519c304ad9f180ac7893e06 Mon Sep 17 00:00:00 2001 From: Eric Kok Date: Thu, 15 Oct 2020 09:21:07 +0200 Subject: [PATCH] Fixed merge conflict --- .../app/settings/ApplicationSettings.java | 76 +++--- .../core/widget/ListWidgetProvider.java | 5 +- .../main/res/layout/widget_torrents_dark.xml | 222 ++++++++++++++++++ 3 files changed, 263 insertions(+), 40 deletions(-) create mode 100644 app/src/main/res/layout/widget_torrents_dark.xml 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 7c0bc0a0..d4d9ffe4 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 @@ -734,44 +734,44 @@ public class ApplicationSettings { prefs.edit().putString(server.getUniqueIdentifier(), lastStats.toString()).apply(); } - /** - * Returns the user configuration for some specific app widget, if the widget is known at all. - * - * @param appWidgetId The unique ID of the app widget to retrieve settings for, as supplied by the AppWidgetManager - * @return A widget configuration object, or null if no settings were stored for the widget ID - */ - public ListWidgetConfig getWidgetConfig(int appWidgetId) { - if (!prefs.contains("widget_server_" + appWidgetId)) - return null; - // @formatter:off - return new ListWidgetConfig( - prefs.getInt("widget_server_" + appWidgetId, -1), - StatusType.valueOf(prefs.getString("widget_status_" + appWidgetId, StatusType.ShowAll.name())), - TorrentsSortBy.valueOf(prefs.getString("widget_sortby_" + appWidgetId, TorrentsSortBy.Alphanumeric.name())), - prefs.getBoolean("widget_reverse_" + appWidgetId, false), - prefs.getBoolean("widget_showstatus_" + appWidgetId, false)); - // @formatter:on - } - - /** - * Stores the user settings for some specific app widget. Existing settings for the supplied app widget ID will be - * overridden. - * - * @param appWidgetId The unique ID of the app widget to store settings for, as supplied by the AppWidgetManager - * @param settings A widget configuration object, which may not be null - */ - public void setWidgetConfig(int appWidgetId, ListWidgetConfig settings) { - if (settings == null) - throw new InvalidParameterException( - "The widget setting may not be null. Use removeWidgetConfig instead to remove existing settings for some app widget."); - Editor edit = prefs.edit(); - edit.putInt("widget_server_" + appWidgetId, settings.getServerId()); - edit.putString("widget_status_" + appWidgetId, settings.getStatusType().name()); - edit.putString("widget_sortby_" + appWidgetId, settings.getSortBy().name()); - edit.putBoolean("widget_reverse_" + appWidgetId, settings.shouldReserveSort()); - edit.putBoolean("widget_showstatus_" + appWidgetId, settings.shouldShowStatusView()); - edit.apply(); - } + /** + * Returns the user configuration for some specific app widget, if the widget is known at all. + * @param appWidgetId The unique ID of the app widget to retrieve settings for, as supplied by the AppWidgetManager + * @return A widget configuration object, or null if no settings were stored for the widget ID + */ + public ListWidgetConfig getWidgetConfig(int appWidgetId) { + if (!prefs.contains("widget_server_" + appWidgetId)) + return null; + // @formatter:off + return new ListWidgetConfig( + prefs.getInt("widget_server_" + appWidgetId, -1), + StatusType.valueOf(prefs.getString("widget_status_" + appWidgetId, StatusType.ShowAll.name())), + TorrentsSortBy.valueOf(prefs.getString("widget_sortby_" + appWidgetId, TorrentsSortBy.Alphanumeric.name())), + prefs.getBoolean("widget_reverse_" + appWidgetId, false), + prefs.getBoolean("widget_showstatus_" + appWidgetId, false), + prefs.getBoolean("widget_darktheme_" + appWidgetId, false)); + // @formatter:on + } + + /** + * Stores the user settings for some specific app widget. Existing settings for the supplied app widget ID will be + * overridden. + * @param appWidgetId The unique ID of the app widget to store settings for, as supplied by the AppWidgetManager + * @param settings A widget configuration object, which may not be null + */ + public void setWidgetConfig(int appWidgetId, ListWidgetConfig settings) { + if (settings == null) + throw new InvalidParameterException( + "The widget setting may not be null. Use removeWidgetConfig instead to remove existing settings for some app widget."); + Editor edit = prefs.edit(); + edit.putInt("widget_server_" + appWidgetId, settings.getServerId()); + edit.putString("widget_status_" + appWidgetId, settings.getStatusType().name()); + edit.putString("widget_sortby_" + appWidgetId, settings.getSortBy().name()); + edit.putBoolean("widget_reverse_" + appWidgetId, settings.shouldReserveSort()); + edit.putBoolean("widget_showstatus_" + appWidgetId, settings.shouldShowStatusView()); + edit.putBoolean("widget_darktheme_" + appWidgetId, settings.shouldUseDarkTheme()); + edit.apply(); + } /** * Remove the setting for some specific app widget. diff --git a/app/src/main/java/org/transdroid/core/widget/ListWidgetProvider.java b/app/src/main/java/org/transdroid/core/widget/ListWidgetProvider.java index d5b06100..7ef8a79d 100644 --- a/app/src/main/java/org/transdroid/core/widget/ListWidgetProvider.java +++ b/app/src/main/java/org/transdroid/core/widget/ListWidgetProvider.java @@ -80,8 +80,9 @@ public class ListWidgetProvider extends AppWidgetProvider { return null; } - // Load the dark or light widget layout xml - RemoteViews rv = new RemoteViews(context.getPackageName(), R.layout.widget_torrents); + // Load the dark or light widget layout xml + RemoteViews rv = new RemoteViews(context.getPackageName(), + config.shouldUseDarkTheme() ? R.layout.widget_torrents_dark : R.layout.widget_torrents); // Set up the widget's list view loading service which refers to the WidgetViewsFactory Intent data = new Intent(context, ListWidgetViewsService_.class); diff --git a/app/src/main/res/layout/widget_torrents_dark.xml b/app/src/main/res/layout/widget_torrents_dark.xml new file mode 100644 index 00000000..3cc5683a --- /dev/null +++ b/app/src/main/res/layout/widget_torrents_dark.xml @@ -0,0 +1,222 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +