Update Jetpack Compose and MDC Android

This commit is contained in:
MM20 2022-03-30 18:46:12 +02:00
parent 4d5190fcd8
commit 81e871203f
No known key found for this signature in database
GPG Key ID: 0B61A8F2DEAFA389
26 changed files with 41 additions and 110 deletions

View File

@ -61,7 +61,7 @@ dependencyResolutionManagement {
listOf("kotlin.stdlib", "kotlinx.coroutines.core", "kotlinx.coroutines.android")
)
version("androidx.compose", "1.2.0-alpha05")
version("androidx.compose", "1.2.0-alpha06")
alias("androidx.compose.runtime")
.to("androidx.compose.runtime", "runtime")
.versionRef("androidx.compose")
@ -94,7 +94,7 @@ dependencyResolutionManagement {
.versionRef("androidx.compose")
alias("androidx.compose.material3")
.to("androidx.compose.material3", "material3")
.version("1.0.0-alpha07")
.version("1.0.0-alpha08")
version("androidx.lifecycle", "2.4.1")
alias("androidx.lifecycle.viewmodel")
@ -241,13 +241,13 @@ dependencyResolutionManagement {
alias("materialcomponents.core")
.to("com.google.android.material", "material")
.version("1.6.0-alpha03")
.version("1.6.0-beta01")
alias("materialcomponents.composethemeadapter3")
.to("com.google.android.material", "compose-theme-adapter-3")
.version("1.0.5")
.version("1.0.6")
alias("materialcomponents.composethemeadapter")
.to("com.google.android.material", "compose-theme-adapter")
.version("1.1.5")
.version("1.1.6")
alias("okhttp")
.to("com.squareup.okhttp3", "okhttp")

View File

@ -1,23 +0,0 @@
package de.mm20.launcher2.ui
import android.content.res.Resources
import androidx.annotation.PluralsRes
import androidx.compose.runtime.Composable
import androidx.compose.ui.platform.LocalConfiguration
import androidx.compose.ui.platform.LocalContext
@Composable
fun pluralResource(@PluralsRes id: Int, quantity: Int): String {
return resources().getQuantityString(id, quantity)
}
@Composable
fun pluralResource(@PluralsRes id: Int, quantity: Int, vararg formatArgs: Any): String {
return resources().getQuantityString(id, quantity, *formatArgs)
}
@Composable
private fun resources(): Resources {
LocalConfiguration.current
return LocalContext.current.resources
}

View File

@ -8,8 +8,8 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.CircularProgressIndicator
import androidx.compose.material.OutlinedTextField
import androidx.compose.material3.CircularProgressIndicator
import androidx.compose.material3.OutlinedTextField
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
@ -58,6 +58,7 @@ fun WeatherLocationSearchDialog(
OutlinedTextField(
singleLine = true,
value = query,
textStyle = MaterialTheme.typography.bodyLarge,
onValueChange = {
query = it
scope.launch {
@ -107,7 +108,6 @@ fun WeatherLocationSearchDialog(
) {
Text(
text = stringResource(R.string.close),
style = MaterialTheme.typography.labelLarge
)
}
}

View File

@ -7,7 +7,6 @@ import androidx.compose.animation.core.updateTransition
import androidx.compose.foundation.BorderStroke
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.OutlinedCard
import androidx.compose.material3.Surface
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue

View File

@ -3,7 +3,6 @@ package de.mm20.launcher2.ui.component
import androidx.compose.foundation.layout.padding
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.rounded.Lock
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.material3.TextButton
import androidx.compose.runtime.Composable
@ -30,7 +29,6 @@ fun MissingPermissionBanner(
) {
Text(
stringResource(R.string.grant_permission),
style = MaterialTheme.typography.labelLarge
)
}
},

View File

@ -1,7 +1,7 @@
package de.mm20.launcher2.ui.component.preferences
import androidx.compose.material.OutlinedTextField
import androidx.compose.material.TextButton
import androidx.compose.material3.OutlinedTextField
import androidx.compose.material3.TextButton
import androidx.compose.material3.AlertDialog
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
@ -33,12 +33,12 @@ fun TextPreference(
text = {
OutlinedTextField(
value = textFieldValue,
textStyle = MaterialTheme.typography.bodyLarge,
onValueChange = { textFieldValue = it },
placeholder = placeholder?.let {
{
Text(
text = it,
style = MaterialTheme.typography.bodyLarge
)
}
},
@ -51,7 +51,6 @@ fun TextPreference(
}) {
Text(
text = stringResource(android.R.string.ok),
style = MaterialTheme.typography.labelLarge
)
}
},
@ -61,7 +60,6 @@ fun TextPreference(
}) {
Text(
text = stringResource(android.R.string.cancel),
style = MaterialTheme.typography.labelLarge
)
}
}

View File

@ -30,7 +30,7 @@ import androidx.compose.ui.window.DialogProperties
import de.mm20.launcher2.ui.MdcLauncherTheme
import de.mm20.launcher2.ui.R
import de.mm20.launcher2.ui.base.ProvideSettings
import de.mm20.launcher2.ui.launcher.search.common.SearchResultGrid
import de.mm20.launcher2.ui.launcher.search.common.grid.SearchResultGrid
@OptIn(ExperimentalComposeUiApi::class)
class HiddenItemsView @JvmOverloads constructor(
@ -85,7 +85,6 @@ class HiddenItemsView @JvmOverloads constructor(
TextButton(onClick = { onDismiss() }) {
Text(
stringResource(id = R.string.close),
style = MaterialTheme.typography.labelLarge
)
}
}

View File

@ -11,7 +11,7 @@ import androidx.compose.ui.unit.dp
import androidx.lifecycle.viewmodel.compose.viewModel
import de.mm20.launcher2.ui.component.LauncherCard
import de.mm20.launcher2.ui.launcher.search.SearchVM
import de.mm20.launcher2.ui.launcher.search.common.SearchResultGrid
import de.mm20.launcher2.ui.launcher.search.common.grid.SearchResultGrid
@Composable
fun ColumnScope.AppResults() {

View File

@ -6,7 +6,6 @@ import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.ColumnScope
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.material3.TextButton
import androidx.compose.runtime.Composable
@ -49,7 +48,6 @@ fun ColumnScope.AppShortcutResults() {
}) {
Text(
stringResource(R.string.turn_off),
style = MaterialTheme.typography.labelLarge
)
}
}

View File

@ -6,7 +6,6 @@ import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.ColumnScope
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.material3.TextButton
import androidx.compose.runtime.Composable
@ -50,7 +49,6 @@ fun ColumnScope.CalendarResults() {
}) {
Text(
stringResource(R.string.turn_off),
style = MaterialTheme.typography.labelLarge
)
}
}

View File

@ -1,34 +1,13 @@
package de.mm20.launcher2.ui.launcher.search.common
package de.mm20.launcher2.ui.launcher.search.common.grid
import androidx.compose.animation.*
import androidx.compose.animation.core.animateFloatAsState
import androidx.compose.animation.core.tween
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.combinedClickable
import androidx.compose.animation.animateContentSize
import androidx.compose.foundation.layout.*
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.geometry.Rect
import androidx.compose.ui.layout.boundsInWindow
import androidx.compose.ui.layout.onGloballyPositioned
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.IntOffset
import androidx.compose.ui.unit.dp
import androidx.compose.ui.window.Popup
import androidx.compose.ui.window.PopupProperties
import de.mm20.launcher2.search.data.Application
import de.mm20.launcher2.search.data.Searchable
import de.mm20.launcher2.ui.component.LauncherCard
import de.mm20.launcher2.ui.component.ShapedLauncherIcon
import de.mm20.launcher2.ui.ktx.toDp
import de.mm20.launcher2.ui.launcher.search.apps.AppItemGridPopup
import de.mm20.launcher2.ui.launcher.search.common.GridItem
import de.mm20.launcher2.ui.locals.LocalGridColumns
import kotlinx.coroutines.delay
import kotlin.math.ceil
@Composable
@ -39,7 +18,10 @@ fun SearchResultGrid(
val columns = LocalGridColumns.current
Column(
modifier = modifier.animateContentSize().fillMaxWidth().padding(4.dp)
modifier = modifier
.animateContentSize()
.fillMaxWidth()
.padding(4.dp)
) {
for (i in 0 until ceil(items.size / columns.toFloat()).toInt()) {
Row {

View File

@ -1,6 +1,5 @@
package de.mm20.launcher2.ui.launcher.search.common.list
import androidx.appcompat.app.AppCompatActivity
import androidx.compose.animation.animateColorAsState
import androidx.compose.animation.core.animateFloatAsState
import androidx.compose.foundation.background

View File

@ -6,7 +6,6 @@ import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.ColumnScope
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.material3.TextButton
import androidx.compose.runtime.Composable
@ -50,7 +49,6 @@ fun ColumnScope.ContactResults() {
}) {
Text(
stringResource(R.string.turn_off),
style = MaterialTheme.typography.labelLarge
)
}
}

View File

@ -11,7 +11,7 @@ import androidx.compose.ui.unit.dp
import androidx.lifecycle.viewmodel.compose.viewModel
import de.mm20.launcher2.ui.component.LauncherCard
import de.mm20.launcher2.ui.launcher.search.SearchVM
import de.mm20.launcher2.ui.launcher.search.common.SearchResultGrid
import de.mm20.launcher2.ui.launcher.search.common.grid.SearchResultGrid
@Composable
fun ColumnScope.FavoritesResults() {

View File

@ -192,14 +192,14 @@ fun FileItem(
viewModel.delete()
showConfirmDialog = false
}) {
Text(stringResource(android.R.string.ok), style = MaterialTheme.typography.labelLarge)
Text(stringResource(android.R.string.ok))
}
},
dismissButton = {
TextButton(onClick = {
showConfirmDialog = false
}) {
Text(stringResource(android.R.string.cancel), style = MaterialTheme.typography.labelLarge)
Text(stringResource(android.R.string.cancel))
}
},
text = {

View File

@ -6,7 +6,6 @@ import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.ColumnScope
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.material3.TextButton
import androidx.compose.runtime.Composable
@ -50,7 +49,6 @@ fun ColumnScope.FileResults() {
}) {
Text(
stringResource(R.string.turn_off),
style = MaterialTheme.typography.labelLarge
)
}
}

View File

@ -137,7 +137,6 @@ fun UnitConverterItem(
) {
Text(
text = stringResource(id = R.string.unit_converter_show_all),
style = MaterialTheme.typography.labelLarge
)
}
}

View File

@ -15,6 +15,7 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalLifecycleOwner
import androidx.compose.ui.res.pluralStringResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
@ -25,7 +26,6 @@ import de.mm20.launcher2.ui.R
import de.mm20.launcher2.ui.component.InnerCard
import de.mm20.launcher2.ui.component.MissingPermissionBanner
import de.mm20.launcher2.ui.launcher.search.common.list.SearchResultList
import de.mm20.launcher2.ui.pluralResource
import java.time.LocalDate
import java.time.ZoneId
@ -119,7 +119,7 @@ fun CalendarWidget() {
val runningEvents by viewModel.hiddenPastEvents.observeAsState(0)
if (runningEvents > 0) {
Info(
text = pluralResource(
text = pluralStringResource(
R.plurals.calendar_widget_running_events,
runningEvents,
runningEvents

View File

@ -102,7 +102,6 @@ class AlarmPartProvider : PartProvider {
DateUtils.MINUTE_IN_MILLIS
)
.toString(),
style = MaterialTheme.typography.labelLarge
)
}
} else {

View File

@ -22,13 +22,13 @@ import androidx.compose.runtime.getValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.res.pluralStringResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import androidx.core.content.getSystemService
import de.mm20.launcher2.preferences.Settings
import de.mm20.launcher2.ui.R
import de.mm20.launcher2.ui.icons.*
import de.mm20.launcher2.ui.pluralResource
import kotlinx.coroutines.channels.awaitClose
import kotlinx.coroutines.channels.trySendBlocking
import kotlinx.coroutines.flow.*
@ -85,7 +85,7 @@ class BatteryPartProvider : PartProvider {
modifier = Modifier.padding(start = 8.dp),
text = it.fullIn?.let {
val m = (it / 60000).toInt()
pluralResource(R.plurals.battery_part_remaining_charge_time, m, m)
pluralStringResource(R.plurals.battery_part_remaining_charge_time, m, m)
} ?: stringResource(R.string.battery_part_charging),
style = MaterialTheme.typography.bodySmall
)
@ -111,7 +111,7 @@ class BatteryPartProvider : PartProvider {
Text(
text = it.fullIn?.let {
val m = (it / 60000).toInt()
pluralResource(R.plurals.battery_part_remaining_charge_time, m, m)
pluralStringResource(R.plurals.battery_part_remaining_charge_time, m, m)
} ?: stringResource(R.string.battery_part_charging),
style = MaterialTheme.typography.bodyMedium
)

View File

@ -73,7 +73,6 @@ fun WeatherWidget() {
}) {
Text(
stringResource(R.string.weather_widget_set_location),
style = MaterialTheme.typography.labelLarge
)
}
}

View File

@ -261,7 +261,6 @@ fun SearchBarStylePreference(
}) {
Text(
text = stringResource(android.R.string.ok),
style = MaterialTheme.typography.labelLarge
)
}
},
@ -269,7 +268,6 @@ fun SearchBarStylePreference(
TextButton(onClick = { showDialog = false }) {
Text(
text = stringResource(android.R.string.cancel),
style = MaterialTheme.typography.labelLarge
)
}
},

View File

@ -14,6 +14,7 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.pluralStringResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import androidx.compose.ui.window.Dialog
@ -25,7 +26,6 @@ import de.mm20.launcher2.ui.component.preferences.Preference
import de.mm20.launcher2.ui.component.preferences.PreferenceCategory
import de.mm20.launcher2.ui.component.preferences.PreferenceScreen
import de.mm20.launcher2.ui.component.preferences.SwitchPreference
import de.mm20.launcher2.ui.pluralResource
@Composable
fun CalendarWidgetSettingsScreen() {
@ -76,9 +76,9 @@ fun ExcludedCalendarsPreference(
var showDialog by remember { mutableStateOf(false) }
Preference(
title = stringResource(R.string.preference_calendar_calendars),
summary = pluralResource(
summary = pluralStringResource(
R.plurals.preference_calendar_calendars_summary,
quantity = calendars.size - value.size,
count = calendars.size - value.size,
calendars.size - value.size
),
onClick = {
@ -161,7 +161,6 @@ fun ExcludedCalendarsPreference(
) {
Text(
text = stringResource(android.R.string.ok),
style = MaterialTheme.typography.labelLarge
)
}
}

View File

@ -5,7 +5,6 @@ import androidx.compose.foundation.layout.height
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.rounded.*
import androidx.compose.material3.AlertDialog
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.material3.TextButton
import androidx.compose.runtime.*
@ -132,7 +131,6 @@ fun ClockStylePreference(
}) {
Text(
text = stringResource(android.R.string.ok),
style = MaterialTheme.typography.labelLarge
)
}
},
@ -140,7 +138,6 @@ fun ClockStylePreference(
TextButton(onClick = { showDialog = false }) {
Text(
text = stringResource(android.R.string.cancel),
style = MaterialTheme.typography.labelLarge
)
}
},

View File

@ -7,7 +7,6 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.material3.LinearProgressIndicator
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.rounded.AccountBox
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.material3.TextButton
import androidx.compose.runtime.Composable
@ -90,7 +89,6 @@ fun FileSearchSettingsScreen() {
}) {
Text(
stringResource(R.string.connect_account),
style = MaterialTheme.typography.labelLarge
)
}
},
@ -124,7 +122,6 @@ fun FileSearchSettingsScreen() {
}) {
Text(
stringResource(R.string.connect_account),
style = MaterialTheme.typography.labelLarge
)
}
},
@ -158,7 +155,6 @@ fun FileSearchSettingsScreen() {
}) {
Text(
stringResource(R.string.connect_account),
style = MaterialTheme.typography.labelLarge
)
}
},
@ -192,7 +188,6 @@ fun FileSearchSettingsScreen() {
}) {
Text(
stringResource(R.string.connect_account),
style = MaterialTheme.typography.labelLarge
)
}
},

View File

@ -12,8 +12,8 @@ import androidx.compose.foundation.lazy.LazyRow
import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.material.OutlinedTextField
import androidx.compose.material.TextField
import androidx.compose.material3.OutlinedTextField
import androidx.compose.material3.TextField
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.rounded.*
import androidx.compose.material3.*
@ -294,7 +294,8 @@ fun EditWebsearchDialog(
onValueChange = {
importUrl = it
importError = false
}
},
textStyle = MaterialTheme.typography.bodyLarge,
)
if (loadingImport) {
CircularProgressIndicator(
@ -371,7 +372,6 @@ fun EditWebsearchDialog(
) {
Text(
stringResource(R.string.websearch_dialog_replace_icon),
style = MaterialTheme.typography.labelLarge
)
}
TextButton(
@ -385,7 +385,6 @@ fun EditWebsearchDialog(
) {
Text(
stringResource(R.string.websearch_dialog_delete_icon),
style = MaterialTheme.typography.labelLarge
)
}
}
@ -404,7 +403,6 @@ fun EditWebsearchDialog(
) {
Text(
stringResource(R.string.websearch_dialog_custom_icon),
style = MaterialTheme.typography.labelLarge
)
}
@ -420,7 +418,8 @@ fun EditWebsearchDialog(
},
label = {
Text(text = stringResource(R.string.websearch_dialog_name))
}
},
textStyle = MaterialTheme.typography.bodyLarge,
)
OutlinedTextField(
modifier = Modifier
@ -433,6 +432,7 @@ fun EditWebsearchDialog(
label = {
Text(text = stringResource(R.string.websearch_dialog_url))
},
textStyle = MaterialTheme.typography.bodyLarge,
)
AnimatedVisibility(showError) {
Text(
@ -538,7 +538,8 @@ private fun ColorPicker(
}
},
singleLine = true,
modifier = Modifier.width(150.dp)
modifier = Modifier.width(150.dp),
textStyle = MaterialTheme.typography.bodyLarge,
)
TextButton(onClick = { showCustomColorPicker = false }) {
Text(