From 3a405f44a8877b7708d43e01cae3c4d0745477cc Mon Sep 17 00:00:00 2001 From: Isira Seneviratne Date: Thu, 13 Apr 2023 17:10:51 +0530 Subject: [PATCH] Add setting to toggle thumbnail loading. --- .../com/github/libretube/constants/PreferenceKeys.kt | 1 + .../com/github/libretube/workers/NotificationWorker.kt | 5 ++--- app/src/main/res/drawable/ic_image.xml | 10 ++++++++++ app/src/main/res/values/strings.xml | 2 ++ app/src/main/res/xml/notification_settings.xml | 7 +++++++ 5 files changed, 22 insertions(+), 3 deletions(-) create mode 100644 app/src/main/res/drawable/ic_image.xml diff --git a/app/src/main/java/com/github/libretube/constants/PreferenceKeys.kt b/app/src/main/java/com/github/libretube/constants/PreferenceKeys.kt index d66223db0..42784bc21 100644 --- a/app/src/main/java/com/github/libretube/constants/PreferenceKeys.kt +++ b/app/src/main/java/com/github/libretube/constants/PreferenceKeys.kt @@ -107,6 +107,7 @@ object PreferenceKeys { * Notifications */ const val NOTIFICATION_ENABLED = "notification_toggle" + const val SHOW_STREAM_THUMBNAILS = "show_stream_thumbnails" const val CHECKING_FREQUENCY = "checking_frequency" const val REQUIRED_NETWORK = "required_network" const val IGNORED_NOTIFICATION_CHANNELS = "ignored_notification_channels" diff --git a/app/src/main/java/com/github/libretube/workers/NotificationWorker.kt b/app/src/main/java/com/github/libretube/workers/NotificationWorker.kt index 67fa32854..6714da900 100644 --- a/app/src/main/java/com/github/libretube/workers/NotificationWorker.kt +++ b/app/src/main/java/com/github/libretube/workers/NotificationWorker.kt @@ -26,7 +26,6 @@ import com.github.libretube.helpers.ImageHelper import com.github.libretube.helpers.PreferenceHelper import com.github.libretube.ui.activities.MainActivity import com.github.libretube.ui.views.TimePickerPreference -import com.github.libretube.util.DataSaverMode import java.time.LocalTime import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.withContext @@ -156,8 +155,8 @@ class NotificationWorker(appContext: Context, parameters: WorkerParameters) : // The intent that will fire when the user taps the notification .setContentIntent(pendingIntent) - // Load stream thumbnails if data saving mode is disabled. - if (!DataSaverMode.isEnabled(applicationContext)) { + // Load stream thumbnails if the relevant toggle is enabled. + if (PreferenceHelper.getBoolean(PreferenceKeys.SHOW_STREAM_THUMBNAILS, false)) { val thumbnail = withContext(Dispatchers.IO) { ImageHelper.getImage(applicationContext, it.thumbnail).drawable?.toBitmap() } diff --git a/app/src/main/res/drawable/ic_image.xml b/app/src/main/res/drawable/ic_image.xml new file mode 100644 index 000000000..306717a9f --- /dev/null +++ b/app/src/main/res/drawable/ic_image.xml @@ -0,0 +1,10 @@ + + + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 2676a266f..bf3424f36 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -268,6 +268,8 @@ Notifications Notifications for new streams Notifications about fresh content from creators you follow. + Show stream thumbnails + Show the thumbnails of new streams. Enabling this will consume additional data. Checking every … %1$s new streams available New streams by %1$s… diff --git a/app/src/main/res/xml/notification_settings.xml b/app/src/main/res/xml/notification_settings.xml index 02503fdf7..f555b2448 100644 --- a/app/src/main/res/xml/notification_settings.xml +++ b/app/src/main/res/xml/notification_settings.xml @@ -11,6 +11,13 @@ app:key="notification_toggle" app:title="@string/notify_new_streams" /> + +