Skip to content

Commit

Permalink
Upgrade Kotlin to 1.9.22 and Upgrade dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickgold committed Feb 14, 2024
1 parent 6e4c4f0 commit e59afbc
Show file tree
Hide file tree
Showing 11 changed files with 43 additions and 73 deletions.
1 change: 0 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,5 @@ plugins {
alias(libs.plugins.agp.library) apply false
alias(libs.plugins.kotlin.android) apply false
alias(libs.plugins.kotlin.jvm) apply false
alias(libs.plugins.mannodermaus.android.junit5) apply false
alias(libs.plugins.vanniktech.maven.publish) apply false
}
1 change: 0 additions & 1 deletion datastore-model/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
plugins {
alias(libs.plugins.agp.library)
alias(libs.plugins.kotlin.android)
alias(libs.plugins.mannodermaus.android.junit5)
alias(libs.plugins.vanniktech.maven.publish)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,5 @@ package dev.patrickgold.jetpref.datastore.ui
*/
@Target(AnnotationTarget.CLASS, AnnotationTarget.PROPERTY, AnnotationTarget.FUNCTION, AnnotationTarget.TYPEALIAS)
@RequiresOptIn(level = RequiresOptIn.Level.WARNING)
@Retention(value = AnnotationRetention.BINARY)
annotation class ExperimentalJetPrefDatastoreUi
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import androidx.compose.material.SliderDefaults
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableFloatStateOf
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
Expand Down Expand Up @@ -67,7 +68,7 @@ internal fun <T : PreferenceModel, V> PreferenceUiScope<T>.DialogSliderPreferenc
require(max > min) { "Maximum value ($max) must be greater than minimum value ($min)!" }

val prefValue by pref.observeAsState()
val (sliderValue, setSliderValue) = remember { mutableStateOf(0.0f) }
val (sliderValue, setSliderValue) = remember { mutableFloatStateOf(0.0f) }
val isDialogOpen = remember { mutableStateOf(false) }

val evalScope = PreferenceDataEvaluatorScope.instance()
Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ android.nonFinalResIds=false

### JetPref-specific flags used in build.gradle.kts scripts ###

projectCompileSdk=33
projectCompileSdk=34
projectMinSdk=23
projectTargetSdk=33
projectTargetSdk=34
projectGroupId=dev.patrickgold.jetpref
projectVersion=0.1.0-beta14

Expand Down
22 changes: 8 additions & 14 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
[versions]
# Main
android-gradle-plugin = "8.2.2"
androidx-activity = "1.5.1"
androidx-compose = "1.4.3"
androidx-compose-compiler = "1.4.7"
androidx-core = "1.10.0"
androidx-lifecycle = "2.5.1"
androidx-navigation = "2.5.1"
kotlin = "1.8.21"
kotlinx-coroutines = "1.7.0"
mannodermaus-android-junit5 = "1.8.2.1"
androidx-activity = "1.8.2"
androidx-compose = "1.6.1"
androidx-compose-compiler = "1.5.9"
androidx-core = "1.12.0"
androidx-lifecycle = "2.7.0"
androidx-navigation = "2.7.7"
kotlin = "1.9.22"
kotlinx-coroutines = "1.7.3"
vanniktech-maven-publish = "0.25.2"

# Testing
androidx-test-ext = "1.1.3"
androidx-test-espresso = "3.4.0"
kotest = "5.4.0"

[libraries]
Expand All @@ -32,8 +29,6 @@ androidx-navigation-compose = { module = "androidx.navigation:navigation-compose
kotlinx-coroutines = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-android", version.ref = "kotlinx-coroutines" }

# Testing
androidx-test-ext = { module = "androidx.test.ext:junit", version.ref = "androidx-test-ext" }
androidx-test-espresso-core = { module = "androidx.test.espresso:espresso-core", version.ref = "androidx-test-espresso" }
kotest-assertions-core = { module = "io.kotest:kotest-assertions-core", version.ref = "kotest" }
kotest-property = { module = "io.kotest:kotest-property", version.ref = "kotest" }
kotest-runner-junit5 = { module = "io.kotest:kotest-runner-junit5", version.ref = "kotest" }
Expand All @@ -44,5 +39,4 @@ agp-application = { id = "com.android.application", version.ref = "android-gradl
agp-library = { id = "com.android.library", version.ref = "android-gradle-plugin" }
kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
mannodermaus-android-junit5 = { id = "de.mannodermaus.android-junit5", version.ref = "mannodermaus-android-junit5" }
vanniktech-maven-publish = { id = "com.vanniktech.maven.publish", version.ref = "vanniktech-maven-publish" }
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,5 @@ package dev.patrickgold.jetpref.material.ui
*/
@Target(AnnotationTarget.CLASS, AnnotationTarget.PROPERTY, AnnotationTarget.FUNCTION, AnnotationTarget.TYPEALIAS)
@RequiresOptIn(level = RequiresOptIn.Level.WARNING)
@Retention(value = AnnotationRetention.BINARY)
annotation class ExperimentalJetPrefMaterialUi
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ internal inline fun whenNotNullOrBlank(
crossinline composer: @Composable (text: String) -> Unit,
): @Composable (() -> Unit)? {
return when {
string != null && string.isNotBlank() -> ({ composer(string) })
!string.isNullOrBlank() -> ({ composer(string) })
else -> null
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ import androidx.compose.material.TextButton
import androidx.compose.material.contentColorFor
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.Shape
Expand Down Expand Up @@ -89,7 +88,6 @@ import androidx.compose.ui.window.DialogProperties
* @see androidx.compose.material.AlertDialog
* @see androidx.compose.ui.window.Dialog
*/
@OptIn(ExperimentalComposeUiApi::class)
@Composable
fun JetPrefAlertDialog(
title: String,
Expand Down Expand Up @@ -154,7 +152,7 @@ fun JetPrefAlertDialog(
content()
}
Row(modifier = Modifier.padding(vertical = 8.dp, horizontal = 16.dp)) {
if (neutralLabel != null && neutralLabel.isNotBlank()) {
if (!neutralLabel.isNullOrBlank()) {
TextButton(
onClick = onNeutral,
modifier = Modifier.padding(end = 8.dp),
Expand All @@ -164,7 +162,7 @@ fun JetPrefAlertDialog(
}
}
Spacer(modifier = Modifier.weight(1.0f))
if (dismissLabel != null && dismissLabel.isNotBlank()) {
if (!dismissLabel.isNullOrBlank()) {
TextButton(
onClick = onDismiss,
modifier = Modifier.padding(end = 8.dp),
Expand All @@ -173,7 +171,7 @@ fun JetPrefAlertDialog(
Text(dismissLabel)
}
}
if (confirmLabel != null && confirmLabel.isNotBlank()) {
if (!confirmLabel.isNullOrBlank()) {
TextButton(
onClick = onConfirm,
colors = confirmColors,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ package dev.patrickgold.jetpref.material.ui

import androidx.compose.foundation.BorderStroke
import androidx.compose.foundation.Image
import androidx.compose.foundation.gestures.awaitEachGesture
import androidx.compose.foundation.gestures.awaitFirstDown
import androidx.compose.foundation.gestures.drag
import androidx.compose.foundation.gestures.forEachGesture
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.BoxWithConstraints
import androidx.compose.foundation.layout.Column
Expand All @@ -40,7 +40,7 @@ import androidx.compose.material.Surface
import androidx.compose.runtime.Composable
import androidx.compose.runtime.SideEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.mutableFloatStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
Expand Down Expand Up @@ -153,7 +153,7 @@ fun Modifier.checkeredBackground(
evenColor: Color = Color.Unspecified,
oddColor: Color = Color.Unspecified,
): Modifier = composed {
val even = evenColor.takeOrElse { MaterialTheme.colors.onBackground.copy(alpha = 0.160784314f) }
val even = evenColor.takeOrElse { MaterialTheme.colors.onBackground.copy(alpha = 0.16078432f) }
val odd = oddColor.takeOrElse { Color.Transparent }

this.drawBehind {
Expand Down Expand Up @@ -200,14 +200,12 @@ private fun HueBar(
onColorChange(state.color())
}

forEachGesture {
awaitPointerEventScope {
val down = awaitFirstDown()
updateSlider(down.position)
drag(down.id) { change ->
if (change.positionChange() != Offset.Zero) change.consume()
updateSlider(change.position)
}
awaitEachGesture {
val down = awaitFirstDown()
updateSlider(down.position)
drag(down.id) { change ->
if (change.positionChange() != Offset.Zero) change.consume()
updateSlider(change.position)
}
}
}
Expand Down Expand Up @@ -247,14 +245,12 @@ private fun AlphaBar(
onColorChange(state.color())
}

forEachGesture {
awaitPointerEventScope {
val down = awaitFirstDown()
updateSlider(down.position)
drag(down.id) { change ->
if (change.positionChange() != Offset.Zero) change.consume()
updateSlider(change.position)
}
awaitEachGesture {
val down = awaitFirstDown()
updateSlider(down.position)
drag(down.id) { change ->
if (change.positionChange() != Offset.Zero) change.consume()
updateSlider(change.position)
}
}
}
Expand Down Expand Up @@ -295,14 +291,12 @@ private fun SaturationValueBox(
onColorChange(state.color())
}

forEachGesture {
awaitPointerEventScope {
val down = awaitFirstDown()
updateBox(down.position)
drag(down.id) { change ->
if (change.positionChange() != Offset.Zero) change.consume()
updateBox(change.position)
}
awaitEachGesture {
val down = awaitFirstDown()
updateBox(down.position)
drag(down.id) { change ->
if (change.positionChange() != Offset.Zero) change.consume()
updateBox(change.position)
}
}
}
Expand Down Expand Up @@ -521,10 +515,10 @@ private class JetPrefColorPickerStateImpl(
initValue: Float = 1f,
initAlpha: Float = 1f,
) : JetPrefColorPickerState {
override var hue by mutableStateOf(initHue)
override var saturation by mutableStateOf(initSaturation)
override var value by mutableStateOf(initValue)
override var alpha by mutableStateOf(initAlpha)
override var hue by mutableFloatStateOf(initHue)
override var saturation by mutableFloatStateOf(initSaturation)
override var value by mutableFloatStateOf(initValue)
override var alpha by mutableFloatStateOf(initAlpha)
}

private interface ShaderBase {
Expand Down

This file was deleted.

0 comments on commit e59afbc

Please sign in to comment.