Removed favorite icon from mini player

This commit is contained in:
h4h13 2019-08-05 13:06:09 +05:30
parent 01804b7829
commit 8690cf5159
12 changed files with 168 additions and 183 deletions

View file

@ -13,7 +13,7 @@ android {
vectorDrawables.useSupportLibrary = true
applicationId "code.name.monkey.retromusic"
versionCode 355
versionCode 357
versionName '3.3.200'
multiDexEnabled true

File diff suppressed because one or more lines are too long

View file

@ -53,7 +53,7 @@ open class MiniPlayerFragment : AbsMusicServiceFragment(), MusicProgressViewUpda
setUpMiniPlayer()
miniPlayerImage.setOnClickListener {
toggleFavorite(MusicPlayerRemote.currentSong)
//toggleFavorite(MusicPlayerRemote.currentSong)
}
if (RetroUtil.isTablet()) {
@ -100,12 +100,12 @@ open class MiniPlayerFragment : AbsMusicServiceFragment(), MusicProgressViewUpda
override fun onServiceConnected() {
updateSongTitle()
updatePlayPauseDrawableState()
updateIsFavorite()
//updateIsFavorite()
}
override fun onPlayingMetaChanged() {
updateSongTitle()
updateIsFavorite()
//updateIsFavorite()
}
override fun onPlayStateChanged() {

View file

@ -12,36 +12,32 @@
* See the GNU General Public License for more details.
*/
package code.name.monkey.retromusic.service;
package code.name.monkey.retromusic.service
import android.database.ContentObserver;
import android.os.Handler;
import android.database.ContentObserver
import android.os.Handler
public class MediaStoreObserver extends ContentObserver implements Runnable {
// milliseconds to delay before calling refresh to aggregate events
private static final long REFRESH_DELAY = 500;
private final MusicService musicService;
private Handler mHandler;
class MediaStoreObserver(
private val musicService: MusicService,
private val mHandler: Handler
) : ContentObserver(mHandler), Runnable {
MediaStoreObserver(MusicService musicService, Handler handler) {
super(handler);
this.musicService = musicService;
mHandler = handler;
}
@Override
public void onChange(boolean selfChange) {
override fun onChange(selfChange: Boolean) {
// if a change is detected, remove any scheduled callback
// then post a new one. This is intended to prevent closely
// spaced events from generating multiple refresh calls
mHandler.removeCallbacks(this);
mHandler.postDelayed(this, REFRESH_DELAY);
mHandler.removeCallbacks(this)
mHandler.postDelayed(this, REFRESH_DELAY)
}
@Override
public void run() {
override fun run() {
// actually call refresh when the delayed callback fires
// do not send a sticky broadcast here
musicService.handleAndSendChangeInternal(MusicService.MEDIA_STORE_CHANGED);
musicService.handleAndSendChangeInternal(MusicService.MEDIA_STORE_CHANGED)
}
companion object {
// milliseconds to delay before calling refresh to aggregate events
private val REFRESH_DELAY: Long = 500
}
}

View file

@ -1088,6 +1088,7 @@ public class MusicService extends MediaBrowserServiceCompat implements SharedPre
try {
int newPosition = playback.seek(millis);
throttledSeekHandler.notifySeek();
updateMediaSessionPlaybackState();
return newPosition;
} catch (Exception e) {
return -1;

View file

@ -1,43 +0,0 @@
/*
* Copyright (c) 2019 Hemanth Savarala.
*
* Licensed under the GNU General Public License v3
*
* This is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by
* the Free Software Foundation either version 3 of the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*/
package code.name.monkey.retromusic.service;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import androidx.annotation.NonNull;
import java.lang.ref.WeakReference;
import static code.name.monkey.retromusic.service.MusicService.SAVE_QUEUES;
class QueueSaveHandler extends Handler {
@NonNull
private final WeakReference<MusicService> mService;
QueueSaveHandler(final MusicService service, @NonNull final Looper looper) {
super(looper);
mService = new WeakReference<>(service);
}
@Override
public void handleMessage(@NonNull Message msg) {
final MusicService service = mService.get();
if (msg.what == SAVE_QUEUES) {
service.saveQueuesImpl();
}
}
}

View file

@ -0,0 +1,35 @@
/*
* Copyright (c) 2019 Hemanth Savarala.
*
* Licensed under the GNU General Public License v3
*
* This is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by
* the Free Software Foundation either version 3 of the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*/
package code.name.monkey.retromusic.service
import android.os.Handler
import android.os.Looper
import android.os.Message
import code.name.monkey.retromusic.service.MusicService.SAVE_QUEUES
import java.lang.ref.WeakReference
internal class QueueSaveHandler(
musicService: MusicService,
looper: Looper
) : Handler(looper) {
private val service: WeakReference<MusicService> = WeakReference(musicService)
override fun handleMessage(msg: Message) {
val service: MusicService? = service.get()
if (msg.what == SAVE_QUEUES) {
service?.saveQueuesImpl()
}
}
}

View file

@ -1,50 +0,0 @@
/*
* Copyright (c) 2019 Hemanth Savarala.
*
* Licensed under the GNU General Public License v3
*
* This is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by
* the Free Software Foundation either version 3 of the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*/
package code.name.monkey.retromusic.service;
import code.name.monkey.retromusic.helper.StopWatch;
import code.name.monkey.retromusic.model.Song;
public class SongPlayCountHelper {
public static final String TAG = SongPlayCountHelper.class.getSimpleName();
private StopWatch stopWatch = new StopWatch();
private Song song = Song.getEmptySong();
public Song getSong() {
return song;
}
boolean shouldBumpPlayCount() {
return song.getDuration() * 0.5d < stopWatch.getElapsedTime();
}
void notifySongChanged(Song song) {
synchronized (this) {
stopWatch.reset();
this.song = song;
}
}
void notifyPlayStateChanged(boolean isPlaying) {
synchronized (this) {
if (isPlaying) {
stopWatch.start();
} else {
stopWatch.pause();
}
}
}
}

View file

@ -0,0 +1,50 @@
/*
* Copyright (c) 2019 Hemanth Savarala.
*
* Licensed under the GNU General Public License v3
*
* This is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by
* the Free Software Foundation either version 3 of the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*/
package code.name.monkey.retromusic.service
import code.name.monkey.retromusic.helper.StopWatch
import code.name.monkey.retromusic.model.Song
class SongPlayCountHelper {
private val stopWatch = StopWatch()
var song = Song.emptySong
private set
fun shouldBumpPlayCount(): Boolean {
return song.duration * 0.5 < stopWatch.elapsedTime
}
fun notifySongChanged(song: Song) {
synchronized(this) {
stopWatch.reset()
this.song = song
}
}
fun notifyPlayStateChanged(isPlaying: Boolean) {
synchronized(this) {
if (isPlaying) {
stopWatch.start()
} else {
stopWatch.pause()
}
}
}
companion object {
val TAG: String = SongPlayCountHelper::class.java.simpleName
}
}

View file

@ -1,43 +0,0 @@
/*
* Copyright (c) 2019 Hemanth Savarala.
*
* Licensed under the GNU General Public License v3
*
* This is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by
* the Free Software Foundation either version 3 of the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*/
package code.name.monkey.retromusic.service;
import android.os.Handler;
import static code.name.monkey.retromusic.service.MusicService.PLAY_STATE_CHANGED;
public class ThrottledSeekHandler implements Runnable {
// milliseconds to throttle before calling run() to aggregate events
private static final long THROTTLE = 500;
private final MusicService musicService;
private Handler handler;
ThrottledSeekHandler(MusicService musicService, Handler handler) {
this.musicService = musicService;
this.handler = handler;
}
void notifySeek() {
handler.removeCallbacks(this);
handler.postDelayed(this, THROTTLE);
}
@Override
public void run() {
musicService.savePositionInTrack();
musicService.sendPublicIntent(PLAY_STATE_CHANGED); // for musixmatch synced lyrics
}
}

View file

@ -0,0 +1,41 @@
/*
* Copyright (c) 2019 Hemanth Savarala.
*
* Licensed under the GNU General Public License v3
*
* This is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by
* the Free Software Foundation either version 3 of the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*/
package code.name.monkey.retromusic.service
import android.os.Handler
import code.name.monkey.retromusic.service.MusicService.PLAY_STATE_CHANGED
class ThrottledSeekHandler(
private val musicService: MusicService,
private val handler: Handler
) : Runnable {
fun notifySeek() {
handler.removeCallbacks(this)
handler.postDelayed(this, THROTTLE)
}
override fun run() {
musicService.savePositionInTrack()
musicService.sendPublicIntent(PLAY_STATE_CHANGED) // for musixmatch synced lyrics
}
companion object {
// milliseconds to throttle before calling run() to aggregate events
private val THROTTLE: Long = 500
}
}

View file

@ -12,46 +12,44 @@
* See the GNU General Public License for more details.
*/
package code.name.monkey.retromusic.service.playback;
import androidx.annotation.Nullable;
package code.name.monkey.retromusic.service.playback
public interface Playback {
interface Playback {
boolean setDataSource(String path);
val isInitialized: Boolean
void setNextDataSource(@Nullable String path);
val isPlaying: Boolean
void setCallbacks(PlaybackCallbacks callbacks);
val audioSessionId: Int
boolean isInitialized();
fun setDataSource(path: String): Boolean
boolean start();
fun setNextDataSource(path: String?)
void stop();
fun setCallbacks(callbacks: PlaybackCallbacks)
void release();
fun start(): Boolean
boolean pause();
fun stop()
boolean isPlaying();
fun release()
int duration();
fun pause(): Boolean
int position();
fun duration(): Int
int seek(int whereto);
fun position(): Int
boolean setVolume(float vol);
fun seek(whereto: Int): Int
boolean setAudioSessionId(int sessionId);
fun setVolume(vol: Float): Boolean
int getAudioSessionId();
fun setAudioSessionId(sessionId: Int): Boolean
interface PlaybackCallbacks {
void onTrackWentToNext();
fun onTrackWentToNext()
void onTrackEnded();
fun onTrackEnded()
}
}