widget: fix wafer cover setup
Apparently: 1. Some OEMs don't actually autocrop to rounded corners 2. I was not correctly using the right corner radius attributes in the first place, making it inconsistent. Let's fix that. Closes #730
This commit is contained in:
parent
dbfe9927bf
commit
3ca9b515cf
11 changed files with 32 additions and 24 deletions
|
@ -158,6 +158,7 @@ class WidgetProvider : AppWidgetProvider() {
|
||||||
uiSettings,
|
uiSettings,
|
||||||
)
|
)
|
||||||
.setupCover(context, state.takeIf { canDisplayWaferCover(uiSettings) })
|
.setupCover(context, state.takeIf { canDisplayWaferCover(uiSettings) })
|
||||||
|
.setupFillingCover(uiSettings)
|
||||||
.setupTimelineControls(context, state)
|
.setupTimelineControls(context, state)
|
||||||
|
|
||||||
private fun newWideWaferLayout(
|
private fun newWideWaferLayout(
|
||||||
|
@ -170,6 +171,7 @@ class WidgetProvider : AppWidgetProvider() {
|
||||||
uiSettings,
|
uiSettings,
|
||||||
)
|
)
|
||||||
.setupCover(context, state.takeIf { canDisplayWaferCover(uiSettings) })
|
.setupCover(context, state.takeIf { canDisplayWaferCover(uiSettings) })
|
||||||
|
.setupFillingCover(uiSettings)
|
||||||
.setupFullControls(context, state)
|
.setupFullControls(context, state)
|
||||||
|
|
||||||
private fun newThinDockedLayout(
|
private fun newThinDockedLayout(
|
||||||
|
@ -231,9 +233,9 @@ class WidgetProvider : AppWidgetProvider() {
|
||||||
// On API 31+, the bar should always be round in order to fit in with other widgets.
|
// On API 31+, the bar should always be round in order to fit in with other widgets.
|
||||||
val background =
|
val background =
|
||||||
if (useRoundedRemoteViews(uiSettings)) {
|
if (useRoundedRemoteViews(uiSettings)) {
|
||||||
R.drawable.ui_widget_bar_round
|
R.drawable.ui_widget_bg_round
|
||||||
} else {
|
} else {
|
||||||
R.drawable.ui_widget_bar_system
|
R.drawable.ui_widget_bg_sharp
|
||||||
}
|
}
|
||||||
setBackgroundResource(R.id.widget_controls, background)
|
setBackgroundResource(R.id.widget_controls, background)
|
||||||
return this
|
return this
|
||||||
|
@ -253,7 +255,7 @@ class WidgetProvider : AppWidgetProvider() {
|
||||||
if (useRoundedRemoteViews(uiSettings)) {
|
if (useRoundedRemoteViews(uiSettings)) {
|
||||||
R.drawable.ui_widget_bg_round
|
R.drawable.ui_widget_bg_round
|
||||||
} else {
|
} else {
|
||||||
R.drawable.ui_widget_bg_system
|
R.drawable.ui_widget_bg_sharp
|
||||||
}
|
}
|
||||||
setBackgroundResource(android.R.id.background, background)
|
setBackgroundResource(android.R.id.background, background)
|
||||||
return this
|
return this
|
||||||
|
@ -292,6 +294,20 @@ class WidgetProvider : AppWidgetProvider() {
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun RemoteViews.setupFillingCover(uiSettings: UISettings): RemoteViews {
|
||||||
|
// Below API 31, enable a rounded background only if round mode is enabled.
|
||||||
|
// On API 31+, the background should always be round in order to fit in with other
|
||||||
|
// widgets.
|
||||||
|
val background =
|
||||||
|
if (useRoundedRemoteViews(uiSettings)) {
|
||||||
|
R.drawable.ui_widget_bg_round
|
||||||
|
} else {
|
||||||
|
R.drawable.ui_widget_bg_sharp
|
||||||
|
}
|
||||||
|
setBackgroundResource(R.id.widget_cover, background)
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set up the album cover, song title, and artist name in a [RemoteViews] layout that contains
|
* Set up the album cover, song title, and artist name in a [RemoteViews] layout that contains
|
||||||
* them.
|
* them.
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:shape="rectangle">
|
android:shape="rectangle">
|
||||||
<corners android:radius="@android:dimen/system_app_widget_background_radius" />
|
|
||||||
<solid android:color="@android:color/white" />
|
<solid android:color="@android:color/white" />
|
||||||
|
<corners android:radius="@android:dimen/system_app_widget_background_radius" />
|
||||||
</shape>
|
</shape>
|
|
@ -1,6 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:shape="rectangle">
|
|
||||||
<corners android:radius="@dimen/size_corners_mid_large" />
|
|
||||||
<solid android:color="@android:color/white" />
|
|
||||||
</shape>
|
|
|
@ -1,5 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:shape="rectangle">
|
|
||||||
<solid android:color="@android:color/white" />
|
|
||||||
</shape>
|
|
|
@ -61,7 +61,7 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_alignParentBottom="true"
|
android:layout_alignParentBottom="true"
|
||||||
android:layout_gravity="center"
|
android:layout_gravity="center"
|
||||||
android:background="@drawable/ui_widget_bar_system"
|
android:background="@drawable/ui_widget_bg_round"
|
||||||
android:backgroundTint="?attr/colorSurface"
|
android:backgroundTint="?attr/colorSurface"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
android:padding="@dimen/spacing_mid_medium">
|
android:padding="@dimen/spacing_mid_medium">
|
||||||
|
|
|
@ -48,7 +48,7 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_alignParentBottom="true"
|
android:layout_alignParentBottom="true"
|
||||||
android:layout_gravity="center"
|
android:layout_gravity="center"
|
||||||
android:background="@drawable/ui_widget_bar_system"
|
android:background="@drawable/ui_widget_bg_round"
|
||||||
android:backgroundTint="?attr/colorSurface"
|
android:backgroundTint="?attr/colorSurface"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
android:padding="@dimen/spacing_mid_medium">
|
android:padding="@dimen/spacing_mid_medium">
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
android:id="@android:id/background"
|
android:id="@android:id/background"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:background="@drawable/ui_widget_bg_system"
|
android:background="@drawable/ui_widget_bg_sharp"
|
||||||
android:backgroundTint="?attr/colorSurface"
|
android:backgroundTint="?attr/colorSurface"
|
||||||
android:theme="@style/Theme.Auxio.Widget">
|
android:theme="@style/Theme.Auxio.Widget">
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
android:id="@android:id/background"
|
android:id="@android:id/background"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:background="@drawable/ui_widget_bg_system"
|
android:background="@drawable/ui_widget_bg_sharp"
|
||||||
android:backgroundTint="?attr/colorSurface"
|
android:backgroundTint="?attr/colorSurface"
|
||||||
android:theme="@style/Theme.Auxio.Widget">
|
android:theme="@style/Theme.Auxio.Widget">
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
android:id="@android:id/background"
|
android:id="@android:id/background"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:background="@drawable/ui_widget_bg_system"
|
android:background="@drawable/ui_widget_bg_sharp"
|
||||||
android:backgroundTint="?attr/colorSurface"
|
android:backgroundTint="?attr/colorSurface"
|
||||||
android:baselineAligned="false"
|
android:baselineAligned="false"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
|
@ -20,6 +20,8 @@
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:scaleType="centerCrop"
|
android:scaleType="centerCrop"
|
||||||
|
android:background="@drawable/ui_widget_bg_round"
|
||||||
|
android:clipToOutline="true"
|
||||||
tools:ignore="ContentDescription" />
|
tools:ignore="ContentDescription" />
|
||||||
|
|
||||||
<android.widget.LinearLayout
|
<android.widget.LinearLayout
|
||||||
|
|
|
@ -4,22 +4,23 @@
|
||||||
android:id="@android:id/background"
|
android:id="@android:id/background"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:background="@drawable/ui_widget_bg_system"
|
android:background="@drawable/ui_widget_bg_sharp"
|
||||||
android:backgroundTint="?attr/colorSurface"
|
android:backgroundTint="?attr/colorSurface"
|
||||||
android:baselineAligned="false"
|
android:baselineAligned="false"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
android:theme="@style/Theme.Auxio.Widget">
|
android:theme="@style/Theme.Auxio.Widget">
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
Wrapping the 1:1 ImageView hack in a LinearLayout allows the view to measure greedily
|
clipToOutline won't actually do anything before Android 12, but that's fine since we won't
|
||||||
without squishing the controls.
|
show a cover then anyway.
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<android.widget.ImageView
|
<android.widget.ImageView
|
||||||
android:id="@+id/widget_cover"
|
android:id="@+id/widget_cover"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:scaleType="centerCrop"
|
android:scaleType="centerCrop"
|
||||||
|
android:background="@drawable/ui_widget_bg_round"
|
||||||
|
android:clipToOutline="true"
|
||||||
tools:ignore="ContentDescription" />
|
tools:ignore="ContentDescription" />
|
||||||
|
|
||||||
<android.widget.LinearLayout
|
<android.widget.LinearLayout
|
||||||
|
|
Loading…
Reference in a new issue