From 93f51b9220b9634801593bd93f22d61ab9c30a3d Mon Sep 17 00:00:00 2001 From: Fabian Zobrist Date: Fri, 31 May 2024 14:55:38 +0200 Subject: [PATCH 1/3] Update dependencies. --- .gitignore | 1 + app/build.gradle | 59 ++++++++++++------------ build.gradle | 7 +-- gradle/wrapper/gradle-wrapper.properties | 2 +- 4 files changed, 36 insertions(+), 33 deletions(-) diff --git a/.gitignore b/.gitignore index 5f99499..b312ce7 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,4 @@ .idea keystore.properties version.properties +.vscode/ diff --git a/app/build.gradle b/app/build.gradle index a636bc3..ecb1c2a 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -3,6 +3,7 @@ plugins { id 'kotlin-android' id 'com.google.dagger.hilt.android' id 'kotlin-kapt' + id 'com.google.devtools.ksp' } // Create a variable called keystorePropertiesFile, and initialize it to your @@ -67,7 +68,7 @@ android { } composeOptions { - kotlinCompilerExtensionVersion = "1.4.8" + kotlinCompilerExtensionVersion = "1.5.14" } compileOptions { @@ -88,44 +89,44 @@ android { dependencies { implementation fileTree(dir: "libs", include: ["*.jar"]) implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" - implementation 'androidx.core:core-ktx:1.10.1' - implementation 'androidx.appcompat:appcompat:1.6.1' - implementation "androidx.compose.material3:material3:1.1.1" + implementation 'androidx.core:core-ktx:1.13.1' + implementation 'androidx.appcompat:appcompat:1.7.0' + implementation "androidx.compose.material3:material3:1.2.1" implementation 'com.google.android.play:core-ktx:1.8.1' implementation 'com.google.android.play:core-ktx:1.8.1' - implementation 'com.google.code.gson:gson:2.9.0' + implementation 'com.google.code.gson:gson:2.10.1' implementation 'androidx.constraintlayout:constraintlayout:2.1.4' - implementation 'androidx.navigation:navigation-fragment-ktx:2.7.1' - implementation 'androidx.navigation:navigation-ui-ktx:2.7.1' + implementation 'androidx.navigation:navigation-fragment-ktx:2.7.7' + implementation 'androidx.navigation:navigation-ui-ktx:2.7.7' implementation 'androidx.legacy:legacy-support-v4:1.0.0' - implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.6.1' - implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.1' - implementation 'androidx.fragment:fragment-ktx:1.6.1' + implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.8.1' + implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.8.1' + implementation 'androidx.fragment:fragment-ktx:1.7.1' implementation 'androidx.preference:preference-ktx:1.2.1' - implementation 'androidx.recyclerview:recyclerview:1.3.1' - implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.6.1' - implementation 'androidx.compose.material:material-icons-extended:1.5.0' + implementation 'androidx.recyclerview:recyclerview:1.3.2' + implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.8.1' + implementation 'androidx.compose.material:material-icons-extended:1.6.7' implementation "com.google.accompanist:accompanist-systemuicontroller:0.27.0" - implementation 'androidx.activity:activity-compose:1.7.2' - implementation "androidx.compose.ui:ui:1.5.0" - implementation "androidx.compose.ui:ui-tooling-preview:1.5.0" - implementation "androidx.compose.runtime:runtime-livedata:1.5.0" - implementation "androidx.navigation:navigation-compose:2.7.1" - implementation "androidx.lifecycle:lifecycle-viewmodel-compose:2.6.1" + implementation 'androidx.activity:activity-compose:1.9.0' + implementation "androidx.compose.ui:ui:1.6.7" + implementation "androidx.compose.ui:ui-tooling-preview:1.6.7" + implementation "androidx.compose.runtime:runtime-livedata:1.6.7" + implementation "androidx.navigation:navigation-compose:2.7.7" + implementation "androidx.lifecycle:lifecycle-viewmodel-compose:2.8.1" testImplementation 'junit:junit:4.13.2' androidTestImplementation 'androidx.test.ext:junit:1.1.5' androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' - implementation "com.google.dagger:hilt-android:2.44" - androidTestImplementation "androidx.compose.ui:ui-test-junit4:1.5.0" - debugImplementation "androidx.compose.ui:ui-tooling:1.5.0" - debugImplementation "androidx.compose.ui:ui-test-manifest:1.5.0" - kapt "com.google.dagger:hilt-compiler:2.44" - implementation "androidx.room:room-runtime:2.5.2" - annotationProcessor "androidx.room:room-compiler:2.5.2" - kapt "androidx.room:room-compiler:2.5.2" - implementation "androidx.room:room-ktx:2.5.2" + implementation "com.google.dagger:hilt-android:2.51.1" + androidTestImplementation "androidx.compose.ui:ui-test-junit4:1.6.7" + debugImplementation "androidx.compose.ui:ui-tooling:1.6.7" + debugImplementation "androidx.compose.ui:ui-test-manifest:1.6.7" + kapt "com.google.dagger:hilt-compiler:2.51.1" + implementation "androidx.room:room-runtime:2.6.1" + annotationProcessor "androidx.room:room-compiler:2.6.1" + ksp "androidx.room:room-compiler:2.6.1" + implementation "androidx.room:room-ktx:2.6.1" implementation "androidx.multidex:multidex:2.0.1" - api "androidx.navigation:navigation-fragment-ktx:2.7.1" + api "androidx.navigation:navigation-fragment-ktx:2.7.7" } // Allow references to generated code diff --git a/build.gradle b/build.gradle index 93c98d9..4b8563e 100644 --- a/build.gradle +++ b/build.gradle @@ -1,12 +1,12 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { - ext.kotlin_version = "1.8.22" + ext.kotlin_version = "1.9.24" repositories { google() mavenCentral() } dependencies { - classpath 'com.android.tools.build:gradle:8.1.2' + classpath 'com.android.tools.build:gradle:8.4.1' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" // NOTE: Do not place your application dependencies here; they belong @@ -15,8 +15,9 @@ buildscript { } plugins { - id 'com.google.dagger.hilt.android' version '2.44' apply false + id 'com.google.dagger.hilt.android' version '2.51.1' apply false id 'org.jetbrains.kotlin.android' version '1.7.20' apply false + id 'com.google.devtools.ksp' version '1.9.24-1.0.20' apply false } allprojects { diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 4f7780d..15f6fd3 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-all.zip -- 2.49.1 From 9abff51cb85a218ca2e3c9bdf9c0677a7045e6bb Mon Sep 17 00:00:00 2001 From: Fabian Zobrist Date: Fri, 31 May 2024 15:49:29 +0200 Subject: [PATCH 2/3] Update deprecated swipe to dismiss box. --- .../tichucounter/ui/history/HistoryView.kt | 166 ++++++++++-------- 1 file changed, 94 insertions(+), 72 deletions(-) diff --git a/app/src/main/java/me/zobrist/tichucounter/ui/history/HistoryView.kt b/app/src/main/java/me/zobrist/tichucounter/ui/history/HistoryView.kt index 8f822d7..6af5e52 100644 --- a/app/src/main/java/me/zobrist/tichucounter/ui/history/HistoryView.kt +++ b/app/src/main/java/me/zobrist/tichucounter/ui/history/HistoryView.kt @@ -12,6 +12,7 @@ import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.LazyListState @@ -25,18 +26,17 @@ import androidx.compose.material3.AlertDialog import androidx.compose.material3.Badge import androidx.compose.material3.Button import androidx.compose.material3.Card -import androidx.compose.material3.DismissDirection -import androidx.compose.material3.DismissValue import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.Icon import androidx.compose.material3.MaterialTheme import androidx.compose.material3.SnackbarDuration import androidx.compose.material3.SnackbarHostState import androidx.compose.material3.SnackbarResult -import androidx.compose.material3.SwipeToDismiss +import androidx.compose.material3.SwipeToDismissBox +import androidx.compose.material3.SwipeToDismissBoxValue import androidx.compose.material3.Text import androidx.compose.material3.TextButton -import androidx.compose.material3.rememberDismissState +import androidx.compose.material3.rememberSwipeToDismissBoxState import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf @@ -48,6 +48,7 @@ import androidx.compose.ui.Alignment.Companion.CenterVertically import androidx.compose.ui.Alignment.Companion.TopEnd import androidx.compose.ui.Modifier import androidx.compose.ui.draw.scale +import androidx.compose.ui.graphics.Color import androidx.compose.ui.platform.LocalDensity import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.style.TextOverflow @@ -213,89 +214,110 @@ fun DismissibleHistoryListItem( val density = LocalDensity.current val dismissState = - rememberDismissState(positionalThreshold = { with(density) { 100.dp.toPx() } }, + rememberSwipeToDismissBoxState(positionalThreshold = { with(density) { 100.dp.toPx() } }, + confirmValueChange = { - if (it == DismissValue.DismissedToStart) { + if (it == SwipeToDismissBoxValue.EndToStart) { onDeleteClicked(game.game.uid) } - if (it == DismissValue.DismissedToEnd) { + if (it == SwipeToDismissBoxValue.StartToEnd) { onOpenClicked(game.game.uid) } true }) - val directions = if (game.game.active) { - setOf() - - } else { - setOf(DismissDirection.EndToStart, DismissDirection.StartToEnd) - } - - SwipeToDismiss( + SwipeToDismissBox( modifier = modifier, state = dismissState, - directions = directions, - background = { - val direction = dismissState.dismissDirection ?: return@SwipeToDismiss - val color by animateColorAsState( - when (dismissState.targetValue) { - DismissValue.DismissedToStart -> MaterialTheme.colorScheme.error - DismissValue.DismissedToEnd -> MaterialTheme.colorScheme.primary - else -> MaterialTheme.colorScheme.background - - }, label = "" - ) - val textColor by animateColorAsState( - when (dismissState.targetValue) { - DismissValue.DismissedToStart -> MaterialTheme.colorScheme.onError - DismissValue.DismissedToEnd -> MaterialTheme.colorScheme.onPrimary - else -> MaterialTheme.colorScheme.onBackground - - }, label = "" - ) - val alignment = when (direction) { - DismissDirection.StartToEnd -> Alignment.CenterStart - DismissDirection.EndToStart -> Alignment.CenterEnd - } - val icon = when (direction) { - DismissDirection.StartToEnd -> Icons.Outlined.RestartAlt - DismissDirection.EndToStart -> Icons.Outlined.Delete - } - val text = when (direction) { - DismissDirection.StartToEnd -> stringResource(id = R.string.continue_play) - DismissDirection.EndToStart -> stringResource(id = R.string.delete) - } - val scale by animateFloatAsState( - if (dismissState.targetValue == DismissValue.Default) 0.75f else 1f, label = "" - ) - - Box( - Modifier - .fillMaxSize() - .padding(top = 2.dp, bottom = 2.dp) - .background(color) - .padding(horizontal = 10.dp), - contentAlignment = alignment - ) { - Column( - verticalArrangement = Arrangement.Center, - horizontalAlignment = Alignment.CenterHorizontally - ) { - Icon( - icon, - contentDescription = null, - modifier = Modifier.scale(scale), - tint = textColor - ) - Text(text = text, color = textColor) - } - } - }, dismissContent = { + enableDismissFromEndToStart = true, + enableDismissFromStartToEnd = true, + backgroundContent = { + ItemBackground(dismissState.targetValue) + }, content = { HistoryListItem(game = game, modifier = Modifier.padding(2.dp)) }) } @OptIn(ExperimentalMaterial3Api::class) +@Composable +fun ItemBackground( + dismissBoxValue: SwipeToDismissBoxValue +) +{ + val backgroundColor by animateColorAsState( + when (dismissBoxValue) { + SwipeToDismissBoxValue.EndToStart -> MaterialTheme.colorScheme.error + SwipeToDismissBoxValue.StartToEnd-> MaterialTheme.colorScheme.primary + else -> MaterialTheme.colorScheme.background + + }, label = "" + ) + val textColor by animateColorAsState( + when (dismissBoxValue) { + SwipeToDismissBoxValue.EndToStart -> MaterialTheme.colorScheme.onError + SwipeToDismissBoxValue.StartToEnd -> MaterialTheme.colorScheme.onPrimary + else -> MaterialTheme.colorScheme.onBackground + + }, label = "" + ) + val scale by animateFloatAsState( + if (dismissBoxValue == SwipeToDismissBoxValue.Settled) 0.75f else 1f, label = "" + ) + + Box( + Modifier + .fillMaxSize() + .padding(top = 2.dp, bottom = 2.dp) + .background(backgroundColor) + .padding(horizontal = 10.dp), + ) { + Column( + verticalArrangement = Arrangement.Center, + horizontalAlignment = Alignment.CenterHorizontally, + modifier = Modifier.align(Alignment.CenterStart) + ) { + Icon(Icons.Outlined.RestartAlt, + contentDescription = null, + tint = textColor, + modifier = Modifier.scale(scale),) + Text(text = stringResource(id = R.string.continue_play), color = textColor) + } + Column( + verticalArrangement = Arrangement.Center, + horizontalAlignment = Alignment.CenterHorizontally, + modifier = Modifier.align(Alignment.CenterEnd) + + ) { + Icon(Icons.Outlined.Delete, + contentDescription = null, + tint = textColor, + modifier = Modifier.scale(scale),) + Text(text = stringResource(id = R.string.delete), color = textColor) + } + } +} + +@OptIn(ExperimentalMaterial3Api::class) +@Preview +@Composable +private fun BackgroundPreview() { + Column { + Box(modifier = Modifier.height(60.dp)) + { + ItemBackground(SwipeToDismissBoxValue.Settled) + } + Box(modifier = Modifier.height(60.dp)) + { + ItemBackground(SwipeToDismissBoxValue.EndToStart) + } + Box(modifier = Modifier.height(60.dp)) + { + ItemBackground(SwipeToDismissBoxValue.StartToEnd) + } + } +} + + @Composable fun HistoryListItem( game: GameWithScores, modifier: Modifier = Modifier -- 2.49.1 From 9434d1f1b98a9b39796a754ab16483d26f6923bc Mon Sep 17 00:00:00 2001 From: Fabian Zobrist Date: Fri, 31 May 2024 16:00:58 +0200 Subject: [PATCH 3/3] Upload as gitea artifacts. --- .gitea/workflows/buildAndroid.yaml | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/.gitea/workflows/buildAndroid.yaml b/.gitea/workflows/buildAndroid.yaml index baae806..9b7549e 100644 --- a/.gitea/workflows/buildAndroid.yaml +++ b/.gitea/workflows/buildAndroid.yaml @@ -30,15 +30,11 @@ jobs: - name: Build abb run: ./gradlew bundleRelease - - name: Deploy latest to Nextcloud - run: | - curl -k -u "${{ secrets.NEXTCLOUD_USERNAME }}:${{ secrets.NEXTCLOUD_PASSWORD }}" -T "app/build/outputs/apk/release/app-release.apk" "${{ secrets.NEXTCLOUD_BASE_URL }}/TichuCounter/latest/app-release.apk" - curl -k -u "${{ secrets.NEXTCLOUD_USERNAME }}:${{ secrets.NEXTCLOUD_PASSWORD }}" -T "app/build/outputs/bundle/release/app-release.aab" "${{ secrets.NEXTCLOUD_BASE_URL }}/TichuCounter/latest/app-release.aab" - - - name: Deploy tagged build to Nextcloud - run: | - curl -k -u "${{ secrets.NEXTCLOUD_USERNAME }}:${{ secrets.NEXTCLOUD_PASSWORD }}" -T "app/build/outputs/apk/release/app-release.apk" "${{ secrets.NEXTCLOUD_BASE_URL }}/TichuCounter/tagged/app-release-${GITHUB_REF_NAME##*/}.apk" - curl -k -u "${{ secrets.NEXTCLOUD_USERNAME }}:${{ secrets.NEXTCLOUD_PASSWORD }}" -T "app/build/outputs/bundle/release/app-release.aab" "${{ secrets.NEXTCLOUD_BASE_URL }}/TichuCounter/tagged/app-release-${GITHUB_REF_NAME##*/}.aab" + - uses: actions/upload-artifact@v3 + with: + name: app-release + retention-days: 10 + path: app/build/outputs/**/release/app-release.* - uses: https://github.com/ravsamhq/notify-slack-action@v2 if: always() -- 2.49.1