Fixed favorite button in Circle widget
This commit is contained in:
parent
2557b6950b
commit
c96dad999a
5 changed files with 12 additions and 3 deletions
|
@ -69,8 +69,8 @@
|
|||
<h2>v5.7.0</h2>
|
||||
<h3>What's New</h3>
|
||||
<ul>
|
||||
<li>Added new Circle widget</li>
|
||||
<li>Added accent color extraction on Android 8.1+ devices</li>
|
||||
<li>Added new Circle widget</li>
|
||||
<li>Added Collapsing appbar to library tabs with an option to switch back to simple appbar
|
||||
</li>
|
||||
<li>Added Search tab</li>
|
||||
|
|
|
@ -33,6 +33,7 @@ import code.name.monkey.retromusic.service.MusicService
|
|||
import code.name.monkey.retromusic.service.MusicService.ACTION_TOGGLE_PAUSE
|
||||
import code.name.monkey.retromusic.service.MusicService.TOGGLE_FAVORITE
|
||||
import code.name.monkey.retromusic.util.ImageUtil
|
||||
import code.name.monkey.retromusic.util.MusicUtil
|
||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||
import code.name.monkey.retromusic.util.RetroUtil
|
||||
import com.bumptech.glide.Glide
|
||||
|
@ -41,6 +42,8 @@ import com.bumptech.glide.request.RequestOptions
|
|||
import com.bumptech.glide.request.target.SimpleTarget
|
||||
import com.bumptech.glide.request.target.Target
|
||||
import com.bumptech.glide.request.transition.Transition
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.runBlocking
|
||||
|
||||
class AppWidgetCircle : BaseAppWidget() {
|
||||
private var target: Target<BitmapPaletteWrapper>? = null // for cancellation
|
||||
|
@ -89,7 +92,9 @@ class AppWidgetCircle : BaseAppWidget() {
|
|||
), 1f
|
||||
)
|
||||
)
|
||||
val isFavorite = true
|
||||
val isFavorite = runBlocking(Dispatchers.IO) {
|
||||
return@runBlocking MusicUtil.repository.isSongFavorite(song.id)
|
||||
}
|
||||
val favoriteRes =
|
||||
if (isFavorite) R.drawable.ic_favorite else R.drawable.ic_favorite_border
|
||||
appWidgetView.setImageViewBitmap(
|
||||
|
|
|
@ -58,7 +58,7 @@ abstract class BaseAppWidget : AppWidgetProvider() {
|
|||
*/
|
||||
fun notifyChange(service: MusicService, what: String) {
|
||||
if (hasInstances(service)) {
|
||||
if (META_CHANGED == what || PLAY_STATE_CHANGED == what) {
|
||||
if (META_CHANGED == what || PLAY_STATE_CHANGED == what || FAVORITE_STATE_CHANGED == what) {
|
||||
performUpdate(service, null)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -141,6 +141,7 @@ public class MusicService extends MediaBrowserServiceCompat
|
|||
public static final String META_CHANGED = RETRO_MUSIC_PACKAGE_NAME + ".metachanged";
|
||||
public static final String QUEUE_CHANGED = RETRO_MUSIC_PACKAGE_NAME + ".queuechanged";
|
||||
public static final String PLAY_STATE_CHANGED = RETRO_MUSIC_PACKAGE_NAME + ".playstatechanged";
|
||||
|
||||
public static final String FAVORITE_STATE_CHANGED =
|
||||
RETRO_MUSIC_PACKAGE_NAME + "favoritestatechanged";
|
||||
public static final String REPEAT_MODE_CHANGED = RETRO_MUSIC_PACKAGE_NAME + ".repeatmodechanged";
|
||||
|
@ -293,6 +294,7 @@ public class MusicService extends MediaBrowserServiceCompat
|
|||
public void onReceive(final Context context, final Intent intent) {
|
||||
playingNotification.updateFavorite(getCurrentSong(), MusicService.this::startForegroundOrNotify);
|
||||
startForegroundOrNotify();
|
||||
appWidgetCircle.notifyChange(MusicService.this, FAVORITE_STATE_CHANGED);
|
||||
}
|
||||
};
|
||||
private final BroadcastReceiver lockScreenReceiver =
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
android:layout_alignEnd="@+id/image"
|
||||
android:layout_margin="4dp"
|
||||
android:background="@drawable/circle_widget_background"
|
||||
android:backgroundTint="?attr/colorSurface"
|
||||
android:clickable="false"
|
||||
android:padding="14dp"
|
||||
android:scaleType="centerInside"
|
||||
|
@ -36,6 +37,7 @@
|
|||
android:layout_alignBottom="@+id/image"
|
||||
android:layout_margin="4dp"
|
||||
android:background="@drawable/widget_button_background"
|
||||
android:backgroundTint="?attr/colorSurface"
|
||||
android:clickable="false"
|
||||
android:padding="18dp"
|
||||
android:scaleType="centerInside"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue