diff --git a/app/build.gradle b/app/build.gradle index ddaff49e..da323179 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,5 +1,6 @@ apply plugin: 'com.android.application' apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' android { compileSdkVersion 33 @@ -58,7 +59,7 @@ dependencies { implementation 'com.google.android.gms:play-services-cast-framework:21.2.0' // Android Material - implementation 'com.google.android.material:material:1.9.0-alpha01' + implementation 'com.google.android.material:material:1.9.0-alpha02' // SearchBar implementation 'com.paulrybitskyi.persistentsearchview:persistentsearchview:1.1.4' diff --git a/app/src/main/java/com/cappielloantonio/play/adapter/ArtistAdapter.java b/app/src/main/java/com/cappielloantonio/play/adapter/ArtistAdapter.java index 8ed2f4dc..0dfbe932 100644 --- a/app/src/main/java/com/cappielloantonio/play/adapter/ArtistAdapter.java +++ b/app/src/main/java/com/cappielloantonio/play/adapter/ArtistAdapter.java @@ -90,20 +90,11 @@ public class ArtistAdapter extends RecyclerView.Adapter livedata = artistRepository.getArtistFullInfo(artist.getId()); - livedata.observeForever(new Observer() { - @Override - public void onChanged(Artist artist) { - CustomGlideRequest.Builder - .from(context, artist.getId(), CustomGlideRequest.ARTIST_PIC, artist.getImageUrl()) - .build() - .transform(new CenterCrop(), new RoundedCorners(CustomGlideRequest.CORNER_RADIUS)) - .into(cover); - - livedata.removeObserver(this); - } - }); + CustomGlideRequest.Builder + .from(context, artist.getPrimary(), CustomGlideRequest.ARTIST_PIC, null) + .build() + .transform(new CenterCrop(), new RoundedCorners(CustomGlideRequest.CORNER_RADIUS)) + .into(cover); } public class ViewHolder extends RecyclerView.ViewHolder { diff --git a/app/src/main/java/com/cappielloantonio/play/adapter/ArtistCatalogueAdapter.java b/app/src/main/java/com/cappielloantonio/play/adapter/ArtistCatalogueAdapter.java index 540f20e4..c5d95fe1 100644 --- a/app/src/main/java/com/cappielloantonio/play/adapter/ArtistCatalogueAdapter.java +++ b/app/src/main/java/com/cappielloantonio/play/adapter/ArtistCatalogueAdapter.java @@ -15,6 +15,8 @@ import androidx.lifecycle.LiveData; import androidx.lifecycle.Observer; import androidx.recyclerview.widget.RecyclerView; +import com.bumptech.glide.load.resource.bitmap.CenterCrop; +import com.bumptech.glide.load.resource.bitmap.RoundedCorners; import com.cappielloantonio.play.App; import com.cappielloantonio.play.R; import com.cappielloantonio.play.glide.CustomGlideRequest; @@ -119,24 +121,11 @@ public class ArtistCatalogueAdapter extends RecyclerView.Adapter livedata = artistRepository.getArtistFullInfo(artist.getId()); - livedata.observeForever(new Observer() { - @Override - public void onChanged(Artist artist) { - CustomGlideRequest.Builder - .from( - context, - artist.getId(), - CustomGlideRequest.ARTIST_PIC, - artist.getImageUrl() - ) - .build() - .into(cover); - - livedata.removeObserver(this); - } - }); + CustomGlideRequest.Builder + .from(context, artist.getPrimary(), CustomGlideRequest.ARTIST_PIC, null) + .build() + .transform(new CenterCrop(), new RoundedCorners(CustomGlideRequest.CORNER_RADIUS)) + .into(cover); } public class ViewHolder extends RecyclerView.ViewHolder { diff --git a/app/src/main/java/com/cappielloantonio/play/adapter/ArtistHorizontalAdapter.java b/app/src/main/java/com/cappielloantonio/play/adapter/ArtistHorizontalAdapter.java index efc1e0c2..02a206c1 100644 --- a/app/src/main/java/com/cappielloantonio/play/adapter/ArtistHorizontalAdapter.java +++ b/app/src/main/java/com/cappielloantonio/play/adapter/ArtistHorizontalAdapter.java @@ -85,25 +85,11 @@ public class ArtistHorizontalAdapter extends RecyclerView.Adapter liveData = artistRepository.getArtistFullInfo(artist.getId()); - liveData.observeForever(new Observer() { - @Override - public void onChanged(Artist artist) { - CustomGlideRequest.Builder - .from( - context, - artist.getId(), - CustomGlideRequest.ARTIST_PIC, - artist.getImageUrl() - ) - .build() - .transform(new CenterCrop(), new CenterCrop(), new RoundedCorners(CustomGlideRequest.CORNER_RADIUS)) - .into(cover); - - liveData.removeObserver(this); - } - }); + CustomGlideRequest.Builder + .from(context, artist.getPrimary(), CustomGlideRequest.ARTIST_PIC, null) + .build() + .transform(new CenterCrop(), new RoundedCorners(CustomGlideRequest.CORNER_RADIUS)) + .into(cover); } public class ViewHolder extends RecyclerView.ViewHolder { diff --git a/app/src/main/java/com/cappielloantonio/play/adapter/ArtistSimilarAdapter.java b/app/src/main/java/com/cappielloantonio/play/adapter/ArtistSimilarAdapter.java index b330993f..d300c1da 100644 --- a/app/src/main/java/com/cappielloantonio/play/adapter/ArtistSimilarAdapter.java +++ b/app/src/main/java/com/cappielloantonio/play/adapter/ArtistSimilarAdapter.java @@ -82,25 +82,11 @@ public class ArtistSimilarAdapter extends RecyclerView.Adapter liveData = artistRepository.getArtistFullInfo(artist.getId()); - liveData.observeForever(new Observer() { - @Override - public void onChanged(Artist artist) { - CustomGlideRequest.Builder - .from( - context, - artist.getId(), - CustomGlideRequest.ARTIST_PIC, - artist.getImageUrl() - ) - .build() - .transform(new CenterCrop(), new RoundedCorners(CustomGlideRequest.CORNER_RADIUS)) - .into(cover); - - liveData.removeObserver(this); - } - }); + CustomGlideRequest.Builder + .from(context, artist.getPrimary(), CustomGlideRequest.ARTIST_PIC, null) + .build() + .transform(new CenterCrop(), new RoundedCorners(CustomGlideRequest.CORNER_RADIUS)) + .into(cover); } public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener, View.OnLongClickListener { diff --git a/app/src/main/java/com/cappielloantonio/play/database/AppDatabase.java b/app/src/main/java/com/cappielloantonio/play/database/AppDatabase.java index 749e2b53..732e667f 100644 --- a/app/src/main/java/com/cappielloantonio/play/database/AppDatabase.java +++ b/app/src/main/java/com/cappielloantonio/play/database/AppDatabase.java @@ -23,9 +23,9 @@ import com.cappielloantonio.play.model.Server; @SuppressLint("RestrictedApi") @Database( - version = 43, - entities = {Queue.class, Server.class, RecentSearch.class, Download.class, Playlist.class, Chronology.class}, - autoMigrations = {@AutoMigration(from = 42, to = 43)} + version = 46, + entities = {Queue.class, Server.class, RecentSearch.class, Download.class, Playlist.class, Chronology.class} + // autoMigrations = {@AutoMigration(from = 43, to = 44)} ) public abstract class AppDatabase extends RoomDatabase { private final static String DB_NAME = "play_db"; diff --git a/app/src/main/java/com/cappielloantonio/play/model/Album.java b/app/src/main/java/com/cappielloantonio/play/model/Album.java deleted file mode 100644 index 7475e65e..00000000 --- a/app/src/main/java/com/cappielloantonio/play/model/Album.java +++ /dev/null @@ -1,222 +0,0 @@ -package com.cappielloantonio.play.model; - -import android.os.Parcel; -import android.os.Parcelable; - -import androidx.annotation.NonNull; - -import com.cappielloantonio.play.subsonic.models.AlbumID3; -import com.cappielloantonio.play.subsonic.models.AlbumInfo; -import com.cappielloantonio.play.subsonic.models.AlbumWithSongsID3; -import com.cappielloantonio.play.util.MappingUtil; - -import java.util.Date; -import java.util.List; - -public class Album implements Parcelable { - private static final String TAG = "Album"; - - public static final String RECENTLY_PLAYED = "RECENTLY_PLAYED"; - public static final String MOST_PLAYED = "MOST_PLAYED"; - public static final String RECENTLY_ADDED = "RECENTLY_ADDED"; - public static final String DOWNLOADED = "DOWNLOADED"; - public static final String STARRED = "STARRED"; - public static final String FROM_ARTIST = "FROM_ARTIST"; - public static final String NEW_RELEASES = "NEW_RELEASES"; - - public static final String ORDER_BY_NAME = "ORDER_BY_NAME"; - public static final String ORDER_BY_ARTIST = "ORDER_BY_ARTIST"; - public static final String ORDER_BY_YEAR = "ORDER_BY_YEAR"; - public static final String ORDER_BY_RANDOM = "ORDER_BY_RANDOM"; - - private String id; - private String title; - private int year; - private String artistId; - private String artistName; - private String primary; - private String blurHash; - private boolean favorite; - private List songs; - private String notes; - private Date created; - - public Album(AlbumID3 albumID3) { - this.id = albumID3.getId(); - this.title = albumID3.getName(); - this.year = albumID3.getYear() != null ? albumID3.getYear() : 0; - this.artistId = albumID3.getArtistId(); - this.artistName = albumID3.getArtist(); - this.primary = albumID3.getCoverArtId(); - this.favorite = albumID3.getStarred() != null; - this.created = albumID3.getCreated(); - } - - public Album(AlbumWithSongsID3 albumWithSongsID3) { - this.id = albumWithSongsID3.getId(); - this.title = albumWithSongsID3.getName(); - this.year = albumWithSongsID3.getYear() != null ? albumWithSongsID3.getYear() : 0; - this.artistId = albumWithSongsID3.getArtistId(); - this.artistName = albumWithSongsID3.getArtist(); - this.primary = albumWithSongsID3.getCoverArtId(); - this.favorite = albumWithSongsID3.getStarred() != null; - this.songs = MappingUtil.mapSong(albumWithSongsID3.getSongs()); - this.created = albumWithSongsID3.getCreated(); - } - - public Album(Download download) { - this.id = download.getAlbumId(); - this.title = download.getAlbumName(); - this.artistId = download.getArtistId(); - this.artistName = download.getArtistName(); - this.primary = download.getPrimary(); - } - - public Album(AlbumInfo info) { - this.notes = info.getNotes(); - } - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getTitle() { - return title; - } - - public void setTitle(String title) { - this.title = title; - } - - public int getYear() { - return year; - } - - public void setYear(int year) { - this.year = year; - } - - public String getArtistId() { - return artistId; - } - - public void setArtistId(String artistId) { - this.artistId = artistId; - } - - public String getArtistName() { - return artistName; - } - - public void setArtistName(String artistName) { - this.artistName = artistName; - } - - public String getPrimary() { - return primary; - } - - public void setPrimary(String primary) { - this.primary = primary; - } - - public String getBlurHash() { - return blurHash; - } - - public void setBlurHash(String blurHash) { - this.blurHash = blurHash; - } - - public boolean isFavorite() { - return favorite; - } - - public void setFavorite(boolean favorite) { - this.favorite = favorite; - } - - public List getSongs() { - return songs; - } - - public void setSongs(List songs) { - this.songs = songs; - } - - public String getNotes() { - return notes; - } - - public void setNotes(String notes) { - this.notes = notes; - } - - public Date getCreated() { - return created; - } - - public void setCreated(Date created) { - this.created = created; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - Album album = (Album) o; - return id.equals(album.id); - } - - @Override - public int hashCode() { - return id.hashCode(); - } - - @NonNull - @Override - public String toString() { - return id; - } - - @Override - public int describeContents() { - return 0; - } - - @Override - public void writeToParcel(Parcel dest, int flags) { - dest.writeString(id); - dest.writeString(title); - dest.writeInt(year); - dest.writeString(artistId); - dest.writeString(artistName); - dest.writeString(primary); - dest.writeString(blurHash); - } - - protected Album(Parcel in) { - this.id = in.readString(); - this.title = in.readString(); - this.year = in.readInt(); - this.artistId = in.readString(); - this.artistName = in.readString(); - this.primary = in.readString(); - this.blurHash = in.readString(); - } - - public static final Creator CREATOR = new Creator() { - public Album createFromParcel(Parcel source) { - return new Album(source); - } - - public Album[] newArray(int size) { - return new Album[size]; - } - }; -} diff --git a/app/src/main/java/com/cappielloantonio/play/model/Album.kt b/app/src/main/java/com/cappielloantonio/play/model/Album.kt new file mode 100644 index 00000000..f587bb74 --- /dev/null +++ b/app/src/main/java/com/cappielloantonio/play/model/Album.kt @@ -0,0 +1,74 @@ +package com.cappielloantonio.play.model + +import android.os.Parcelable +import androidx.annotation.Keep +import com.cappielloantonio.play.subsonic.models.AlbumID3 +import com.cappielloantonio.play.subsonic.models.AlbumWithSongsID3 +import com.cappielloantonio.play.util.MappingUtil +import kotlinx.android.parcel.Parcelize +import java.util.* + +@Keep +@Parcelize +class Album( + var id: String, + val title: String, + val year: Int? = 0, + val artistId: String, + val artistName: String, + val primary: String, + var starred: Boolean?, + val songs: List?, + val created: Date? +) : Parcelable { + + constructor(albumID3: AlbumID3) : this( + albumID3.id, + albumID3.name, + albumID3.year ?: 0, + albumID3.artistId, + albumID3.artist, + albumID3.coverArtId, + albumID3.starred != null, + null, + albumID3.created + ) + + constructor(albumWithSongsID3: AlbumWithSongsID3) : this( + albumWithSongsID3.id, + albumWithSongsID3.name, + albumWithSongsID3.year ?: 0, + albumWithSongsID3.artistId, + albumWithSongsID3.artist, + albumWithSongsID3.coverArtId, + albumWithSongsID3.starred != null, + MappingUtil.mapSong(albumWithSongsID3.songs), + albumWithSongsID3.created + ) + + constructor(download: Download) : this( + download.albumId, + download.albumName, + 0, + download.artistId, + download.artistName, + download.primary, + null, + null, + null + ) + + companion object { + const val RECENTLY_PLAYED = "RECENTLY_PLAYED" + const val MOST_PLAYED = "MOST_PLAYED" + const val RECENTLY_ADDED = "RECENTLY_ADDED" + const val DOWNLOADED = "DOWNLOADED" + const val STARRED = "STARRED" + const val FROM_ARTIST = "FROM_ARTIST" + const val NEW_RELEASES = "NEW_RELEASES" + const val ORDER_BY_NAME = "ORDER_BY_NAME" + const val ORDER_BY_ARTIST = "ORDER_BY_ARTIST" + const val ORDER_BY_YEAR = "ORDER_BY_YEAR" + const val ORDER_BY_RANDOM = "ORDER_BY_RANDOM" + } +} \ No newline at end of file diff --git a/app/src/main/java/com/cappielloantonio/play/model/Artist.java b/app/src/main/java/com/cappielloantonio/play/model/Artist.java deleted file mode 100644 index b7e52fb4..00000000 --- a/app/src/main/java/com/cappielloantonio/play/model/Artist.java +++ /dev/null @@ -1,246 +0,0 @@ -package com.cappielloantonio.play.model; - -import android.os.Parcel; -import android.os.Parcelable; - -import androidx.annotation.NonNull; - -import com.cappielloantonio.play.subsonic.models.ArtistID3; -import com.cappielloantonio.play.subsonic.models.ArtistInfo2; -import com.cappielloantonio.play.subsonic.models.ArtistWithAlbumsID3; -import com.cappielloantonio.play.subsonic.models.SimilarArtistID3; -import com.cappielloantonio.play.util.MappingUtil; - -import java.util.ArrayList; -import java.util.List; - -public class Artist implements Parcelable { - private static final String TAG = "Artist"; - - public static final String DOWNLOADED = "DOWNLOADED"; - public static final String STARRED = "STARRED"; - - public static final String ORDER_BY_NAME = "ORDER_BY_NAME"; - public static final String ORDER_BY_RANDOM = "ORDER_BY_RANDOM"; - - private List albums; - private List similarArtists; - - private String id; - private String name; - private String primary; - private String primaryBlurHash; - private String backdrop; - private String backdropBlurHash; - private int albumCount; - private boolean favorite; - private String bio; - private String imageUrl; - private String lastfm; - - public Artist(ArtistID3 artistID3) { - this.id = artistID3.getId(); - this.name = artistID3.getName(); - this.primary = artistID3.getCoverArtId(); - this.backdrop = artistID3.getCoverArtId(); - this.albumCount = artistID3.getAlbumCount(); - this.favorite = artistID3.getStarred() != null; - } - - public Artist(ArtistWithAlbumsID3 artistWithAlbumsID3) { - this.id = artistWithAlbumsID3.getId(); - this.name = artistWithAlbumsID3.getName(); - this.primary = artistWithAlbumsID3.getCoverArtId(); - this.backdrop = artistWithAlbumsID3.getCoverArtId(); - this.albumCount = artistWithAlbumsID3.getAlbumCount(); - this.albums = MappingUtil.mapAlbum(artistWithAlbumsID3.getAlbums()); - this.favorite = artistWithAlbumsID3.getStarred() != null; - this.albums = MappingUtil.mapAlbum(artistWithAlbumsID3.getAlbums()); - } - - public Artist(SimilarArtistID3 similarArtistID3) { - this.id = similarArtistID3.getId(); - this.name = similarArtistID3.getName(); - this.primary = similarArtistID3.getCoverArtId(); - this.backdrop = similarArtistID3.getCoverArtId(); - this.albumCount = similarArtistID3.getAlbumCount(); - } - - public Artist(ArtistInfo2 artistInfo2) { - this.similarArtists = MappingUtil.mapSimilarArtist(artistInfo2.getSimilarArtists()); - this.bio = artistInfo2.getBiography(); - this.imageUrl = artistInfo2.getLargeImageUrl(); - this.lastfm = artistInfo2.getLastFmUrl(); - } - - public Artist(String id, String name) { - this.id = id; - this.name = name; - } - - public Artist(Download download) { - this.id = download.getArtistId(); - this.name = download.getArtistName(); - } - - public String getId() { - return id; - } - - public void setId(@NonNull String id) { - this.id = id; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getPrimary() { - return primary; - } - - public void setPrimary(String primary) { - this.primary = primary; - } - - public String getPrimaryBlurHash() { - return primaryBlurHash; - } - - public void setPrimaryBlurHash(String primaryBlurHash) { - this.primaryBlurHash = primaryBlurHash; - } - - public String getBackdrop() { - return backdrop; - } - - public void setBackdrop(String backdrop) { - this.backdrop = backdrop; - } - - public String getBackdropBlurHash() { - return backdropBlurHash; - } - - public void setBackdropBlurHash(String backdropBlurHash) { - this.backdropBlurHash = backdropBlurHash; - } - - public int getAlbumCount() { - return albumCount; - } - - public void setAlbumCount(int albumCount) { - this.albumCount = albumCount; - } - - public List getAlbums() { - return albums; - } - - public void setAlbums(List albums) { - this.albums = albums; - } - - public boolean isFavorite() { - return favorite; - } - - public void setFavorite(boolean favorite) { - this.favorite = favorite; - } - - public List getSimilarArtists() { - return similarArtists; - } - - public void setSimilarArtists(List similarArtists) { - this.similarArtists = similarArtists; - } - - public String getBio() { - return bio; - } - - public void setBio(String bio) { - this.bio = bio; - } - - public String getImageUrl() { - return imageUrl; - } - - public void setImageUrl(String imageUrl) { - this.imageUrl = imageUrl; - } - - public String getLastfm() { - return lastfm; - } - - public void setLastfm(String lastfm) { - this.lastfm = lastfm; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - Artist artist = (Artist) o; - return id.equals(artist.id); - } - - @Override - public int hashCode() { - return id.hashCode(); - } - - @NonNull - @Override - public String toString() { - return id; - } - - @Override - public int describeContents() { - return 0; - } - - @Override - public void writeToParcel(Parcel dest, int flags) { - dest.writeString(id); - dest.writeString(name); - dest.writeString(primary); - dest.writeString(primaryBlurHash); - dest.writeString(backdrop); - dest.writeString(backdropBlurHash); - } - - protected Artist(Parcel in) { - this.albums = new ArrayList<>(); - this.id = in.readString(); - this.name = in.readString(); - this.primary = in.readString(); - this.primaryBlurHash = in.readString(); - this.backdrop = in.readString(); - this.backdropBlurHash = in.readString(); - } - - public static final Parcelable.Creator CREATOR = new Parcelable.Creator() { - @Override - public Artist createFromParcel(Parcel source) { - return new Artist(source); - } - - @Override - public Artist[] newArray(int size) { - return new Artist[size]; - } - }; -} \ No newline at end of file diff --git a/app/src/main/java/com/cappielloantonio/play/model/Artist.kt b/app/src/main/java/com/cappielloantonio/play/model/Artist.kt new file mode 100644 index 00000000..090f3152 --- /dev/null +++ b/app/src/main/java/com/cappielloantonio/play/model/Artist.kt @@ -0,0 +1,103 @@ +package com.cappielloantonio.play.model + +import android.os.Parcelable +import androidx.annotation.Keep +import com.cappielloantonio.play.subsonic.models.ArtistID3 +import com.cappielloantonio.play.subsonic.models.ArtistInfo2 +import com.cappielloantonio.play.subsonic.models.ArtistWithAlbumsID3 +import com.cappielloantonio.play.subsonic.models.SimilarArtistID3 +import com.cappielloantonio.play.util.MappingUtil +import kotlinx.android.parcel.Parcelize + +@Keep +@Parcelize +class Artist( + val id: String?, + val name: String?, + val primary: String?, + val albumCount: Int?, + var starred: Boolean?, + val bio: String?, + val imageUrl: String?, + val lastfm: String?, + val albums: List?, + val similarArtists: List?, +) : Parcelable { + + constructor(artistID3: ArtistID3) : this( + artistID3.id, + artistID3.name, + artistID3.coverArtId, + artistID3.albumCount, + artistID3.starred != null, + null, + null, + null, + null, + null + ) + + constructor(artistWithAlbumsID3: ArtistWithAlbumsID3) : this( + artistWithAlbumsID3.id, + artistWithAlbumsID3.name, + artistWithAlbumsID3.coverArtId, + artistWithAlbumsID3.albumCount, + artistWithAlbumsID3.starred != null, + null, + null, + null, + MappingUtil.mapAlbum(artistWithAlbumsID3.albums), + null + ) + + constructor(similarArtistID3: SimilarArtistID3) : this( + similarArtistID3.id, + similarArtistID3.name, + similarArtistID3.coverArtId, + similarArtistID3.albumCount, + null, + null, + null, + null, + null, + null + ) + + constructor(artistInfo2: ArtistInfo2) : this( + null, + null, + null, + null, + null, + artistInfo2.biography, + artistInfo2.largeImageUrl, + artistInfo2.lastFmUrl, + null, + MappingUtil.mapSimilarArtist(artistInfo2.similarArtists) + ) + + constructor(id: String, name: String) : this( + id, + name, + null, + null, + null, + null, + null, + null, + null, + null + ) + + constructor(download: Download) : this( + download.artistId, + download.artistName + ) + + companion object { + const val DOWNLOADED = "DOWNLOADED" + const val STARRED = "STARRED" + const val ORDER_BY_NAME = "ORDER_BY_NAME" + const val ORDER_BY_RANDOM = "ORDER_BY_RANDOM" + } +} \ No newline at end of file diff --git a/app/src/main/java/com/cappielloantonio/play/model/Chronology.java b/app/src/main/java/com/cappielloantonio/play/model/Chronology.java deleted file mode 100644 index d25f0c18..00000000 --- a/app/src/main/java/com/cappielloantonio/play/model/Chronology.java +++ /dev/null @@ -1,250 +0,0 @@ -package com.cappielloantonio.play.model; - -import android.os.Parcel; -import android.os.Parcelable; - -import androidx.annotation.NonNull; -import androidx.room.ColumnInfo; -import androidx.room.Entity; -import androidx.room.PrimaryKey; - -@Entity(tableName = "chronology") -public class Chronology implements Parcelable { - @PrimaryKey(autoGenerate = true) - private int uuid; - - @ColumnInfo(name = "id") - private String trackId; - - @ColumnInfo(name = "title") - private String title; - - @ColumnInfo(name = "albumId") - private String albumId; - - @ColumnInfo(name = "albumName") - private String albumName; - - @ColumnInfo(name = "artistId") - private String artistId; - - @ColumnInfo(name = "artistName") - private String artistName; - - @ColumnInfo(name = "cover_art_id") - private String coverArtId; - - @ColumnInfo(name = "duration") - private long duration; - - @ColumnInfo(name = "container") - private String container; - - @ColumnInfo(name = "bitrate") - private int bitrate; - - @ColumnInfo(name = "extension") - private String extension; - - @ColumnInfo(name = "timestamp") - private Long timestamp; - - @ColumnInfo(name = "server") - private String server; - - public Chronology(String trackId, String title, String albumId, String albumName, String artistId, String artistName, String coverArtId, long duration, String container, int bitrate, String extension, String server) { - this.trackId = trackId; - this.title = title; - this.albumId = albumId; - this.albumName = albumName; - this.artistId = artistId; - this.artistName = artistName; - this.coverArtId = coverArtId; - this.duration = duration; - this.container = container; - this.bitrate = bitrate; - this.extension = extension; - this.timestamp = System.currentTimeMillis(); - this.server = server; - } - - public int getUuid() { - return uuid; - } - - public void setUuid(int uuid) { - this.uuid = uuid; - } - - public String getTrackId() { - return trackId; - } - - public void setTrackId(String trackId) { - this.trackId = trackId; - } - - public String getTitle() { - return title; - } - - public void setTitle(String title) { - this.title = title; - } - - public String getAlbumId() { - return albumId; - } - - public void setAlbumId(String albumId) { - this.albumId = albumId; - } - - public String getAlbumName() { - return albumName; - } - - public void setAlbumName(String albumName) { - this.albumName = albumName; - } - - public String getArtistId() { - return artistId; - } - - public void setArtistId(String artistId) { - this.artistId = artistId; - } - - public String getArtistName() { - return artistName; - } - - public void setArtistName(String artistName) { - this.artistName = artistName; - } - - public String getCoverArtId() { - return coverArtId; - } - - public void setCoverArtId(String coverArtId) { - this.coverArtId = coverArtId; - } - - public long getDuration() { - return duration; - } - - public void setDuration(long duration) { - this.duration = duration; - } - - public String getContainer() { - return container; - } - - public void setContainer(String container) { - this.container = container; - } - - public int getBitrate() { - return bitrate; - } - - public void setBitrate(int bitrate) { - this.bitrate = bitrate; - } - - public String getExtension() { - return extension; - } - - public void setExtension(String extension) { - this.extension = extension; - } - - public Long getTimestamp() { - return timestamp; - } - - public void setTimestamp(Long timestamp) { - this.timestamp = timestamp; - } - - public String getServer() { - return server; - } - - public void setServer(String server) { - this.server = server; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - Chronology item = (Chronology) o; - return trackId.equals(item.trackId); - } - - @Override - public int hashCode() { - return trackId.hashCode(); - } - - @NonNull - @Override - public String toString() { - return trackId; - } - - @Override - public int describeContents() { - return 0; - } - - @Override - public void writeToParcel(Parcel dest, int flags) { - dest.writeString(this.trackId); - dest.writeString(this.title); - dest.writeString(this.albumId); - dest.writeString(this.albumName); - dest.writeString(this.artistId); - dest.writeString(this.artistName); - dest.writeString(this.coverArtId); - dest.writeLong(this.duration); - dest.writeString(this.container); - dest.writeInt(this.bitrate); - dest.writeString(this.extension); - dest.writeLong(this.timestamp); - dest.writeString(this.server); - } - - protected Chronology(Parcel in) { - this.trackId = in.readString(); - this.title = in.readString(); - this.albumId = in.readString(); - this.albumName = in.readString(); - this.artistId = in.readString(); - this.artistName = in.readString(); - this.coverArtId = in.readString(); - this.duration = in.readLong(); - this.container = in.readString(); - this.bitrate = in.readInt(); - this.extension = in.readString(); - this.timestamp = in.readLong(); - this.server = in.readString(); - } - - public static final Creator CREATOR = new Creator() { - public Chronology createFromParcel(Parcel source) { - return new Chronology(source); - } - - public Chronology[] newArray(int size) { - return new Chronology[size]; - } - }; -} diff --git a/app/src/main/java/com/cappielloantonio/play/model/Chronology.kt b/app/src/main/java/com/cappielloantonio/play/model/Chronology.kt new file mode 100644 index 00000000..c5ed29e3 --- /dev/null +++ b/app/src/main/java/com/cappielloantonio/play/model/Chronology.kt @@ -0,0 +1,55 @@ +package com.cappielloantonio.play.model + +import android.os.Parcelable +import androidx.annotation.Keep +import androidx.room.ColumnInfo +import androidx.room.Entity +import androidx.room.PrimaryKey +import kotlinx.android.parcel.Parcelize + +@Keep +@Parcelize +@Entity(tableName = "chronology") +data class Chronology( + @ColumnInfo(name = "id") + val trackId: String, + + @ColumnInfo(name = "title") + val title: String, + + @ColumnInfo(name = "albumId") + val albumId: String, + + @ColumnInfo(name = "albumName") + val albumName: String, + + @ColumnInfo(name = "artistId") + val artistId: String, + + @ColumnInfo(name = "artistName") + val artistName: String, + + @ColumnInfo(name = "cover_art_id") + val coverArtId: String, + + @ColumnInfo(name = "duration") + val duration: Long, + + @ColumnInfo(name = "container") + val container: String, + + @ColumnInfo(name = "bitrate") + val bitrate: Int, + + @ColumnInfo(name = "extension") + val extension: String, + + @ColumnInfo(name = "server") + val server: String, +) : Parcelable { + @PrimaryKey(autoGenerate = true) + var uuid: Int = 0 + + @ColumnInfo(name = "timestamp") + var timestamp: Long = System.currentTimeMillis() +} \ No newline at end of file diff --git a/app/src/main/java/com/cappielloantonio/play/model/Download.java b/app/src/main/java/com/cappielloantonio/play/model/Download.java deleted file mode 100644 index c088cd89..00000000 --- a/app/src/main/java/com/cappielloantonio/play/model/Download.java +++ /dev/null @@ -1,245 +0,0 @@ -package com.cappielloantonio.play.model; - -import androidx.annotation.NonNull; -import androidx.room.ColumnInfo; -import androidx.room.Entity; -import androidx.room.PrimaryKey; - -import com.cappielloantonio.play.App; -import com.cappielloantonio.play.util.MusicUtil; -import com.cappielloantonio.play.util.PreferenceUtil; - -import java.util.UUID; - -@Entity(tableName = "download") -public class Download { - @NonNull - @PrimaryKey - @ColumnInfo(name = "id") - private String id; - - @ColumnInfo(name = "mediaId") - private String mediaID; - - @ColumnInfo(name = "title") - private String title; - - @ColumnInfo(name = "albumId") - private String albumId; - - @ColumnInfo(name = "albumName") - private String albumName; - - @ColumnInfo(name = "artistId") - private String artistId; - - @ColumnInfo(name = "artistName") - private String artistName; - - @ColumnInfo(name = "trackNumber") - private int trackNumber; - - @ColumnInfo(name = "primary") - private String primary; - - @ColumnInfo(name = "duration") - private long duration; - - @ColumnInfo(name = "server") - private String server; - - @ColumnInfo(name = "playlistId") - private String playlistId; - - @ColumnInfo(name = "playlistName") - private String playlistName; - - @ColumnInfo(name = "container") - private String container; - - @ColumnInfo(name = "bitrate") - private int bitrate; - - @ColumnInfo(name = "extension") - private String extension; - - @ColumnInfo(name = "type") - private String type; - - public Download(@NonNull String id, String mediaID, String title, String albumId, String albumName, String artistId, String artistName, int trackNumber, String primary, long duration, String server, String playlistId, String playlistName, String container, int bitrate, String extension, String type) { - this.id = id; - this.mediaID = mediaID; - this.title = title; - this.albumId = albumId; - this.albumName = albumName; - this.artistId = artistId; - this.artistName = artistName; - this.trackNumber = trackNumber; - this.primary = primary; - this.duration = duration; - this.server = server; - this.playlistId = playlistId; - this.playlistName = playlistName; - this.container = container; - this.bitrate = bitrate; - this.extension = extension; - this.type = type; - } - - public Download(Media media, String playlistId, String playlistName) { - this.id = UUID.randomUUID().toString(); - this.mediaID = media.getId(); - this.title = media.getTitle(); - this.albumId = media.getAlbumId(); - this.albumName = media.getAlbumName(); - this.artistId = media.getArtistId(); - this.artistName = MusicUtil.normalizedArtistName(media.getArtistName()); - this.trackNumber = media.getTrackNumber(); - this.primary = media.getCoverArtId(); - this.duration = media.getDuration(); - this.server = PreferenceUtil.getInstance(App.getInstance()).getServerId(); - this.playlistId = playlistId; - this.playlistName = playlistName; - this.container = media.getContainer(); - this.bitrate = media.getBitrate(); - this.extension = media.getExtension(); - this.type = media.getType(); - } - - @NonNull - public String getId() { - return id; - } - - public void setId(@NonNull String id) { - this.id = id; - } - - public String getMediaID() { - return mediaID; - } - - public void setMediaID(String mediaID) { - this.mediaID = mediaID; - } - - public String getTitle() { - return title; - } - - public void setTitle(String title) { - this.title = title; - } - - public String getAlbumId() { - return albumId; - } - - public void setAlbumId(String albumId) { - this.albumId = albumId; - } - - public String getAlbumName() { - return albumName; - } - - public void setAlbumName(String albumName) { - this.albumName = albumName; - } - - public String getArtistId() { - return artistId; - } - - public void setArtistId(String artistId) { - this.artistId = artistId; - } - - public String getArtistName() { - return artistName; - } - - public void setArtistName(String artistName) { - this.artistName = artistName; - } - - public int getTrackNumber() { - return trackNumber; - } - - public void setTrackNumber(int trackNumber) { - this.trackNumber = trackNumber; - } - - public String getPrimary() { - return primary; - } - - public void setPrimary(String primary) { - this.primary = primary; - } - - public long getDuration() { - return duration; - } - - public void setDuration(long duration) { - this.duration = duration; - } - - public String getServer() { - return server; - } - - public void setServer(String server) { - this.server = server; - } - - public String getPlaylistId() { - return playlistId; - } - - public void setPlaylistId(String playlistId) { - this.playlistId = playlistId; - } - - public String getPlaylistName() { - return playlistName; - } - - public void setPlaylistName(String playlistName) { - this.playlistName = playlistName; - } - - public String getContainer() { - return container; - } - - public void setContainer(String container) { - this.container = container; - } - - public int getBitrate() { - return bitrate; - } - - public void setBitrate(int bitrate) { - this.bitrate = bitrate; - } - - public String getExtension() { - return extension; - } - - public void setExtension(String extension) { - this.extension = extension; - } - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } -} diff --git a/app/src/main/java/com/cappielloantonio/play/model/Download.kt b/app/src/main/java/com/cappielloantonio/play/model/Download.kt new file mode 100644 index 00000000..a84b8b25 --- /dev/null +++ b/app/src/main/java/com/cappielloantonio/play/model/Download.kt @@ -0,0 +1,89 @@ +package com.cappielloantonio.play.model + +import android.os.Parcelable +import androidx.annotation.Keep +import androidx.room.ColumnInfo +import androidx.room.Entity +import androidx.room.PrimaryKey +import com.cappielloantonio.play.App +import com.cappielloantonio.play.util.MusicUtil +import com.cappielloantonio.play.util.PreferenceUtil +import kotlinx.android.parcel.Parcelize +import java.util.* + +@Keep +@Parcelize +@Entity(tableName = "download") +class Download( + @PrimaryKey @ColumnInfo(name = "id") + var id: String, + + @ColumnInfo(name = "mediaId") + val mediaID: String, + + @ColumnInfo(name = "title") + val title: String, + + @ColumnInfo(name = "albumId") + val albumId: String, + + @ColumnInfo(name = "albumName") + val albumName: String, + + @ColumnInfo(name = "artistId") + val artistId: String, + + @ColumnInfo(name = "artistName") + val artistName: String, + + @ColumnInfo(name = "trackNumber") + val trackNumber: Int = 0, + + @ColumnInfo(name = "primary") + val primary: String, + + @ColumnInfo(name = "duration") + val duration: Long = 0, + + @ColumnInfo(name = "server") + val server: String, + + @ColumnInfo(name = "playlistId") + val playlistId: String? = null, + + @ColumnInfo(name = "playlistName") + val playlistName: String? = null, + + @ColumnInfo(name = "container") + val container: String, + + @ColumnInfo(name = "bitrate") + val bitrate: Int = 0, + + @ColumnInfo(name = "extension") + val extension: String, + + @ColumnInfo(name = "type") + val type: String, +) : Parcelable { + + constructor(media: Media, playlistId: String?, playlistName: String?) : this( + UUID.randomUUID().toString(), + media.id!!, + media.title!!, + media.albumId!!, + media.albumName!!, + media.artistId!!, + MusicUtil.normalizedArtistName(media.artistName), + media.trackNumber!!, + media.coverArtId!!, + media.duration!!, + PreferenceUtil.getInstance(App.getInstance()).serverId, + playlistId, + playlistName, + media.container!!, + media.bitrate, + media.extension!!, + media.type!! + ) +} \ No newline at end of file diff --git a/app/src/main/java/com/cappielloantonio/play/model/Genre.java b/app/src/main/java/com/cappielloantonio/play/model/Genre.java deleted file mode 100644 index 65ba558e..00000000 --- a/app/src/main/java/com/cappielloantonio/play/model/Genre.java +++ /dev/null @@ -1,103 +0,0 @@ -package com.cappielloantonio.play.model; - -import android.os.Parcel; -import android.os.Parcelable; - -import androidx.annotation.NonNull; - -public class Genre implements Parcelable { - public static final String ORDER_BY_NAME = "ORDER_BY_NAME"; - public static final String ORDER_BY_RANDOM = "ORDER_BY_RANDOM"; - - private String id; - private String name; - private int songCount; - private int albumCount; - - public Genre(com.cappielloantonio.play.subsonic.models.Genre genre) { - this.id = genre.getGenre(); - this.name = genre.getGenre(); - this.songCount = genre.getSongCount(); - this.albumCount = genre.getAlbumCount(); - } - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public int getSongCount() { - return songCount; - } - - public void setSongCount(int songCount) { - this.songCount = songCount; - } - - public int getAlbumCount() { - return albumCount; - } - - public void setAlbumCount(int albumCount) { - this.albumCount = albumCount; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - Genre genre = (Genre) o; - return id.equals(genre.id); - } - - @Override - public int hashCode() { - return id.hashCode(); - } - - @NonNull - @Override - public String toString() { - return id; - } - - @Override - public int describeContents() { - return 0; - } - - @Override - public void writeToParcel(Parcel dest, int flags) { - dest.writeString(this.id); - dest.writeString(this.name); - dest.writeInt(this.songCount); - } - - protected Genre(Parcel in) { - this.id = in.readString(); - this.name = in.readString(); - this.songCount = in.readInt(); - } - - public static final Creator CREATOR = new Creator() { - public Genre createFromParcel(Parcel source) { - return new Genre(source); - } - - public Genre[] newArray(int size) { - return new Genre[size]; - } - }; -} diff --git a/app/src/main/java/com/cappielloantonio/play/model/Genre.kt b/app/src/main/java/com/cappielloantonio/play/model/Genre.kt new file mode 100644 index 00000000..3d55a451 --- /dev/null +++ b/app/src/main/java/com/cappielloantonio/play/model/Genre.kt @@ -0,0 +1,28 @@ +package com.cappielloantonio.play.model + +import android.os.Parcelable +import androidx.annotation.Keep +import com.cappielloantonio.play.subsonic.models.Genre +import kotlinx.android.parcel.Parcelize + +@Keep +@Parcelize +class Genre( + val id: String, + val name: String, + val songCount: Int = 0, + val albumCount: Int = 0 +) : Parcelable { + + constructor(genre: Genre) : this( + genre.genre, + genre.genre, + genre.songCount, + genre.albumCount + ) + + companion object { + const val ORDER_BY_NAME = "ORDER_BY_NAME" + const val ORDER_BY_RANDOM = "ORDER_BY_RANDOM" + } +} \ No newline at end of file diff --git a/app/src/main/java/com/cappielloantonio/play/model/Media.java b/app/src/main/java/com/cappielloantonio/play/model/Media.java deleted file mode 100644 index 82c1f3e8..00000000 --- a/app/src/main/java/com/cappielloantonio/play/model/Media.java +++ /dev/null @@ -1,473 +0,0 @@ -package com.cappielloantonio.play.model; - -import android.os.Parcel; -import android.os.Parcelable; - -import androidx.annotation.NonNull; - -import com.cappielloantonio.play.subsonic.models.Child; -import com.cappielloantonio.play.subsonic.models.PodcastEpisode; - -public class Media implements Parcelable { - private static final String TAG = "Media"; - - public static final String MEDIA_TYPE_MUSIC = "music"; - public static final String MEDIA_TYPE_PODCAST = "podcast"; - public static final String MEDIA_TYPE_AUDIOBOOK = "audiobook"; - public static final String MEDIA_TYPE_VIDEO = "video"; - - public static final float MEDIA_PLAYBACK_SPEED_080 = 0.8f; - public static final float MEDIA_PLAYBACK_SPEED_100 = 1.0f; - public static final float MEDIA_PLAYBACK_SPEED_125 = 1.25f; - public static final float MEDIA_PLAYBACK_SPEED_150 = 1.50f; - public static final float MEDIA_PLAYBACK_SPEED_175 = 1.75f; - public static final float MEDIA_PLAYBACK_SPEED_200 = 2.0f; - - public static final String RECENTLY_PLAYED = "RECENTLY_PLAYED"; - public static final String MOST_PLAYED = "MOST_PLAYED"; - public static final String RECENTLY_ADDED = "RECENTLY_ADDED"; - public static final String BY_GENRE = "BY_GENRE"; - public static final String BY_GENRES = "BY_GENRES"; - public static final String BY_ARTIST = "BY_ARTIST"; - public static final String BY_YEAR = "BY_YEAR"; - public static final String STARRED = "STARRED"; - public static final String DOWNLOADED = "DOWNLOADED"; - public static final String FROM_ALBUM = "FROM_ALBUM"; - - private String id; - private String title; - private String channelId; - private String streamId; - private String albumId; - private String albumName; - private String artistId; - private String artistName; - private String coverArtId; - private int trackNumber; - private int discNumber; - private int year; - private long duration; - private String description; - private String status; - private boolean starred; - private String path; - private long size; - private String container; - private int bitrate; - private String extension; - private long added; - private String type; - private int playCount; - private long lastPlay; - private int rating; - private long publishDate; - - public Media(Child child) { - this.id = child.getId(); - this.title = child.getTitle(); - this.trackNumber = child.getTrack() != null ? child.getTrack() : 0; - this.discNumber = child.getDiscNumber() != null ? child.getDiscNumber() : 0; - this.year = child.getYear() != null ? child.getYear() : 0; - this.duration = child.getDuration() != null ? child.getDuration() : 0; - this.albumId = child.getAlbumId(); - this.albumName = child.getAlbum(); - this.artistId = child.getArtistId(); - this.artistName = child.getArtist(); - this.coverArtId = child.getCoverArtId(); - this.starred = child.getStarred() != null; - this.path = child.getPath(); - this.size = child.getSize() != null ? child.getSize() : 0; - this.container = child.getContentType(); - this.bitrate = child.getBitRate() != null ? child.getBitRate() : 0; - this.extension = child.getSuffix(); - this.added = child.getCreated().getTime(); - this.playCount = 0; - this.lastPlay = 0; - this.rating = child.getUserRating() != null ? child.getUserRating() : 0; - // this.type = MEDIA_TYPE_MUSIC; - this.type = child.getType(); - } - - public Media(PodcastEpisode podcastEpisode) { - this.id = podcastEpisode.getId(); - this.title = podcastEpisode.getTitle(); - this.albumName = podcastEpisode.getAlbum(); - this.artistName = podcastEpisode.getArtist(); - this.trackNumber = podcastEpisode.getTrack() != null ? podcastEpisode.getTrack() : 0; - this.year = podcastEpisode.getYear(); - this.coverArtId = podcastEpisode.getCoverArtId(); - this.duration = podcastEpisode.getDuration(); - this.starred = podcastEpisode.getStarred() != null; - this.streamId = podcastEpisode.getStreamId(); - this.channelId = podcastEpisode.getChannelId(); - this.description = podcastEpisode.getDescription(); - this.status = podcastEpisode.getStatus(); - this.publishDate = podcastEpisode.getPublishDate().getTime(); - this.container = podcastEpisode.getContentType(); - this.bitrate = podcastEpisode.getBitRate(); - this.extension = podcastEpisode.getSuffix(); - // this.type = MEDIA_TYPE_PODCAST; - this.type = podcastEpisode.getType(); - } - - public Media(Queue queue) { - this.id = queue.getId(); - this.title = queue.getTitle(); - this.albumId = queue.getAlbumId(); - this.albumName = queue.getAlbumName(); - this.artistId = queue.getArtistId(); - this.artistName = queue.getArtistName(); - this.coverArtId = queue.getCoverArtId(); - this.duration = queue.getDuration(); - this.streamId = queue.getStreamId(); - this.channelId = queue.getChannelId(); - this.publishDate = queue.getPublishingDate(); - this.container = queue.getContainer(); - this.bitrate = queue.getBitrate(); - this.extension = queue.getExtension(); - this.type = queue.getType(); - } - - public Media(Download download) { - this.id = download.getMediaID(); - this.title = download.getTitle(); - this.albumId = download.getAlbumId(); - this.albumName = download.getAlbumName(); - this.artistId = download.getArtistId(); - this.artistName = download.getArtistName(); - this.trackNumber = download.getTrackNumber(); - this.coverArtId = download.getPrimary(); - this.duration = download.getDuration(); - this.container = download.getContainer(); - this.bitrate = download.getBitrate(); - this.extension = download.getExtension(); - this.type = download.getType(); - } - - public Media(Chronology item) { - this.id = item.getTrackId(); - this.title = item.getTitle(); - this.albumId = item.getAlbumId(); - this.albumName = item.getAlbumName(); - this.artistId = item.getArtistId(); - this.artistName = item.getArtistName(); - this.coverArtId = item.getCoverArtId(); - this.duration = item.getDuration(); - this.container = item.getContainer(); - this.bitrate = item.getBitrate(); - this.extension = item.getExtension(); - this.type = MEDIA_TYPE_MUSIC; - } - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getTitle() { - return title; - } - - public void setTitle(String title) { - this.title = title; - } - - public String getChannelId() { - return channelId; - } - - public void setChannelId(String channelId) { - this.channelId = channelId; - } - - public String getStreamId() { - return streamId; - } - - public void setStreamId(String streamId) { - this.streamId = streamId; - } - - public String getAlbumId() { - return albumId; - } - - public void setAlbumId(String albumId) { - this.albumId = albumId; - } - - public String getAlbumName() { - return albumName; - } - - public void setAlbumName(String albumName) { - this.albumName = albumName; - } - - public String getArtistId() { - return artistId; - } - - public void setArtistId(String artistId) { - this.artistId = artistId; - } - - public String getArtistName() { - return artistName; - } - - public void setArtistName(String artistName) { - this.artistName = artistName; - } - - public String getCoverArtId() { - return coverArtId; - } - - public void setCoverArtId(String coverArtId) { - this.coverArtId = coverArtId; - } - - public int getTrackNumber() { - return trackNumber; - } - - public void setTrackNumber(int trackNumber) { - this.trackNumber = trackNumber; - } - - public int getDiscNumber() { - return discNumber; - } - - public void setDiscNumber(int discNumber) { - this.discNumber = discNumber; - } - - public int getYear() { - return year; - } - - public void setYear(int year) { - this.year = year; - } - - public long getDuration() { - return duration; - } - - public void setDuration(long duration) { - this.duration = duration; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public String getStatus() { - return status; - } - - public void setStatus(String status) { - this.status = status; - } - - public boolean isStarred() { - return starred; - } - - public void setStarred(boolean starred) { - this.starred = starred; - } - - public String getPath() { - return path; - } - - public void setPath(String path) { - this.path = path; - } - - public long getSize() { - return size; - } - - public void setSize(long size) { - this.size = size; - } - - public String getContainer() { - return container; - } - - public void setContainer(String container) { - this.container = container; - } - - public int getBitrate() { - return bitrate; - } - - public void setBitrate(int bitRate) { - this.bitrate = bitRate; - } - - public String getExtension() { - return extension; - } - - public void setExtension(String extension) { - this.extension = extension; - } - - public long getAdded() { - return added; - } - - public void setAdded(long added) { - this.added = added; - } - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - - public int getPlayCount() { - return playCount; - } - - public void setPlayCount(int playCount) { - this.playCount = playCount; - } - - public long getLastPlay() { - return lastPlay; - } - - public void setLastPlay(long lastPlay) { - this.lastPlay = lastPlay; - } - - public int getRating() { - return rating; - } - - public void setRating(int rating) { - this.rating = rating; - } - - public long getPublishDate() { - return publishDate; - } - - public void setPublishDate(long publishDate) { - this.publishDate = publishDate; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - Media song = (Media) o; - return id.equals(song.id); - } - - @Override - public int hashCode() { - return id.hashCode(); - } - - @NonNull - @Override - public String toString() { - return id; - } - - @Override - public int describeContents() { - return 0; - } - - @Override - public void writeToParcel(Parcel dest, int flags) { - dest.writeString(this.id); - dest.writeString(this.title); - dest.writeString(this.channelId); - dest.writeString(this.streamId); - dest.writeString(this.albumId); - dest.writeString(this.albumName); - dest.writeString(this.artistId); - dest.writeString(this.artistName); - dest.writeString(this.coverArtId); - dest.writeInt(this.trackNumber); - dest.writeInt(this.discNumber); - dest.writeInt(this.year); - dest.writeLong(this.duration); - dest.writeString(this.description); - dest.writeString(this.status); - dest.writeString(Boolean.toString(starred)); - dest.writeString(this.path); - dest.writeLong(this.size); - dest.writeString(this.container); - dest.writeInt(this.bitrate); - dest.writeString(this.extension); - dest.writeLong(this.added); - dest.writeString(this.type); - dest.writeInt(this.playCount); - dest.writeLong(this.lastPlay); - dest.writeInt(this.rating); - dest.writeLong(this.publishDate); - } - - protected Media(Parcel in) { - this.id = in.readString(); - this.title = in.readString(); - this.channelId = in.readString(); - this.streamId = in.readString(); - this.albumId = in.readString(); - this.albumName = in.readString(); - this.artistId = in.readString(); - this.artistName = in.readString(); - this.coverArtId = in.readString(); - this.trackNumber = in.readInt(); - this.discNumber = in.readInt(); - this.year = in.readInt(); - this.duration = in.readLong(); - this.description = in.readString(); - this.status = in.readString(); - this.starred = Boolean.parseBoolean(in.readString()); - this.path = in.readString(); - this.size = in.readLong(); - this.container = in.readString(); - this.bitrate = in.readInt(); - this.extension = in.readString(); - this.added = in.readLong(); - this.type = in.readString(); - this.playCount = in.readInt(); - this.lastPlay = in.readLong(); - this.rating = in.readInt(); - this.publishDate = in.readLong(); - } - - public static final Creator CREATOR = new Creator() { - public Media createFromParcel(Parcel source) { - return new Media(source); - } - - public Media[] newArray(int size) { - return new Media[size]; - } - }; -} diff --git a/app/src/main/java/com/cappielloantonio/play/model/Media.kt b/app/src/main/java/com/cappielloantonio/play/model/Media.kt new file mode 100644 index 00000000..389de2f3 --- /dev/null +++ b/app/src/main/java/com/cappielloantonio/play/model/Media.kt @@ -0,0 +1,215 @@ +package com.cappielloantonio.play.model + +import android.os.Parcelable +import androidx.annotation.Keep +import com.cappielloantonio.play.subsonic.models.Child +import com.cappielloantonio.play.subsonic.models.PodcastEpisode +import kotlinx.android.parcel.Parcelize + +@Keep +@Parcelize +class Media( + val id: String?, + val title: String?, + val channelId: String?, + val streamId: String?, + val albumId: String?, + val albumName: String?, + val artistId: String?, + val artistName: String?, + val coverArtId: String?, + val trackNumber: Int?, + val discNumber: Int?, + val year: Int?, + val duration: Long?, + val description: String?, + val status: String?, + var starred: Boolean?, + val path: String?, + val size: Long?, + val container: String?, + val bitrate: Int, + val extension: String?, + val added: Long?, + val type: String?, + val playCount: Int?, + val lastPlay: Long?, + val rating: Int?, + val publishDate: Long? +) : Parcelable { + + constructor(child: Child) : this( + child.id, + child.title, + null, + null, + child.albumId, + child.album, + child.artistId, + child.artist, + child.coverArtId, + child.track, + child.discNumber, + child.year, + child.duration.toLong(), + null, + null, + child.starred != null, + child.path, + child.size, + child.contentType, + child.bitRate, + child.suffix, + child.created.time, + child.type, + 0, + 0, + child.userRating, + 0 + ) + + constructor(podcastEpisode: PodcastEpisode) : this( + podcastEpisode.id, + podcastEpisode.title, + podcastEpisode.channelId, + podcastEpisode.streamId, + null, + podcastEpisode.album, + null, + podcastEpisode.artist, + podcastEpisode.coverArtId, + podcastEpisode.track, + null, + podcastEpisode.year, + podcastEpisode.duration.toLong(), + podcastEpisode.description, + podcastEpisode.status, + podcastEpisode.starred != null, + null, + null, + podcastEpisode.contentType, + podcastEpisode.bitRate, + podcastEpisode.suffix, + podcastEpisode.created.time, + podcastEpisode.type, + null, + null, + podcastEpisode.userRating, + podcastEpisode.publishDate.time + ) + + constructor(queue: Queue) : this( + queue.id, + queue.title, + queue.channelId, + queue.streamId, + queue.albumId, + queue.albumName, + queue.artistId, + queue.artistName, + queue.coverArtId, + null, + null, + null, + queue.duration, + null, + null, + null, + null, + null, + queue.container, + queue.bitrate, + queue.extension, + null, + queue.type, + null, + null, + null, + queue.publishingDate + ) + + constructor(download: Download) : this( + download.mediaID, + download.title, + null, + null, + download.albumId, + download.albumName, + download.artistId, + download.artistName, + download.primary, + download.trackNumber, + null, + null, + download.duration, + null, + null, + null, + null, + null, + download.container, + download.bitrate, + download.extension, + null, + download.type, + null, + null, + null, + null + ) + + constructor(item: Chronology) : this( + item.trackId, + item.title, + null, + null, + item.albumId, + item.albumName, + item.artistId, + item.artistName, + item.coverArtId, + null, + null, + null, + item.duration, + null, + null, + null, + null, + null, + item.container, + item.bitrate, + item.extension, + null, + MEDIA_TYPE_MUSIC, + null, + null, + null, + null + ) + + companion object { + const val MEDIA_TYPE_MUSIC = "music" + const val MEDIA_TYPE_PODCAST = "podcast" + const val MEDIA_TYPE_AUDIOBOOK = "audiobook" + const val MEDIA_TYPE_VIDEO = "video" + + const val MEDIA_PLAYBACK_SPEED_080 = 0.8f + const val MEDIA_PLAYBACK_SPEED_100 = 1.0f + const val MEDIA_PLAYBACK_SPEED_125 = 1.25f + const val MEDIA_PLAYBACK_SPEED_150 = 1.50f + const val MEDIA_PLAYBACK_SPEED_175 = 1.75f + const val MEDIA_PLAYBACK_SPEED_200 = 2.0f + + const val RECENTLY_PLAYED = "RECENTLY_PLAYED" + const val MOST_PLAYED = "MOST_PLAYED" + const val RECENTLY_ADDED = "RECENTLY_ADDED" + const val BY_GENRE = "BY_GENRE" + const val BY_GENRES = "BY_GENRES" + const val BY_ARTIST = "BY_ARTIST" + const val BY_YEAR = "BY_YEAR" + const val STARRED = "STARRED" + const val DOWNLOADED = "DOWNLOADED" + const val FROM_ALBUM = "FROM_ALBUM" + } +} \ No newline at end of file diff --git a/app/src/main/java/com/cappielloantonio/play/model/Playlist.java b/app/src/main/java/com/cappielloantonio/play/model/Playlist.java deleted file mode 100644 index 5c8a4235..00000000 --- a/app/src/main/java/com/cappielloantonio/play/model/Playlist.java +++ /dev/null @@ -1,145 +0,0 @@ -package com.cappielloantonio.play.model; - -import android.os.Parcel; -import android.os.Parcelable; - -import androidx.annotation.NonNull; -import androidx.room.ColumnInfo; -import androidx.room.Entity; -import androidx.room.Ignore; -import androidx.room.PrimaryKey; - -@Entity(tableName = "playlist") -public class Playlist implements Parcelable { - public static final String ALL = "ALL"; - public static final String DOWNLOADED = "DOWNLOADED"; - - public static final String ORDER_BY_NAME = "ORDER_BY_NAME"; - public static final String ORDER_BY_RANDOM = "ORDER_BY_RANDOM"; - - @NonNull - @PrimaryKey - @ColumnInfo(name = "id") - private String id; - - @ColumnInfo(name = "playlist_name") - private String name; - - @ColumnInfo(name = "primary") - private String primary; - - @Ignore - private String blurHash; - - @ColumnInfo(name = "song_count") - private int songCount; - - @ColumnInfo(name = "playlist_duration") - private long duration; - - @ColumnInfo(name = "server") - private String server; - - public Playlist(com.cappielloantonio.play.subsonic.models.Playlist playlist) { - this.id = playlist.getId(); - this.name = playlist.getName(); - this.primary = playlist.getCoverArtId(); - this.blurHash = playlist.getCoverArtId(); - this.songCount = playlist.getSongCount(); - this.duration = playlist.getDuration(); - } - - @Ignore - public Playlist(String id, String name) { - this.id = id; - this.name = name; - } - - public Playlist(@NonNull String id, String name, String primary, int songCount, long duration, String server) { - this.id = id; - this.name = name; - this.primary = primary; - this.songCount = songCount; - this.duration = duration; - this.server = server; - } - - @NonNull - public String getId() { - return id; - } - - public String getName() { - return name; - } - - public String getPrimary() { - return primary; - } - - public String getBlurHash() { - return blurHash; - } - - public int getSongCount() { - return songCount; - } - - public long getDuration() { - return duration; - } - - public String getServer() { - return server; - } - - public void setServer(String server) { - this.server = server; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - Playlist playlist = (Playlist) o; - return id.equals(playlist.id); - } - - @Override - public int hashCode() { - return id.hashCode(); - } - - @NonNull - @Override - public String toString() { - return id; - } - - @Override - public int describeContents() { - return 0; - } - - @Override - public void writeToParcel(Parcel dest, int flags) { - dest.writeString(this.id); - dest.writeString(this.name); - } - - protected Playlist(Parcel in) { - this.id = in.readString(); - this.name = in.readString(); - } - - public static final Creator CREATOR = new Creator() { - public Playlist createFromParcel(Parcel source) { - return new Playlist(source); - } - - public Playlist[] newArray(int size) { - return new Playlist[size]; - } - }; -} \ No newline at end of file diff --git a/app/src/main/java/com/cappielloantonio/play/model/Playlist.kt b/app/src/main/java/com/cappielloantonio/play/model/Playlist.kt new file mode 100644 index 00000000..43284ee5 --- /dev/null +++ b/app/src/main/java/com/cappielloantonio/play/model/Playlist.kt @@ -0,0 +1,50 @@ +package com.cappielloantonio.play.model + +import android.os.Parcelable +import androidx.annotation.Keep +import androidx.room.ColumnInfo +import androidx.room.Entity +import androidx.room.Ignore +import androidx.room.PrimaryKey +import com.cappielloantonio.play.subsonic.models.Playlist +import kotlinx.android.parcel.Parcelize + +@Keep +@Parcelize +@Entity(tableName = "playlist") +class Playlist( + @PrimaryKey + @ColumnInfo(name = "id") + var id: String, + + @ColumnInfo(name = "playlist_name") + var name: String, + + @ColumnInfo(name = "primary") + var primary: String? = null, + + @ColumnInfo(name = "song_count") + var songCount: Int = 0, + + @ColumnInfo(name = "playlist_duration") + var duration: Long = 0, + + @ColumnInfo(name = "server") + var server: String? = null, +) : Parcelable { + + constructor(playlist: Playlist) : this( + playlist.id, + playlist.name, + playlist.coverArtId, + playlist.songCount, + playlist.duration.toLong() + ) + + companion object { + const val ALL = "ALL" + const val DOWNLOADED = "DOWNLOADED" + const val ORDER_BY_NAME = "ORDER_BY_NAME" + const val ORDER_BY_RANDOM = "ORDER_BY_RANDOM" + } +} \ No newline at end of file diff --git a/app/src/main/java/com/cappielloantonio/play/model/PodcastChannel.java b/app/src/main/java/com/cappielloantonio/play/model/PodcastChannel.java deleted file mode 100644 index 91369148..00000000 --- a/app/src/main/java/com/cappielloantonio/play/model/PodcastChannel.java +++ /dev/null @@ -1,113 +0,0 @@ -package com.cappielloantonio.play.model; - -import com.cappielloantonio.play.util.MappingUtil; - -import java.util.List; - -public class PodcastChannel { - protected String id; - protected String url; - protected String title; - protected String description; - protected String coverArtId; - protected String originalImageUrl; - protected String status; - protected String errorMessage; - protected List episodes; - - public PodcastChannel(com.cappielloantonio.play.subsonic.models.PodcastChannel podcastChannel) { - this.id = podcastChannel.getId(); - this.url = podcastChannel.getUrl(); - this.title = podcastChannel.getTitle(); - this.description = podcastChannel.getDescription(); - this.coverArtId = podcastChannel.getCoverArtId(); - this.originalImageUrl = podcastChannel.getOriginalImageUrl(); - this.status = podcastChannel.getStatus(); - this.errorMessage = podcastChannel.getErrorMessage(); - this.episodes = MappingUtil.mapPodcastEpisode(podcastChannel.getEpisodes()); - } - - public PodcastChannel(String id, String url, String title, String description, String coverArtId, String originalImageUrl, String status, String errorMessage, List episodes) { - this.id = id; - this.url = url; - this.title = title; - this.description = description; - this.coverArtId = coverArtId; - this.originalImageUrl = originalImageUrl; - this.status = status; - this.errorMessage = errorMessage; - this.episodes = episodes; - } - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getUrl() { - return url; - } - - public void setUrl(String url) { - this.url = url; - } - - public String getTitle() { - return title; - } - - public void setTitle(String title) { - this.title = title; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public String getCoverArtId() { - return coverArtId; - } - - public void setCoverArtId(String coverArtId) { - this.coverArtId = coverArtId; - } - - public String getOriginalImageUrl() { - return originalImageUrl; - } - - public void setOriginalImageUrl(String originalImageUrl) { - this.originalImageUrl = originalImageUrl; - } - - public String getStatus() { - return status; - } - - public void setStatus(String status) { - this.status = status; - } - - public String getErrorMessage() { - return errorMessage; - } - - public void setErrorMessage(String errorMessage) { - this.errorMessage = errorMessage; - } - - public List getEpisodes() { - return episodes; - } - - public void setEpisodes(List episodes) { - this.episodes = episodes; - } -} diff --git a/app/src/main/java/com/cappielloantonio/play/model/PodcastChannel.kt b/app/src/main/java/com/cappielloantonio/play/model/PodcastChannel.kt new file mode 100644 index 00000000..909d9f28 --- /dev/null +++ b/app/src/main/java/com/cappielloantonio/play/model/PodcastChannel.kt @@ -0,0 +1,34 @@ +package com.cappielloantonio.play.model + +import android.os.Parcelable +import androidx.annotation.Keep +import com.cappielloantonio.play.subsonic.models.PodcastChannel +import com.cappielloantonio.play.util.MappingUtil +import kotlinx.android.parcel.Parcelize + +@Keep +@Parcelize +class PodcastChannel( + var id: String, + var url: String, + var title: String, + var description: String, + var coverArtId: String, + var originalImageUrl: String, + var status: String, + var errorMessage: String, + var episodes: List, +) : Parcelable { + + constructor(podcastChannel: PodcastChannel) : this( + podcastChannel.id, + podcastChannel.url, + podcastChannel.title, + podcastChannel.description, + podcastChannel.coverArtId, + podcastChannel.originalImageUrl, + podcastChannel.status, + podcastChannel.errorMessage, + MappingUtil.mapPodcastEpisode(podcastChannel.episodes) + ) +} \ No newline at end of file diff --git a/app/src/main/java/com/cappielloantonio/play/model/Queue.java b/app/src/main/java/com/cappielloantonio/play/model/Queue.java deleted file mode 100644 index a996e2bf..00000000 --- a/app/src/main/java/com/cappielloantonio/play/model/Queue.java +++ /dev/null @@ -1,228 +0,0 @@ -package com.cappielloantonio.play.model; - -import androidx.room.ColumnInfo; -import androidx.room.Entity; -import androidx.room.PrimaryKey; - -@Entity(tableName = "queue") -public class Queue { - @PrimaryKey - @ColumnInfo(name = "track_order") - private int trackOrder; - - @ColumnInfo(name = "id") - private String id; - - @ColumnInfo(name = "title") - private String title; - - @ColumnInfo(name = "albumId") - private String albumId; - - @ColumnInfo(name = "albumName") - private String albumName; - - @ColumnInfo(name = "artistId") - private String artistId; - - @ColumnInfo(name = "artistName") - private String artistName; - - @ColumnInfo(name = "cover_art_id") - private String coverArtId; - - @ColumnInfo(name = "duration") - private long duration; - - @ColumnInfo(name = "last_play", defaultValue = "0") - private long lastPlay; - - @ColumnInfo(name = "playing_changed", defaultValue = "0") - private long playingChanged; - - @ColumnInfo(name = "stream_id") - private String streamId; - - @ColumnInfo(name = "channel_id") - private String channelId; - - @ColumnInfo(name = "publishing_date", defaultValue = "0") - private long publishingDate; - - @ColumnInfo(name = "container") - private String container; - - @ColumnInfo(name = "bitrate") - private int bitrate; - - @ColumnInfo(name = "extension") - private String extension; - - @ColumnInfo(name = "media_type") - private String type; - - public Queue(int trackOrder, String id, String title, String albumId, String albumName, String artistId, String artistName, String coverArtId, long duration, long lastPlay, long playingChanged, String streamId, String channelId, long publishingDate, String container, int bitrate, String extension, String type) { - this.trackOrder = trackOrder; - this.id = id; - this.title = title; - this.albumId = albumId; - this.albumName = albumName; - this.artistId = artistId; - this.artistName = artistName; - this.coverArtId = coverArtId; - this.duration = duration; - this.lastPlay = lastPlay; - this.playingChanged = playingChanged; - this.streamId = streamId; - this.channelId = channelId; - this.publishingDate = publishingDate; - this.container = container; - this.bitrate = bitrate; - this.extension = extension; - this.type = type; - } - - public int getTrackOrder() { - return trackOrder; - } - - public void setTrackOrder(int trackOrder) { - this.trackOrder = trackOrder; - } - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getTitle() { - return title; - } - - public void setTitle(String title) { - this.title = title; - } - - public String getAlbumId() { - return albumId; - } - - public void setAlbumId(String albumId) { - this.albumId = albumId; - } - - public String getAlbumName() { - return albumName; - } - - public void setAlbumName(String albumName) { - this.albumName = albumName; - } - - public String getArtistId() { - return artistId; - } - - public void setArtistId(String artistId) { - this.artistId = artistId; - } - - public String getArtistName() { - return artistName; - } - - public void setArtistName(String artistName) { - this.artistName = artistName; - } - - public String getCoverArtId() { - return coverArtId; - } - - public void setCoverArtId(String coverArtId) { - this.coverArtId = coverArtId; - } - - public long getDuration() { - return duration; - } - - public void setDuration(long duration) { - this.duration = duration; - } - - public long getLastPlay() { - return lastPlay; - } - - public void setLastPlay(long lastPlay) { - this.lastPlay = lastPlay; - } - - public long getPlayingChanged() { - return playingChanged; - } - - public void setPlayingChanged(long playingChanged) { - this.playingChanged = playingChanged; - } - - public String getStreamId() { - return streamId; - } - - public void setStreamId(String streamId) { - this.streamId = streamId; - } - - public String getChannelId() { - return channelId; - } - - public void setChannelId(String channelId) { - this.channelId = channelId; - } - - public long getPublishingDate() { - return publishingDate; - } - - public void setPublishingDate(long publishingDate) { - this.publishingDate = publishingDate; - } - - public String getContainer() { - return container; - } - - public void setContainer(String container) { - this.container = container; - } - - public int getBitrate() { - return bitrate; - } - - public void setBitrate(int bitrate) { - this.bitrate = bitrate; - } - - public String getExtension() { - return extension; - } - - public void setExtension(String extension) { - this.extension = extension; - } - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } -} diff --git a/app/src/main/java/com/cappielloantonio/play/model/Queue.kt b/app/src/main/java/com/cappielloantonio/play/model/Queue.kt new file mode 100644 index 00000000..bfd6d0c1 --- /dev/null +++ b/app/src/main/java/com/cappielloantonio/play/model/Queue.kt @@ -0,0 +1,68 @@ +package com.cappielloantonio.play.model + +import android.os.Parcelable +import androidx.annotation.Keep +import androidx.room.ColumnInfo +import androidx.room.Entity +import androidx.room.PrimaryKey +import kotlinx.android.parcel.Parcelize + +@Keep +@Parcelize +@Entity(tableName = "queue") +data class Queue( + @PrimaryKey + @ColumnInfo(name = "track_order") + val trackOrder: Int, + + @ColumnInfo(name = "id") + val id: String?, + + @ColumnInfo(name = "title") + val title: String?, + + @ColumnInfo(name = "albumId") + val albumId: String?, + + @ColumnInfo(name = "albumName") + val albumName: String?, + + @ColumnInfo(name = "artistId") + val artistId: String?, + + @ColumnInfo(name = "artistName") + val artistName: String?, + + @ColumnInfo(name = "cover_art_id") + val coverArtId: String?, + + @ColumnInfo(name = "duration") + val duration: Long, + + @ColumnInfo(name = "last_play", defaultValue = "0") + val lastPlay: Long, + + @ColumnInfo(name = "playing_changed", defaultValue = "0") + val playingChanged: Long, + + @ColumnInfo(name = "stream_id") + val streamId: String?, + + @ColumnInfo(name = "channel_id") + val channelId: String?, + + @ColumnInfo(name = "publishing_date", defaultValue = "0") + val publishingDate: Long, + + @ColumnInfo(name = "container") + val container: String?, + + @ColumnInfo(name = "bitrate") + val bitrate: Int, + + @ColumnInfo(name = "extension") + val extension: String?, + + @ColumnInfo(name = "media_type") + val type: String? +) : Parcelable \ No newline at end of file diff --git a/app/src/main/java/com/cappielloantonio/play/model/RecentSearch.java b/app/src/main/java/com/cappielloantonio/play/model/RecentSearch.java deleted file mode 100644 index d59f96f4..00000000 --- a/app/src/main/java/com/cappielloantonio/play/model/RecentSearch.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.cappielloantonio.play.model; - -import androidx.annotation.NonNull; -import androidx.room.ColumnInfo; -import androidx.room.Entity; -import androidx.room.PrimaryKey; - -@Entity(tableName = "recent_search") -public class RecentSearch { - @NonNull - @PrimaryKey - @ColumnInfo(name = "search") - private String search; - - public RecentSearch(@NonNull String search) { - this.search = search; - } - - @NonNull - public String getSearch() { - return search; - } - - public void setSearch(@NonNull String search) { - this.search = search; - } -} diff --git a/app/src/main/java/com/cappielloantonio/play/model/RecentSearch.kt b/app/src/main/java/com/cappielloantonio/play/model/RecentSearch.kt new file mode 100644 index 00000000..549a1e83 --- /dev/null +++ b/app/src/main/java/com/cappielloantonio/play/model/RecentSearch.kt @@ -0,0 +1,17 @@ +package com.cappielloantonio.play.model + +import android.os.Parcelable +import androidx.annotation.Keep +import androidx.room.ColumnInfo +import androidx.room.Entity +import androidx.room.PrimaryKey +import kotlinx.android.parcel.Parcelize + +@Keep +@Parcelize +@Entity(tableName = "recent_search") +data class RecentSearch( + @PrimaryKey + @ColumnInfo(name = "search") + var search: String +) : Parcelable diff --git a/app/src/main/java/com/cappielloantonio/play/model/Server.java b/app/src/main/java/com/cappielloantonio/play/model/Server.java deleted file mode 100644 index d1df6762..00000000 --- a/app/src/main/java/com/cappielloantonio/play/model/Server.java +++ /dev/null @@ -1,154 +0,0 @@ -package com.cappielloantonio.play.model; - -import android.os.Parcel; -import android.os.Parcelable; - -import androidx.annotation.NonNull; -import androidx.room.ColumnInfo; -import androidx.room.Entity; -import androidx.room.PrimaryKey; - -@Entity(tableName = "server") -public class Server implements Parcelable { - @NonNull - @PrimaryKey - @ColumnInfo(name = "id") - private String serverId; - - @ColumnInfo(name = "server_name") - private String serverName; - - @ColumnInfo(name = "username") - private String username; - - @ColumnInfo(name = "password") - private String password; - - @ColumnInfo(name = "address") - private String address; - - @ColumnInfo(name = "timestamp") - private long timestamp; - - @ColumnInfo(name = "low_security", defaultValue = "false") - private boolean lowSecurity; - - public Server(@NonNull String serverId, String serverName, String username, String password, String address, long timestamp, boolean lowSecurity) { - this.serverId = serverId; - this.serverName = serverName; - this.username = username; - this.password = password; - this.address = address; - this.timestamp = timestamp; - this.lowSecurity = lowSecurity; - } - - @NonNull - public String getServerId() { - return serverId; - } - - public void setServerId(@NonNull String serverId) { - this.serverId = serverId; - } - - public String getServerName() { - return serverName; - } - - public void setServerName(String serverName) { - this.serverName = serverName; - } - - public String getUsername() { - return username; - } - - public void setUsername(String username) { - this.username = username; - } - - public String getPassword() { - return password; - } - - public void setPassword(String password) { - this.password = password; - } - - public String getAddress() { - return address; - } - - public void setAddress(String address) { - this.address = address; - } - - public long getTimestamp() { - return timestamp; - } - - public void setTimestamp(long timestamp) { - this.timestamp = timestamp; - } - - public boolean isLowSecurity() { - return lowSecurity; - } - - public void setLowSecurity(boolean lowSecurity) { - this.lowSecurity = lowSecurity; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - Server server = (Server) o; - return serverId.equals(server.getServerId()); - } - - @Override - public int hashCode() { - return serverId.hashCode(); - } - - @NonNull - @Override - public String toString() { - return serverId; - } - - @Override - public int describeContents() { - return 0; - } - - @Override - public void writeToParcel(Parcel dest, int flags) { - dest.writeString(serverId); - dest.writeString(serverName); - dest.writeString(username); - dest.writeString(address); - dest.writeLong(timestamp); - } - - protected Server(Parcel in) { - this.serverId = in.readString(); - this.serverName = in.readString(); - this.username = in.readString(); - this.address = in.readString(); - this.timestamp = in.readLong(); - } - - public static final Creator CREATOR = new Creator() { - public Server createFromParcel(Parcel in) { - return new Server(in); - } - - public Server[] newArray(int size) { - return new Server[size]; - } - }; -} diff --git a/app/src/main/java/com/cappielloantonio/play/model/Server.kt b/app/src/main/java/com/cappielloantonio/play/model/Server.kt new file mode 100644 index 00000000..0cbdace7 --- /dev/null +++ b/app/src/main/java/com/cappielloantonio/play/model/Server.kt @@ -0,0 +1,35 @@ +package com.cappielloantonio.play.model + +import android.os.Parcelable +import androidx.annotation.Keep +import androidx.room.ColumnInfo +import androidx.room.Entity +import androidx.room.PrimaryKey +import kotlinx.android.parcel.Parcelize + +@Keep +@Parcelize +@Entity(tableName = "server") +data class Server( + @PrimaryKey + @ColumnInfo(name = "id") + val serverId: String, + + @ColumnInfo(name = "server_name") + val serverName: String, + + @ColumnInfo(name = "username") + val username: String, + + @ColumnInfo(name = "password") + val password: String, + + @ColumnInfo(name = "address") + val address: String, + + @ColumnInfo(name = "timestamp") + val timestamp: Long, + + @ColumnInfo(name = "low_security", defaultValue = "false") + val isLowSecurity: Boolean +) : Parcelable \ No newline at end of file diff --git a/app/src/main/java/com/cappielloantonio/play/repository/AlbumRepository.java b/app/src/main/java/com/cappielloantonio/play/repository/AlbumRepository.java index 8ba79070..2b16c483 100644 --- a/app/src/main/java/com/cappielloantonio/play/repository/AlbumRepository.java +++ b/app/src/main/java/com/cappielloantonio/play/repository/AlbumRepository.java @@ -218,29 +218,6 @@ public class AlbumRepository { return album; } - public MutableLiveData getAlbumInfo(String id) { - MutableLiveData album = new MutableLiveData<>(); - - App.getSubsonicClientInstance(application, false) - .getBrowsingClient() - .getAlbumInfo2(id) - .enqueue(new Callback() { - @Override - public void onResponse(@NonNull Call call, @NonNull Response response) { - if (response.isSuccessful() && response.body() != null && response.body().getAlbumInfo() != null) { - album.setValue(MappingUtil.mapAlbum(response.body().getAlbumInfo())); - } - } - - @Override - public void onFailure(@NonNull Call call, @NonNull Throwable t) { - - } - }); - - return album; - } - public void getInstantMix(Album album, int count, MediaCallback callback) { App.getSubsonicClientInstance(application, false) .getBrowsingClient() diff --git a/app/src/main/java/com/cappielloantonio/play/repository/PlaylistRepository.java b/app/src/main/java/com/cappielloantonio/play/repository/PlaylistRepository.java index aff01a20..1cb9b177 100644 --- a/app/src/main/java/com/cappielloantonio/play/repository/PlaylistRepository.java +++ b/app/src/main/java/com/cappielloantonio/play/repository/PlaylistRepository.java @@ -1,6 +1,7 @@ package com.cappielloantonio.play.repository; import android.app.Application; +import android.util.Log; import androidx.annotation.NonNull; import androidx.lifecycle.LiveData; @@ -108,12 +109,12 @@ public class PlaylistRepository { .enqueue(new Callback() { @Override public void onResponse(@NonNull Call call, @NonNull Response response) { - + Log.d("PLAYLIST", response.toString()); } @Override public void onFailure(@NonNull Call call, @NonNull Throwable t) { - + Log.d("PLAYLIST", t.toString()); } }); } diff --git a/app/src/main/java/com/cappielloantonio/play/ui/dialog/PlaylistChooserDialog.java b/app/src/main/java/com/cappielloantonio/play/ui/dialog/PlaylistChooserDialog.java index 51ffdefc..e0268b3d 100644 --- a/app/src/main/java/com/cappielloantonio/play/ui/dialog/PlaylistChooserDialog.java +++ b/app/src/main/java/com/cappielloantonio/play/ui/dialog/PlaylistChooserDialog.java @@ -82,7 +82,7 @@ public class PlaylistChooserDialog extends DialogFragment implements ClickCallba playlistDialogHorizontalAdapter = new PlaylistDialogHorizontalAdapter(requireContext(), this); bind.playlistDialogRecyclerView.setAdapter(playlistDialogHorizontalAdapter); - playlistChooserViewModel.getPlaylistList(getViewLifecycleOwner()).observe(getViewLifecycleOwner(), playlists -> { + playlistChooserViewModel.getPlaylistList(requireActivity()).observe(requireActivity(), playlists -> { if (playlists != null) { if (playlists.size() > 0) { if (bind != null) bind.noPlaylistsCreatedTextView.setVisibility(View.GONE); diff --git a/app/src/main/java/com/cappielloantonio/play/ui/dialog/PlaylistEditorDialog.java b/app/src/main/java/com/cappielloantonio/play/ui/dialog/PlaylistEditorDialog.java index a8fa3abd..bac2a09c 100644 --- a/app/src/main/java/com/cappielloantonio/play/ui/dialog/PlaylistEditorDialog.java +++ b/app/src/main/java/com/cappielloantonio/play/ui/dialog/PlaylistEditorDialog.java @@ -102,7 +102,7 @@ public class PlaylistEditorDialog extends DialogFragment { playlistDialogSongHorizontalAdapter = new PlaylistDialogSongHorizontalAdapter(requireContext()); bind.playlistSongRecyclerView.setAdapter(playlistDialogSongHorizontalAdapter); - playlistEditorViewModel.getPlaylistSongLiveList().observe(getViewLifecycleOwner(), songs -> playlistDialogSongHorizontalAdapter.setItems(songs)); + playlistEditorViewModel.getPlaylistSongLiveList().observe(requireActivity(), songs -> playlistDialogSongHorizontalAdapter.setItems(songs)); new ItemTouchHelper(new ItemTouchHelper.SimpleCallback(ItemTouchHelper.UP | ItemTouchHelper.DOWN, ItemTouchHelper.LEFT) { int originalPosition = -1; diff --git a/app/src/main/java/com/cappielloantonio/play/ui/fragment/ArtistPageFragment.java b/app/src/main/java/com/cappielloantonio/play/ui/fragment/ArtistPageFragment.java index 2759c6be..931c42f5 100644 --- a/app/src/main/java/com/cappielloantonio/play/ui/fragment/ArtistPageFragment.java +++ b/app/src/main/java/com/cappielloantonio/play/ui/fragment/ArtistPageFragment.java @@ -140,6 +140,7 @@ public class ArtistPageFragment extends Fragment implements ClickCallback { private void initPlayButtons() { bind.artistPageShuffleButton.setOnClickListener(v -> { ArtistRepository artistRepository = new ArtistRepository(App.getInstance()); + artistRepository.getArtistRandomSong(getViewLifecycleOwner(), artistPageViewModel.getArtist(), 20).observe(getViewLifecycleOwner(), songs -> { if (songs.size() > 0) { MediaManager.startQueue(mediaBrowserListenableFuture, requireContext(), songs, 0); diff --git a/app/src/main/java/com/cappielloantonio/play/ui/fragment/PlayerControllerFragment.java b/app/src/main/java/com/cappielloantonio/play/ui/fragment/PlayerControllerFragment.java index 7cc8dd2a..aa66106c 100644 --- a/app/src/main/java/com/cappielloantonio/play/ui/fragment/PlayerControllerFragment.java +++ b/app/src/main/java/com/cappielloantonio/play/ui/fragment/PlayerControllerFragment.java @@ -240,7 +240,7 @@ public class PlayerControllerFragment extends Fragment { private void initMediaListenable() { playerBottomSheetViewModel.getLiveMedia().observe(getViewLifecycleOwner(), media -> { if (media != null) { - buttonFavorite.setChecked(media.isStarred()); + buttonFavorite.setChecked(Boolean.TRUE.equals(media.getStarred())); buttonFavorite.setOnClickListener(v -> playerBottomSheetViewModel.setFavorite(requireContext(), media)); buttonFavorite.setOnLongClickListener(v -> { Bundle bundle = new Bundle(); diff --git a/app/src/main/java/com/cappielloantonio/play/ui/fragment/bottomsheetdialog/AlbumBottomSheetDialog.java b/app/src/main/java/com/cappielloantonio/play/ui/fragment/bottomsheetdialog/AlbumBottomSheetDialog.java index 577c4eb6..9395087a 100644 --- a/app/src/main/java/com/cappielloantonio/play/ui/fragment/bottomsheetdialog/AlbumBottomSheetDialog.java +++ b/app/src/main/java/com/cappielloantonio/play/ui/fragment/bottomsheetdialog/AlbumBottomSheetDialog.java @@ -93,7 +93,7 @@ public class AlbumBottomSheetDialog extends BottomSheetDialogFragment implements artistAlbum.setText(MusicUtil.getReadableString(albumBottomSheetViewModel.getAlbum().getArtistName())); ToggleButton favoriteToggle = view.findViewById(R.id.button_favorite); - favoriteToggle.setChecked(albumBottomSheetViewModel.getAlbum().isFavorite()); + favoriteToggle.setChecked(Boolean.TRUE.equals(albumBottomSheetViewModel.getAlbum().getStarred())); favoriteToggle.setOnClickListener(v -> { albumBottomSheetViewModel.setFavorite(); dismissBottomSheet(); diff --git a/app/src/main/java/com/cappielloantonio/play/ui/fragment/bottomsheetdialog/ArtistBottomSheetDialog.java b/app/src/main/java/com/cappielloantonio/play/ui/fragment/bottomsheetdialog/ArtistBottomSheetDialog.java index 9c5c0f90..c50c0f20 100644 --- a/app/src/main/java/com/cappielloantonio/play/ui/fragment/bottomsheetdialog/ArtistBottomSheetDialog.java +++ b/app/src/main/java/com/cappielloantonio/play/ui/fragment/bottomsheetdialog/ArtistBottomSheetDialog.java @@ -88,7 +88,7 @@ public class ArtistBottomSheetDialog extends BottomSheetDialogFragment implement nameArtist.setSelected(true); ToggleButton favoriteToggle = view.findViewById(R.id.button_favorite); - favoriteToggle.setChecked(artistBottomSheetViewModel.getArtist().isFavorite()); + favoriteToggle.setChecked(Boolean.TRUE.equals(artistBottomSheetViewModel.getArtist().getStarred())); favoriteToggle.setOnClickListener(v -> { artistBottomSheetViewModel.setFavorite(); dismissBottomSheet(); diff --git a/app/src/main/java/com/cappielloantonio/play/ui/fragment/bottomsheetdialog/SongBottomSheetDialog.java b/app/src/main/java/com/cappielloantonio/play/ui/fragment/bottomsheetdialog/SongBottomSheetDialog.java index fbad457f..7c9814b2 100644 --- a/app/src/main/java/com/cappielloantonio/play/ui/fragment/bottomsheetdialog/SongBottomSheetDialog.java +++ b/app/src/main/java/com/cappielloantonio/play/ui/fragment/bottomsheetdialog/SongBottomSheetDialog.java @@ -90,7 +90,7 @@ public class SongBottomSheetDialog extends BottomSheetDialogFragment implements artistSong.setText(MusicUtil.getReadableString(songBottomSheetViewModel.getSong().getArtistName())); ToggleButton favoriteToggle = view.findViewById(R.id.button_favorite); - favoriteToggle.setChecked(songBottomSheetViewModel.getSong().isStarred()); + favoriteToggle.setChecked(Boolean.TRUE.equals(songBottomSheetViewModel.getSong().getStarred())); favoriteToggle.setOnClickListener(v -> { songBottomSheetViewModel.setFavorite(requireContext()); dismissBottomSheet(); diff --git a/app/src/main/java/com/cappielloantonio/play/util/MappingUtil.java b/app/src/main/java/com/cappielloantonio/play/util/MappingUtil.java index d262ba98..631d4c33 100644 --- a/app/src/main/java/com/cappielloantonio/play/util/MappingUtil.java +++ b/app/src/main/java/com/cappielloantonio/play/util/MappingUtil.java @@ -60,10 +60,6 @@ public class MappingUtil { return new Album(albumWithSongsID3); } - public static Album mapAlbum(AlbumInfo albumInfo) { - return new Album(albumInfo); - } - public static ArrayList mapArtist(List artistID3List) { ArrayList artists = new ArrayList(); @@ -173,7 +169,7 @@ public class MappingUtil { ArrayList playlists = new ArrayList(); for (Download download : downloads) { - playlists.add(new Playlist(download.getPlaylistId(), download.getPlaylistName())); + playlists.add(new Playlist(download.getPlaylistId(), download.getPlaylistName(), null, 0, 0, null)); } return playlists; diff --git a/app/src/main/java/com/cappielloantonio/play/viewmodel/AlbumBottomSheetViewModel.java b/app/src/main/java/com/cappielloantonio/play/viewmodel/AlbumBottomSheetViewModel.java index 660998e2..7d23a994 100644 --- a/app/src/main/java/com/cappielloantonio/play/viewmodel/AlbumBottomSheetViewModel.java +++ b/app/src/main/java/com/cappielloantonio/play/viewmodel/AlbumBottomSheetViewModel.java @@ -45,12 +45,12 @@ public class AlbumBottomSheetViewModel extends AndroidViewModel { } public void setFavorite() { - if (album.isFavorite()) { + if (Boolean.TRUE.equals(album.getStarred())) { artistRepository.unstar(album.getId()); - album.setFavorite(false); + album.setStarred(false); } else { artistRepository.star(album.getId()); - album.setFavorite(true); + album.setStarred(true); } } } diff --git a/app/src/main/java/com/cappielloantonio/play/viewmodel/ArtistBottomSheetViewModel.java b/app/src/main/java/com/cappielloantonio/play/viewmodel/ArtistBottomSheetViewModel.java index 6f330fa2..dda967ef 100644 --- a/app/src/main/java/com/cappielloantonio/play/viewmodel/ArtistBottomSheetViewModel.java +++ b/app/src/main/java/com/cappielloantonio/play/viewmodel/ArtistBottomSheetViewModel.java @@ -28,12 +28,12 @@ public class ArtistBottomSheetViewModel extends AndroidViewModel { } public void setFavorite() { - if (artist.isFavorite()) { + if (Boolean.TRUE.equals(artist.getStarred())) { albumRepository.unstar(artist.getId()); - artist.setFavorite(false); + artist.setStarred(false); } else { albumRepository.star(artist.getId()); - artist.setFavorite(true); + artist.setStarred(true); } } } diff --git a/app/src/main/java/com/cappielloantonio/play/viewmodel/PlayerBottomSheetViewModel.java b/app/src/main/java/com/cappielloantonio/play/viewmodel/PlayerBottomSheetViewModel.java index d2a8e798..7b945e5a 100644 --- a/app/src/main/java/com/cappielloantonio/play/viewmodel/PlayerBottomSheetViewModel.java +++ b/app/src/main/java/com/cappielloantonio/play/viewmodel/PlayerBottomSheetViewModel.java @@ -4,10 +4,12 @@ import android.app.Application; import android.content.Context; import androidx.annotation.NonNull; +import androidx.annotation.OptIn; import androidx.lifecycle.AndroidViewModel; import androidx.lifecycle.LifecycleOwner; import androidx.lifecycle.LiveData; import androidx.lifecycle.MutableLiveData; +import androidx.media3.common.util.UnstableApi; import com.cappielloantonio.play.model.Artist; import com.cappielloantonio.play.model.Queue; @@ -22,6 +24,7 @@ import com.cappielloantonio.play.util.PreferenceUtil; import java.util.Collections; import java.util.List; +@OptIn(markerClass = UnstableApi.class) public class PlayerBottomSheetViewModel extends AndroidViewModel { private static final String TAG = "PlayerBottomSheetViewModel"; @@ -50,7 +53,7 @@ public class PlayerBottomSheetViewModel extends AndroidViewModel { public void setFavorite(Context context, Media media) { if (media != null) { - if (media.isStarred()) { + if (Boolean.TRUE.equals(media.getStarred())) { songRepository.unstar(media.getId()); media.setStarred(false); } else { diff --git a/app/src/main/java/com/cappielloantonio/play/viewmodel/SongBottomSheetViewModel.java b/app/src/main/java/com/cappielloantonio/play/viewmodel/SongBottomSheetViewModel.java index 9c75aa2d..135e0e6c 100644 --- a/app/src/main/java/com/cappielloantonio/play/viewmodel/SongBottomSheetViewModel.java +++ b/app/src/main/java/com/cappielloantonio/play/viewmodel/SongBottomSheetViewModel.java @@ -50,7 +50,7 @@ public class SongBottomSheetViewModel extends AndroidViewModel { } public void setFavorite(Context context) { - if (song.isStarred()) { + if (Boolean.TRUE.equals(song.getStarred())) { songRepository.unstar(song.getId()); song.setStarred(false); } else { diff --git a/build.gradle b/build.gradle index 7a40f001..4a258fba 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ buildscript { mavenCentral() } dependencies { - classpath 'com.android.tools.build:gradle:7.4.1' + classpath 'com.android.tools.build:gradle:7.4.2' classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.20' // NOTE: Do not place your application dependencies here; they belong