Add option to hide widget background card for app widgets
This commit is contained in:
parent
ad3e19ce0d
commit
69aa41bf8e
@ -437,6 +437,15 @@ fun ColumnScope.ConfigureAppWidget(
|
||||
onWidgetUpdated(widget.copy(config = widget.config.copy(borderless = it)))
|
||||
}
|
||||
)
|
||||
Divider()
|
||||
SwitchPreference(
|
||||
title = stringResource(R.string.widget_config_appwidget_background),
|
||||
iconPadding = false,
|
||||
value = widget.config.background,
|
||||
onValueChanged = {
|
||||
onWidgetUpdated(widget.copy(config = widget.config.copy(background = it)))
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
if (isAtLeastApiLevel(28) && widgetInfo.widgetFeatures and AppWidgetProviderInfo.WIDGET_FEATURE_RECONFIGURABLE != 0) {
|
||||
|
||||
@ -4,6 +4,7 @@ import android.appwidget.AppWidgetHost
|
||||
import android.appwidget.AppWidgetManager
|
||||
import androidx.compose.animation.AnimatedVisibility
|
||||
import androidx.compose.animation.core.animateDpAsState
|
||||
import androidx.compose.animation.core.animateFloatAsState
|
||||
import androidx.compose.foundation.gestures.DraggableState
|
||||
import androidx.compose.foundation.gestures.Orientation
|
||||
import androidx.compose.foundation.gestures.draggable
|
||||
@ -47,6 +48,7 @@ import de.mm20.launcher2.ui.launcher.widgets.favorites.FavoritesWidget
|
||||
import de.mm20.launcher2.ui.launcher.widgets.music.MusicWidget
|
||||
import de.mm20.launcher2.ui.launcher.widgets.notes.NotesWidget
|
||||
import de.mm20.launcher2.ui.launcher.widgets.weather.WeatherWidget
|
||||
import de.mm20.launcher2.ui.locals.LocalCardStyle
|
||||
import de.mm20.launcher2.widgets.AppWidget
|
||||
import de.mm20.launcher2.widgets.CalendarWidget
|
||||
import de.mm20.launcher2.widgets.FavoritesWidget
|
||||
@ -54,7 +56,6 @@ import de.mm20.launcher2.widgets.MusicWidget
|
||||
import de.mm20.launcher2.widgets.NotesWidget
|
||||
import de.mm20.launcher2.widgets.WeatherWidget
|
||||
import de.mm20.launcher2.widgets.Widget
|
||||
import java.util.UUID
|
||||
|
||||
@Composable
|
||||
fun WidgetItem(
|
||||
@ -62,7 +63,7 @@ fun WidgetItem(
|
||||
appWidgetHost: AppWidgetHost,
|
||||
modifier: Modifier = Modifier,
|
||||
editMode: Boolean = false,
|
||||
onWidgetAdd: (widget: Widget, offset: Int) -> Unit = {_, _ ->},
|
||||
onWidgetAdd: (widget: Widget, offset: Int) -> Unit = { _, _ -> },
|
||||
onWidgetUpdate: (widget: Widget) -> Unit = {},
|
||||
onWidgetRemove: () -> Unit = {},
|
||||
draggableState: DraggableState = rememberDraggableState {},
|
||||
@ -79,9 +80,15 @@ fun WidgetItem(
|
||||
AppWidgetManager.getInstance(context).getAppWidgetInfo(widget.config.widgetId)
|
||||
} else null
|
||||
|
||||
val backgroundOpacity by animateFloatAsState(
|
||||
if (widget is AppWidget && !widget.config.background && !editMode) 0f else LocalCardStyle.current.opacity,
|
||||
label = "widgetCardBackgroundOpacity",
|
||||
)
|
||||
|
||||
LauncherCard(
|
||||
modifier = modifier.zIndex(if (isDragged) 1f else 0f),
|
||||
elevation = elevation
|
||||
elevation = elevation,
|
||||
backgroundOpacity = backgroundOpacity,
|
||||
) {
|
||||
Column {
|
||||
AnimatedVisibility(editMode) {
|
||||
@ -203,6 +210,7 @@ fun WidgetItem(
|
||||
widgetId = it.config.widgetId
|
||||
)
|
||||
)
|
||||
|
||||
is WeatherWidget -> it.copy(id = widget.id)
|
||||
is MusicWidget -> it.copy(id = widget.id)
|
||||
is CalendarWidget -> it.copy(id = widget.id)
|
||||
|
||||
@ -795,6 +795,7 @@
|
||||
<string name="preference_search_result_ordering_weight_factor_high">Variable</string>
|
||||
<string name="widget_config_appwidget_height">Height</string>
|
||||
<string name="widget_config_appwidget_borderless">Borderless</string>
|
||||
<string name="widget_config_appwidget_background">Background card</string>
|
||||
<string name="widget_config_appwidget_configure">Configure widget</string>
|
||||
<string name="widget_config_appwidget_resize_hint">Drag to resize</string>
|
||||
<string name="widget_config_weather_integration_settings">Weather integration settings</string>
|
||||
|
||||
@ -16,6 +16,7 @@ data class AppWidgetConfig(
|
||||
val widgetId: Int,
|
||||
val height: Int,
|
||||
val borderless: Boolean = false,
|
||||
val background: Boolean = true,
|
||||
)
|
||||
|
||||
data class AppWidget(
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user