mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-01-06 17:40:30 +05:30
add a pref for it
This commit is contained in:
parent
c1120ab487
commit
d5bddba863
@ -234,11 +234,16 @@ class MainActivity : BaseActivity() {
|
|||||||
* Initialize the notification badge showing the amount of new videos
|
* Initialize the notification badge showing the amount of new videos
|
||||||
*/
|
*/
|
||||||
private fun setupSubscriptionsBadge() {
|
private fun setupSubscriptionsBadge() {
|
||||||
|
if (!PreferenceHelper.getBoolean(
|
||||||
|
PreferenceKeys.NEW_VIDEOS_BADGE,
|
||||||
|
false
|
||||||
|
)) return
|
||||||
|
|
||||||
val subscriptionsViewModel = ViewModelProvider(this)[SubscriptionsViewModel::class.java]
|
val subscriptionsViewModel = ViewModelProvider(this)[SubscriptionsViewModel::class.java]
|
||||||
subscriptionsViewModel.fetchSubscriptions()
|
subscriptionsViewModel.fetchSubscriptions()
|
||||||
|
|
||||||
val lastSeenVideoId = PreferenceHelper.getLastSeenVideoId()
|
|
||||||
subscriptionsViewModel.videoFeed.observe(this) {
|
subscriptionsViewModel.videoFeed.observe(this) {
|
||||||
|
val lastSeenVideoId = PreferenceHelper.getLastSeenVideoId()
|
||||||
val lastSeenVideoIndex = subscriptionsViewModel.videoFeed.value?.indexOfFirst {
|
val lastSeenVideoIndex = subscriptionsViewModel.videoFeed.value?.indexOfFirst {
|
||||||
lastSeenVideoId == it.url?.toID()
|
lastSeenVideoId == it.url?.toID()
|
||||||
} ?: return@observe
|
} ?: return@observe
|
||||||
|
@ -34,6 +34,7 @@ object PreferenceKeys {
|
|||||||
const val LEGACY_SUBSCRIPTIONS = "legacy_subscriptions"
|
const val LEGACY_SUBSCRIPTIONS = "legacy_subscriptions"
|
||||||
const val LEGACY_SUBSCRIPTIONS_COLUMNS = "legacy_subscriptions_columns"
|
const val LEGACY_SUBSCRIPTIONS_COLUMNS = "legacy_subscriptions_columns"
|
||||||
const val ALTERNATIVE_TRENDING_LAYOUT = "trending_layout"
|
const val ALTERNATIVE_TRENDING_LAYOUT = "trending_layout"
|
||||||
|
const val NEW_VIDEOS_BADGE = "new_videos_badge"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instance
|
* Instance
|
||||||
|
10
app/src/main/res/drawable/ic_badge.xml
Normal file
10
app/src/main/res/drawable/ic_badge.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="48"
|
||||||
|
android:viewportHeight="48">
|
||||||
|
<path
|
||||||
|
android:fillColor="#FF000000"
|
||||||
|
android:pathData="m17.3,45 l-3.8,-6.5 -7.55,-1.55 0.85,-7.35L2,24l4.8,-5.55 -0.85,-7.35 7.55,-1.55L17.3,3 24,6.1 30.7,3l3.85,6.55 7.5,1.55 -0.85,7.35L46,24l-4.8,5.6 0.85,7.35 -7.5,1.55L30.7,45 24,41.9ZM21.85,30.65L33.2,19.4l-2.25,-2.05 -9.1,9 -4.75,-4.95 -2.3,2.25Z" />
|
||||||
|
</vector>
|
@ -319,4 +319,6 @@
|
|||||||
<string name="renamePlaylist">Rename playlist</string>
|
<string name="renamePlaylist">Rename playlist</string>
|
||||||
<string name="wifi">WiFi</string>
|
<string name="wifi">WiFi</string>
|
||||||
<string name="mobile_data">Mobile data</string>
|
<string name="mobile_data">Mobile data</string>
|
||||||
|
<string name="new_videos_badge">Indicator for new videos</string>
|
||||||
|
<string name="new_videos_badge_summary">Show a badge with the amount of new videos</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -24,6 +24,12 @@
|
|||||||
app:key="reset_settings"
|
app:key="reset_settings"
|
||||||
app:title="@string/reset" />
|
app:title="@string/reset" />
|
||||||
|
|
||||||
|
<SwitchPreferenceCompat
|
||||||
|
android:icon="@drawable/ic_badge"
|
||||||
|
android:summary="@string/new_videos_badge_summary"
|
||||||
|
app:key="new_videos_badge"
|
||||||
|
app:title="@string/new_videos_badge" />
|
||||||
|
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
|
|
||||||
<PreferenceCategory app:title="@string/backup_restore">
|
<PreferenceCategory app:title="@string/backup_restore">
|
||||||
|
Loading…
Reference in New Issue
Block a user