widgets: remove compact/mini widgets

Remove the compact and mini widgets, as there seems to be no real way
for both controls and metadata to be packed into them.
This commit is contained in:
OxygenCobalt 2021-08-17 19:44:41 -06:00
parent 73ec99a214
commit 1f9d23863f
No known key found for this signature in database
GPG key ID: 37DBE3621FE9AD47
14 changed files with 16 additions and 133 deletions

View file

@ -189,7 +189,7 @@ fun @receiver:DrawableRes Int.resolveDrawable(context: Context) =
* Resolve a drawable resource into an [AnimatedVectorDrawable]
* @see resolveDrawable
*/
fun @receiver:DrawableRes Int.toAnimDrawable(context: Context) =
fun @receiver:DrawableRes Int.resolveAnimDrawable(context: Context) =
resolveDrawable(context) as AnimatedVectorDrawable
/**

View file

@ -26,19 +26,20 @@ import android.util.AttributeSet
import androidx.annotation.RequiresApi
import androidx.appcompat.widget.AppCompatImageButton
import org.oxycblt.auxio.R
import org.oxycblt.auxio.toAnimDrawable
import org.oxycblt.auxio.resolveAnimDrawable
/**
* Custom [AppCompatImageButton] that handles the animated play/pause icons.
* @author OxygenCobalt
* TODO: Replace this with a material icon that does the path manipulation manually.
*/
class PlayPauseButton @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = -1
) : AppCompatImageButton(context, attrs, defStyleAttr) {
private val iconPauseToPlay = R.drawable.ic_pause_to_play.toAnimDrawable(context)
private val iconPlayToPause = R.drawable.ic_play_to_pause.toAnimDrawable(context)
private val iconPauseToPlay = R.drawable.ic_pause_to_play.resolveAnimDrawable(context)
private val iconPlayToPause = R.drawable.ic_play_to_pause.resolveAnimDrawable(context)
init {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {

View file

@ -94,19 +94,6 @@ fun createDefaultWidget(context: Context): RemoteViews {
return createViews(context, R.layout.widget_default)
}
fun createMiniWidget(context: Context, state: WidgetState): RemoteViews {
val views = createViews(context, R.layout.widget_mini)
views.applyMeta(state)
return views
}
fun createCompactWidget(context: Context, state: WidgetState): RemoteViews {
val views = createViews(context, R.layout.widget_compact)
views.applyMeta(state)
views.applyCover(context, state)
return views
}
fun createSmallWidget(context: Context, state: WidgetState): RemoteViews {
val views = createViews(context, R.layout.widget_small)
views.applyMeta(state)

View file

@ -71,13 +71,9 @@ class WidgetProvider : AppWidgetProvider() {
)
// Map each widget form to the cells where it would look at least okay.
// The large widgets are 140 instead of 110 so that they're backwards compatible
// with the old widget size reporting
val views = mapOf(
SizeF(180f, 40f) to createMiniWidget(context, state),
SizeF(250f, 40f) to createCompactWidget(context, state),
SizeF(180f, 140f) to createSmallWidget(context, state),
SizeF(250f, 140f) to createFullWidget(context, state)
SizeF(180f, 110f) to createSmallWidget(context, state),
SizeF(250f, 110f) to createFullWidget(context, state)
)
appWidgetManager.applyViewsCompat(context, views)

View file

@ -6,7 +6,7 @@
android:top="-2dp">
<shape android:shape="rectangle">
<stroke
android:width="0.5dp"
android:width="@dimen/size_stroke_small"
android:color="@color/divider" />
</shape>
</item>

View file

@ -1,11 +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="#00000000" />
<size
android:width="1000px"
android:height="1000px"/>
</shape>

View file

@ -22,6 +22,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@{header.name}"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:text="Songs" />

View file

@ -1,63 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@android:id/background"
android:background="?attr/colorSurface"
android:theme="@style/Theme.Widget"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<!--
We can't use ConstraintLayout on widgets due to RemoteView limitations, but
for this widget form to work, we need to get the cover to preserve it's aspect
ratio. So, we use a fixed-size 1000x1000 drawable and then align the cover view
to that so that the bounds will scale properly.
This is easily one of the worst layout hacks I've done, but it seems to work.
-->
<ImageView
android:id="@+id/widget_aspect_ratio"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:scaleType="fitCenter"
android:src="@drawable/ui_widget_aspect_ratio"
android:visibility="invisible"
tools:ignore="ContentDescription" />
<ImageView
android:id="@+id/widget_cover"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_alignStart="@id/widget_aspect_ratio"
android:layout_alignTop="@id/widget_aspect_ratio"
android:layout_alignEnd="@id/widget_aspect_ratio"
android:layout_alignBottom="@id/widget_aspect_ratio"
android:src="@drawable/ic_song"
tools:ignore="ContentDescription" />
<LinearLayout
android:id="@+id/widget_panel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:layout_toEndOf="@+id/widget_cover"
android:gravity="center"
android:orientation="vertical"
android:padding="@dimen/spacing_medium">
<TextView
android:id="@+id/widget_song"
style="@style/Widget.Component.AppWidget.TextView.Primary"
android:text="@string/def_widget_song" />
<TextView
android:id="@+id/widget_artist"
style="@style/Widget.Component.AppWidget.TextView.Secondary"
android:text="@string/def_widget_artist" />
</LinearLayout>
</RelativeLayout>

View file

@ -1,26 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/background"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentTop="true"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:background="?attr/colorSurface"
android:gravity="center"
android:orientation="vertical"
android:padding="@dimen/spacing_medium"
android:theme="@style/Theme.Widget">
<TextView
android:id="@+id/widget_song"
style="@style/Widget.Component.AppWidget.TextView.Primary"
android:text="@string/def_widget_song" />
<TextView
android:id="@+id/widget_artist"
style="@style/Widget.Component.AppWidget.TextView.Secondary"
android:text="@string/def_widget_artist" />
</LinearLayout>

View file

@ -1,8 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!--
TODO: Rejig these dimens to line up with the 8dp grid. Dimens like the stroke should
be increased.-->
<!-- TODO: Rejig these dimens to line up with the 8dp grid. -->
<!-- Spacing Namespace | Dimens for padding/margin attributes -->
<dimen name="spacing_micro">2dp</dimen>
@ -38,7 +36,8 @@
<dimen name="size_clear">32dp</dimen>
<dimen name="size_app_icon">48dp</dimen>
<dimen name="size_stroke">2dp</dimen>
<dimen name="size_stroke_small">1dp</dimen>
<dimen name="size_stroke_large">2dp</dimen>
<!-- Text Size Namespace | Text Sizes -->
<dimen name="text_size_small">16sp</dimen>

View file

@ -52,7 +52,6 @@
<item name="android:layout_width">0dp</item>
<item name="android:layout_weight">1</item>
<item name="android:scaleType">fitCenter</item>
<item name="android:padding">@dimen/spacing_micro</item>
</style>
<style name="Widget.Component.AppWidget.Button" parent="Widget.Component.AppWidget.Button.Base">

View file

@ -27,7 +27,7 @@
<style name="Widget.ProgressBar.Compact" parent="@style/Widget.AppCompat.ProgressBar.Horizontal">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">@dimen/size_stroke</item>
<item name="android:layout_height">@dimen/size_stroke_large</item>
<item name="android:progressBackgroundTint">?attr/colorControlNormal</item>
<item name="android:progressTint">?attr/colorAccent</item>
</style>
@ -216,6 +216,6 @@
<style name="Widget.Button.Vibrant.Secondary" parent="@style/Widget.Button.Vibrant.Base">
<item name="strokeColor">@color/divider</item>
<item name="strokeWidth">@dimen/size_stroke</item>
<item name="strokeWidth">@dimen/size_stroke_small</item>
</style>
</resources>

View file

@ -3,7 +3,7 @@
android:description="@string/info_widget_desc"
android:initialLayout="@layout/widget_small"
android:minResizeWidth="180dp"
android:minResizeHeight="40dp"
android:minResizeHeight="110dp"
android:previewLayout="@layout/widget_small"
android:resizeMode="horizontal|vertical"
android:minWidth="180dp"

View file

@ -4,7 +4,7 @@
android:minWidth="180dp"
android:minHeight="110dp"
android:minResizeWidth="180dp"
android:minResizeHeight="40dp"
android:minResizeHeight="110dp"
android:previewImage="@drawable/ui_widget_preview"
android:resizeMode="horizontal|vertical"
android:updatePeriodMillis="0"