mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-14 05:05:06 +01:00
Glance widget fixes (#7706)
* Fix glance failing when there's too much children * Adjust cover error placeholder
This commit is contained in:
parent
3bc6b1e202
commit
16abfeeff0
@ -164,8 +164,7 @@ class UpdatesGridGlanceWidget : GlanceAppWidget() {
|
||||
Box(
|
||||
modifier = modifier
|
||||
.size(width = CoverWidth, height = CoverHeight)
|
||||
.appWidgetInnerRadius()
|
||||
.background(ColorProvider(R.color.appwidget_surface_variant)),
|
||||
.appWidgetInnerRadius(),
|
||||
) {
|
||||
if (cover != null) {
|
||||
Image(
|
||||
@ -179,11 +178,9 @@ class UpdatesGridGlanceWidget : GlanceAppWidget() {
|
||||
} else {
|
||||
// Enjoy placeholder
|
||||
Image(
|
||||
provider = ImageProvider(R.drawable.appwidget_cover_placeholder),
|
||||
provider = ImageProvider(R.drawable.appwidget_cover_error),
|
||||
contentDescription = null,
|
||||
modifier = GlanceModifier
|
||||
.fillMaxSize()
|
||||
.padding(4.dp),
|
||||
modifier = GlanceModifier.fillMaxSize(),
|
||||
contentScale = ContentScale.Crop,
|
||||
)
|
||||
}
|
||||
@ -281,7 +278,8 @@ private val ContainerModifier = GlanceModifier
|
||||
*/
|
||||
private fun DpSize.calculateRowAndColumnCount(): Pair<Int, Int> {
|
||||
// Hack: Size provided by Glance manager is not reliable so take at least 1 row and 1 column
|
||||
val rowCount = (height.value / 95).toInt().coerceAtLeast(1)
|
||||
val columnCount = (width.value / 64).toInt().coerceAtLeast(1)
|
||||
// Set max to 10 children each direction because of Glance limitation
|
||||
val rowCount = (height.value / 95).toInt().coerceIn(1, 10)
|
||||
val columnCount = (width.value / 64).toInt().coerceIn(1, 10)
|
||||
return Pair(rowCount, columnCount)
|
||||
}
|
||||
|
24
app/src/main/res/drawable/appwidget_cover_error.xml
Normal file
24
app/src/main/res/drawable/appwidget_cover_error.xml
Normal file
@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item>
|
||||
<shape android:shape="rectangle">
|
||||
<solid android:color="@color/cover_placeholder" />
|
||||
<corners android:radius="@dimen/appwidget_inner_radius" />
|
||||
</shape>
|
||||
</item>
|
||||
<item
|
||||
android:top="24dp"
|
||||
android:bottom="24dp"
|
||||
android:left="24dp"
|
||||
android:right="24dp">
|
||||
<vector
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:fillColor="@color/cover_placeholder"
|
||||
android:pathData="M21,5v6.59l-2.29,-2.3c-0.39,-0.39 -1.03,-0.39 -1.42,0L14,12.59 10.71,9.3c-0.39,-0.39 -1.02,-0.39 -1.41,0L6,12.59 3,9.58L3,5c0,-1.1 0.9,-2 2,-2h14c1.1,0 2,0.9 2,2zM18,11.42l3,3.01L21,19c0,1.1 -0.9,2 -2,2L5,21c-1.1,0 -2,-0.9 -2,-2v-6.58l2.29,2.29c0.39,0.39 1.02,0.39 1.41,0l3.3,-3.3 3.29,3.29c0.39,0.39 1.02,0.39 1.41,0l3.3,-3.28z"/>
|
||||
</vector>
|
||||
</item>
|
||||
</layer-list>
|
@ -1,9 +0,0 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:fillColor="@color/appwidget_background"
|
||||
android:pathData="M10,6L8.59,7.41 13.17,12l-4.58,4.59L10,18l6,-6z" />
|
||||
</vector>
|
Loading…
Reference in New Issue
Block a user