diff --git a/app/build.gradle b/app/build.gradle index d4962fbb7..d2bb2f36b 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -11,7 +11,7 @@ android { defaultConfig { applicationId namespace - versionName "2.6.0-beta" + versionName "2.5.0" versionCode 19 // API 33 is still busted, waiting until the XML element issue is fixed diff --git a/app/src/main/java/org/oxycblt/auxio/widgets/WidgetComponent.kt b/app/src/main/java/org/oxycblt/auxio/widgets/WidgetComponent.kt index 43f3f7a86..14f80720f 100644 --- a/app/src/main/java/org/oxycblt/auxio/widgets/WidgetComponent.kt +++ b/app/src/main/java/org/oxycblt/auxio/widgets/WidgetComponent.kt @@ -22,6 +22,7 @@ import android.graphics.Bitmap import android.os.Build import coil.request.ImageRequest import coil.transform.RoundedCornersTransformation +import kotlin.math.sqrt import org.oxycblt.auxio.R import org.oxycblt.auxio.image.BitmapProvider import org.oxycblt.auxio.image.SquareFrameTransform @@ -93,23 +94,27 @@ class WidgetComponent(private val context: Context) : 0 } + // Resize the image in a such a way that we don't hit the RemoteView size + // limit. The limit is technically the byte-size of an RGB_8888 bitmap 1.5x + // the screen size, but the size of a RemoteView can for some reason be 10x + // the size of the binded bitmaps, which means we need to heavily reduce + // our image size as to make sure we stay around an order of magnitude below + // the memory limit. This fixed size is also needed to ensure consistent + // outlines on rounded images. + val metrics = context.resources.displayMetrics + val sw = metrics.widthPixels + val sh = metrics.heightPixels + builder.size((sqrt((6f * sw * sh)) / 8f).toInt()) + return if (cornerRadius > 0) { this@WidgetComponent.logD("Loading round covers: $cornerRadius") - val metrics = context.resources.displayMetrics - // Use RoundedCornersTransformation. This is because our hack to get a 1:1 // aspect ratio on widget ImageViews doesn't actually result in a square // ImageView, so clipToOutline won't work. - builder - .transformations( - SquareFrameTransform.INSTANCE, - RoundedCornersTransformation(cornerRadius.toFloat())) - // The output of RoundedCornersTransformation is dimension-dependent, - // so scale up the image to the screen size to ensure consistent radii. - // Make sure we stop at 1024, so we don't accidentally make a massive - // bitmap on very large screens. - .size(minOf(metrics.widthPixels, metrics.heightPixels, 1024)) + builder.transformations( + SquareFrameTransform.INSTANCE, + RoundedCornersTransformation(cornerRadius.toFloat())) } else { builder } diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml index 1b8759fa1..3391516ad 100644 --- a/app/src/main/res/values/dimens.xml +++ b/app/src/main/res/values/dimens.xml @@ -53,8 +53,6 @@ 88dp 128dp - 176dp - 110dp - @dimen/widget_width_min - @dimen/widget_height_min + 176dp + 100dp \ No newline at end of file diff --git a/app/src/main/res/xml-v31/widget_info.xml b/app/src/main/res/xml-v31/widget_info.xml index e618e617a..78fac7356 100644 --- a/app/src/main/res/xml-v31/widget_info.xml +++ b/app/src/main/res/xml-v31/widget_info.xml @@ -4,8 +4,6 @@ android:initialLayout="@layout/widget_default" android:minWidth="@dimen/widget_width_def" android:minHeight="@dimen/widget_height_def" - android:minResizeWidth="@dimen/widget_width_min" - android:minResizeHeight="@dimen/widget_height_min" android:previewImage="@drawable/ui_widget_preview" android:previewLayout="@layout/widget_small" android:resizeMode="horizontal|vertical" diff --git a/app/src/main/res/xml/widget_info.xml b/app/src/main/res/xml/widget_info.xml index 3ef1eb157..fb777a4be 100644 --- a/app/src/main/res/xml/widget_info.xml +++ b/app/src/main/res/xml/widget_info.xml @@ -3,8 +3,6 @@ android:initialLayout="@layout/widget_default" android:minWidth="@dimen/widget_width_def" android:minHeight="@dimen/widget_height_def" - android:minResizeWidth="@dimen/widget_width_min" - android:minResizeHeight="@dimen/widget_height_min" android:previewImage="@drawable/ui_widget_preview" android:resizeMode="horizontal|vertical" android:updatePeriodMillis="0"