Added new dark icon
This commit is contained in:
parent
0456914e2a
commit
9ea7735261
68 changed files with 306 additions and 249 deletions
|
@ -9,6 +9,7 @@ import android.view.ViewGroup
|
|||
import code.name.monkey.appthemehelper.ThemeStore
|
||||
import code.name.monkey.retromusic.R
|
||||
import code.name.monkey.retromusic.model.PlaylistSong
|
||||
import code.name.monkey.retromusic.model.Song
|
||||
import code.name.monkey.retromusic.util.PlaylistsUtil
|
||||
import code.name.monkey.retromusic.views.RoundedBottomSheetDialogFragment
|
||||
import kotlinx.android.synthetic.main.dialog_remove_from_playlist.*
|
||||
|
@ -28,7 +29,7 @@ class RemoveFromPlaylistDialog : RoundedBottomSheetDialogFragment() {
|
|||
val songs = arguments!!.getParcelableArrayList<PlaylistSong>("songs")
|
||||
val title: Int
|
||||
val content: CharSequence
|
||||
if (songs != null && songs.size > 1) {
|
||||
if (songs!!.size > 1) {
|
||||
title = R.string.remove_songs_from_playlist_title
|
||||
content = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
Html.fromHtml(getString(R.string.remove_x_songs_from_playlist, songs.size), Html.FROM_HTML_MODE_LEGACY)
|
||||
|
@ -37,7 +38,7 @@ class RemoveFromPlaylistDialog : RoundedBottomSheetDialogFragment() {
|
|||
}
|
||||
} else {
|
||||
title = R.string.remove_song_from_playlist_title
|
||||
content = Html.fromHtml(getString(R.string.remove_song_x_from_playlist, songs!![0].title))
|
||||
content = Html.fromHtml(getString(R.string.remove_song_x_from_playlist, songs[0].title))
|
||||
}
|
||||
actionRemove.text = content
|
||||
bannerTitle.setText(title)
|
||||
|
@ -48,6 +49,7 @@ class RemoveFromPlaylistDialog : RoundedBottomSheetDialogFragment() {
|
|||
|
||||
actionRemove.setOnClickListener {
|
||||
PlaylistsUtil.removeFromPlaylist(activity!!, songs)
|
||||
dismiss()
|
||||
}
|
||||
actionCancel.setOnClickListener { dismiss() }
|
||||
}
|
||||
|
|
|
@ -63,7 +63,7 @@ public final class RetroGlideExtension {
|
|||
}
|
||||
|
||||
public static Key createSignature(Song song) {
|
||||
return new MediaStoreSignature("", song.getDateModified(), 0);
|
||||
return new MediaStoreSignature("", song.dateModified, 0);
|
||||
}
|
||||
|
||||
public static Object getArtistModel(Artist artist) {
|
||||
|
@ -88,9 +88,9 @@ public final class RetroGlideExtension {
|
|||
|
||||
public static Object getSongModel(Song song, boolean ignoreMediaStore) {
|
||||
if (ignoreMediaStore) {
|
||||
return new AudioFileCover(song.getData());
|
||||
return new AudioFileCover(song.data);
|
||||
} else {
|
||||
return MusicUtil.getMediaStoreAlbumCoverUri(song.getAlbumId());
|
||||
return MusicUtil.getMediaStoreAlbumCoverUri(song.albumId);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ object MusicPlayerRemote {
|
|||
val currentSong: Song
|
||||
get() = if (musicService != null) {
|
||||
musicService!!.currentSong
|
||||
} else Song.emptySong
|
||||
} else Song.EMPTY_SONG
|
||||
|
||||
/**
|
||||
* Async
|
||||
|
|
|
@ -2,8 +2,6 @@ package code.name.monkey.retromusic.helper
|
|||
|
||||
import code.name.monkey.retromusic.model.Song
|
||||
|
||||
import java.util.Collections
|
||||
|
||||
|
||||
object ShuffleHelper {
|
||||
|
||||
|
|
|
@ -39,10 +39,7 @@ object GenreMenuHelper {
|
|||
return false
|
||||
}
|
||||
|
||||
private fun getGenreSongs(activity: Activity,
|
||||
genre: Genre): ArrayList<Song> {
|
||||
val songs: ArrayList<Song>
|
||||
songs = GenreLoader.getSongs(activity, genre.id).blockingFirst()
|
||||
return songs
|
||||
private fun getGenreSongs(activity: Activity, genre: Genre): ArrayList<Song> {
|
||||
return GenreLoader.getSongs(activity, genre.id).blockingFirst()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -86,7 +86,7 @@ open class AlbumLoader {
|
|||
}
|
||||
}
|
||||
|
||||
fun getSongLoaderSortOrder(): String {
|
||||
private fun getSongLoaderSortOrder(): String {
|
||||
return PreferenceUtil.getInstance().albumSortOrder + ", " +
|
||||
//PreferenceUtil.getInstance().getAlbumSongSortOrder() + "," +
|
||||
PreferenceUtil.getInstance().albumDetailSongSortOrder
|
||||
|
|
|
@ -2,9 +2,7 @@ package code.name.monkey.retromusic.loaders
|
|||
|
||||
|
||||
import android.content.Context
|
||||
import code.name.monkey.retromusic.misc.DisposingObserver
|
||||
import code.name.monkey.retromusic.model.Playlist
|
||||
import code.name.monkey.retromusic.model.Song
|
||||
import code.name.monkey.retromusic.model.smartplaylist.AbsSmartPlaylist
|
||||
import code.name.monkey.retromusic.model.smartplaylist.HistoryPlaylist
|
||||
import code.name.monkey.retromusic.model.smartplaylist.LastAddedPlaylist
|
||||
|
|
|
@ -58,7 +58,7 @@ object SongLoader {
|
|||
val artistId = cursor.getInt(9)
|
||||
val artistName = cursor.getString(10)
|
||||
|
||||
return Song(id, title, trackNumber, year, duration, data, dateModified, albumId, albumName,
|
||||
return Song(id, title, trackNumber, year, duration, data, dateModified, albumId, albumName?:"",
|
||||
artistId, artistName)
|
||||
}
|
||||
|
||||
|
@ -119,7 +119,7 @@ object SongLoader {
|
|||
val song: Song = if (cursor != null && cursor.moveToFirst()) {
|
||||
getSongFromCursorImpl(cursor)
|
||||
} else {
|
||||
Song.emptySong
|
||||
Song.EMPTY_SONG
|
||||
}
|
||||
cursor?.close()
|
||||
e.onNext(song)
|
||||
|
|
|
@ -36,6 +36,6 @@ class Album {
|
|||
}
|
||||
|
||||
fun safeGetFirstSong(): Song {
|
||||
return if (songs!!.isEmpty()) Song.emptySong else songs[0]
|
||||
return if (songs!!.isEmpty()) Song.EMPTY_SONG else songs[0]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,18 +1,10 @@
|
|||
package code.name.monkey.retromusic.model;
|
||||
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
public class PlaylistSong extends Song {
|
||||
public static final Parcelable.Creator<PlaylistSong> CREATOR = new Parcelable.Creator<PlaylistSong>() {
|
||||
public PlaylistSong createFromParcel(Parcel source) {
|
||||
return new PlaylistSong(source);
|
||||
}
|
||||
public static PlaylistSong EMPTY_PLAYLIST_SONG = new PlaylistSong(-1, "", -1, -1, -1, "", -1, -1, "", -1, "", -1, -1);
|
||||
|
||||
public PlaylistSong[] newArray(int size) {
|
||||
return new PlaylistSong[size];
|
||||
}
|
||||
};
|
||||
public final int playlistId;
|
||||
public final int idInPlayList;
|
||||
|
||||
|
@ -22,12 +14,6 @@ public class PlaylistSong extends Song {
|
|||
this.idInPlayList = idInPlayList;
|
||||
}
|
||||
|
||||
protected PlaylistSong(Parcel in) {
|
||||
super(in);
|
||||
this.playlistId = in.readInt();
|
||||
this.idInPlayList = in.readInt();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
|
@ -58,6 +44,7 @@ public class PlaylistSong extends Song {
|
|||
'}';
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
|
@ -69,4 +56,20 @@ public class PlaylistSong extends Song {
|
|||
dest.writeInt(this.playlistId);
|
||||
dest.writeInt(this.idInPlayList);
|
||||
}
|
||||
|
||||
protected PlaylistSong(Parcel in) {
|
||||
super(in);
|
||||
this.playlistId = in.readInt();
|
||||
this.idInPlayList = in.readInt();
|
||||
}
|
||||
|
||||
public static final Creator<PlaylistSong> CREATOR = new Creator<PlaylistSong>() {
|
||||
public PlaylistSong createFromParcel(Parcel source) {
|
||||
return new PlaylistSong(source);
|
||||
}
|
||||
|
||||
public PlaylistSong[] newArray(int size) {
|
||||
return new PlaylistSong[size];
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
137
app/src/main/java/code/name/monkey/retromusic/model/Song.java
Normal file
137
app/src/main/java/code/name/monkey/retromusic/model/Song.java
Normal file
|
@ -0,0 +1,137 @@
|
|||
package code.name.monkey.retromusic.model;
|
||||
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
/**
|
||||
* @author Karim Abou Zeid (kabouzeid)
|
||||
*/
|
||||
public class Song implements Parcelable {
|
||||
public static final Song EMPTY_SONG = new Song(-1, "", -1, -1, -1, "", -1, -1, "", -1, "");
|
||||
|
||||
public final int id;
|
||||
public final String title;
|
||||
public final int trackNumber;
|
||||
public final int year;
|
||||
public final long duration;
|
||||
public final String data;
|
||||
public final long dateModified;
|
||||
public final int albumId;
|
||||
public final String albumName;
|
||||
public final int artistId;
|
||||
public final String artistName;
|
||||
|
||||
public Song(int id, String title, int trackNumber, int year, long duration, String data, long dateModified, int albumId, String albumName, int artistId, String artistName) {
|
||||
this.id = id;
|
||||
this.title = title;
|
||||
this.trackNumber = trackNumber;
|
||||
this.year = year;
|
||||
this.duration = duration;
|
||||
this.data = data;
|
||||
this.dateModified = dateModified;
|
||||
this.albumId = albumId;
|
||||
this.albumName = albumName;
|
||||
this.artistId = artistId;
|
||||
this.artistName = artistName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
Song song = (Song) o;
|
||||
|
||||
if (id != song.id) return false;
|
||||
if (trackNumber != song.trackNumber) return false;
|
||||
if (year != song.year) return false;
|
||||
if (duration != song.duration) return false;
|
||||
if (dateModified != song.dateModified) return false;
|
||||
if (albumId != song.albumId) return false;
|
||||
if (artistId != song.artistId) return false;
|
||||
if (title != null ? !title.equals(song.title) : song.title != null) return false;
|
||||
if (data != null ? !data.equals(song.data) : song.data != null) return false;
|
||||
if (albumName != null ? !albumName.equals(song.albumName) : song.albumName != null)
|
||||
return false;
|
||||
return artistName != null ? artistName.equals(song.artistName) : song.artistName == null;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = id;
|
||||
result = 31 * result + (title != null ? title.hashCode() : 0);
|
||||
result = 31 * result + trackNumber;
|
||||
result = 31 * result + year;
|
||||
result = 31 * result + (int) (duration ^ (duration >>> 32));
|
||||
result = 31 * result + (data != null ? data.hashCode() : 0);
|
||||
result = 31 * result + (int) (dateModified ^ (dateModified >>> 32));
|
||||
result = 31 * result + albumId;
|
||||
result = 31 * result + (albumName != null ? albumName.hashCode() : 0);
|
||||
result = 31 * result + artistId;
|
||||
result = 31 * result + (artistName != null ? artistName.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Song{" +
|
||||
"id=" + id +
|
||||
", title='" + title + '\'' +
|
||||
", trackNumber=" + trackNumber +
|
||||
", year=" + year +
|
||||
", duration=" + duration +
|
||||
", data='" + data + '\'' +
|
||||
", dateModified=" + dateModified +
|
||||
", albumId=" + albumId +
|
||||
", albumName='" + albumName + '\'' +
|
||||
", artistId=" + artistId +
|
||||
", artistName='" + artistName + '\'' +
|
||||
'}';
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
dest.writeInt(this.id);
|
||||
dest.writeString(this.title);
|
||||
dest.writeInt(this.trackNumber);
|
||||
dest.writeInt(this.year);
|
||||
dest.writeLong(this.duration);
|
||||
dest.writeString(this.data);
|
||||
dest.writeLong(this.dateModified);
|
||||
dest.writeInt(this.albumId);
|
||||
dest.writeString(this.albumName);
|
||||
dest.writeInt(this.artistId);
|
||||
dest.writeString(this.artistName);
|
||||
}
|
||||
|
||||
protected Song(Parcel in) {
|
||||
this.id = in.readInt();
|
||||
this.title = in.readString();
|
||||
this.trackNumber = in.readInt();
|
||||
this.year = in.readInt();
|
||||
this.duration = in.readLong();
|
||||
this.data = in.readString();
|
||||
this.dateModified = in.readLong();
|
||||
this.albumId = in.readInt();
|
||||
this.albumName = in.readString();
|
||||
this.artistId = in.readInt();
|
||||
this.artistName = in.readString();
|
||||
}
|
||||
|
||||
public static final Creator<Song> CREATOR = new Creator<Song>() {
|
||||
public Song createFromParcel(Parcel source) {
|
||||
return new Song(source);
|
||||
}
|
||||
|
||||
public Song[] newArray(int size) {
|
||||
return new Song[size];
|
||||
}
|
||||
};
|
||||
}
|
|
@ -1,81 +0,0 @@
|
|||
package code.name.monkey.retromusic.model
|
||||
|
||||
import android.os.Parcel
|
||||
import android.os.Parcelable
|
||||
|
||||
|
||||
open class Song : Parcelable {
|
||||
val id: Int
|
||||
val title: String?
|
||||
val trackNumber: Int
|
||||
val year: Int
|
||||
val duration: Long
|
||||
val data: String?
|
||||
val dateModified: Long
|
||||
val albumId: Int
|
||||
val albumName: String?
|
||||
val artistId: Int
|
||||
val artistName: String?
|
||||
|
||||
constructor(id: Int, title: String, trackNumber: Int, year: Int, duration: Long, data: String, dateModified: Long, albumId: Int, albumName: String, artistId: Int, artistName: String) {
|
||||
this.id = id
|
||||
this.title = title
|
||||
this.trackNumber = trackNumber
|
||||
this.year = year
|
||||
this.duration = duration
|
||||
this.data = data
|
||||
this.dateModified = dateModified
|
||||
this.albumId = albumId
|
||||
this.albumName = albumName
|
||||
this.artistId = artistId
|
||||
this.artistName = artistName
|
||||
}
|
||||
|
||||
protected constructor(`in`: Parcel) {
|
||||
this.id = `in`.readInt()
|
||||
this.title = `in`.readString()
|
||||
this.trackNumber = `in`.readInt()
|
||||
this.year = `in`.readInt()
|
||||
this.duration = `in`.readLong()
|
||||
this.data = `in`.readString()
|
||||
this.dateModified = `in`.readLong()
|
||||
this.albumId = `in`.readInt()
|
||||
this.albumName = `in`.readString()
|
||||
this.artistId = `in`.readInt()
|
||||
this.artistName = `in`.readString()
|
||||
}
|
||||
|
||||
override fun describeContents(): Int {
|
||||
return 0
|
||||
}
|
||||
|
||||
override fun writeToParcel(dest: Parcel, flags: Int) {
|
||||
dest.writeInt(this.id)
|
||||
dest.writeString(this.title)
|
||||
dest.writeInt(this.trackNumber)
|
||||
dest.writeInt(this.year)
|
||||
dest.writeLong(this.duration)
|
||||
dest.writeString(this.data)
|
||||
dest.writeLong(this.dateModified)
|
||||
dest.writeInt(this.albumId)
|
||||
dest.writeString(this.albumName)
|
||||
dest.writeInt(this.artistId)
|
||||
dest.writeString(this.artistName)
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
var emptySong = Song(-1, "", -1, -1, -1, "", -1, -1, "", -1, "")
|
||||
|
||||
@JvmField
|
||||
val CREATOR: Parcelable.Creator<Song> = object : Parcelable.Creator<Song> {
|
||||
override fun createFromParcel(source: Parcel): Song {
|
||||
return Song(source)
|
||||
}
|
||||
|
||||
override fun newArray(size: Int): Array<Song> {
|
||||
return emptyArray()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,13 +1,8 @@
|
|||
package code.name.monkey.retromusic.mvp.contract
|
||||
|
||||
import code.name.monkey.retromusic.model.*
|
||||
import java.util.ArrayList
|
||||
|
||||
import code.name.monkey.retromusic.model.AbsCustomPlaylist
|
||||
import code.name.monkey.retromusic.model.Album
|
||||
import code.name.monkey.retromusic.model.Artist
|
||||
import code.name.monkey.retromusic.model.Genre
|
||||
import code.name.monkey.retromusic.model.Playlist
|
||||
import code.name.monkey.retromusic.model.Song
|
||||
import code.name.monkey.retromusic.mvp.BasePresenter
|
||||
import code.name.monkey.retromusic.mvp.BaseView
|
||||
|
||||
|
|
|
@ -162,17 +162,17 @@ public class MusicPlaybackQueueStore extends SQLiteOpenHelper {
|
|||
Song song = queue.get(i);
|
||||
ContentValues values = new ContentValues(4);
|
||||
|
||||
values.put(BaseColumns._ID, song.getId());
|
||||
values.put(AudioColumns.TITLE, song.getTitle());
|
||||
values.put(AudioColumns.TRACK, song.getTrackNumber());
|
||||
values.put(AudioColumns.YEAR, song.getYear());
|
||||
values.put(AudioColumns.DURATION, song.getDuration());
|
||||
values.put(AudioColumns.DATA, song.getData());
|
||||
values.put(AudioColumns.DATE_MODIFIED, song.getDateModified());
|
||||
values.put(AudioColumns.ALBUM_ID, song.getAlbumId());
|
||||
values.put(AudioColumns.ALBUM, song.getAlbumName());
|
||||
values.put(AudioColumns.ARTIST_ID, song.getArtistId());
|
||||
values.put(AudioColumns.ARTIST, song.getArtistName());
|
||||
values.put(BaseColumns._ID, song.id);
|
||||
values.put(AudioColumns.TITLE, song.title);
|
||||
values.put(AudioColumns.TRACK, song.trackNumber);
|
||||
values.put(AudioColumns.YEAR, song.year);
|
||||
values.put(AudioColumns.DURATION, song.duration);
|
||||
values.put(AudioColumns.DATA, song.data);
|
||||
values.put(AudioColumns.DATE_MODIFIED, song.dateModified);
|
||||
values.put(AudioColumns.ALBUM_ID, song.albumId);
|
||||
values.put(AudioColumns.ALBUM, song.albumName);
|
||||
values.put(AudioColumns.ARTIST_ID, song.artistId);
|
||||
values.put(AudioColumns.ARTIST, song.artistName);
|
||||
|
||||
database.insert(tableName, null, values);
|
||||
}
|
||||
|
|
|
@ -248,7 +248,7 @@ public class MusicService extends Service implements SharedPreferences.OnSharedP
|
|||
};
|
||||
|
||||
private static String getTrackUri(@NonNull Song song) {
|
||||
return MusicUtil.getSongFileUri(song.getId()).toString();
|
||||
return MusicUtil.getSongFileUri(song.id).toString();
|
||||
}
|
||||
|
||||
private static Bitmap copy(Bitmap bitmap) {
|
||||
|
@ -649,7 +649,7 @@ public class MusicService extends Service implements SharedPreferences.OnSharedP
|
|||
}
|
||||
|
||||
public void updateNotification() {
|
||||
if (playingNotification != null && getCurrentSong().getId() != -1) {
|
||||
if (playingNotification != null && getCurrentSong().id != -1) {
|
||||
playingNotification.update();
|
||||
}
|
||||
}
|
||||
|
@ -666,19 +666,19 @@ public class MusicService extends Service implements SharedPreferences.OnSharedP
|
|||
private void updateMediaSessionMetaData() {
|
||||
final Song song = getCurrentSong();
|
||||
|
||||
if (song.getId() == -1) {
|
||||
if (song.id == -1) {
|
||||
mediaSession.setMetadata(null);
|
||||
return;
|
||||
}
|
||||
|
||||
final MediaMetadataCompat.Builder metaData = new MediaMetadataCompat.Builder()
|
||||
.putString(MediaMetadataCompat.METADATA_KEY_ARTIST, song.getArtistName())
|
||||
.putString(MediaMetadataCompat.METADATA_KEY_ALBUM_ARTIST, song.getArtistName())
|
||||
.putString(MediaMetadataCompat.METADATA_KEY_ALBUM, song.getAlbumName())
|
||||
.putString(MediaMetadataCompat.METADATA_KEY_TITLE, song.getTitle())
|
||||
.putLong(MediaMetadataCompat.METADATA_KEY_DURATION, song.getDuration())
|
||||
.putString(MediaMetadataCompat.METADATA_KEY_ARTIST, song.artistName)
|
||||
.putString(MediaMetadataCompat.METADATA_KEY_ALBUM_ARTIST, song.artistName)
|
||||
.putString(MediaMetadataCompat.METADATA_KEY_ALBUM, song.albumName)
|
||||
.putString(MediaMetadataCompat.METADATA_KEY_TITLE, song.title)
|
||||
.putLong(MediaMetadataCompat.METADATA_KEY_DURATION, song.duration)
|
||||
.putLong(MediaMetadataCompat.METADATA_KEY_TRACK_NUMBER, getPosition() + 1)
|
||||
.putLong(MediaMetadataCompat.METADATA_KEY_YEAR, song.getYear())
|
||||
.putLong(MediaMetadataCompat.METADATA_KEY_YEAR, song.year)
|
||||
.putBitmap(MediaMetadataCompat.METADATA_KEY_ALBUM_ART, null);
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
|
@ -730,7 +730,7 @@ public class MusicService extends Service implements SharedPreferences.OnSharedP
|
|||
if (position >= 0 && position < getPlayingQueue().size()) {
|
||||
return getPlayingQueue().get(position);
|
||||
} else {
|
||||
return Song.Companion.getEmptySong();
|
||||
return Song.EMPTY_SONG;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -847,13 +847,13 @@ public class MusicService extends Service implements SharedPreferences.OnSharedP
|
|||
|
||||
public void removeSong(@NonNull Song song) {
|
||||
for (int i = 0; i < playingQueue.size(); i++) {
|
||||
if (playingQueue.get(i).getId() == song.getId()) {
|
||||
if (playingQueue.get(i).id == song.id) {
|
||||
playingQueue.remove(i);
|
||||
rePosition(i);
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < originalPlayingQueue.size(); i++) {
|
||||
if (originalPlayingQueue.get(i).getId() == song.getId()) {
|
||||
if (originalPlayingQueue.get(i).id == song.id) {
|
||||
originalPlayingQueue.remove(i);
|
||||
}
|
||||
}
|
||||
|
@ -1019,7 +1019,7 @@ public class MusicService extends Service implements SharedPreferences.OnSharedP
|
|||
public long getQueueDurationMillis(int position) {
|
||||
long duration = 0;
|
||||
for (int i = position + 1; i < playingQueue.size(); i++)
|
||||
duration += playingQueue.get(i).getDuration();
|
||||
duration += playingQueue.get(i).duration;
|
||||
return duration;
|
||||
}
|
||||
|
||||
|
@ -1073,11 +1073,11 @@ public class MusicService extends Service implements SharedPreferences.OnSharedP
|
|||
break;
|
||||
case SHUFFLE_MODE_NONE:
|
||||
this.shuffleMode = shuffleMode;
|
||||
int currentSongId = getCurrentSong().getId();
|
||||
int currentSongId = getCurrentSong().id;
|
||||
playingQueue = new ArrayList<>(originalPlayingQueue);
|
||||
int newPosition = 0;
|
||||
for (Song song : getPlayingQueue()) {
|
||||
if (song.getId() == currentSongId) {
|
||||
if (song.id == currentSongId) {
|
||||
newPosition = getPlayingQueue().indexOf(song);
|
||||
}
|
||||
}
|
||||
|
@ -1104,11 +1104,11 @@ public class MusicService extends Service implements SharedPreferences.OnSharedP
|
|||
|
||||
final Song song = getCurrentSong();
|
||||
|
||||
intent.putExtra("id", song.getId());
|
||||
intent.putExtra("artist", song.getArtistName());
|
||||
intent.putExtra("album", song.getAlbumName());
|
||||
intent.putExtra("track", song.getTitle());
|
||||
intent.putExtra("duration", song.getDuration());
|
||||
intent.putExtra("id", song.id);
|
||||
intent.putExtra("artist", song.artistName);
|
||||
intent.putExtra("album", song.albumName);
|
||||
intent.putExtra("track", song.title);
|
||||
intent.putExtra("duration", song.duration);
|
||||
intent.putExtra("position", (long) getSongProgressMillis());
|
||||
intent.putExtra("playing", isPlaying());
|
||||
intent.putExtra("scrobbling_source", RETRO_MUSIC_PACKAGE_NAME);
|
||||
|
@ -1143,9 +1143,9 @@ public class MusicService extends Service implements SharedPreferences.OnSharedP
|
|||
savePosition();
|
||||
savePositionInTrack();
|
||||
final Song currentSong = getCurrentSong();
|
||||
HistoryStore.getInstance(this).addSongId(currentSong.getId());
|
||||
HistoryStore.getInstance(this).addSongId(currentSong.id);
|
||||
if (songPlayCountHelper.shouldBumpPlayCount()) {
|
||||
SongPlayCountStore.getInstance(this).bumpPlayCount(songPlayCountHelper.getSong().getId());
|
||||
SongPlayCountStore.getInstance(this).bumpPlayCount(songPlayCountHelper.getSong().id);
|
||||
}
|
||||
songPlayCountHelper.notifySongChanged(currentSong);
|
||||
break;
|
||||
|
@ -1375,14 +1375,14 @@ public class MusicService extends Service implements SharedPreferences.OnSharedP
|
|||
public static final String TAG = SongPlayCountHelper.class.getSimpleName();
|
||||
|
||||
private StopWatch stopWatch = new StopWatch();
|
||||
private Song song = Song.Companion.getEmptySong();
|
||||
private Song song = Song.EMPTY_SONG;
|
||||
|
||||
public Song getSong() {
|
||||
return song;
|
||||
}
|
||||
|
||||
boolean shouldBumpPlayCount() {
|
||||
return song.getDuration() * 0.5d < stopWatch.getElapsedTime();
|
||||
return song.duration * 0.5d < stopWatch.getElapsedTime();
|
||||
}
|
||||
|
||||
void notifySongChanged(Song song) {
|
||||
|
|
|
@ -241,9 +241,9 @@ public class WearBrowserService extends MediaBrowserService {
|
|||
List<Song> songList = SongLoader.INSTANCE.getAllSongs(mContext).blockingFirst();
|
||||
for (Song song : songList) {
|
||||
fillMediaItems(mediaItems,
|
||||
String.valueOf(song.getId()),
|
||||
song.getTitle(),
|
||||
song.getArtistName(),
|
||||
String.valueOf(song.id),
|
||||
song.title,
|
||||
song.albumName,
|
||||
Uri.parse("android.resource://code.name.monkey.retromusic/drawable/default_album_art"),
|
||||
MediaBrowser.MediaItem.FLAG_PLAYABLE);
|
||||
}
|
||||
|
@ -253,9 +253,9 @@ public class WearBrowserService extends MediaBrowserService {
|
|||
List<Song> albumSongList = AlbumLoader.Companion.getAlbum(mContext, Integer.parseInt(parentId.substring(1))).blockingFirst().getSongs();
|
||||
for (Song song : albumSongList) {
|
||||
fillMediaItems(mediaItems,
|
||||
String.valueOf(song.getId()),
|
||||
song.getTitle(),
|
||||
song.getArtistName(),
|
||||
String.valueOf(song.id),
|
||||
song.title,
|
||||
song.albumName,
|
||||
Uri.parse("android.resource://code.name.monkey.retromusic/drawable/default_album_art"),
|
||||
MediaBrowser.MediaItem.FLAG_PLAYABLE);
|
||||
}
|
||||
|
@ -264,9 +264,9 @@ public class WearBrowserService extends MediaBrowserService {
|
|||
List<Song> artistSongs = ArtistLoader.INSTANCE.getArtist(mContext, Integer.parseInt(parentId.substring(1))).blockingFirst().getSongs();
|
||||
for (Song song : artistSongs) {
|
||||
fillMediaItems(mediaItems,
|
||||
String.valueOf(song.getId()),
|
||||
song.getTitle(),
|
||||
song.getAlbumName(),
|
||||
String.valueOf(song.id),
|
||||
song.title,
|
||||
song.albumName,
|
||||
Uri.parse("android.resource://code.name.monkey.retromusic/drawable/default_album_art"),
|
||||
MediaBrowser.MediaItem.FLAG_PLAYABLE);
|
||||
}
|
||||
|
@ -288,9 +288,9 @@ public class WearBrowserService extends MediaBrowserService {
|
|||
List<Song> playlistSongs = PlaylistSongsLoader.INSTANCE.getPlaylistSongList(mContext, Integer.parseInt(parentId.substring(1))).blockingFirst();
|
||||
for (Song song : playlistSongs) {
|
||||
fillMediaItems(mediaItems,
|
||||
String.valueOf(song.getId()),
|
||||
song.getTitle(),
|
||||
song.getAlbumName(),
|
||||
String.valueOf(song.id),
|
||||
song.title,
|
||||
song.albumName,
|
||||
Uri.parse("android.resource://code.name.monkey.retromusic/drawable/default_album_art"),
|
||||
MediaBrowser.MediaItem.FLAG_PLAYABLE);
|
||||
}
|
||||
|
|
|
@ -82,7 +82,7 @@ class ArtistDetailActivity : AbsSlidingMusicPanelActivity(), ArtistDetailContrac
|
|||
|
||||
setUpViews()
|
||||
|
||||
artistDetailsPresenter = ArtistDetailsPresenter(this, intent.extras)
|
||||
artistDetailsPresenter = ArtistDetailsPresenter(this, intent.extras!!)
|
||||
artistDetailsPresenter!!.subscribe()
|
||||
|
||||
contentContainer.setOnScrollChangeListener { _: NestedScrollView?, _: Int, scrollY: Int, _: Int, oldScrollY: Int ->
|
||||
|
|
|
@ -195,7 +195,6 @@ class PlaylistDetailActivity : AbsSlidingMusicPanelActivity(), CabHolder, Playli
|
|||
}
|
||||
|
||||
private fun setToolbarTitle(title: String) {
|
||||
|
||||
supportActionBar!!.title = title
|
||||
}
|
||||
|
||||
|
@ -230,11 +229,6 @@ class PlaylistDetailActivity : AbsSlidingMusicPanelActivity(), CabHolder, Playli
|
|||
super.onDestroy()
|
||||
}
|
||||
|
||||
override fun onPlayingMetaChanged() {
|
||||
super.onPlayingMetaChanged()
|
||||
songsPresenter!!.subscribe()
|
||||
}
|
||||
|
||||
override fun loading() {}
|
||||
|
||||
override fun showEmptyView() {
|
||||
|
@ -249,7 +243,6 @@ class PlaylistDetailActivity : AbsSlidingMusicPanelActivity(), CabHolder, Playli
|
|||
}
|
||||
|
||||
companion object {
|
||||
|
||||
var EXTRA_PLAYLIST = "extra_playlist"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@ import android.view.ViewGroup
|
|||
import android.widget.TextView
|
||||
import android.widget.Toast
|
||||
import androidx.annotation.LayoutRes
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.recyclerview.widget.DefaultItemAnimator
|
||||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
|
@ -63,6 +64,7 @@ class SupportDevelopmentActivity : AbsBaseActivity(), BillingProcessor.IBillingH
|
|||
setContentView(R.layout.activity_donation)
|
||||
|
||||
|
||||
|
||||
setStatusbarColorAuto()
|
||||
setNavigationbarColorAuto()
|
||||
setTaskDescriptionColorAuto()
|
||||
|
|
|
@ -26,7 +26,6 @@ import code.name.monkey.retromusic.ui.adapter.base.MediaEntryViewHolder
|
|||
import code.name.monkey.retromusic.util.MusicUtil
|
||||
import code.name.monkey.retromusic.util.NavigationUtil
|
||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||
import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions
|
||||
import com.simplecityapps.recyclerview_fastscroll.views.FastScrollRecyclerView
|
||||
import java.util.*
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ abstract class AbsOffsetSongAdapter : SongAdapter {
|
|||
|
||||
override// could also return null, just to be safe return empty song
|
||||
val song: Song
|
||||
get() = if (itemViewType == OFFSET_ITEM) Song.emptySong else dataSet[adapterPosition - 1]
|
||||
get() = if (itemViewType == OFFSET_ITEM) Song.EMPTY_SONG else dataSet[adapterPosition - 1]
|
||||
|
||||
override fun onClick(v: View?) {
|
||||
if (isInQuickSelectMode && itemViewType != OFFSET_ITEM) {
|
||||
|
|
|
@ -24,7 +24,7 @@ class OrderablePlaylistSongAdapter(activity: AppCompatActivity,
|
|||
private val onMoveItemListener: OnMoveItemListener?) : PlaylistSongAdapter(activity, dataSet, itemLayoutRes, usePalette, cabHolder), DraggableItemAdapter<OrderablePlaylistSongAdapter.ViewHolder> {
|
||||
|
||||
init {
|
||||
setMultiSelectMenuRes(R.menu.menu_playlists_songs_selection)
|
||||
setMultiSelectMenuRes(code.name.monkey.retromusic.R.menu.menu_playlists_songs_selection)
|
||||
}
|
||||
|
||||
override fun createViewHolder(view: View): SongAdapter.ViewHolder {
|
||||
|
@ -49,9 +49,7 @@ class OrderablePlaylistSongAdapter(activity: AppCompatActivity,
|
|||
override fun onMultipleItemAction(menuItem: MenuItem, selection: ArrayList<Song>) {
|
||||
when (menuItem.itemId) {
|
||||
R.id.action_remove_from_playlist -> {
|
||||
val songs = ArrayList<PlaylistSong>()
|
||||
songs.addAll(songs)
|
||||
RemoveFromPlaylistDialog.create(songs).show(activity.supportFragmentManager, "ADD_PLAYLIST")
|
||||
RemoveFromPlaylistDialog.create(selection as ArrayList<PlaylistSong>).show(activity.supportFragmentManager, "ADD_PLAYLIST")
|
||||
return
|
||||
}
|
||||
}
|
||||
|
@ -94,8 +92,8 @@ class OrderablePlaylistSongAdapter(activity: AppCompatActivity,
|
|||
private var mDragStateFlags: Int = 0
|
||||
|
||||
override var songMenuRes: Int
|
||||
get() = R.menu.menu_item_playlist_song
|
||||
set(value: Int) {
|
||||
get() = code.name.monkey.retromusic.R.menu.menu_item_playlist_song
|
||||
set(value) {
|
||||
super.songMenuRes = value
|
||||
}
|
||||
|
||||
|
@ -111,7 +109,7 @@ class OrderablePlaylistSongAdapter(activity: AppCompatActivity,
|
|||
|
||||
override fun onSongMenuItemClick(item: MenuItem): Boolean {
|
||||
when (item.itemId) {
|
||||
R.id.action_remove_from_playlist -> {
|
||||
code.name.monkey.retromusic.R.id.action_remove_from_playlist -> {
|
||||
RemoveFromPlaylistDialog.create(song as PlaylistSong).show(activity.supportFragmentManager, "REMOVE_FROM_PLAYLIST")
|
||||
return true
|
||||
}
|
||||
|
@ -130,7 +128,6 @@ class OrderablePlaylistSongAdapter(activity: AppCompatActivity,
|
|||
}
|
||||
|
||||
companion object {
|
||||
|
||||
val TAG = OrderablePlaylistSongAdapter::class.java.simpleName
|
||||
val TAG: String = OrderablePlaylistSongAdapter::class.java.simpleName
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,14 +2,12 @@ package code.name.monkey.retromusic.ui.adapter.song
|
|||
|
||||
import android.view.MenuItem
|
||||
import android.view.View
|
||||
import android.widget.ImageView
|
||||
import androidx.annotation.LayoutRes
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.util.Pair
|
||||
import code.name.monkey.appthemehelper.ThemeStore
|
||||
import code.name.monkey.retromusic.R
|
||||
import code.name.monkey.retromusic.interfaces.CabHolder
|
||||
import code.name.monkey.retromusic.model.PlaylistSong
|
||||
import code.name.monkey.retromusic.model.Song
|
||||
import code.name.monkey.retromusic.util.MusicUtil
|
||||
import code.name.monkey.retromusic.util.NavigationUtil
|
||||
|
|
|
@ -12,7 +12,6 @@ import android.view.ViewGroup
|
|||
import android.widget.SeekBar
|
||||
import androidx.fragment.app.Fragment
|
||||
import code.name.monkey.appthemehelper.ThemeStore
|
||||
import code.name.monkey.appthemehelper.util.TintHelper
|
||||
import code.name.monkey.retromusic.R
|
||||
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||
|
@ -95,17 +94,14 @@ class VolumeFragment : Fragment(), SeekBar.OnSeekBarChangeListener, OnAudioVolum
|
|||
}
|
||||
|
||||
fun tintWhiteColor() {
|
||||
setProgressBarColor(Color.WHITE)
|
||||
setTintable(Color.WHITE)
|
||||
}
|
||||
|
||||
private fun setProgressBarColor(newColor: Int) {
|
||||
|
||||
val text = ColorStateList(arrayOf(intArrayOf(-android.R.attr.state_checked), intArrayOf(android.R.attr.state_checked)), intArrayOf(ThemeStore.textColorSecondary(context!!), ThemeStore.textColorPrimary(context!!)))
|
||||
|
||||
volumeSeekBar.progressTintList = text
|
||||
volumeSeekBar.progressBackgroundTintList = text
|
||||
|
||||
//TintHelper.setTint(volumeSeekBar, newColor, false)
|
||||
volumeSeekBar.thumbTintList = ColorStateList.valueOf(newColor)
|
||||
volumeSeekBar.progressTintList = ColorStateList.valueOf(newColor)
|
||||
volumeSeekBar.progressBackgroundTintList = ColorStateList.valueOf(newColor)
|
||||
volumeDown.setColorFilter(newColor, PorterDuff.Mode.SRC_IN)
|
||||
volumeUp.setColorFilter(newColor, PorterDuff.Mode.SRC_IN)
|
||||
}
|
||||
|
|
|
@ -364,7 +364,7 @@ public class FoldersFragment extends AbsMainActivityFragment implements
|
|||
File file1 = (File) extra;
|
||||
int startIndex = -1;
|
||||
for (int i = 0; i < songs.size(); i++) {
|
||||
if (file1.getPath().equals(songs.get(i).getData())) { // path is already canonical here
|
||||
if (file1.getPath().equals(songs.get(i).data)) { // path is already canonical here
|
||||
startIndex = i;
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ import android.view.animation.DecelerateInterpolator
|
|||
import android.view.animation.LinearInterpolator
|
||||
import android.widget.SeekBar
|
||||
import androidx.core.content.ContextCompat
|
||||
import code.name.monkey.appthemehelper.ThemeStore
|
||||
import code.name.monkey.appthemehelper.util.ColorUtil
|
||||
import code.name.monkey.appthemehelper.util.MaterialValueHelper
|
||||
import code.name.monkey.appthemehelper.util.TintHelper
|
||||
|
@ -129,8 +130,12 @@ class BlurPlaybackControlsFragment : AbsPlayerControlsFragment() {
|
|||
|
||||
private fun setProgressBarColor(newColor: Int) {
|
||||
val ld = progressSlider.progressDrawable as LayerDrawable
|
||||
val clipDrawable = ld.findDrawableByLayerId(android.R.id.progress) as ClipDrawable
|
||||
clipDrawable.setColorFilter(newColor, PorterDuff.Mode.SRC_IN)
|
||||
val clipDrawableProgress = ld.findDrawableByLayerId(android.R.id.progress) as ClipDrawable
|
||||
clipDrawableProgress.setColorFilter(newColor, PorterDuff.Mode.SRC_IN)
|
||||
|
||||
val clipDrawableBackground = ld.findDrawableByLayerId(android.R.id.background)
|
||||
clipDrawableBackground.setColorFilter(MaterialValueHelper.getPrimaryDisabledTextColor(context!!, ColorUtil.isColorLight(ThemeStore.primaryColor(context!!))), PorterDuff.Mode.SRC_IN)
|
||||
|
||||
}
|
||||
|
||||
private fun setUpPlayPauseFab() {
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
package code.name.monkey.retromusic.ui.fragments.player.color
|
||||
|
||||
import android.animation.ObjectAnimator
|
||||
import android.content.res.ColorStateList
|
||||
import android.graphics.Color
|
||||
import android.graphics.PorterDuff
|
||||
import android.graphics.drawable.ClipDrawable
|
||||
import android.graphics.drawable.LayerDrawable
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
|
@ -21,7 +24,7 @@ import code.name.monkey.retromusic.service.MusicService
|
|||
import code.name.monkey.retromusic.ui.fragments.VolumeFragment
|
||||
import code.name.monkey.retromusic.ui.fragments.base.AbsPlayerControlsFragment
|
||||
import code.name.monkey.retromusic.util.MusicUtil
|
||||
import kotlinx.android.synthetic.main.fragment_color_player_playback_controls.*
|
||||
import kotlinx.android.synthetic.main.fragment_player_playback_controls.*
|
||||
import kotlinx.android.synthetic.main.media_button.*
|
||||
import kotlinx.android.synthetic.main.player_time.*
|
||||
|
||||
|
@ -38,7 +41,6 @@ class ColorPlaybackControlsFragment : AbsPlayerControlsFragment() {
|
|||
}
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||
|
||||
return inflater.inflate(R.layout.fragment_color_player_playback_controls, container, false)
|
||||
}
|
||||
|
||||
|
@ -103,7 +105,7 @@ class ColorPlaybackControlsFragment : AbsPlayerControlsFragment() {
|
|||
title!!.setTextColor(lastPlaybackControlsColor)
|
||||
text!!.setTextColor(lastDisabledPlaybackControlsColor)
|
||||
|
||||
TintHelper.setTintAuto(progressSlider!!, lastPlaybackControlsColor, false)
|
||||
setProgressBarColor(lastPlaybackControlsColor, lastDisabledPlaybackControlsColor)
|
||||
|
||||
volumeFragment.setTintable(lastPlaybackControlsColor)
|
||||
|
||||
|
@ -115,6 +117,16 @@ class ColorPlaybackControlsFragment : AbsPlayerControlsFragment() {
|
|||
updatePrevNextColor()
|
||||
}
|
||||
|
||||
private fun setProgressBarColor(c1: Int, c2: Int) {
|
||||
progressSlider.thumbTintList = ColorStateList.valueOf(c1)
|
||||
val ld = progressSlider.progressDrawable as LayerDrawable
|
||||
|
||||
val clipDrawableProgress = ld.findDrawableByLayerId(android.R.id.progress) as ClipDrawable
|
||||
clipDrawableProgress.setColorFilter(c1, PorterDuff.Mode.SRC_IN)
|
||||
|
||||
val clipDrawableBackground = ld.findDrawableByLayerId(android.R.id.background)
|
||||
clipDrawableBackground.setColorFilter(c2, PorterDuff.Mode.SRC_IN)
|
||||
}
|
||||
|
||||
private fun setUpPlayPauseFab() {
|
||||
TintHelper.setTintAuto(playPauseButton, Color.WHITE, true)
|
||||
|
|
|
@ -56,7 +56,7 @@ class FlatPlayerFragment : AbsPlayerFragment(), PlayerAlbumCoverFragment.Callbac
|
|||
valueAnimator!!.addUpdateListener { animation ->
|
||||
val drawable = DrawableGradient(GradientDrawable.Orientation.TOP_BOTTOM,
|
||||
intArrayOf(animation.animatedValue as Int, android.R.color.transparent), 0)
|
||||
colorGradientBackground.background = drawable
|
||||
colorGradientBackground!!.background = drawable
|
||||
|
||||
}
|
||||
valueAnimator!!.setDuration(ViewUtil.RETRO_MUSIC_ANIM_TIME.toLong()).start()
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package code.name.monkey.retromusic.ui.fragments.player.material
|
||||
|
||||
import android.animation.ObjectAnimator
|
||||
import android.content.res.ColorStateList
|
||||
import android.graphics.PorterDuff
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
|
@ -21,6 +22,7 @@ import code.name.monkey.retromusic.ui.fragments.base.AbsPlayerControlsFragment
|
|||
import code.name.monkey.retromusic.util.MusicUtil
|
||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||
import kotlinx.android.synthetic.main.fragment_material_playback_controls.*
|
||||
import kotlinx.android.synthetic.main.fragment_volume.*
|
||||
import kotlinx.android.synthetic.main.player_time.*
|
||||
|
||||
/**
|
||||
|
@ -105,6 +107,10 @@ class MaterialControlsFragment : AbsPlayerControlsFragment() {
|
|||
if (PreferenceUtil.getInstance().adaptiveColor) {
|
||||
lastPlaybackControlsColor = color
|
||||
text.setTextColor(color)
|
||||
|
||||
progressSlider.thumbTintList = ColorStateList.valueOf(color)
|
||||
progressSlider.progressTintList = ColorStateList.valueOf(color)
|
||||
progressSlider.progressBackgroundTintList = ColorStateList.valueOf(color)
|
||||
}
|
||||
|
||||
updatePlayPauseColor()
|
||||
|
|
|
@ -1,20 +1,14 @@
|
|||
package code.name.monkey.retromusic.ui.fragments.player.normal
|
||||
|
||||
import android.animation.Animator
|
||||
import android.animation.AnimatorSet
|
||||
import android.animation.ArgbEvaluator
|
||||
import android.animation.ValueAnimator
|
||||
import android.graphics.drawable.GradientDrawable
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewAnimationUtils
|
||||
import android.view.ViewGroup
|
||||
import androidx.appcompat.widget.Toolbar
|
||||
import code.name.monkey.appthemehelper.ThemeStore
|
||||
import code.name.monkey.appthemehelper.util.ATHUtil
|
||||
import code.name.monkey.appthemehelper.util.ColorUtil
|
||||
import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper
|
||||
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
||||
import code.name.monkey.retromusic.model.Song
|
||||
|
@ -24,8 +18,6 @@ import code.name.monkey.retromusic.util.PreferenceUtil
|
|||
import code.name.monkey.retromusic.util.ViewUtil
|
||||
import code.name.monkey.retromusic.views.DrawableGradient
|
||||
import kotlinx.android.synthetic.main.fragment_player.*
|
||||
import kotlinx.android.synthetic.main.fragment_player_playback_controls.*
|
||||
import kotlinx.android.synthetic.main.media_button.*
|
||||
|
||||
|
||||
class PlayerFragment : AbsPlayerFragment(), PlayerAlbumCoverFragment.Callbacks {
|
||||
|
@ -45,9 +37,8 @@ class PlayerFragment : AbsPlayerFragment(), PlayerAlbumCoverFragment.Callbacks {
|
|||
|
||||
valueAnimator = ValueAnimator.ofObject(ArgbEvaluator(), android.R.color.transparent, i)
|
||||
valueAnimator!!.addUpdateListener { animation ->
|
||||
val drawable = DrawableGradient(GradientDrawable.Orientation.TOP_BOTTOM,
|
||||
intArrayOf(animation.animatedValue as Int, android.R.color.transparent), 0)
|
||||
colorGradientBackground.background = drawable
|
||||
val drawable = DrawableGradient(GradientDrawable.Orientation.TOP_BOTTOM, intArrayOf(animation.animatedValue as Int, android.R.color.transparent), 0)
|
||||
colorGradientBackground!!.background = drawable
|
||||
}
|
||||
valueAnimator!!.setDuration(ViewUtil.RETRO_MUSIC_ANIM_TIME.toLong()).start()
|
||||
}
|
||||
|
|
|
@ -28,7 +28,6 @@ import code.name.monkey.retromusic.util.PreferenceUtil
|
|||
import kotlinx.android.synthetic.main.fragment_player_playback_controls.*
|
||||
import kotlinx.android.synthetic.main.media_button.*
|
||||
import kotlinx.android.synthetic.main.player_time.*
|
||||
import kotlinx.android.synthetic.main.volume_controls.*
|
||||
|
||||
class PlayerPlaybackControlsFragment : AbsPlayerControlsFragment() {
|
||||
|
||||
|
@ -130,8 +129,12 @@ class PlayerPlaybackControlsFragment : AbsPlayerControlsFragment() {
|
|||
|
||||
private fun setProgressBarColor(newColor: Int) {
|
||||
val ld = progressSlider.progressDrawable as LayerDrawable
|
||||
val clipDrawable = ld.findDrawableByLayerId(android.R.id.progress) as ClipDrawable
|
||||
clipDrawable.setColorFilter(newColor, PorterDuff.Mode.SRC_IN)
|
||||
|
||||
val clipDrawableProgress = ld.findDrawableByLayerId(android.R.id.progress) as ClipDrawable
|
||||
clipDrawableProgress.setColorFilter(newColor, PorterDuff.Mode.SRC_IN)
|
||||
|
||||
val clipDrawableBackground = ld.findDrawableByLayerId(android.R.id.background)
|
||||
clipDrawableBackground.setColorFilter(MaterialValueHelper.getPrimaryDisabledTextColor(context!!, ColorUtil.isColorLight(ThemeStore.primaryColor(context!!))), PorterDuff.Mode.SRC_IN)
|
||||
}
|
||||
|
||||
private fun setUpPlayPauseFab() {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package code.name.monkey.retromusic.ui.fragments.player.plain
|
||||
|
||||
import android.animation.ObjectAnimator
|
||||
import android.content.res.ColorStateList
|
||||
import android.graphics.PorterDuff
|
||||
import android.graphics.drawable.ClipDrawable
|
||||
import android.graphics.drawable.LayerDrawable
|
||||
|
@ -28,7 +29,6 @@ import code.name.monkey.retromusic.util.PreferenceUtil
|
|||
import kotlinx.android.synthetic.main.fragment_plain_controls_fragment.*
|
||||
import kotlinx.android.synthetic.main.media_button.*
|
||||
import kotlinx.android.synthetic.main.player_time.*
|
||||
import kotlinx.android.synthetic.main.volume_controls.*
|
||||
|
||||
/**
|
||||
* @author Hemanth S (h4h13).
|
||||
|
@ -130,15 +130,16 @@ class PlainPlaybackControlsFragment : AbsPlayerControlsFragment() {
|
|||
if (PreferenceUtil.getInstance().adaptiveColor) {
|
||||
TintHelper.setTintAuto(playPauseButton, MaterialValueHelper.getPrimaryTextColor(context!!, ColorUtil.isColorLight(color)), false)
|
||||
TintHelper.setTintAuto(playPauseButton, color, true)
|
||||
setProgressBarColor(progressSlider, color)
|
||||
setProgressBarColor(color)
|
||||
}
|
||||
updateRepeatState()
|
||||
updateShuffleState()
|
||||
updatePrevNextColor()
|
||||
}
|
||||
|
||||
private fun setProgressBarColor(progressBar: SeekBar?, newColor: Int) {
|
||||
val ld = progressBar!!.progressDrawable as LayerDrawable
|
||||
private fun setProgressBarColor(newColor: Int) {
|
||||
progressSlider.thumbTintList = ColorStateList.valueOf(newColor)
|
||||
val ld = progressSlider.progressDrawable as LayerDrawable
|
||||
val clipDrawable = ld.findDrawableByLayerId(android.R.id.progress) as ClipDrawable
|
||||
clipDrawable.setColorFilter(newColor, PorterDuff.Mode.SRC_IN)
|
||||
}
|
||||
|
|
|
@ -16,6 +16,10 @@ import android.text.TextUtils;
|
|||
import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.core.content.FileProvider;
|
||||
|
||||
import org.jaudiotagger.audio.AudioFileIO;
|
||||
import org.jaudiotagger.tag.FieldKey;
|
||||
|
||||
|
@ -26,9 +30,6 @@ import java.util.List;
|
|||
import java.util.Locale;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.core.content.FileProvider;
|
||||
import code.name.monkey.retromusic.R;
|
||||
import code.name.monkey.retromusic.helper.MusicPlayerRemote;
|
||||
import code.name.monkey.retromusic.loaders.PlaylistLoader;
|
||||
|
@ -60,7 +61,7 @@ public class MusicUtil {
|
|||
public static Intent createShareSongFileIntent(@NonNull final Song song, Context context) {
|
||||
try {
|
||||
return new Intent().setAction(Intent.ACTION_SEND).putExtra(Intent.EXTRA_STREAM,
|
||||
FileProvider.getUriForFile(context, context.getApplicationContext().getPackageName(), new File(song.getData())))
|
||||
FileProvider.getUriForFile(context, context.getApplicationContext().getPackageName(), new File(song.data)))
|
||||
.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
|
||||
.setType("audio/*");
|
||||
} catch (IllegalArgumentException e) {
|
||||
|
@ -135,7 +136,7 @@ public class MusicUtil {
|
|||
|
||||
long duration = 0;
|
||||
for (int i = 0; i < songs.size(); i++) {
|
||||
duration += songs.get(i).getDuration();
|
||||
duration += songs.get(i).duration;
|
||||
}
|
||||
|
||||
return songCount + " " + songString + " • " + MusicUtil.getReadableDurationString(duration);
|
||||
|
@ -200,7 +201,7 @@ public class MusicUtil {
|
|||
final StringBuilder selection = new StringBuilder();
|
||||
selection.append(BaseColumns._ID + " IN (");
|
||||
for (int i = 0; i < songs.size(); i++) {
|
||||
selection.append(songs.get(i).getId());
|
||||
selection.append(songs.get(i).id);
|
||||
if (i < songs.size() - 1) {
|
||||
selection.append(",");
|
||||
}
|
||||
|
@ -264,7 +265,7 @@ public class MusicUtil {
|
|||
public static String getLyrics(Song song) {
|
||||
String lyrics = null;
|
||||
|
||||
File file = new File(song.getData());
|
||||
File file = new File(song.data);
|
||||
|
||||
try {
|
||||
lyrics = AudioFileIO.read(file).getTagOrCreateDefault().getFirst(FieldKey.LYRICS);
|
||||
|
@ -279,7 +280,7 @@ public class MusicUtil {
|
|||
if (dir != null && dir.exists() && dir.isDirectory()) {
|
||||
String format = ".*%s.*\\.(lrc|txt)";
|
||||
String filename = Pattern.quote(FileUtil.stripExtension(file.getName()));
|
||||
String songtitle = Pattern.quote(song.getTitle());
|
||||
String songtitle = Pattern.quote(song.title);
|
||||
|
||||
final ArrayList<Pattern> patterns = new ArrayList<>();
|
||||
patterns.add(Pattern.compile(String.format(format, filename),
|
||||
|
@ -352,7 +353,7 @@ public class MusicUtil {
|
|||
//getFavoritesPlaylist(context).blockingFirst().id.subscribe(MusicUtil::setPlaylist);
|
||||
//return PlaylistsUtil.doPlaylistContains(context, getFavoritesPlaylist(context).blockingFirst().id, song.id);
|
||||
return PlaylistsUtil
|
||||
.doPlaylistContains(context, getFavoritesPlaylist(context).blockingFirst().id, song.getId());
|
||||
.doPlaylistContains(context, getFavoritesPlaylist(context).blockingFirst().id, song.id);
|
||||
}
|
||||
|
||||
public static boolean isArtistNameUnknown(@Nullable String artistName) {
|
||||
|
@ -394,7 +395,7 @@ public class MusicUtil {
|
|||
public static long getTotalDuration(@NonNull final Context context, @NonNull List<Song> songs) {
|
||||
long duration = 0;
|
||||
for (int i = 0; i < songs.size(); i++) {
|
||||
duration += songs.get(i).getDuration();
|
||||
duration += songs.get(i).duration;
|
||||
}
|
||||
return duration;
|
||||
}
|
||||
|
|
|
@ -149,7 +149,7 @@ public class PlaylistsUtil {
|
|||
for (int i = 0; i < len; i++) {
|
||||
contentValues[i] = new ContentValues();
|
||||
contentValues[i].put(MediaStore.Audio.Playlists.Members.PLAY_ORDER, base + offset + i);
|
||||
contentValues[i].put(MediaStore.Audio.Playlists.Members.AUDIO_ID, songs.get(offset + i).getId());
|
||||
contentValues[i].put(MediaStore.Audio.Playlists.Members.AUDIO_ID, songs.get(offset + i).id);
|
||||
}
|
||||
return contentValues;
|
||||
}
|
||||
|
@ -158,7 +158,7 @@ public class PlaylistsUtil {
|
|||
Uri uri = MediaStore.Audio.Playlists.Members.getContentUri(
|
||||
"external", playlistId);
|
||||
String selection = MediaStore.Audio.Playlists.Members.AUDIO_ID + " =?";
|
||||
String[] selectionArgs = new String[]{String.valueOf(song.getId())};
|
||||
String[] selectionArgs = new String[]{String.valueOf(song.id)};
|
||||
|
||||
try {
|
||||
context.getContentResolver().delete(uri, selection, selectionArgs);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue