diff --git a/app/build.gradle.kts b/app/build.gradle.kts index a40d496..f5ca583 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -13,7 +13,7 @@ android { defaultConfig { applicationId = "be.chvp.nanoledger" minSdk = 26 - targetSdk = 33 + targetSdk = 34 versionCode = 10700 versionName = "0.1.6" @@ -40,7 +40,6 @@ android { jvmTarget = "17" freeCompilerArgs += arrayOf( - "-opt-in=androidx.compose.material.ExperimentalMaterialApi", "-opt-in=androidx.compose.material3.ExperimentalMaterial3Api", ) } @@ -48,11 +47,9 @@ android { quiet = true disable.addAll( arrayOf( - "OldTargetApi", "NewerVersionAvailable", - "IntentWithNullActionLaunch", "GradleDependency", - "ComposableLambdaParameterNaming", + "ObsoleteLintCustomCheck", ), ) checkAllWarnings = true @@ -66,7 +63,7 @@ android { viewBinding = true } composeOptions { - kotlinCompilerExtensionVersion = "1.5.8" + kotlinCompilerExtensionVersion = "1.5.9" } packaging { resources { @@ -87,7 +84,6 @@ dependencies { implementation(libs.activity.compose) implementation(libs.activity.ktx) implementation(platform(libs.compose.bom)) - implementation(libs.compose.material) implementation(libs.compose.material.icons.extended) implementation(libs.compose.material3) implementation(libs.compose.runtime) diff --git a/app/src/main/java/be/chvp/nanoledger/ui/add/AddActivity.kt b/app/src/main/java/be/chvp/nanoledger/ui/add/AddActivity.kt index 7a2d35c..e525bb2 100644 --- a/app/src/main/java/be/chvp/nanoledger/ui/add/AddActivity.kt +++ b/app/src/main/java/be/chvp/nanoledger/ui/add/AddActivity.kt @@ -21,7 +21,7 @@ import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.text.KeyboardOptions import androidx.compose.foundation.verticalScroll import androidx.compose.material.icons.Icons -import androidx.compose.material.icons.filled.ArrowBack +import androidx.compose.material.icons.automirrored.filled.ArrowBack import androidx.compose.material.icons.filled.Done import androidx.compose.material3.AlertDialog import androidx.compose.material3.CircularProgressIndicator @@ -262,7 +262,7 @@ fun Bar() { } }) { Icon( - Icons.Default.ArrowBack, + Icons.AutoMirrored.Default.ArrowBack, contentDescription = stringResource(R.string.back), ) } diff --git a/app/src/main/java/be/chvp/nanoledger/ui/main/MainActivity.kt b/app/src/main/java/be/chvp/nanoledger/ui/main/MainActivity.kt index f411ab4..fd9dec0 100644 --- a/app/src/main/java/be/chvp/nanoledger/ui/main/MainActivity.kt +++ b/app/src/main/java/be/chvp/nanoledger/ui/main/MainActivity.kt @@ -20,9 +20,6 @@ import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.Add import androidx.compose.material.icons.filled.Settings -import androidx.compose.material.pullrefresh.PullRefreshIndicator -import androidx.compose.material.pullrefresh.pullRefresh -import androidx.compose.material.pullrefresh.rememberPullRefreshState import androidx.compose.material3.Card import androidx.compose.material3.FloatingActionButton import androidx.compose.material3.Icon @@ -32,6 +29,8 @@ import androidx.compose.material3.Scaffold import androidx.compose.material3.Text import androidx.compose.material3.TopAppBar import androidx.compose.material3.TopAppBarDefaults +import androidx.compose.material3.pulltorefresh.PullToRefreshContainer +import androidx.compose.material3.pulltorefresh.rememberPullToRefreshState import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.getValue @@ -39,6 +38,7 @@ import androidx.compose.runtime.livedata.observeAsState import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier +import androidx.compose.ui.input.nestedscroll.nestedScroll import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.font.FontFamily @@ -155,8 +155,26 @@ fun MainContent( val context = LocalContext.current val transactions by mainViewModel.transactions.observeAsState() val isRefreshing by mainViewModel.isRefreshing.observeAsState() - val state = rememberPullRefreshState(isRefreshing ?: false, { mainViewModel.refresh() }) - Box(modifier = Modifier.pullRefresh(state).padding(contentPadding)) { + val state = rememberPullToRefreshState() + if (state.isRefreshing && !(isRefreshing ?: false)) { + LaunchedEffect(true) { + state.endRefresh() + } + } else if (!state.isRefreshing && (isRefreshing ?: false)) { + LaunchedEffect(true) { + state.startRefresh() + } + } + if (state.isRefreshing) { + LaunchedEffect(true) { + mainViewModel.refresh() + // Due to the way compositing works, we cancel the refresh in the + // first if (even if the first if is moved below this one, and then + // we have no way to undo the cancel). + state.startRefresh() + } + } + Box(modifier = Modifier.nestedScroll(state.nestedScrollConnection).padding(contentPadding)) { if ((transactions?.size ?: 0) > 0 || (isRefreshing ?: true)) { LazyColumn(modifier = Modifier.fillMaxSize()) { items(transactions?.size ?: 0) { @@ -241,7 +259,7 @@ fun MainContent( } } } - PullRefreshIndicator(isRefreshing ?: false, state, Modifier.align(Alignment.TopCenter)) + PullToRefreshContainer(state = state, modifier = Modifier.align(Alignment.TopCenter)) } } diff --git a/app/src/main/java/be/chvp/nanoledger/ui/preferences/PreferencesActivity.kt b/app/src/main/java/be/chvp/nanoledger/ui/preferences/PreferencesActivity.kt index 14dd454..63a3b28 100644 --- a/app/src/main/java/be/chvp/nanoledger/ui/preferences/PreferencesActivity.kt +++ b/app/src/main/java/be/chvp/nanoledger/ui/preferences/PreferencesActivity.kt @@ -14,17 +14,15 @@ import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.verticalScroll -import androidx.compose.material.ContentAlpha import androidx.compose.material.icons.Icons -import androidx.compose.material.icons.filled.ArrowBack +import androidx.compose.material.icons.automirrored.filled.ArrowBack import androidx.compose.material3.AlertDialog -import androidx.compose.material3.Divider import androidx.compose.material3.DropdownMenuItem import androidx.compose.material3.ExposedDropdownMenuBox import androidx.compose.material3.ExposedDropdownMenuDefaults +import androidx.compose.material3.HorizontalDivider import androidx.compose.material3.Icon import androidx.compose.material3.IconButton -import androidx.compose.material3.LocalContentColor import androidx.compose.material3.MaterialTheme import androidx.compose.material3.OutlinedTextField import androidx.compose.material3.Scaffold @@ -42,6 +40,7 @@ import androidx.compose.runtime.setValue import androidx.compose.ui.Modifier import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.stringResource +import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.unit.dp import be.chvp.nanoledger.R import be.chvp.nanoledger.ui.theme.NanoLedgerTheme @@ -90,7 +89,7 @@ class PreferencesActivity() : ComponentActivity() { ) { openFile.launch(arrayOf("*/*")) } - Divider() + HorizontalDivider() val defaultCurrency by preferencesViewModel.defaultCurrency.observeAsState() var newDefaultCurrency by remember { mutableStateOf(defaultCurrency ?: "") } var defaultCurrencyOpen by remember { mutableStateOf(false) } @@ -109,7 +108,7 @@ class PreferencesActivity() : ComponentActivity() { ) { OutlinedTextField(newDefaultCurrency, { newDefaultCurrency = it }) } - Divider() + HorizontalDivider() val defaultStatus by preferencesViewModel.defaultStatus.observeAsState() var expandedStatus by rememberSaveable { mutableStateOf(false) } ExposedDropdownMenuBox( @@ -142,7 +141,7 @@ class PreferencesActivity() : ComponentActivity() { } } } - Divider() + HorizontalDivider() val currencyBeforeAmount by preferencesViewModel.currencyBeforeAmount.observeAsState() var expandedCurrency by rememberSaveable { mutableStateOf(false) } @@ -209,7 +208,7 @@ fun Setting( subtext, modifier = Modifier.padding(bottom = 8.dp, start = 8.dp), style = MaterialTheme.typography.bodyMedium, - color = LocalContentColor.current.copy(alpha = ContentAlpha.medium), + fontWeight = FontWeight.Normal, ) } } @@ -222,7 +221,7 @@ fun Bar() { navigationIcon = { IconButton(onClick = { (context as Activity).finish() }) { Icon( - Icons.Default.ArrowBack, + Icons.AutoMirrored.Default.ArrowBack, contentDescription = stringResource(R.string.back), ) } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 2662ba8..98b0069 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -10,7 +10,7 @@ androidx-test-ext-junit = "1.1.5" espresso-core = "3.5.1" lifecycle = "2.7.0" activity = "1.8.2" -compose-bom = "2023.10.01" +compose-bom = "2024.02.00" material = "1.11.0" [libraries] @@ -18,7 +18,6 @@ activity-compose = { group = "androidx.activity", name = "activity-compose", ver activity-ktx = { group = "androidx.activity", name = "activity-ktx", version.ref = "activity" } androidx-test-ext-junit = { group = "androidx.test.ext", name = "junit", version.ref = "androidx-test-ext-junit" } compose-bom = { group = "androidx.compose", name = "compose-bom", version.ref = "compose-bom" } -compose-material = { group = "androidx.compose.material", name = "material" } compose-material-icons-extended = { group = "androidx.compose.material", name = "material-icons-extended" } compose-material3 = { group = "androidx.compose.material3", name = "material3" } compose-runtime = { group = "androidx.compose.runtime", name = "runtime-livedata" }