Skip to content

Commit 73c2037

Browse files
authored
Merge pull request #89 from TimPushkin/updates
Prepare for `1.4.3`
2 parents d86da02 + 06a4c2b commit 73c2037

File tree

7 files changed

+92
-114
lines changed

7 files changed

+92
-114
lines changed

app/build.gradle.kts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ plugins {
1212
object Version {
1313
private const val MAJOR = 1
1414
private const val MINOR = 4
15-
private const val PATCH = 2
15+
private const val PATCH = 3
1616

1717
const val CODE = MAJOR * 10000 + MINOR * 100 + PATCH
1818
const val NAME = "$MAJOR.$MINOR.$PATCH"
@@ -104,11 +104,6 @@ dependencies {
104104
androidTestImplementation(libs.androidx.test.extJunit)
105105
}
106106

107-
ksp {
108-
arg("room.incremental", "true")
109-
arg("room.generateKotlin", "true")
110-
}
111-
112107
room {
113108
schemaDirectory("$projectDir/schemas")
114109
}

app/src/main/java/ru/spbu/depnav/data/db/DatabaseModule.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ object DatabaseModule {
4343
DB_ASSET
4444
)
4545
.createFromAsset(DB_ASSET)
46-
.fallbackToDestructiveMigration()
46+
.fallbackToDestructiveMigration(false)
4747
.build()
4848

4949
@Provides

app/src/main/java/ru/spbu/depnav/ui/MainActivity.kt

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import androidx.activity.SystemBarStyle
2525
import androidx.activity.compose.setContent
2626
import androidx.activity.enableEdgeToEdge
2727
import androidx.compose.foundation.isSystemInDarkTheme
28-
import androidx.compose.runtime.CompositionLocalProvider
2928
import androidx.compose.runtime.LaunchedEffect
3029
import androidx.compose.runtime.getValue
3130
import androidx.lifecycle.compose.collectAsStateWithLifecycle
@@ -47,27 +46,20 @@ class MainActivity : ComponentActivity() {
4746
super.onCreate(savedInstanceState)
4847

4948
setContent {
50-
CompositionLocalProvider(
51-
// Fix for https://issuetracker.google.com/issues/336842920 -- should be removed as
52-
// soon as Compose UI 1.7.0 becomes stable
53-
androidx.lifecycle.compose.LocalLifecycleOwner provides
54-
androidx.compose.ui.platform.LocalLifecycleOwner.current
55-
) {
56-
val themeMode by prefs.themeModeFlow.collectAsStateWithLifecycle()
57-
val darkTheme = when (themeMode) {
58-
ThemeMode.LIGHT -> false
59-
ThemeMode.DARK -> true
60-
ThemeMode.SYSTEM -> isSystemInDarkTheme()
61-
}
62-
63-
LaunchedEffect(darkTheme) {
64-
val style =
65-
SystemBarStyle.auto(Color.TRANSPARENT, Color.TRANSPARENT) { darkTheme }
66-
enableEdgeToEdge(style, style)
67-
}
49+
val themeMode by prefs.themeModeFlow.collectAsStateWithLifecycle()
50+
val darkTheme = when (themeMode) {
51+
ThemeMode.LIGHT -> false
52+
ThemeMode.DARK -> true
53+
ThemeMode.SYSTEM -> isSystemInDarkTheme()
54+
}
6855

69-
DepNavTheme(darkTheme = darkTheme) { MapScreen(prefs) }
56+
LaunchedEffect(darkTheme) {
57+
val style =
58+
SystemBarStyle.auto(Color.TRANSPARENT, Color.TRANSPARENT) { darkTheme }
59+
enableEdgeToEdge(style, style)
7060
}
61+
62+
DepNavTheme(darkTheme = darkTheme) { MapScreen(prefs) }
7163
}
7264
}
7365
}

app/src/main/java/ru/spbu/depnav/ui/component/MapSearchBar.kt

Lines changed: 61 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@ import androidx.compose.foundation.layout.Spacer
2929
import androidx.compose.foundation.layout.WindowInsets
3030
import androidx.compose.foundation.layout.WindowInsetsSides
3131
import androidx.compose.foundation.layout.asPaddingValues
32-
import androidx.compose.foundation.layout.calculateEndPadding
33-
import androidx.compose.foundation.layout.calculateStartPadding
3432
import androidx.compose.foundation.layout.only
3533
import androidx.compose.foundation.layout.padding
3634
import androidx.compose.foundation.layout.safeDrawing
@@ -50,23 +48,25 @@ import androidx.compose.material3.minimumInteractiveComponentSize
5048
import androidx.compose.runtime.Composable
5149
import androidx.compose.runtime.getValue
5250
import androidx.compose.ui.Modifier
51+
import androidx.compose.ui.platform.LocalDensity
5352
import androidx.compose.ui.platform.LocalFocusManager
5453
import androidx.compose.ui.platform.LocalLayoutDirection
5554
import androidx.compose.ui.platform.LocalSoftwareKeyboardController
5655
import androidx.compose.ui.res.stringResource
5756
import androidx.compose.ui.text.style.TextOverflow
57+
import ovh.plrapps.mapcompose.utils.lerp
5858
import ru.spbu.depnav.R
5959
import ru.spbu.depnav.ui.theme.DEFAULT_PADDING
6060
import ru.spbu.depnav.ui.theme.ON_MAP_SURFACE_ALPHA
6161
import ru.spbu.depnav.ui.viewmodel.SearchResults
6262

6363
// These are basically copied from SearchBar implementation
64-
private val ACTIVATION_ENTER_SPEC = tween<Float>(
64+
private val EXPANSION_ENTER_SPEC = tween<Float>(
6565
durationMillis = 600,
6666
delayMillis = 100,
6767
easing = CubicBezierEasing(0.05f, 0.7f, 0.1f, 1.0f)
6868
)
69-
private val ACTIVATION_EXIT_SPEC = tween<Float>(
69+
private val EXPANSION_EXIT_SPEC = tween<Float>(
7070
durationMillis = 350,
7171
delayMillis = 100,
7272
easing = CubicBezierEasing(0.0f, 1.0f, 0.0f, 1.0f)
@@ -76,106 +76,97 @@ private val ACTIVATION_EXIT_SPEC = tween<Float>(
7676
* Search bar for querying map markers on [ru.spbu.depnav.ui.screen.MapScreen].
7777
*/
7878
@Composable
79-
@Suppress(
80-
"LongMethod", // No point in further shrinking
81-
"LongParameterList" // Considered OK for a composable
82-
)
79+
@Suppress("LongParameterList") // Considered OK for a composable
8380
@OptIn(ExperimentalMaterial3Api::class)
8481
fun MapSearchBar(
8582
query: String,
8683
onQueryChange: (String) -> Unit,
8784
mapTitle: String,
88-
active: Boolean,
89-
onActiveChange: (Boolean) -> Unit,
85+
expanded: Boolean,
86+
onExpandedChange: (Boolean) -> Unit,
9087
results: SearchResults,
9188
onResultClick: (Int) -> Unit,
9289
onMenuClick: () -> Unit,
9390
modifier: Modifier = Modifier
9491
) {
95-
val activationAnimationProgress by animateFloatAsState(
96-
targetValue = if (active) 1f else 0f,
97-
animationSpec = if (active) ACTIVATION_ENTER_SPEC else ACTIVATION_EXIT_SPEC,
92+
val expansionAnimationProgress by animateFloatAsState(
93+
targetValue = if (expanded) 1f else 0f,
94+
animationSpec = if (expanded) EXPANSION_ENTER_SPEC else EXPANSION_EXIT_SPEC,
9895
label = "Map search bar activation animation progress"
9996
)
10097

101-
val (insetsStartPadding, insetsEndPadding) = with(WindowInsets.safeDrawing.asPaddingValues()) {
102-
val layoutDirection = LocalLayoutDirection.current
103-
calculateStartPadding(layoutDirection) to calculateEndPadding(layoutDirection)
104-
}
105-
106-
val outerStartPadding = insetsStartPadding * (1 - activationAnimationProgress)
107-
val outerEndPadding = insetsEndPadding * (1 - activationAnimationProgress)
108-
val innerStartPadding = insetsStartPadding * activationAnimationProgress
109-
val innerEndPadding = insetsEndPadding * activationAnimationProgress
110-
111-
val focusManager = LocalFocusManager.current
112-
113-
val containerColorAlpha =
114-
ON_MAP_SURFACE_ALPHA + (1 - ON_MAP_SURFACE_ALPHA) * activationAnimationProgress
115-
11698
SearchBar(
117-
query = query,
118-
onQueryChange = onQueryChange,
119-
onSearch = { focusManager.clearFocus() },
120-
active = active,
121-
onActiveChange = onActiveChange,
122-
modifier = Modifier
123-
.run {
124-
if (active) padding(start = outerStartPadding, end = outerEndPadding)
125-
else windowInsetsPadding(WindowInsets.safeDrawing.only(WindowInsetsSides.Horizontal))
126-
}
127-
.then(modifier),
128-
placeholder = {
129-
Text(
130-
stringResource(R.string.search_on_map, mapTitle),
131-
overflow = TextOverflow.Ellipsis,
132-
maxLines = 1
133-
)
134-
},
135-
leadingIcon = {
136-
AnimatedLeadingIcon(
137-
active,
138-
onMenuClick = onMenuClick,
139-
modifier = Modifier.padding(start = innerStartPadding),
140-
onNavigateBackClick = { onActiveChange(false) }
141-
)
142-
},
143-
trailingIcon = {
144-
AnimatedTrailingIcon(
145-
active,
146-
query.isEmpty(),
147-
onClearClick = { onQueryChange("") },
148-
modifier = Modifier.padding(end = innerEndPadding)
99+
inputField = {
100+
SearchBarDefaults.InputField(
101+
query = query,
102+
onQueryChange = onQueryChange,
103+
onSearch = with (LocalFocusManager.current) { { clearFocus() } },
104+
expanded = expanded,
105+
onExpandedChange = onExpandedChange,
106+
modifier = Modifier.windowInsetsPadding(
107+
WindowInsets.safeDrawing.only(WindowInsetsSides.Horizontal) *
108+
expansionAnimationProgress
109+
),
110+
placeholder = {
111+
Text(
112+
stringResource(R.string.search_on_map, mapTitle),
113+
overflow = TextOverflow.Ellipsis,
114+
maxLines = 1
115+
)
116+
},
117+
leadingIcon = {
118+
AnimatedLeadingIcon(
119+
expanded,
120+
onMenuClick = onMenuClick,
121+
onNavigateBackClick = { onExpandedChange(false) }
122+
)
123+
},
124+
trailingIcon = {
125+
AnimatedTrailingIcon(
126+
expanded,
127+
queryEmpty = query.isEmpty(),
128+
onClearClick = { onQueryChange("") }
129+
)
130+
}
149131
)
150132
},
133+
expanded = expanded,
134+
onExpandedChange = onExpandedChange,
135+
modifier = modifier,
151136
colors = SearchBarDefaults.colors(
152137
containerColor = MaterialTheme.colorScheme.surfaceVariant.copy(
153-
alpha = containerColorAlpha
138+
alpha = lerp(ON_MAP_SURFACE_ALPHA, 1f, expansionAnimationProgress)
154139
)
155-
)
140+
),
156141
) {
157142
val keyboard = LocalSoftwareKeyboardController.current
158143

159144
SearchResultsView(
160145
results,
161146
onScroll = { onTop -> keyboard?.apply { if (onTop) show() else hide() } },
162147
onResultClick = {
163-
onActiveChange(false)
148+
onExpandedChange(false)
164149
onResultClick(it)
165150
},
166151
modifier = Modifier
152+
.windowInsetsPadding(WindowInsets.safeDrawing)
167153
.padding(horizontal = DEFAULT_PADDING * 1.5f)
168-
.padding(
169-
start = innerStartPadding,
170-
end = innerEndPadding,
171-
bottom = WindowInsets.safeDrawing
172-
.asPaddingValues()
173-
.calculateBottomPadding()
174-
)
175154
)
176155
}
177156
}
178157

158+
@Composable
159+
private operator fun WindowInsets.times(num: Float): WindowInsets {
160+
val paddings = asPaddingValues(LocalDensity.current)
161+
val layoutDirection = LocalLayoutDirection.current
162+
return WindowInsets(
163+
paddings.calculateLeftPadding(layoutDirection) * num,
164+
paddings.calculateTopPadding() * num,
165+
paddings.calculateRightPadding(layoutDirection) * num,
166+
paddings.calculateBottomPadding() * num
167+
)
168+
}
169+
179170
@Composable
180171
private fun AnimatedLeadingIcon(
181172
searchBarActive: Boolean,

app/src/main/java/ru/spbu/depnav/ui/screen/MapScreen.kt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -218,12 +218,12 @@ private fun BoxScope.AnimatedSearchBar(
218218
onResultClick: (Int) -> Unit,
219219
onMenuClick: () -> Unit
220220
) {
221-
var searchBarActive by rememberSaveable { mutableStateOf(false) }
221+
var searchBarExpanded by rememberSaveable { mutableStateOf(false) }
222222
if (!visible) {
223-
searchBarActive = false
223+
searchBarExpanded = false
224224
}
225225

226-
if (!searchBarActive && query.isNotEmpty()) {
226+
if (!searchBarExpanded && query.isNotEmpty()) {
227227
onQueryChange("")
228228
}
229229

@@ -236,16 +236,16 @@ private fun BoxScope.AnimatedSearchBar(
236236
exit = slideOutVertically(targetOffsetY = { -it }) + fadeOut()
237237
) {
238238
val horizontalPadding by animateDpAsState(
239-
if (searchBarActive) 0.dp else DEFAULT_PADDING,
239+
if (searchBarExpanded) 0.dp else DEFAULT_PADDING,
240240
label = "Map search bar horizontal padding"
241241
)
242242

243243
MapSearchBar(
244244
query = query,
245245
onQueryChange = onQueryChange,
246246
mapTitle = mapTitle,
247-
active = searchBarActive,
248-
onActiveChange = { searchBarActive = it },
247+
expanded = searchBarExpanded,
248+
onExpandedChange = { searchBarExpanded = it },
249249
results = searchResults,
250250
onResultClick = onResultClick,
251251
onMenuClick = onMenuClick,

gradle/libs.versions.toml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
[versions]
22

3-
kotlin = "2.0.20"
4-
kspPlugin = "2.0.20-1.0.24"
5-
hilt = "2.52"
6-
lifecycle = "2.8.4"
7-
room = "2.6.1"
3+
kotlin = "2.1.20"
4+
kspPlugin = "2.1.20-2.0.0"
5+
hilt = "2.56.2"
6+
lifecycle = "2.8.7"
7+
room = "2.7.0"
88

99

1010
[libraries]
@@ -20,15 +20,15 @@ androidx-room-compiler = { group = "androidx.room", name = "room-compiler", vers
2020
google-dagger-hilt = { group = "com.google.dagger", name = "hilt-android", version.ref = "hilt" }
2121
google-dagger-hiltCompiler = { group = "com.google.dagger", name = "hilt-compiler", version.ref = "hilt" }
2222

23-
androidx-compose-bom = "androidx.compose:compose-bom:2024.08.00"
23+
androidx-compose-bom = "androidx.compose:compose-bom:2025.04.00"
2424
androidx-compose-material3 = { module = "androidx.compose.material3:material3" }
2525
androidx-compose-ui = { module = "androidx.compose.ui:ui" }
2626
androidx-compose-ui-tooling = { module = "androidx.compose.ui:ui-tooling" }
2727
androidx-compose-ui-tooling-preview = { module = "androidx.compose.ui:ui-tooling-preview" }
2828

29-
androidx-core-ktx = "androidx.core:core-ktx:1.13.1"
30-
androidx-activity-compose = "androidx.activity:activity-compose:1.9.1"
31-
plrapps-mapcompose = "ovh.plrapps:mapcompose:2.12.6"
29+
androidx-core-ktx = "androidx.core:core-ktx:1.16.0"
30+
androidx-activity-compose = "androidx.activity:activity-compose:1.10.1"
31+
plrapps-mapcompose = "ovh.plrapps:mapcompose:2.16.2"
3232

3333
junit = "junit:junit:4.13.2"
3434
androidx-test-runner = "androidx.test:runner:1.6.2"
@@ -38,7 +38,7 @@ androidx-test-extJunit = "androidx.test.ext:junit:1.2.1"
3838

3939
[plugins]
4040

41-
android-application = { id = "com.android.application", version = "8.5.2" }
41+
android-application = { id = "com.android.application", version = "8.9.1" }
4242
jetbrains-kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
4343
jetbrains-kotlin-plugin-compose = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
4444
google-dagger-hilt-android = { id = "com.google.dagger.hilt.android", version.ref = "hilt" }
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#Tue Aug 27 22:36:14 CEST 2024
22
distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
4-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip
4+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
55
zipStoreBase=GRADLE_USER_HOME
66
zipStorePath=wrapper/dists

0 commit comments

Comments
 (0)