From 97e7272151fe40a6576af8d5b8d0315d05fac1ca Mon Sep 17 00:00:00 2001 From: Aayush Gupta Date: Thu, 6 Nov 2025 15:43:07 +0800 Subject: [PATCH] Removed badly hacked default playlist thumbnail icon The defaults should be supplied to the image loading software not the database library. This would also break when we shrink resources as that would rename the resources. Signed-off-by: Aayush Gupta --- .../playlist/dao/PlaylistStreamDAO.kt | 32 +++---------------- .../database/playlist/model/PlaylistEntity.kt | 4 --- .../local/dialog/PlaylistAppendDialog.java | 7 ++-- 3 files changed, 8 insertions(+), 35 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/database/playlist/dao/PlaylistStreamDAO.kt b/app/src/main/java/org/schabi/newpipe/database/playlist/dao/PlaylistStreamDAO.kt index 11ad38685..7edb15526 100644 --- a/app/src/main/java/org/schabi/newpipe/database/playlist/dao/PlaylistStreamDAO.kt +++ b/app/src/main/java/org/schabi/newpipe/database/playlist/dao/PlaylistStreamDAO.kt @@ -15,7 +15,6 @@ import org.schabi.newpipe.database.BasicDAO import org.schabi.newpipe.database.playlist.PlaylistDuplicatesEntry import org.schabi.newpipe.database.playlist.PlaylistMetadataEntry import org.schabi.newpipe.database.playlist.PlaylistStreamEntry -import org.schabi.newpipe.database.playlist.model.PlaylistEntity.Companion.DEFAULT_THUMBNAIL import org.schabi.newpipe.database.playlist.model.PlaylistEntity.Companion.DEFAULT_THUMBNAIL_ID import org.schabi.newpipe.database.playlist.model.PlaylistStreamEntity @@ -73,11 +72,7 @@ interface PlaylistStreamDAO : BasicDAO { @Query( """ SELECT uid, name, is_thumbnail_permanent, thumbnail_stream_id, display_index, - - CASE WHEN thumbnail_stream_id = $DEFAULT_THUMBNAIL_ID - THEN :defaultThumbnail - ELSE (SELECT thumbnail_url FROM streams WHERE streams.uid = thumbnail_stream_id) - END AS thumbnail_url, + (SELECT thumbnail_url FROM streams WHERE streams.uid = thumbnail_stream_id) AS thumbnail_url, COALESCE(COUNT(playlist_id), 0) AS streamCount FROM playlists @@ -88,12 +83,7 @@ interface PlaylistStreamDAO : BasicDAO { ORDER BY display_index """ ) - fun getPlaylistMetadata(defaultThumbnail: String): Flowable> - - // TODO: Remove on migrating classes to Kotlin - fun getPlaylistMetadata(): Flowable> { - return getPlaylistMetadata(DEFAULT_THUMBNAIL) - } + fun getPlaylistMetadata(): Flowable> @RewriteQueriesToDropUnusedColumns @Transaction @@ -118,11 +108,7 @@ interface PlaylistStreamDAO : BasicDAO { @Query( """ SELECT playlists.uid, name, is_thumbnail_permanent, thumbnail_stream_id, display_index, - - CASE WHEN thumbnail_stream_id = $DEFAULT_THUMBNAIL_ID - THEN :defaultThumbnail - ELSE (SELECT thumbnail_url FROM streams WHERE streams.uid = thumbnail_stream_id ) - END AS thumbnail_url, + (SELECT thumbnail_url FROM streams WHERE streams.uid = thumbnail_stream_id) AS thumbnail_url, COALESCE(COUNT(playlist_id), 0) AS streamCount, COALESCE(SUM(url = :streamUrl), 0) AS timesStreamIsContained FROM playlists @@ -137,15 +123,5 @@ interface PlaylistStreamDAO : BasicDAO { ORDER BY display_index, name """ ) - fun getPlaylistDuplicatesMetadata( - streamUrl: String, - defaultThumbnail: String - ): Flowable> - - // TODO: Remove on migrating classes to Kotlin - fun getPlaylistDuplicatesMetadata( - streamUrl: String - ): Flowable> { - return getPlaylistDuplicatesMetadata(streamUrl, DEFAULT_THUMBNAIL) - } + fun getPlaylistDuplicatesMetadata(streamUrl: String): Flowable> } diff --git a/app/src/main/java/org/schabi/newpipe/database/playlist/model/PlaylistEntity.kt b/app/src/main/java/org/schabi/newpipe/database/playlist/model/PlaylistEntity.kt index a72a1cee5..4ea4eb3a7 100644 --- a/app/src/main/java/org/schabi/newpipe/database/playlist/model/PlaylistEntity.kt +++ b/app/src/main/java/org/schabi/newpipe/database/playlist/model/PlaylistEntity.kt @@ -10,7 +10,6 @@ import androidx.room.ColumnInfo import androidx.room.Entity import androidx.room.Ignore import androidx.room.PrimaryKey -import org.schabi.newpipe.R import org.schabi.newpipe.database.playlist.PlaylistMetadataEntry @Entity(tableName = PlaylistEntity.Companion.PLAYLIST_TABLE) @@ -42,9 +41,6 @@ data class PlaylistEntity @JvmOverloads constructor( ) companion object { - @JvmField - val DEFAULT_THUMBNAIL = "drawable://" + R.drawable.placeholder_thumbnail_playlist - const val DEFAULT_THUMBNAIL_ID = -1L const val PLAYLIST_TABLE = "playlists" diff --git a/app/src/main/java/org/schabi/newpipe/local/dialog/PlaylistAppendDialog.java b/app/src/main/java/org/schabi/newpipe/local/dialog/PlaylistAppendDialog.java index 00b03513d..48d17d1d8 100644 --- a/app/src/main/java/org/schabi/newpipe/local/dialog/PlaylistAppendDialog.java +++ b/app/src/main/java/org/schabi/newpipe/local/dialog/PlaylistAppendDialog.java @@ -1,5 +1,7 @@ package org.schabi.newpipe.local.dialog; +import static org.schabi.newpipe.database.playlist.model.PlaylistEntity.DEFAULT_THUMBNAIL_ID; + import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; @@ -14,7 +16,6 @@ import androidx.recyclerview.widget.RecyclerView; import org.schabi.newpipe.NewPipeDatabase; import org.schabi.newpipe.R; -import org.schabi.newpipe.database.playlist.model.PlaylistEntity; import org.schabi.newpipe.database.playlist.PlaylistDuplicatesEntry; import org.schabi.newpipe.database.stream.model.StreamEntity; import org.schabi.newpipe.local.LocalItemListAdapter; @@ -160,8 +161,8 @@ public final class PlaylistAppendDialog extends PlaylistDialog { .subscribe(ignored -> { successToast.show(); - if (playlist.getThumbnailUrl() != null - && playlist.getThumbnailUrl().equals(PlaylistEntity.DEFAULT_THUMBNAIL) + if (playlist.getThumbnailStreamId() != null + && playlist.getThumbnailStreamId() == DEFAULT_THUMBNAIL_ID ) { playlistDisposables.add(manager .changePlaylistThumbnail(playlist.getUid(), streams.get(0).getUid(),