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)))
|
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) {
|
if (isAtLeastApiLevel(28) && widgetInfo.widgetFeatures and AppWidgetProviderInfo.WIDGET_FEATURE_RECONFIGURABLE != 0) {
|
||||||
|
|||||||
@ -4,6 +4,7 @@ import android.appwidget.AppWidgetHost
|
|||||||
import android.appwidget.AppWidgetManager
|
import android.appwidget.AppWidgetManager
|
||||||
import androidx.compose.animation.AnimatedVisibility
|
import androidx.compose.animation.AnimatedVisibility
|
||||||
import androidx.compose.animation.core.animateDpAsState
|
import androidx.compose.animation.core.animateDpAsState
|
||||||
|
import androidx.compose.animation.core.animateFloatAsState
|
||||||
import androidx.compose.foundation.gestures.DraggableState
|
import androidx.compose.foundation.gestures.DraggableState
|
||||||
import androidx.compose.foundation.gestures.Orientation
|
import androidx.compose.foundation.gestures.Orientation
|
||||||
import androidx.compose.foundation.gestures.draggable
|
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.music.MusicWidget
|
||||||
import de.mm20.launcher2.ui.launcher.widgets.notes.NotesWidget
|
import de.mm20.launcher2.ui.launcher.widgets.notes.NotesWidget
|
||||||
import de.mm20.launcher2.ui.launcher.widgets.weather.WeatherWidget
|
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.AppWidget
|
||||||
import de.mm20.launcher2.widgets.CalendarWidget
|
import de.mm20.launcher2.widgets.CalendarWidget
|
||||||
import de.mm20.launcher2.widgets.FavoritesWidget
|
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.NotesWidget
|
||||||
import de.mm20.launcher2.widgets.WeatherWidget
|
import de.mm20.launcher2.widgets.WeatherWidget
|
||||||
import de.mm20.launcher2.widgets.Widget
|
import de.mm20.launcher2.widgets.Widget
|
||||||
import java.util.UUID
|
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun WidgetItem(
|
fun WidgetItem(
|
||||||
@ -62,7 +63,7 @@ fun WidgetItem(
|
|||||||
appWidgetHost: AppWidgetHost,
|
appWidgetHost: AppWidgetHost,
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
editMode: Boolean = false,
|
editMode: Boolean = false,
|
||||||
onWidgetAdd: (widget: Widget, offset: Int) -> Unit = {_, _ ->},
|
onWidgetAdd: (widget: Widget, offset: Int) -> Unit = { _, _ -> },
|
||||||
onWidgetUpdate: (widget: Widget) -> Unit = {},
|
onWidgetUpdate: (widget: Widget) -> Unit = {},
|
||||||
onWidgetRemove: () -> Unit = {},
|
onWidgetRemove: () -> Unit = {},
|
||||||
draggableState: DraggableState = rememberDraggableState {},
|
draggableState: DraggableState = rememberDraggableState {},
|
||||||
@ -79,9 +80,15 @@ fun WidgetItem(
|
|||||||
AppWidgetManager.getInstance(context).getAppWidgetInfo(widget.config.widgetId)
|
AppWidgetManager.getInstance(context).getAppWidgetInfo(widget.config.widgetId)
|
||||||
} else null
|
} else null
|
||||||
|
|
||||||
|
val backgroundOpacity by animateFloatAsState(
|
||||||
|
if (widget is AppWidget && !widget.config.background && !editMode) 0f else LocalCardStyle.current.opacity,
|
||||||
|
label = "widgetCardBackgroundOpacity",
|
||||||
|
)
|
||||||
|
|
||||||
LauncherCard(
|
LauncherCard(
|
||||||
modifier = modifier.zIndex(if (isDragged) 1f else 0f),
|
modifier = modifier.zIndex(if (isDragged) 1f else 0f),
|
||||||
elevation = elevation
|
elevation = elevation,
|
||||||
|
backgroundOpacity = backgroundOpacity,
|
||||||
) {
|
) {
|
||||||
Column {
|
Column {
|
||||||
AnimatedVisibility(editMode) {
|
AnimatedVisibility(editMode) {
|
||||||
@ -203,6 +210,7 @@ fun WidgetItem(
|
|||||||
widgetId = it.config.widgetId
|
widgetId = it.config.widgetId
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
is WeatherWidget -> it.copy(id = widget.id)
|
is WeatherWidget -> it.copy(id = widget.id)
|
||||||
is MusicWidget -> it.copy(id = widget.id)
|
is MusicWidget -> it.copy(id = widget.id)
|
||||||
is CalendarWidget -> 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="preference_search_result_ordering_weight_factor_high">Variable</string>
|
||||||
<string name="widget_config_appwidget_height">Height</string>
|
<string name="widget_config_appwidget_height">Height</string>
|
||||||
<string name="widget_config_appwidget_borderless">Borderless</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_configure">Configure widget</string>
|
||||||
<string name="widget_config_appwidget_resize_hint">Drag to resize</string>
|
<string name="widget_config_appwidget_resize_hint">Drag to resize</string>
|
||||||
<string name="widget_config_weather_integration_settings">Weather integration settings</string>
|
<string name="widget_config_weather_integration_settings">Weather integration settings</string>
|
||||||
|
|||||||
@ -16,6 +16,7 @@ data class AppWidgetConfig(
|
|||||||
val widgetId: Int,
|
val widgetId: Int,
|
||||||
val height: Int,
|
val height: Int,
|
||||||
val borderless: Boolean = false,
|
val borderless: Boolean = false,
|
||||||
|
val background: Boolean = true,
|
||||||
)
|
)
|
||||||
|
|
||||||
data class AppWidget(
|
data class AppWidget(
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user