mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-14 14:20:30 +05:30
Add setting to toggle thumbnail loading.
This commit is contained in:
parent
184f46dd6b
commit
3a405f44a8
@ -107,6 +107,7 @@ object PreferenceKeys {
|
|||||||
* Notifications
|
* Notifications
|
||||||
*/
|
*/
|
||||||
const val NOTIFICATION_ENABLED = "notification_toggle"
|
const val NOTIFICATION_ENABLED = "notification_toggle"
|
||||||
|
const val SHOW_STREAM_THUMBNAILS = "show_stream_thumbnails"
|
||||||
const val CHECKING_FREQUENCY = "checking_frequency"
|
const val CHECKING_FREQUENCY = "checking_frequency"
|
||||||
const val REQUIRED_NETWORK = "required_network"
|
const val REQUIRED_NETWORK = "required_network"
|
||||||
const val IGNORED_NOTIFICATION_CHANNELS = "ignored_notification_channels"
|
const val IGNORED_NOTIFICATION_CHANNELS = "ignored_notification_channels"
|
||||||
|
@ -26,7 +26,6 @@ import com.github.libretube.helpers.ImageHelper
|
|||||||
import com.github.libretube.helpers.PreferenceHelper
|
import com.github.libretube.helpers.PreferenceHelper
|
||||||
import com.github.libretube.ui.activities.MainActivity
|
import com.github.libretube.ui.activities.MainActivity
|
||||||
import com.github.libretube.ui.views.TimePickerPreference
|
import com.github.libretube.ui.views.TimePickerPreference
|
||||||
import com.github.libretube.util.DataSaverMode
|
|
||||||
import java.time.LocalTime
|
import java.time.LocalTime
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.withContext
|
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
|
// The intent that will fire when the user taps the notification
|
||||||
.setContentIntent(pendingIntent)
|
.setContentIntent(pendingIntent)
|
||||||
|
|
||||||
// Load stream thumbnails if data saving mode is disabled.
|
// Load stream thumbnails if the relevant toggle is enabled.
|
||||||
if (!DataSaverMode.isEnabled(applicationContext)) {
|
if (PreferenceHelper.getBoolean(PreferenceKeys.SHOW_STREAM_THUMBNAILS, false)) {
|
||||||
val thumbnail = withContext(Dispatchers.IO) {
|
val thumbnail = withContext(Dispatchers.IO) {
|
||||||
ImageHelper.getImage(applicationContext, it.thumbnail).drawable?.toBitmap()
|
ImageHelper.getImage(applicationContext, it.thumbnail).drawable?.toBitmap()
|
||||||
}
|
}
|
||||||
|
10
app/src/main/res/drawable/ic_image.xml
Normal file
10
app/src/main/res/drawable/ic_image.xml
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:tint="?attr/colorControlNormal"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24">
|
||||||
|
<path
|
||||||
|
android:fillColor="@android:color/white"
|
||||||
|
android:pathData="M21,19V5c0,-1.1 -0.9,-2 -2,-2H5c-1.1,0 -2,0.9 -2,2v14c0,1.1 0.9,2 2,2h14c1.1,0 2,-0.9 2,-2zM8.5,13.5l2.5,3.01L14.5,12l4.5,6H5l3.5,-4.5z" />
|
||||||
|
</vector>
|
@ -268,6 +268,8 @@
|
|||||||
<string name="notifications">Notifications</string>
|
<string name="notifications">Notifications</string>
|
||||||
<string name="notify_new_streams">Notifications for new streams</string>
|
<string name="notify_new_streams">Notifications for new streams</string>
|
||||||
<string name="notify_new_streams_summary">Notifications about fresh content from creators you follow.</string>
|
<string name="notify_new_streams_summary">Notifications about fresh content from creators you follow.</string>
|
||||||
|
<string name="show_stream_thumbnails">Show stream thumbnails</string>
|
||||||
|
<string name="show_stream_thumbnails_summary">Show the thumbnails of new streams. Enabling this will consume additional data.</string>
|
||||||
<string name="checking_frequency">Checking every …</string>
|
<string name="checking_frequency">Checking every …</string>
|
||||||
<string name="new_streams_count">%1$s new streams available</string>
|
<string name="new_streams_count">%1$s new streams available</string>
|
||||||
<string name="new_streams_by">New streams by %1$s…</string>
|
<string name="new_streams_by">New streams by %1$s…</string>
|
||||||
|
@ -11,6 +11,13 @@
|
|||||||
app:key="notification_toggle"
|
app:key="notification_toggle"
|
||||||
app:title="@string/notify_new_streams" />
|
app:title="@string/notify_new_streams" />
|
||||||
|
|
||||||
|
<SwitchPreferenceCompat
|
||||||
|
android:icon="@drawable/ic_image"
|
||||||
|
app:defaultValue="false"
|
||||||
|
app:key="show_stream_thumbnails"
|
||||||
|
app:title="@string/show_stream_thumbnails"
|
||||||
|
app:summary="@string/show_stream_thumbnails_summary" />
|
||||||
|
|
||||||
<ListPreference
|
<ListPreference
|
||||||
android:icon="@drawable/ic_time"
|
android:icon="@drawable/ic_time"
|
||||||
app:defaultValue="60"
|
app:defaultValue="60"
|
||||||
|
Loading…
Reference in New Issue
Block a user