Add widget resize tooltip
This commit is contained in:
parent
7ebc662c6f
commit
7d54512962
@ -7,6 +7,7 @@ import android.appwidget.AppWidgetProviderInfo
|
|||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.compose.foundation.background
|
import androidx.compose.foundation.background
|
||||||
|
import androidx.compose.foundation.clickable
|
||||||
import androidx.compose.foundation.gestures.Orientation
|
import androidx.compose.foundation.gestures.Orientation
|
||||||
import androidx.compose.foundation.gestures.draggable
|
import androidx.compose.foundation.gestures.draggable
|
||||||
import androidx.compose.foundation.gestures.rememberDraggableState
|
import androidx.compose.foundation.gestures.rememberDraggableState
|
||||||
@ -19,7 +20,6 @@ import androidx.compose.foundation.layout.fillMaxWidth
|
|||||||
import androidx.compose.foundation.layout.height
|
import androidx.compose.foundation.layout.height
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.foundation.layout.requiredSize
|
import androidx.compose.foundation.layout.requiredSize
|
||||||
import androidx.compose.foundation.layout.size
|
|
||||||
import androidx.compose.foundation.layout.width
|
import androidx.compose.foundation.layout.width
|
||||||
import androidx.compose.foundation.rememberScrollState
|
import androidx.compose.foundation.rememberScrollState
|
||||||
import androidx.compose.foundation.text.KeyboardOptions
|
import androidx.compose.foundation.text.KeyboardOptions
|
||||||
@ -36,14 +36,17 @@ import androidx.compose.material3.MaterialTheme
|
|||||||
import androidx.compose.material3.OutlinedButton
|
import androidx.compose.material3.OutlinedButton
|
||||||
import androidx.compose.material3.OutlinedCard
|
import androidx.compose.material3.OutlinedCard
|
||||||
import androidx.compose.material3.OutlinedTextField
|
import androidx.compose.material3.OutlinedTextField
|
||||||
|
import androidx.compose.material3.PlainTooltipBox
|
||||||
import androidx.compose.material3.Text
|
import androidx.compose.material3.Text
|
||||||
import androidx.compose.material3.TextButton
|
import androidx.compose.material3.TextButton
|
||||||
|
import androidx.compose.material3.rememberPlainTooltipState
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.LaunchedEffect
|
import androidx.compose.runtime.LaunchedEffect
|
||||||
import androidx.compose.runtime.collectAsState
|
import androidx.compose.runtime.collectAsState
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
import androidx.compose.runtime.mutableStateOf
|
import androidx.compose.runtime.mutableStateOf
|
||||||
import androidx.compose.runtime.remember
|
import androidx.compose.runtime.remember
|
||||||
|
import androidx.compose.runtime.rememberCoroutineScope
|
||||||
import androidx.compose.runtime.saveable.rememberSaveable
|
import androidx.compose.runtime.saveable.rememberSaveable
|
||||||
import androidx.compose.runtime.setValue
|
import androidx.compose.runtime.setValue
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
@ -55,7 +58,6 @@ import androidx.compose.ui.platform.LocalLifecycleOwner
|
|||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
import androidx.compose.ui.text.input.ImeAction
|
import androidx.compose.ui.text.input.ImeAction
|
||||||
import androidx.compose.ui.text.input.KeyboardType
|
import androidx.compose.ui.text.input.KeyboardType
|
||||||
import androidx.compose.ui.text.style.TextOverflow
|
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import de.mm20.launcher2.calendar.CalendarRepository
|
import de.mm20.launcher2.calendar.CalendarRepository
|
||||||
import de.mm20.launcher2.ktx.isAtLeastApiLevel
|
import de.mm20.launcher2.ktx.isAtLeastApiLevel
|
||||||
@ -77,6 +79,7 @@ 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 kotlinx.coroutines.launchg
|
||||||
import org.koin.androidx.compose.get
|
import org.koin.androidx.compose.get
|
||||||
import kotlin.math.roundToInt
|
import kotlin.math.roundToInt
|
||||||
|
|
||||||
@ -347,6 +350,12 @@ fun ColumnScope.ConfigureAppWidget(
|
|||||||
.padding(horizontal = 8.dp)
|
.padding(horizontal = 8.dp)
|
||||||
.fillMaxWidth(),
|
.fillMaxWidth(),
|
||||||
verticalAlignment = Alignment.CenterVertically
|
verticalAlignment = Alignment.CenterVertically
|
||||||
|
) {
|
||||||
|
val scope = rememberCoroutineScope()
|
||||||
|
val tooltipState = rememberPlainTooltipState()
|
||||||
|
PlainTooltipBox(
|
||||||
|
tooltipState = tooltipState,
|
||||||
|
tooltip = { Text(stringResource(R.string.widget_config_appwidget_resize_hint)) }
|
||||||
) {
|
) {
|
||||||
Box(
|
Box(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
@ -358,7 +367,6 @@ fun ColumnScope.ConfigureAppWidget(
|
|||||||
.draggable(
|
.draggable(
|
||||||
state = draggableState,
|
state = draggableState,
|
||||||
orientation = Orientation.Vertical,
|
orientation = Orientation.Vertical,
|
||||||
startDragImmediately = true,
|
|
||||||
onDragStopped = {
|
onDragStopped = {
|
||||||
onWidgetUpdated(
|
onWidgetUpdated(
|
||||||
widget.copy(
|
widget.copy(
|
||||||
@ -369,7 +377,12 @@ fun ColumnScope.ConfigureAppWidget(
|
|||||||
)
|
)
|
||||||
dragDelta = 0
|
dragDelta = 0
|
||||||
}
|
}
|
||||||
),
|
)
|
||||||
|
.clickable {
|
||||||
|
scope.launch {
|
||||||
|
tooltipState.show()
|
||||||
|
}
|
||||||
|
},
|
||||||
contentAlignment = Alignment.Center
|
contentAlignment = Alignment.Center
|
||||||
) {
|
) {
|
||||||
Icon(
|
Icon(
|
||||||
@ -377,6 +390,8 @@ fun ColumnScope.ConfigureAppWidget(
|
|||||||
contentDescription = null,
|
contentDescription = null,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
var textFieldValue by remember(widget.config.height) { mutableStateOf(widget.config.height.toString()) }
|
var textFieldValue by remember(widget.config.height) { mutableStateOf(widget.config.height.toString()) }
|
||||||
OutlinedTextField(
|
OutlinedTextField(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
@ -445,7 +460,8 @@ fun ColumnScope.ConfigureAppWidget(
|
|||||||
)
|
)
|
||||||
}) {
|
}) {
|
||||||
Text(
|
Text(
|
||||||
stringResource(id = R.string.widget_config_appwidget_configure))
|
stringResource(id = R.string.widget_config_appwidget_configure)
|
||||||
|
)
|
||||||
Icon(
|
Icon(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.padding(start = ButtonDefaults.IconSpacing)
|
.padding(start = ButtonDefaults.IconSpacing)
|
||||||
|
|||||||
@ -796,6 +796,7 @@
|
|||||||
<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_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_weather_integration_settings">Weather integration settings</string>
|
<string name="widget_config_weather_integration_settings">Weather integration settings</string>
|
||||||
<string name="widget_config_calendar_no_calendars">No calendars found</string>
|
<string name="widget_config_calendar_no_calendars">No calendars found</string>
|
||||||
<string name="app_widget_loading_failed">App widget failed to load.</string>
|
<string name="app_widget_loading_failed">App widget failed to load.</string>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user