diff --git a/app/build.gradle b/app/build.gradle index c25b74de..e4412624 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -3,28 +3,18 @@ plugins { alias libs.plugins.jetbrains.kotlin.android alias libs.plugins.google.dagger.hilt.android alias libs.plugins.google.devtools.ksp - id 'kotlin-kapt' } def keystorePropertiesFile = rootProject.file('keystore.properties') def keystoreProperties = new Properties() if (keystorePropertiesFile.exists()) keystoreProperties.load(new FileInputStream(keystorePropertiesFile)) -static def versionToCode(major, minor, patch) { - assert 0 <= major && major <= 99 - assert 0 <= minor && minor <= 99 - assert 0 <= patch && patch <= 99 - return major * 10000 + minor * 100 + patch -} - -static def versionToName(major, minor, patch) { - return "$major.$minor.$patch" -} +def version = ['major': 1, 'minor': 3, 'patch': 3] android { namespace 'ru.spbu.depnav' - compileSdk 33 + compileSdk 34 signingConfigs { release { @@ -40,9 +30,9 @@ android { defaultConfig { applicationId 'ru.spbu.depnav' minSdk 21 - targetSdk 33 - versionCode versionToCode(1, 3, 3) - versionName versionToName(1, 3, 3) + targetSdk 34 + versionCode version.major * 10000 + version.minor * 100 + version.patch + versionName "${version.major}.${version.minor}.${version.patch}" testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner' @@ -59,10 +49,6 @@ android { } } - compileOptions { - sourceCompatibility JavaVersion.VERSION_17 - targetCompatibility JavaVersion.VERSION_17 - } kotlin { jvmToolchain(17) } @@ -92,7 +78,7 @@ dependencies { ksp libs.androidx.room.compiler implementation libs.google.dagger.hilt - kapt libs.google.dagger.hiltCompiler + ksp libs.google.dagger.hiltCompiler implementation platform(libs.androidx.compose.bom) implementation 'androidx.compose.ui:ui' @@ -105,15 +91,9 @@ dependencies { implementation libs.androidx.navigation.compose implementation libs.androidx.hilt.navigationCompose implementation libs.plrapps.mapcompose - implementation libs.google.accompanist.systemuicontroller testImplementation libs.junit androidTestImplementation libs.androidx.test.runner androidTestImplementation libs.androidx.test.rules androidTestImplementation libs.androidx.test.extJunit } - -// Hilt configuration -kapt { - correctErrorTypes true -} diff --git a/app/src/main/java/ru/spbu/depnav/MainActivity.kt b/app/src/main/java/ru/spbu/depnav/MainActivity.kt index 7860654d..55e4200c 100644 --- a/app/src/main/java/ru/spbu/depnav/MainActivity.kt +++ b/app/src/main/java/ru/spbu/depnav/MainActivity.kt @@ -18,12 +18,15 @@ package ru.spbu.depnav +import android.graphics.Color import android.os.Bundle import androidx.activity.ComponentActivity +import androidx.activity.SystemBarStyle import androidx.activity.compose.setContent +import androidx.activity.enableEdgeToEdge import androidx.activity.viewModels import androidx.compose.foundation.isSystemInDarkTheme -import androidx.core.view.WindowCompat +import androidx.compose.runtime.LaunchedEffect import androidx.lifecycle.viewModelScope import androidx.navigation.compose.NavHost import androidx.navigation.compose.composable @@ -50,16 +53,20 @@ class MainActivity : ComponentActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - WindowCompat.setDecorFitsSystemWindows(window, false) - setContent { - DepNavTheme( - darkTheme = when (prefs.themeMode) { - PreferencesManager.ThemeMode.LIGHT -> false - PreferencesManager.ThemeMode.DARK -> true - PreferencesManager.ThemeMode.SYSTEM -> isSystemInDarkTheme() - } - ) { + val darkTheme = when (prefs.themeMode) { + PreferencesManager.ThemeMode.LIGHT -> false + PreferencesManager.ThemeMode.DARK -> true + PreferencesManager.ThemeMode.SYSTEM -> isSystemInDarkTheme() + } + + LaunchedEffect(darkTheme) { + val systemBarStyle = + SystemBarStyle.auto(Color.TRANSPARENT, Color.TRANSPARENT) { darkTheme } + enableEdgeToEdge(systemBarStyle, systemBarStyle) + } + + DepNavTheme(darkTheme = darkTheme) { val navController = rememberNavController() NavHost(navController = navController, startDestination = NavDestination.MAP.name) { diff --git a/app/src/main/java/ru/spbu/depnav/ui/map/FloorSwitch.kt b/app/src/main/java/ru/spbu/depnav/ui/map/FloorSwitch.kt index 913b0437..01331509 100644 --- a/app/src/main/java/ru/spbu/depnav/ui/map/FloorSwitch.kt +++ b/app/src/main/java/ru/spbu/depnav/ui/map/FloorSwitch.kt @@ -25,7 +25,7 @@ import androidx.compose.animation.fadeIn import androidx.compose.animation.fadeOut import androidx.compose.animation.slideInVertically import androidx.compose.animation.slideOutVertically -import androidx.compose.animation.with +import androidx.compose.animation.togetherWith import androidx.compose.foundation.layout.Column import androidx.compose.foundation.shape.CircleShape import androidx.compose.material.icons.Icons @@ -44,7 +44,6 @@ import ru.spbu.depnav.R import ru.spbu.depnav.ui.theme.DepNavTheme /** Two buttons to switch the current map one floor up or down. */ -@OptIn(ExperimentalAnimationApi::class) @Composable fun FloorSwitch( floor: Int, @@ -72,13 +71,14 @@ fun FloorSwitch( targetState = floor, transitionSpec = { if (targetState > initialState) { - slideInVertically { height -> -height } + fadeIn() with + slideInVertically { height -> -height } + fadeIn() togetherWith slideOutVertically { height -> height } + fadeOut() } else { - slideInVertically { height -> height } + fadeIn() with + slideInVertically { height -> height } + fadeIn() togetherWith slideOutVertically { height -> -height } + fadeOut() } using SizeTransform(clip = false) - } + }, + label = "floor switch scroll" ) { targetFloor -> Text(targetFloor.toString()) } diff --git a/app/src/main/java/ru/spbu/depnav/ui/map/MapScreenViewModel.kt b/app/src/main/java/ru/spbu/depnav/ui/map/MapScreenViewModel.kt index 80ecfee3..efbc580e 100644 --- a/app/src/main/java/ru/spbu/depnav/ui/map/MapScreenViewModel.kt +++ b/app/src/main/java/ru/spbu/depnav/ui/map/MapScreenViewModel.kt @@ -20,6 +20,7 @@ package ru.spbu.depnav.ui.map import android.util.Log import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableIntStateOf import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.setValue import androidx.compose.runtime.snapshotFlow @@ -98,11 +99,11 @@ class MapScreenViewModel @Inject constructor( private var floors = emptyMap() /** Number of floors the current map has. */ - var floorsNum by mutableStateOf(floors.size) + var floorsNum by mutableIntStateOf(floors.size) private set /** The floor currently displayed. */ - var currentFloor by mutableStateOf(0) + var currentFloor by mutableIntStateOf(0) /** Controls the color of map tiles. */ var tileColor: Color = Color.Black diff --git a/app/src/main/java/ru/spbu/depnav/ui/map/TopButton.kt b/app/src/main/java/ru/spbu/depnav/ui/map/TopButton.kt index 81b9fb96..c85458b3 100644 --- a/app/src/main/java/ru/spbu/depnav/ui/map/TopButton.kt +++ b/app/src/main/java/ru/spbu/depnav/ui/map/TopButton.kt @@ -77,6 +77,8 @@ fun TopButton( text = text, modifier = Modifier .weight(1f) + // TODO: fix this being applied in landscape mode even when there is enough + // space .basicMarquee(), maxLines = 1, ) diff --git a/app/src/main/java/ru/spbu/depnav/ui/theme/Theme.kt b/app/src/main/java/ru/spbu/depnav/ui/theme/Theme.kt index 3d924fd5..6877f737 100644 --- a/app/src/main/java/ru/spbu/depnav/ui/theme/Theme.kt +++ b/app/src/main/java/ru/spbu/depnav/ui/theme/Theme.kt @@ -26,11 +26,8 @@ import androidx.compose.material3.dynamicDarkColorScheme import androidx.compose.material3.dynamicLightColorScheme import androidx.compose.material3.lightColorScheme import androidx.compose.runtime.Composable -import androidx.compose.runtime.SideEffect -import androidx.compose.ui.graphics.Color import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.unit.dp -import com.google.accompanist.systemuicontroller.rememberSystemUiController private val LightColorScheme = lightColorScheme( primary = md_theme_light_primary, @@ -106,11 +103,6 @@ fun DepNavTheme( dynamicColor: Boolean = true, content: @Composable () -> Unit ) { - val systemUiController = rememberSystemUiController() - SideEffect { - systemUiController.setSystemBarsColor(color = Color.Transparent, darkIcons = !darkTheme) - } - val colorScheme = when { dynamicColor && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> { val context = LocalContext.current diff --git a/build.gradle b/build.gradle index 107153d0..0a9d4ecb 100644 --- a/build.gradle +++ b/build.gradle @@ -1,9 +1,9 @@ plugins { alias libs.plugins.android.application apply false alias libs.plugins.jetbrains.kotlin.android apply false - alias libs.plugins.google.dagger.hilt.android apply false -} -task clean(type: Delete) { - delete rootProject.buildDir + // 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/gradle/libs.versions.toml b/gradle/libs.versions.toml index 18ffd397..f2c299ca 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,11 +1,11 @@ [versions] -kotlin = "1.8.21" -ksp = "1.0.11" -kspPlugin = "1.8.21-1.0.11" # Should be "$kotlin-$ksp", but could not find a way to do this automatically -composeCompiler = "1.4.7" -hilt = "2.46.1" -lifecycle = "2.6.1" +kotlin = "1.9.10" +ksp = "1.0.13" +kspPlugin = "1.9.10-1.0.13" # Must be "$kotlin-$ksp" +composeCompiler = "1.5.3" +hilt = "2.48.1" +lifecycle = "2.6.2" room = "2.5.2" @@ -21,16 +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.06.01" +androidx-compose-bom = "androidx.compose:compose-bom:2023.10.00" -androidx-core-ktx = "androidx.core:core-ktx:1.10.1" -androidx-activity-compose = "androidx.activity:activity-compose:1.7.2" -androidx-navigation-compose = "androidx.navigation:navigation-compose:2.6.0" +androidx-core-ktx = "androidx.core:core-ktx:1.12.0" +androidx-activity-compose = "androidx.activity:activity-compose:1.8.0" +androidx-navigation-compose = "androidx.navigation:navigation-compose:2.7.4" androidx-hilt-navigationCompose = "androidx.hilt:hilt-navigation-compose:1.0.0" -plrapps-mapcompose = "ovh.plrapps:mapcompose:2.7.1" -google-accompanist-systemuicontroller = "com.google.accompanist:accompanist-systemuicontroller:0.30.1" +plrapps-mapcompose = "ovh.plrapps:mapcompose:2.9.4" -junit = 'junit:junit:4.13.2' +junit = "junit:junit:4.13.2" androidx-test-runner = "androidx.test:runner:1.5.2" androidx-test-rules = "androidx.test:rules:1.5.0" androidx-test-extJunit = "androidx.test.ext:junit:1.1.5" @@ -38,7 +37,7 @@ androidx-test-extJunit = "androidx.test.ext:junit:1.1.5" [plugins] -android-application = "com.android.application:8.0.2" +android-application = "com.android.application:8.1.2" 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 6f3ac1d9..3e19f2a7 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 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/settings.gradle b/settings.gradle index 104c679d..e9fb9fd8 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,8 +1,8 @@ pluginManagement { repositories { - gradlePluginPortal() google() mavenCentral() + gradlePluginPortal() } }