From 4c17a65201dd02c797d71a1e7a8a08aec9ad6bec Mon Sep 17 00:00:00 2001 From: TimPushkin Date: Fri, 17 May 2024 14:57:53 +0300 Subject: [PATCH 1/2] Update dependencies --- app/build.gradle | 8 ++--- .../java/ru/spbu/depnav/ui/MainActivity.kt | 31 ++++++++++++------- .../spbu/depnav/ui/component/MainMenuSheet.kt | 4 +-- .../spbu/depnav/ui/component/MapSearchBar.kt | 7 ++--- gradle/libs.versions.toml | 24 ++++++++------ gradle/wrapper/gradle-wrapper.properties | 4 +-- 6 files changed, 45 insertions(+), 33 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 66b3b82f..dfdbfedd 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -80,10 +80,10 @@ dependencies { ksp libs.google.dagger.hiltCompiler implementation platform(libs.androidx.compose.bom) - implementation 'androidx.compose.ui:ui' - implementation 'androidx.compose.material3:material3' - implementation 'androidx.compose.ui:ui-tooling-preview' - debugImplementation 'androidx.compose.ui:ui-tooling' + implementation libs.androidx.compose.material3 + implementation libs.androidx.compose.ui + implementation libs.androidx.compose.ui.tooling.preview + debugImplementation libs.androidx.compose.ui.tooling implementation libs.androidx.core.ktx implementation libs.androidx.activity.compose diff --git a/app/src/main/java/ru/spbu/depnav/ui/MainActivity.kt b/app/src/main/java/ru/spbu/depnav/ui/MainActivity.kt index 70c89dc4..aad764cf 100644 --- a/app/src/main/java/ru/spbu/depnav/ui/MainActivity.kt +++ b/app/src/main/java/ru/spbu/depnav/ui/MainActivity.kt @@ -25,6 +25,7 @@ import androidx.activity.SystemBarStyle import androidx.activity.compose.setContent import androidx.activity.enableEdgeToEdge import androidx.compose.foundation.isSystemInDarkTheme +import androidx.compose.runtime.CompositionLocalProvider import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.getValue import androidx.lifecycle.compose.collectAsStateWithLifecycle @@ -46,19 +47,27 @@ class MainActivity : ComponentActivity() { super.onCreate(savedInstanceState) setContent { - val themeMode by prefs.themeModeFlow.collectAsStateWithLifecycle() - val darkTheme = when (themeMode) { - ThemeMode.LIGHT -> false - ThemeMode.DARK -> true - ThemeMode.SYSTEM -> isSystemInDarkTheme() - } + CompositionLocalProvider( + // Fix for https://issuetracker.google.com/issues/336842920 -- should be removed as + // soon as Compose UI 1.7.0 becomes stable + androidx.lifecycle.compose.LocalLifecycleOwner provides + androidx.compose.ui.platform.LocalLifecycleOwner.current + ) { + val themeMode by prefs.themeModeFlow.collectAsStateWithLifecycle() + val darkTheme = when (themeMode) { + ThemeMode.LIGHT -> false + ThemeMode.DARK -> true + ThemeMode.SYSTEM -> isSystemInDarkTheme() + } - LaunchedEffect(darkTheme) { - val style = SystemBarStyle.auto(Color.TRANSPARENT, Color.TRANSPARENT) { darkTheme } - enableEdgeToEdge(style, style) - } + LaunchedEffect(darkTheme) { + val style = + SystemBarStyle.auto(Color.TRANSPARENT, Color.TRANSPARENT) { darkTheme } + enableEdgeToEdge(style, style) + } - DepNavTheme(darkTheme = darkTheme) { MapScreen(prefs) } + DepNavTheme(darkTheme = darkTheme) { MapScreen(prefs) } + } } } } diff --git a/app/src/main/java/ru/spbu/depnav/ui/component/MainMenuSheet.kt b/app/src/main/java/ru/spbu/depnav/ui/component/MainMenuSheet.kt index 65375d27..f61413f9 100644 --- a/app/src/main/java/ru/spbu/depnav/ui/component/MainMenuSheet.kt +++ b/app/src/main/java/ru/spbu/depnav/ui/component/MainMenuSheet.kt @@ -28,7 +28,7 @@ import androidx.compose.foundation.layout.size import androidx.compose.material.icons.Icons import androidx.compose.material.icons.rounded.Info import androidx.compose.material.icons.rounded.Settings -import androidx.compose.material3.Divider +import androidx.compose.material3.HorizontalDivider import androidx.compose.material3.Icon import androidx.compose.material3.MaterialTheme import androidx.compose.material3.ModalDrawerSheet @@ -65,7 +65,7 @@ fun MainMenuSheet( MapItems(selectedMapId, availableMaps, onMapSelected) - Divider( + HorizontalDivider( modifier = Modifier.padding( horizontal = ITEM_HORIZONTAL_PADDING, vertical = DIVIDER_VERTICAL_PADDING diff --git a/app/src/main/java/ru/spbu/depnav/ui/component/MapSearchBar.kt b/app/src/main/java/ru/spbu/depnav/ui/component/MapSearchBar.kt index 5f1d1845..e0892f5f 100644 --- a/app/src/main/java/ru/spbu/depnav/ui/component/MapSearchBar.kt +++ b/app/src/main/java/ru/spbu/depnav/ui/component/MapSearchBar.kt @@ -36,7 +36,7 @@ import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.systemBars import androidx.compose.foundation.layout.windowInsetsPadding import androidx.compose.material.icons.Icons -import androidx.compose.material.icons.rounded.ArrowBack +import androidx.compose.material.icons.automirrored.rounded.ArrowBack import androidx.compose.material.icons.rounded.Clear import androidx.compose.material.icons.rounded.Menu import androidx.compose.material3.ExperimentalMaterial3Api @@ -47,7 +47,6 @@ import androidx.compose.material3.Text import androidx.compose.material3.minimumInteractiveComponentSize import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue -import androidx.compose.ui.ExperimentalComposeUiApi import androidx.compose.ui.Modifier import androidx.compose.ui.platform.LocalFocusManager import androidx.compose.ui.platform.LocalLayoutDirection @@ -78,7 +77,7 @@ private val ACTIVATION_EXIT_SPEC = tween( "LongMethod", // No point in further shrinking "LongParameterList" // Considered OK for a composable ) -@OptIn(ExperimentalMaterial3Api::class, ExperimentalComposeUiApi::class) +@OptIn(ExperimentalMaterial3Api::class) fun MapSearchBar( query: String, onQueryChange: (String) -> Unit, @@ -181,7 +180,7 @@ private fun AnimatedLeadingIcon( if (active) { IconButton(onClick = onNavigateBackClick) { Icon( - Icons.Rounded.ArrowBack, + Icons.AutoMirrored.Rounded.ArrowBack, contentDescription = stringResource(R.string.label_navigate_back) ) } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 9626f09d..3647a36d 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,10 +1,10 @@ [versions] -kotlin = "1.9.21" -kspPlugin = "1.9.21-1.0.15" -composeCompiler = "1.5.6" -hilt = "2.49" -lifecycle = "2.6.2" +kotlin = "1.9.24" +kspPlugin = "1.9.24-1.0.20" +composeCompiler = "1.5.14" +hilt = "2.51.1" +lifecycle = "2.8.0" room = "2.6.1" @@ -21,11 +21,15 @@ androidx-room-compiler = { group = "androidx.room", name = "room-compiler", vers google-dagger-hilt = { group = "com.google.dagger", name = "hilt-android", version.ref = "hilt" } google-dagger-hiltCompiler = { group = "com.google.dagger", name = "hilt-compiler", version.ref = "hilt" } -androidx-compose-bom = "androidx.compose:compose-bom:2023.10.01" +androidx-compose-bom = "androidx.compose:compose-bom:2024.05.00" +androidx-compose-material3 = { module = "androidx.compose.material3:material3" } +androidx-compose-ui = { module = "androidx.compose.ui:ui" } +androidx-compose-ui-tooling = { module = "androidx.compose.ui:ui-tooling" } +androidx-compose-ui-tooling-preview = { module = "androidx.compose.ui:ui-tooling-preview" } -androidx-core-ktx = "androidx.core:core-ktx:1.12.0" -androidx-activity-compose = "androidx.activity:activity-compose:1.8.1" -plrapps-mapcompose = "ovh.plrapps:mapcompose:2.9.8" +androidx-core-ktx = "androidx.core:core-ktx:1.13.1" +androidx-activity-compose = "androidx.activity:activity-compose:1.9.0" +plrapps-mapcompose = "ovh.plrapps:mapcompose:2.12.4" junit = "junit:junit:4.13.2" androidx-test-runner = "androidx.test:runner:1.5.2" @@ -35,7 +39,7 @@ androidx-test-extJunit = "androidx.test.ext:junit:1.1.5" [plugins] -android-application = "com.android.application:8.2.0" +android-application = { id = "com.android.application", version = "8.4.0" } jetbrains-kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" } google-dagger-hilt-android = { id = "com.google.dagger.hilt.android", version.ref = "hilt" } google-devtools-ksp = { id = "com.google.devtools.ksp", version.ref = "kspPlugin" } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 9d6d1297..a2a2ecc6 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Thu May 18 22:44:59 MSK 2023 +#Fri May 17 12:35:02 MSK 2024 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists From 71d6a094513cfcce59c481eaede6c9f7ec417e94 Mon Sep 17 00:00:00 2001 From: TimPushkin Date: Fri, 17 May 2024 16:45:46 +0300 Subject: [PATCH 2/2] Migrate Gradle scripts to Kotlin DSL --- app/build.gradle | 105 ------------------------------------- app/build.gradle.kts | 116 +++++++++++++++++++++++++++++++++++++++++ app/proguard-rules.pro | 2 +- build.gradle | 9 ---- build.gradle.kts | 9 ++++ settings.gradle | 18 ------- settings.gradle.kts | 24 +++++++++ 7 files changed, 150 insertions(+), 133 deletions(-) delete mode 100644 app/build.gradle create mode 100644 app/build.gradle.kts delete mode 100644 build.gradle create mode 100644 build.gradle.kts delete mode 100644 settings.gradle create mode 100644 settings.gradle.kts diff --git a/app/build.gradle b/app/build.gradle deleted file mode 100644 index dfdbfedd..00000000 --- a/app/build.gradle +++ /dev/null @@ -1,105 +0,0 @@ -plugins { - alias libs.plugins.android.application - alias libs.plugins.jetbrains.kotlin.android - alias libs.plugins.androidx.room - alias libs.plugins.google.dagger.hilt.android - alias libs.plugins.google.devtools.ksp -} - -kotlin { - jvmToolchain(17) - compilerOptions { - freeCompilerArgs.add('-opt-in=kotlin.RequiresOptIn') - } -} - -def keystorePropertiesFile = rootProject.file('keystore.properties') -def keystoreProperties = new Properties() -if (keystorePropertiesFile.exists()) keystoreProperties.load(new FileInputStream(keystorePropertiesFile)) - -def version = ['major': 1, 'minor': 4, 'patch': 0] - -android { - namespace 'ru.spbu.depnav' - - compileSdk 34 - - signingConfigs { - release { - if (!keystoreProperties.isEmpty()) { - storeFile file(keystoreProperties['storeFile']) - storePassword keystoreProperties['storePassword'] - keyAlias keystoreProperties['keyAlias'] - keyPassword keystoreProperties['keyPassword'] - } - } - } - - defaultConfig { - applicationId 'ru.spbu.depnav' - minSdk 21 - targetSdk 34 - versionCode version.major * 10000 + version.minor * 100 + version.patch - versionName "${version.major}.${version.minor}.${version.patch}" - - testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner' - } - - buildTypes { - release { - minifyEnabled true - proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' - signingConfig signingConfigs.release - } - } - - buildFeatures { - compose true - } - composeOptions { - kotlinCompilerExtensionVersion libs.versions.composeCompiler.get() - } - packagingOptions { - resources { - excludes += '/META-INF/{AL2.0,LGPL2.1}' - } - } -} - -dependencies { - implementation libs.androidx.lifecycle.runtimeKtx - implementation libs.androidx.lifecycle.runtimeCompose - implementation libs.androidx.lifecycle.viewmodelCompose - - implementation libs.androidx.room.runtime - implementation libs.androidx.room.ktx - annotationProcessor libs.androidx.room.compiler - ksp libs.androidx.room.compiler - - implementation libs.google.dagger.hilt - ksp libs.google.dagger.hiltCompiler - - implementation platform(libs.androidx.compose.bom) - implementation libs.androidx.compose.material3 - implementation libs.androidx.compose.ui - implementation libs.androidx.compose.ui.tooling.preview - debugImplementation libs.androidx.compose.ui.tooling - - implementation libs.androidx.core.ktx - implementation libs.androidx.activity.compose - implementation libs.plrapps.mapcompose - - testImplementation libs.junit - androidTestImplementation libs.androidx.test.runner - androidTestImplementation libs.androidx.test.rules - androidTestImplementation libs.androidx.test.extJunit -} - -ksp { - arg 'room.incremental', 'true' - arg 'room.generateKotlin', 'true' -} - -room { - schemaDirectory "$projectDir/schemas" -} diff --git a/app/build.gradle.kts b/app/build.gradle.kts new file mode 100644 index 00000000..a3267f2b --- /dev/null +++ b/app/build.gradle.kts @@ -0,0 +1,116 @@ +import java.util.Properties + +plugins { + alias(libs.plugins.android.application) + alias(libs.plugins.jetbrains.kotlin.android) + alias(libs.plugins.androidx.room) + alias(libs.plugins.google.dagger.hilt.android) + alias(libs.plugins.google.devtools.ksp) +} + +object Version { + private const val MAJOR = 1 + private const val MINOR = 4 + private const val PATCH = 0 + + const val CODE = MAJOR * 10000 + MINOR * 100 + PATCH + const val NAME = "$MAJOR.$MINOR.$PATCH" +} + +kotlin { + jvmToolchain(17) + compilerOptions { + freeCompilerArgs.add("-opt-in=kotlin.RequiresOptIn") + } +} + +android { + namespace = "ru.spbu.depnav" + compileSdk = 34 + + defaultConfig { + applicationId = "ru.spbu.depnav" + minSdk = 21 + targetSdk = 34 + versionCode = Version.CODE + versionName = Version.NAME + + testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + } + + signingConfigs { + val keystorePropertiesFile = rootProject.file("keystore.properties") + if (keystorePropertiesFile.exists()) { + val keystoreProperties = Properties().apply { + load(keystorePropertiesFile.inputStream()) + } + create("release") { + storeFile = file(keystoreProperties.getProperty("storeFile")) + storePassword = keystoreProperties.getProperty("storePassword") + keyAlias = keystoreProperties.getProperty("keyAlias") + keyPassword = keystoreProperties.getProperty("keyPassword") + } + } + } + + buildTypes { + release { + isMinifyEnabled = true + proguardFiles( + getDefaultProguardFile("proguard-android-optimize.txt"), + "proguard-rules.pro" + ) + signingConfig = signingConfigs.findByName("release") + } + } + + buildFeatures { + compose = true + } + composeOptions { + kotlinCompilerExtensionVersion = libs.versions.composeCompiler.get() + } + packaging { + resources { + excludes += "/META-INF/{AL2.0,LGPL2.1}" + } + } +} + +dependencies { + implementation(libs.androidx.lifecycle.runtimeKtx) + implementation(libs.androidx.lifecycle.runtimeCompose) + implementation(libs.androidx.lifecycle.viewmodelCompose) + + implementation(libs.androidx.room.runtime) + implementation(libs.androidx.room.ktx) + annotationProcessor(libs.androidx.room.compiler) + ksp(libs.androidx.room.compiler) + + implementation(libs.google.dagger.hilt) + ksp(libs.google.dagger.hiltCompiler) + + implementation(platform(libs.androidx.compose.bom)) + implementation(libs.androidx.compose.material3) + implementation(libs.androidx.compose.ui) + implementation(libs.androidx.compose.ui.tooling.preview) + debugImplementation(libs.androidx.compose.ui.tooling) + + implementation(libs.androidx.core.ktx) + implementation(libs.androidx.activity.compose) + implementation(libs.plrapps.mapcompose) + + testImplementation(libs.junit) + androidTestImplementation(libs.androidx.test.runner) + androidTestImplementation(libs.androidx.test.rules) + androidTestImplementation(libs.androidx.test.extJunit) +} + +ksp { + arg("room.incremental", "true") + arg("room.generateKotlin", "true") +} + +room { + schemaDirectory("$projectDir/schemas") +} diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro index 43a5bd2b..3f1d6fb7 100644 --- a/app/proguard-rules.pro +++ b/app/proguard-rules.pro @@ -1,6 +1,6 @@ # Add project specific ProGuard rules here. # You can control the set of applied configuration files using the -# proguardFiles setting in build.gradle. +# proguardFiles setting in build.gradle.kts. # # For more details, see # http://developer.android.com/guide/developing/tools/proguard.html diff --git a/build.gradle b/build.gradle deleted file mode 100644 index 0a9d4ecb..00000000 --- a/build.gradle +++ /dev/null @@ -1,9 +0,0 @@ -plugins { - alias libs.plugins.android.application apply false - alias libs.plugins.jetbrains.kotlin.android apply false - - // Must be declared in the same scope as AGP to fix https://github.com/google/dagger/issues/3068 - alias libs.plugins.google.dagger.hilt.android apply false - // Must be declared in the same scope as Hilt - alias libs.plugins.google.devtools.ksp apply false -} diff --git a/build.gradle.kts b/build.gradle.kts new file mode 100644 index 00000000..33714b6e --- /dev/null +++ b/build.gradle.kts @@ -0,0 +1,9 @@ +plugins { + alias(libs.plugins.android.application) apply false + alias(libs.plugins.jetbrains.kotlin.android) apply false + + // Must be declared in the same scope as AGP to fix https://github.com/google/dagger/issues/3068 + alias(libs.plugins.google.dagger.hilt.android) apply false + // Must be declared in the same scope as Hilt + alias(libs.plugins.google.devtools.ksp) apply false +} diff --git a/settings.gradle b/settings.gradle deleted file mode 100644 index e9fb9fd8..00000000 --- a/settings.gradle +++ /dev/null @@ -1,18 +0,0 @@ -pluginManagement { - repositories { - google() - mavenCentral() - gradlePluginPortal() - } -} - -dependencyResolutionManagement { - repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) - repositories { - google() - mavenCentral() - } -} - -rootProject.name = 'DepNav' -include ':app' diff --git a/settings.gradle.kts b/settings.gradle.kts new file mode 100644 index 00000000..79e985b3 --- /dev/null +++ b/settings.gradle.kts @@ -0,0 +1,24 @@ +pluginManagement { + repositories { + google { + content { + includeGroupAndSubgroups("com.android") + includeGroupAndSubgroups("com.google") + includeGroupAndSubgroups("androidx") + } + } + mavenCentral() + gradlePluginPortal() + } +} + +dependencyResolutionManagement { + repositoriesMode = RepositoriesMode.FAIL_ON_PROJECT_REPOS + repositories { + google() + mavenCentral() + } +} + +rootProject.name = "DepNav" +include(":app")