From d5f27652d2980244ec81dbb1b1255038260040e1 Mon Sep 17 00:00:00 2001 From: Timofei Pushkin Date: Fri, 19 Sep 2025 19:36:09 +0200 Subject: [PATCH 1/2] Update compile/target SDK and dependencies --- app/build.gradle.kts | 4 +- .../spbu/depnav/ui/component/MainMenuSheet.kt | 5 ++- .../spbu/depnav/ui/viewmodel/MapViewModel.kt | 5 +-- .../java/ru/spbu/depnav/utils/map/Markers.kt | 13 +++--- .../ru/spbu/depnav/utils/ranking/TfIdf.kt | 43 ------------------- gradle/libs.versions.toml | 26 +++++------ gradle/wrapper/gradle-wrapper.properties | 4 +- 7 files changed, 29 insertions(+), 71 deletions(-) delete mode 100644 app/src/main/java/ru/spbu/depnav/utils/ranking/TfIdf.kt diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 1e44785a..81720183 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -27,12 +27,12 @@ kotlin { android { namespace = "ru.spbu.depnav" - compileSdk = 35 + compileSdk = 36 defaultConfig { applicationId = "ru.spbu.depnav" minSdk = 21 - targetSdk = 35 + targetSdk = 36 versionCode = Version.CODE versionName = Version.NAME 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 f61413f9..e338a1f6 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 @@ -18,6 +18,7 @@ package ru.spbu.depnav.ui.component +import android.annotation.SuppressLint import androidx.compose.animation.AnimatedVisibility import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column @@ -44,6 +45,7 @@ import androidx.compose.ui.res.stringResource import androidx.compose.ui.unit.dp import ru.spbu.depnav.R import ru.spbu.depnav.ui.viewmodel.AvailableMap +import androidx.compose.ui.platform.LocalResources // https://m3.material.io/components/navigation-drawer/specs#368147de-9661-4a28-9fc1-ce2f8c9eac40 private val ITEM_HEIGHT = 56.dp @@ -136,7 +138,8 @@ private fun ColumnScope.MapItems( @Composable private fun MapLogo(internalMapName: String, contentDescription: String) { - val logoId = LocalContext.current.resources.getIdentifier( + @SuppressLint("DiscouragedApi") + val logoId = LocalResources.current.getIdentifier( "logo_${internalMapName.replace('-', '_')}", "drawable", LocalContext.current.packageName ) Icon( diff --git a/app/src/main/java/ru/spbu/depnav/ui/viewmodel/MapViewModel.kt b/app/src/main/java/ru/spbu/depnav/ui/viewmodel/MapViewModel.kt index 9674974a..0d27059b 100644 --- a/app/src/main/java/ru/spbu/depnav/ui/viewmodel/MapViewModel.kt +++ b/app/src/main/java/ru/spbu/depnav/ui/viewmodel/MapViewModel.kt @@ -202,7 +202,7 @@ class MapViewModel @Inject constructor( } while (state.value.language != language) val mapState = with(mapInfo) { - MapState(levelsNum, floorWidth, floorHeight, tileSize) { scale(0f) } + MapState(levelsNum, floorWidth, floorHeight, tileSize) { scale(0.0) } }.apply { setScrollOffsetRatio(0.5f, 0.5f) addClusterers(markerAlpha) @@ -275,8 +275,7 @@ class MapViewModel @Inject constructor( x = marker.x, y = marker.y, zIndex = 1f, - clickable = false, - clipShape = null + clickable = false ) { Pin() } } diff --git a/app/src/main/java/ru/spbu/depnav/utils/map/Markers.kt b/app/src/main/java/ru/spbu/depnav/utils/map/Markers.kt index e7144173..fbdcf6af 100644 --- a/app/src/main/java/ru/spbu/depnav/utils/map/Markers.kt +++ b/app/src/main/java/ru/spbu/depnav/utils/map/Markers.kt @@ -32,19 +32,19 @@ import ru.spbu.depnav.data.model.Marker import ru.spbu.depnav.data.model.MarkerText import ru.spbu.depnav.ui.component.MarkerView -private const val INVISIBLE_UNTIL_SCALE_PORTION = 0.2f -private const val OPAQUE_SINCE_SCALE_PORTION = 0.5f -private const val INVISIBLE_UNTIL_SCALED_BY = 0.1f -private const val OPAQUE_SINCE_SCALED_BY = 0.5f +private const val INVISIBLE_UNTIL_SCALE_PORTION = 0.2 +private const val OPAQUE_SINCE_SCALE_PORTION = 0.5 +private const val INVISIBLE_UNTIL_SCALED_BY = 0.1 +private const val OPAQUE_SINCE_SCALED_BY = 0.5 /** Returns alpha value to use for map markers calculated based on the current map scale. */ -fun getMarkerAlpha(minScale: Float, scale: Float, maxScale: Float) = if (minScale < maxScale) { +fun getMarkerAlpha(minScale: Double, scale: Double, maxScale: Double) = if (minScale < maxScale) { val invisibleUntil = minScale + ((maxScale - minScale) * INVISIBLE_UNTIL_SCALE_PORTION) .coerceAtMost(INVISIBLE_UNTIL_SCALED_BY) val opaqueFrom = minScale + ((maxScale - minScale) * OPAQUE_SINCE_SCALE_PORTION) .coerceAtMost(OPAQUE_SINCE_SCALED_BY) val coercedScale = scale.coerceIn(invisibleUntil, opaqueFrom) - (coercedScale - invisibleUntil) / (opaqueFrom - invisibleUntil) + ((coercedScale - invisibleUntil) / (opaqueFrom - invisibleUntil)).toFloat() } else { 1f // minScale >= maxScale, so zooming is impossible, i.e. the scale cannot be changed } @@ -63,7 +63,6 @@ fun MapState.addMarker( y = marker.y, clickable = markerText.run { !title.isNullOrBlank() || !description.isNullOrBlank() }, relativeOffset = Offset(-0.5f, -0.5f), - clipShape = null, renderingStrategy = RenderingStrategy.Clustering(getClustererId(marker.type)) ) { val alpha by alphaFlow.collectAsStateWithLifecycle() diff --git a/app/src/main/java/ru/spbu/depnav/utils/ranking/TfIdf.kt b/app/src/main/java/ru/spbu/depnav/utils/ranking/TfIdf.kt deleted file mode 100644 index 8130f923..00000000 --- a/app/src/main/java/ru/spbu/depnav/utils/ranking/TfIdf.kt +++ /dev/null @@ -1,43 +0,0 @@ -/** - * DepNav -- department navigator. - * Copyright (C) 2022 Timofei Pushkin - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package ru.spbu.depnav.utils.ranking - -import kotlin.math.log10 - -/** tf-idf ranking algorithm. */ -class TfIdf : Ranker { - override fun rank( - queryWordStats: Iterable, - docWordNum: Int, - avgWordNum: Double, - docsNum: Int - ): Double { - var rank = 0.0 - for (queryWordStat in queryWordStats) { - rank += tf(queryWordStat.appearanceNum, docWordNum) * - idf(docsNum, queryWordStat.matchedDocsNum) - } - return rank - } - - private fun tf(appearanceNum: Int, docWordNum: Int) = appearanceNum.toDouble() / docWordNum - - private fun idf(docsCount: Int, matchedDocsCount: Int) = - log10((docsCount + 1.0) / (matchedDocsCount + 1)) -} diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 628e2081..90e08e19 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,10 +1,10 @@ [versions] -kotlin = "2.1.20" -kspPlugin = "2.1.20-2.0.0" -hilt = "2.56.2" -lifecycle = "2.8.7" -room = "2.7.0" +kotlin = "2.2.20" +kspPlugin = "2.2.20-2.0.3" +hilt = "2.57.1" +lifecycle = "2.9.4" +room = "2.7.2" # 2.8.0+ requires minSdk 23, without giving much yet [libraries] @@ -20,25 +20,25 @@ 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:2025.04.00" +androidx-compose-bom = "androidx.compose:compose-bom:2025.09.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.16.0" -androidx-activity-compose = "androidx.activity:activity-compose:1.10.1" -plrapps-mapcompose = "ovh.plrapps:mapcompose:2.16.2" +androidx-core-ktx = "androidx.core:core-ktx:1.17.0" +androidx-activity-compose = "androidx.activity:activity-compose:1.11.0" +plrapps-mapcompose = "ovh.plrapps:mapcompose:3.2.1" junit = "junit:junit:4.13.2" -androidx-test-runner = "androidx.test:runner:1.6.2" -androidx-test-rules = "androidx.test:rules:1.6.1" -androidx-test-extJunit = "androidx.test.ext:junit:1.2.1" +androidx-test-runner = "androidx.test:runner:1.7.0" +androidx-test-rules = "androidx.test:rules:1.7.0" +androidx-test-extJunit = "androidx.test.ext:junit:1.3.0" [plugins] -android-application = { id = "com.android.application", version = "8.9.1" } +android-application = { id = "com.android.application", version = "8.13.0" } jetbrains-kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" } jetbrains-kotlin-plugin-compose = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" } google-dagger-hilt-android = { id = "com.google.dagger.hilt.android", version.ref = "hilt" } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 51edaea4..3d21b1a8 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Tue Aug 27 22:36:14 CEST 2024 +#Fri Sep 19 18:54:02 CEST 2025 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.1.0-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists From 6afab5949e62e713f6ca65bf8166c29baf58fc1e Mon Sep 17 00:00:00 2001 From: Timofei Pushkin Date: Fri, 19 Sep 2025 19:37:14 +0200 Subject: [PATCH 2/2] Bump app version to `1.4.4` --- app/build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 81720183..6f6345f4 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -12,7 +12,7 @@ plugins { object Version { private const val MAJOR = 1 private const val MINOR = 4 - private const val PATCH = 3 + private const val PATCH = 4 const val CODE = MAJOR * 10000 + MINOR * 100 + PATCH const val NAME = "$MAJOR.$MINOR.$PATCH"