widgets: add thin widget
Rework the smallest widgets to have no textual metadata, alongside adding a new widget size class. Turns out the last tiny widget redesign made the controls far too small. Instead, remove the textual metadata and make these widgets more akin to the small and wide widgets. This also introduces a new side class alongside that with more controls, again to make it similar to the other size classes.
This commit is contained in:
@@ -33,14 +33,21 @@ import org.oxycblt.auxio.util.newMainIntent
|
||||
fun createDefaultWidget(context: Context) = createViews(context, R.layout.widget_default)
|
||||
|
||||
/**
|
||||
* The tiny widget is for an edge-case situation where a widget falls under the size class of the
|
||||
* small widget, either via landscape mode or exceptionally small screens.
|
||||
* The tiny widget like a small or medium widget, but for landscape or exceptionally small screens.
|
||||
*/
|
||||
fun createTinyWidget(context: Context, state: WidgetComponent.WidgetState) =
|
||||
createViews(context, R.layout.widget_tiny)
|
||||
.applyMeta(context, state)
|
||||
.applyCover(context, state)
|
||||
.applyBasicControls(context, state)
|
||||
|
||||
/**
|
||||
* The thin widget is like a wide or large widget, but for landscape or exceptionally small screens.
|
||||
*/
|
||||
fun createThinWidget(context: Context, state: WidgetComponent.WidgetState) =
|
||||
createViews(context, R.layout.widget_thin)
|
||||
.applyCover(context, state)
|
||||
.applyFullControls(context, state)
|
||||
|
||||
/**
|
||||
* The small widget is for 2x2 widgets and just shows the cover art and playback controls. This is
|
||||
* generally because a Medium widget is too large for this widget size and a text-only widget is too
|
||||
|
||||
@@ -42,6 +42,8 @@ import org.oxycblt.auxio.util.unlikelyToBeNull
|
||||
* changes. This is tolerable.
|
||||
*
|
||||
* For more specific details about these sub-widgets, see Forms.kt.
|
||||
*
|
||||
* @author OxygenCobalt
|
||||
*/
|
||||
class WidgetProvider : AppWidgetProvider() {
|
||||
/*
|
||||
@@ -57,6 +59,7 @@ class WidgetProvider : AppWidgetProvider() {
|
||||
val views =
|
||||
mapOf(
|
||||
SizeF(180f, 100f) to createTinyWidget(context, state),
|
||||
SizeF(372f, 100f) to createThinWidget(context, state),
|
||||
SizeF(180f, 152f) to createSmallWidget(context, state),
|
||||
SizeF(272f, 152f) to createWideWidget(context, state),
|
||||
SizeF(180f, 270f) to createMediumWidget(context, state),
|
||||
@@ -122,13 +125,6 @@ class WidgetProvider : AppWidgetProvider() {
|
||||
val name = ComponentName(context, WidgetProvider::class.java)
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
||||
for (id in getAppWidgetIds(name)) {
|
||||
val options = getAppWidgetOptions(id)
|
||||
logD(
|
||||
options.getParcelableArrayList<SizeF>(AppWidgetManager.OPTION_APPWIDGET_SIZES)
|
||||
?: "no sizes")
|
||||
}
|
||||
|
||||
// Widgets are automatically responsive on Android 12, no need to do anything.
|
||||
updateAppWidget(name, RemoteViews(views))
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user