Rounded corners of cover in widget (#6483)

This commit is contained in:
mueller-ma 2023-05-18 10:33:02 +02:00 committed by GitHub
parent 194067deea
commit 3da7fcf8f0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 0 deletions

View File

@ -13,6 +13,9 @@ import android.view.View;
import android.widget.RemoteViews;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.resource.bitmap.FitCenter;
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
import com.bumptech.glide.request.RequestOptions;
import java.util.concurrent.TimeUnit;
@ -83,10 +86,16 @@ public abstract class WidgetUpdater {
views.setOnClickPendingIntent(R.id.imgvCover, startMediaPlayer);
views.setOnClickPendingIntent(R.id.butPlaybackSpeed, startPlaybackSpeedDialog);
int radius = context.getResources().getDimensionPixelSize(R.dimen.widget_inner_radius);
RequestOptions options = new RequestOptions()
.dontAnimate()
.transform(new FitCenter(), new RoundedCorners(radius));
try {
icon = Glide.with(context)
.asBitmap()
.load(widgetState.media.getImageLocation())
.apply(options)
.submit(iconSize, iconSize)
.get(500, TimeUnit.MILLISECONDS);
views.setImageViewBitmap(R.id.imgvCover, icon);
@ -95,6 +104,7 @@ public abstract class WidgetUpdater {
icon = Glide.with(context)
.asBitmap()
.load(ImageResourceUtils.getFallbackImageLocation(widgetState.media))
.apply(options)
.submit(iconSize, iconSize)
.get(500, TimeUnit.MILLISECONDS);
views.setImageViewBitmap(R.id.imgvCover, icon);

View File

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<dimen name="widget_margin">0dp</dimen>
<dimen name="widget_inner_radius">4dp</dimen>
<dimen name="external_player_height">64dp</dimen>
<dimen name="text_size_micro">12sp</dimen>
<dimen name="text_size_small">14sp</dimen>