add a pref for it

This commit is contained in:
Bnyro 2022-09-12 14:30:48 +02:00
parent c1120ab487
commit d5bddba863
5 changed files with 25 additions and 1 deletions

View File

@ -234,11 +234,16 @@ class MainActivity : BaseActivity() {
* Initialize the notification badge showing the amount of new videos
*/
private fun setupSubscriptionsBadge() {
if (!PreferenceHelper.getBoolean(
PreferenceKeys.NEW_VIDEOS_BADGE,
false
)) return
val subscriptionsViewModel = ViewModelProvider(this)[SubscriptionsViewModel::class.java]
subscriptionsViewModel.fetchSubscriptions()
val lastSeenVideoId = PreferenceHelper.getLastSeenVideoId()
subscriptionsViewModel.videoFeed.observe(this) {
val lastSeenVideoId = PreferenceHelper.getLastSeenVideoId()
val lastSeenVideoIndex = subscriptionsViewModel.videoFeed.value?.indexOfFirst {
lastSeenVideoId == it.url?.toID()
} ?: return@observe

View File

@ -34,6 +34,7 @@ object PreferenceKeys {
const val LEGACY_SUBSCRIPTIONS = "legacy_subscriptions"
const val LEGACY_SUBSCRIPTIONS_COLUMNS = "legacy_subscriptions_columns"
const val ALTERNATIVE_TRENDING_LAYOUT = "trending_layout"
const val NEW_VIDEOS_BADGE = "new_videos_badge"
/**
* Instance

View 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>

View File

@ -319,4 +319,6 @@
<string name="renamePlaylist">Rename playlist</string>
<string name="wifi">WiFi</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>

View File

@ -24,6 +24,12 @@
app:key="reset_settings"
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 app:title="@string/backup_restore">