fix: Resolve parcel serialization build warnings

This commit is contained in:
le-firehawk 2025-10-03 23:30:55 +09:30
parent 44679855cd
commit 17372fc4d0
26 changed files with 205 additions and 183 deletions

View file

@ -8,18 +8,18 @@ import androidx.room.PrimaryKey
import com.cappielloantonio.tempo.subsonic.models.Child
import com.cappielloantonio.tempo.util.Preferences
import kotlinx.parcelize.Parcelize
import java.util.*
import java.util.Date
@Keep
@Parcelize
@Entity(tableName = "chronology")
class Chronology(@PrimaryKey override val id: String) : Child(id) {
class Chronology(
@PrimaryKey override val id: String,
@ColumnInfo(name = "timestamp")
var timestamp: Long = System.currentTimeMillis()
var timestamp: Long = System.currentTimeMillis(),
@ColumnInfo(name = "server")
var server: String? = null
var server: String? = null,
) : Child(id) {
constructor(mediaItem: MediaItem) : this(mediaItem.mediaMetadata.extras!!.getString("id")!!) {
parentId = mediaItem.mediaMetadata.extras!!.getString("parentId")
isDir = mediaItem.mediaMetadata.extras!!.getBoolean("isDir")

View file

@ -10,19 +10,17 @@ import kotlinx.parcelize.Parcelize
@Keep
@Parcelize
@Entity(tableName = "download")
class Download(@PrimaryKey override val id: String) : Child(id) {
class Download(
@PrimaryKey override val id: String,
@ColumnInfo(name = "playlist_id")
var playlistId: String? = null
var playlistId: String? = null,
@ColumnInfo(name = "playlist_name")
var playlistName: String? = null
var playlistName: String? = null,
@ColumnInfo(name = "download_state", defaultValue = "1")
var downloadState: Int = 0
var downloadState: Int = 0,
@ColumnInfo(name = "download_uri", defaultValue = "")
var downloadUri: String? = null
var downloadUri: String? = null,
) : Child(id) {
constructor(child: Child) : this(child.id) {
parentId = child.parentId
isDir = child.isDir
@ -62,5 +60,5 @@ class Download(@PrimaryKey override val id: String) : Child(id) {
@Keep
data class DownloadStack(
var id: String,
var view: String?
var view: String?,
)

View file

@ -10,20 +10,18 @@ import kotlinx.parcelize.Parcelize
@Keep
@Parcelize
@Entity(tableName = "queue")
class Queue(override val id: String) : Child(id) {
class Queue(
override val id: String,
@PrimaryKey
@ColumnInfo(name = "track_order")
var trackOrder: Int = 0
var trackOrder: Int = 0,
@ColumnInfo(name = "last_play")
var lastPlay: Long = 0
var lastPlay: Long = 0,
@ColumnInfo(name = "playing_changed")
var playingChanged: Long = 0
var playingChanged: Long = 0,
@ColumnInfo(name = "stream_id")
var streamId: String? = null
var streamId: String? = null,
) : Child(id) {
constructor(child: Child) : this(child.id) {
parentId = child.parentId
isDir = child.isDir

View file

@ -4,38 +4,36 @@ import android.os.Parcelable
import androidx.annotation.Keep
import com.google.gson.annotations.SerializedName
import kotlinx.parcelize.Parcelize
import java.time.Instant
import java.time.LocalDate
import java.util.*
import java.util.Date
@Keep
@Parcelize
open class AlbumID3 : Parcelable {
var id: String? = null
var name: String? = null
var artist: String? = null
var artistId: String? = null
open class AlbumID3(
var id: String? = null,
var name: String? = null,
var artist: String? = null,
var artistId: String? = null,
@SerializedName("coverArt")
var coverArtId: String? = null
var songCount: Int? = 0
var duration: Int? = 0
var playCount: Long? = 0
var created: Date? = null
var starred: Date? = null
var year: Int = 0
var genre: String? = null
var played: Date? = Date(0)
var userRating: Int? = 0
var recordLabels: List<RecordLabel>? = null
var musicBrainzId: String? = null
var genres: List<ItemGenre>? = null
var artists: List<ArtistID3>? = null
var displayArtist: String? = null
var releaseTypes: List<String>? = null
var moods: List<String>? = null
var sortName: String? = null
var originalReleaseDate: ItemDate? = null
var releaseDate: ItemDate? = null
var isCompilation: Boolean? = null
var discTitles: List<DiscTitle>? = null
}
var coverArtId: String? = null,
var songCount: Int? = 0,
var duration: Int? = 0,
var playCount: Long? = 0,
var created: Date? = null,
var starred: Date? = null,
var year: Int = 0,
var genre: String? = null,
var played: Date? = Date(0),
var userRating: Int? = 0,
var recordLabels: List<RecordLabel>? = null,
var musicBrainzId: String? = null,
var genres: List<ItemGenre>? = null,
var artists: List<ArtistID3>? = null,
var displayArtist: String? = null,
var releaseTypes: List<String>? = null,
var moods: List<String>? = null,
var sortName: String? = null,
var originalReleaseDate: ItemDate? = null,
var releaseDate: ItemDate? = null,
var isCompilation: Boolean? = null,
var discTitles: List<DiscTitle>? = null,
) : Parcelable

View file

@ -7,7 +7,7 @@ import kotlinx.parcelize.Parcelize
@Keep
@Parcelize
class AlbumWithSongsID3 : AlbumID3(), Parcelable {
class AlbumWithSongsID3(
@SerializedName("song")
var songs: List<Child>? = null
}
var songs: List<Child>? = null,
) : AlbumID3(), Parcelable

View file

@ -7,10 +7,10 @@ import java.util.Date
@Keep
@Parcelize
class Artist : Parcelable {
var id: String? = null
var name: String? = null
var starred: Date? = null
var userRating: Int? = null
var averageRating: Double? = null
}
class Artist(
var id: String? = null,
var name: String? = null,
var starred: Date? = null,
var userRating: Int? = null,
var averageRating: Double? = null,
) : Parcelable

View file

@ -4,15 +4,15 @@ import android.os.Parcelable
import androidx.annotation.Keep
import com.google.gson.annotations.SerializedName
import kotlinx.parcelize.Parcelize
import java.util.*
import java.util.Date
@Keep
@Parcelize
open class ArtistID3 : Parcelable {
var id: String? = null
var name: String? = null
open class ArtistID3(
var id: String? = null,
var name: String? = null,
@SerializedName("coverArt")
var coverArtId: String? = null
var albumCount = 0
var starred: Date? = null
}
var coverArtId: String? = null,
var albumCount: Int = 0,
var starred: Date? = null,
) : Parcelable

View file

@ -7,7 +7,7 @@ import kotlinx.parcelize.Parcelize
@Keep
@Parcelize
class ArtistWithAlbumsID3 : ArtistID3(), Parcelable {
class ArtistWithAlbumsID3(
@SerializedName("album")
var albums: List<AlbumID3>? = null
}
var albums: List<AlbumID3>? = null,
) : ArtistID3(), Parcelable

View file

@ -8,15 +8,15 @@ import java.util.Date
@Keep
@Parcelize
class Directory : Parcelable {
class Directory(
@SerializedName("child")
var children: List<Child>? = null
var id: String? = null
var children: List<Child>? = null,
var id: String? = null,
@SerializedName("parent")
var parentId: String? = null
var name: String? = null
var starred: Date? = null
var userRating: Int? = null
var averageRating: Double? = null
var playCount: Long? = null
}
var parentId: String? = null,
var name: String? = null,
var starred: Date? = null,
var userRating: Int? = null,
var averageRating: Double? = null,
var playCount: Long? = null,
) : Parcelable

View file

@ -6,7 +6,7 @@ import kotlinx.parcelize.Parcelize
@Keep
@Parcelize
open class DiscTitle : Parcelable {
var disc: Int? = null
var title: String? = null
}
open class DiscTitle(
var disc: Int? = null,
var title: String? = null,
) : Parcelable

View file

@ -7,9 +7,9 @@ import kotlinx.parcelize.Parcelize
@Keep
@Parcelize
class Genre : Parcelable {
class Genre(
@SerializedName("value")
var genre: String? = null
var songCount = 0
var albumCount = 0
}
var genre: String? = null,
var songCount: Int = 0,
var albumCount: Int = 0,
) : Parcelable

View file

@ -6,9 +6,9 @@ import kotlinx.parcelize.Parcelize
@Keep
@Parcelize
class InternetRadioStation : Parcelable {
var id: String? = null
var name: String? = null
var streamUrl: String? = null
var homePageUrl: String? = null
}
class InternetRadioStation(
var id: String? = null,
var name: String? = null,
var streamUrl: String? = null,
var homePageUrl: String? = null,
) : Parcelable

View file

@ -9,11 +9,11 @@ import java.util.Locale
@Keep
@Parcelize
open class ItemDate : Parcelable {
var year: Int? = null
var month: Int? = null
var day: Int? = null
open class ItemDate(
var year: Int? = null,
var month: Int? = null,
var day: Int? = null,
) : Parcelable {
fun getFormattedDate(): String? {
if (year == null && month == null && day == null) return null
@ -22,8 +22,7 @@ open class ItemDate : Parcelable {
SimpleDateFormat("yyyy", Locale.getDefault())
} else if (day == null) {
SimpleDateFormat("MMMM yyyy", Locale.getDefault())
}
else{
} else {
SimpleDateFormat("MMMM dd, yyyy", Locale.getDefault())
}

View file

@ -6,6 +6,6 @@ import kotlinx.parcelize.Parcelize
@Keep
@Parcelize
open class ItemGenre : Parcelable {
var name: String? = null
}
open class ItemGenre(
var name: String? = null,
) : Parcelable

View file

@ -6,7 +6,7 @@ import kotlinx.parcelize.Parcelize
@Keep
@Parcelize
class MusicFolder : Parcelable {
var id: String? = null
var name: String? = null
}
class MusicFolder(
var id: String? = null,
var name: String? = null,
) : Parcelable

View file

@ -8,10 +8,9 @@ import kotlinx.parcelize.Parcelize
@Parcelize
class NowPlayingEntry(
@SerializedName("_id")
override val id: String
) : Child(id) {
var username: String? = null
var minutesAgo = 0
var playerId = 0
var playerName: String? = null
}
override val id: String,
var username: String? = null,
var minutesAgo: Int = 0,
var playerId: Int = 0,
var playerName: String? = null,
) : Child(id)

View file

@ -7,8 +7,9 @@ import androidx.room.Entity
import androidx.room.Ignore
import androidx.room.PrimaryKey
import com.google.gson.annotations.SerializedName
import kotlinx.parcelize.IgnoredOnParcel
import kotlinx.parcelize.Parcelize
import java.util.*
import java.util.Date
@Keep
@Parcelize
@ -16,27 +17,56 @@ import java.util.*
open class Playlist(
@PrimaryKey
@ColumnInfo(name = "id")
open var id: String
) : Parcelable {
open var id: String,
@ColumnInfo(name = "name")
var name: String? = null
var name: String? = null,
@ColumnInfo(name = "duration")
var duration: Long = 0,
@ColumnInfo(name = "coverArt")
var coverArtId: String? = null,
) : Parcelable {
@Ignore
@IgnoredOnParcel
var comment: String? = null
@Ignore
@IgnoredOnParcel
var owner: String? = null
@Ignore
@IgnoredOnParcel
@SerializedName("public")
var isUniversal: Boolean? = null
@Ignore
@IgnoredOnParcel
var songCount: Int = 0
@ColumnInfo(name = "duration")
var duration: Long = 0
@Ignore
@IgnoredOnParcel
var created: Date? = null
@Ignore
@IgnoredOnParcel
var changed: Date? = null
@ColumnInfo(name = "coverArt")
var coverArtId: String? = null
@Ignore
@IgnoredOnParcel
var allowedUsers: List<String>? = null
@Ignore
constructor(
id: String,
name: String?,
comment: String?,
owner: String?,
isUniversal: Boolean?,
songCount: Int,
duration: Long,
created: Date?,
changed: Date?,
coverArtId: String?,
allowedUsers: List<String>?,
) : this(id, name, duration, coverArtId) {
this.comment = comment
this.owner = owner
this.isUniversal = isUniversal
this.songCount = songCount
this.created = created
this.changed = changed
this.allowedUsers = allowedUsers
}
}

View file

@ -9,8 +9,7 @@ import kotlinx.parcelize.Parcelize
@Parcelize
class PlaylistWithSongs(
@SerializedName("_id")
override var id: String
) : Playlist(id), Parcelable {
override var id: String,
@SerializedName("entry")
var entries: List<Child>? = null
}
var entries: List<Child>? = null,
) : Playlist(id), Parcelable

View file

@ -6,5 +6,5 @@ import com.google.gson.annotations.SerializedName
@Keep
class Playlists(
@SerializedName("playlist")
var playlists: List<Playlist>? = null
var playlists: List<Playlist>? = null,
)

View file

@ -3,20 +3,21 @@ package com.cappielloantonio.tempo.subsonic.models
import android.os.Parcelable
import androidx.annotation.Keep
import com.google.gson.annotations.SerializedName
import kotlinx.parcelize.IgnoredOnParcel
import kotlinx.parcelize.Parcelize
@Keep
@Parcelize
class PodcastChannel : Parcelable {
class PodcastChannel(
@SerializedName("episode")
var episodes: List<PodcastEpisode>? = null
var id: String? = null
var url: String? = null
var title: String? = null
var description: String? = null
var episodes: List<PodcastEpisode>? = null,
var id: String? = null,
var url: String? = null,
var title: String? = null,
var description: String? = null,
@SerializedName("coverArt")
var coverArtId: String? = null
var originalImageUrl: String? = null
var status: String? = null
var errorMessage: String? = null
}
var coverArtId: String? = null,
var originalImageUrl: String? = null,
var status: String? = null,
var errorMessage: String? = null,
) : Parcelable

View file

@ -3,37 +3,38 @@ package com.cappielloantonio.tempo.subsonic.models
import android.os.Parcelable
import androidx.annotation.Keep
import com.google.gson.annotations.SerializedName
import kotlinx.parcelize.IgnoredOnParcel
import kotlinx.parcelize.Parcelize
import java.util.*
@Keep
@Parcelize
class PodcastEpisode : Parcelable {
var id: String? = null
class PodcastEpisode(
var id: String? = null,
@SerializedName("parent")
var parentId: String? = null
var isDir = false
var title: String? = null
var album: String? = null
var artist: String? = null
var year: Int? = null
var genre: String? = null
var parentId: String? = null,
var isDir: Boolean = false,
var title: String? = null,
var album: String? = null,
var artist: String? = null,
var year: Int? = null,
var genre: String? = null,
@SerializedName("coverArt")
var coverArtId: String? = null
var size: Long? = null
var contentType: String? = null
var suffix: String? = null
var duration: Int? = null
var coverArtId: String? = null,
var size: Long? = null,
var contentType: String? = null,
var suffix: String? = null,
var duration: Int? = null,
@SerializedName("bitRate")
var bitrate: Int? = null
var path: String? = null
var isVideo: Boolean = false
var created: Date? = null
var artistId: String? = null
var type: String? = null
var streamId: String? = null
var channelId: String? = null
var description: String? = null
var status: String? = null
var publishDate: Date? = null
}
var bitrate: Int? = null,
var path: String? = null,
var isVideo: Boolean = false,
var created: Date? = null,
var artistId: String? = null,
var type: String? = null,
var streamId: String? = null,
var channelId: String? = null,
var description: String? = null,
var status: String? = null,
var publishDate: Date? = null,
) : Parcelable

View file

@ -2,10 +2,11 @@ package com.cappielloantonio.tempo.subsonic.models
import android.os.Parcelable
import androidx.annotation.Keep
import kotlinx.parcelize.IgnoredOnParcel
import kotlinx.parcelize.Parcelize
@Keep
@Parcelize
open class RecordLabel : Parcelable {
var name: String? = null
}
open class RecordLabel(
var name: String? = null,
) : Parcelable

View file

@ -3,8 +3,9 @@ package com.cappielloantonio.tempo.subsonic.models
import android.os.Parcelable
import androidx.annotation.Keep
import com.google.gson.annotations.SerializedName
import kotlinx.parcelize.IgnoredOnParcel
import kotlinx.parcelize.Parcelize
import java.util.*
import java.util.Date
@Keep
@Parcelize

View file

@ -295,11 +295,6 @@ open class MediaLibrarySessionCallback(
args: Bundle
): ListenableFuture<SessionResult> {
val mediaItemId = args.getString(
MediaConstants.EXTRA_KEY_MEDIA_ID,
session.player.currentMediaItem?.mediaId
)
when (customCommand.customAction) {
CUSTOM_COMMAND_TOGGLE_SHUFFLE_MODE_ON -> {
session.player.shuffleModeEnabled = true
@ -398,4 +393,4 @@ open class MediaLibrarySessionCallback(
): ListenableFuture<LibraryResult<ImmutableList<MediaItem>>> {
return MediaBrowserTree.search(query)
}
}
}

View file

@ -147,6 +147,7 @@ class MediaService : MediaLibraryService(), SessionAvailabilityListener {
player.repeatMode = Preferences.getRepeatMode()
}
@Suppress("DEPRECATION")
private fun initializeCastPlayer() {
if (GoogleApiAvailability.getInstance()
.isGooglePlayServicesAvailable(this) == ConnectionResult.SUCCESS

View file

@ -9,6 +9,7 @@ import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.GoogleApiAvailability;
public class Flavors {
@SuppressWarnings("deprecation")
public static void initializeCastContext(Context context) {
if (GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(context) == ConnectionResult.SUCCESS)
CastContext.getSharedInstance(context, ContextCompat.getMainExecutor(context));