Skip to content

Commit

Permalink
Merge pull request #73 from TimPushkin/updates
Browse files Browse the repository at this point in the history
Upgrade dependencies
  • Loading branch information
TimPushkin authored Oct 27, 2023
2 parents 6ba4494 + 3405dd8 commit 2a9b615
Show file tree
Hide file tree
Showing 10 changed files with 52 additions and 71 deletions.
32 changes: 6 additions & 26 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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'

Expand All @@ -59,10 +49,6 @@ android {
}
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}
kotlin {
jvmToolchain(17)
}
Expand Down Expand Up @@ -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'
Expand All @@ -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
}
27 changes: 17 additions & 10 deletions app/src/main/java/ru/spbu/depnav/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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) {
Expand Down
10 changes: 5 additions & 5 deletions app/src/main/java/ru/spbu/depnav/ui/map/FloorSwitch.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand Down Expand Up @@ -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())
}
Expand Down
5 changes: 3 additions & 2 deletions app/src/main/java/ru/spbu/depnav/ui/map/MapScreenViewModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -98,11 +99,11 @@ class MapScreenViewModel @Inject constructor(
private var floors = emptyMap<Int, Floor>()

/** 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
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/java/ru/spbu/depnav/ui/map/TopButton.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Expand Down
8 changes: 0 additions & 8 deletions app/src/main/java/ru/spbu/depnav/ui/theme/Theme.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -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
}
27 changes: 13 additions & 14 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -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"


Expand All @@ -21,24 +21,23 @@ 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"


[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" }
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
pluginManagement {
repositories {
gradlePluginPortal()
google()
mavenCentral()
gradlePluginPortal()
}
}

Expand Down

0 comments on commit 2a9b615

Please sign in to comment.