From 01f7f5e67395d8d95d1ec50ae21b5906ee053769 Mon Sep 17 00:00:00 2001 From: starry-shivam Date: Sun, 24 Sep 2023 11:28:54 +0530 Subject: [PATCH] Bump target SDK, upgrade AGP version, switch from KAPT to KSP & more Signed-off-by: starry-shivam --- .idea/kotlinc.xml | 2 +- app/build.gradle | 73 ++++++++++--------- .../com/starry/greenstash/MainActivity.kt | 48 +----------- .../starry/greenstash/backup/BackupManager.kt | 17 ++++- .../greenstash/ui/navigation/NavGraph.kt | 2 + .../ui/screens/backups/BackupScreen.kt | 16 +--- .../screens/input/composables/InputScreen.kt | 4 + build.gradle | 11 +-- gradle.properties | 4 +- gradle/wrapper/gradle-wrapper.properties | 2 +- 10 files changed, 76 insertions(+), 103 deletions(-) diff --git a/.idea/kotlinc.xml b/.idea/kotlinc.xml index 217e5c51..fdf8d994 100644 --- a/.idea/kotlinc.xml +++ b/.idea/kotlinc.xml @@ -1,6 +1,6 @@ - \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle index 5cc74573..5bc24668 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -2,7 +2,7 @@ plugins { id 'com.android.application' id 'org.jetbrains.kotlin.android' id 'dagger.hilt.android.plugin' - id 'kotlin-kapt' + id 'com.google.devtools.ksp' id "com.mikepenz.aboutlibraries.plugin" version "10.5.2" } @@ -10,12 +10,12 @@ apply plugin: 'com.mikepenz.aboutlibraries.plugin' android { namespace 'com.starry.greenstash' - compileSdk 33 + compileSdk 34 defaultConfig { applicationId "com.starry.greenstash" minSdk 24 - targetSdk 33 + targetSdk 34 versionCode 27 versionName "2.7.0" @@ -24,11 +24,8 @@ android { useSupportLibrary true } - javaCompileOptions { - annotationProcessorOptions { - arguments += ["room.schemaLocation": - "$projectDir/schemas".toString()] - } + ksp { + arg('room.schemaLocation', "$projectDir/schemas") } } @@ -47,18 +44,21 @@ android { } } compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 + sourceCompatibility JavaVersion.VERSION_17 + targetCompatibility JavaVersion.VERSION_17 coreLibraryDesugaringEnabled true } kotlinOptions { - jvmTarget = '1.8' + jvmTarget = '17' + freeCompilerArgs = [] } buildFeatures { compose true + buildConfig = true + } composeOptions { - kotlinCompilerExtensionVersion '1.4.7' + kotlinCompilerExtensionVersion '1.5.2' } packagingOptions { resources { @@ -76,38 +76,41 @@ aboutLibraries { dependencies { // Android core components. - implementation 'androidx.core:core-ktx:1.10.1' - implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.6.1' + implementation 'androidx.core:core-ktx:1.12.0' + implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.6.2' implementation 'androidx.activity:activity-compose:1.7.2' - implementation "com.google.accompanist:accompanist-systemuicontroller:0.27.0" - implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.6.1" + implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.6.2" + implementation "androidx.lifecycle:lifecycle-viewmodel-compose:2.6.2" // Jetpack compose. - implementation "androidx.compose.ui:ui:$compose_version" - implementation "androidx.compose.ui:ui-tooling-preview:$compose_version" - implementation "androidx.compose.material3:material3:1.1.0" - implementation "androidx.compose.material:material:$compose_version" - implementation "androidx.compose.animation:animation:$compose_version" - implementation "com.google.accompanist:accompanist-navigation-animation:0.29.0-alpha" - implementation "androidx.lifecycle:lifecycle-viewmodel-compose:2.6.1" - implementation "androidx.compose.runtime:runtime-livedata:$compose_version" + implementation platform('androidx.compose:compose-bom:2023.08.00') + implementation "androidx.compose.ui:ui" + implementation "androidx.compose.ui:ui-tooling-preview" + implementation "androidx.compose.material:material" + implementation "androidx.compose.animation:animation" + implementation "androidx.compose.runtime:runtime-livedata" + implementation "androidx.compose.material3:material3" + // Accompanist compose. + implementation "com.google.accompanist:accompanist-systemuicontroller:0.28.0" + implementation "com.google.accompanist:accompanist-navigation-animation:0.33.1-alpha" // Material theme for main activity. implementation 'com.google.android.material:material:1.9.0' // Android 12+ splash API. implementation 'androidx.core:core-splashscreen:1.0.1' // Room database - implementation "androidx.room:room-ktx:2.5.1" + implementation "androidx.room:room-ktx:2.5.2" implementation 'androidx.appcompat:appcompat:1.6.1' - kapt "androidx.room:room-compiler:2.5.1" - androidTestImplementation "androidx.room:room-testing:2.5.1" - // Room database backup library. - implementation 'de.raphaelebner:roomdatabasebackup:1.0.0-beta12' + implementation 'androidx.core:core-ktx:1.12.0' + ksp "androidx.room:room-compiler:2.5.2" + androidTestImplementation "androidx.room:room-testing:2.5.2" // Dagger - Hilt. implementation "com.google.dagger:hilt-android:$hilt_version" implementation "androidx.hilt:hilt-navigation-compose:1.0.0" - kapt "com.google.dagger:hilt-android-compiler:$hilt_version" - kapt "androidx.hilt:hilt-compiler:1.0.0" - // DataStore Preferences + ksp "com.google.dagger:hilt-android-compiler:$hilt_version" + ksp "androidx.hilt:hilt-compiler:1.0.0" + // DataStore Preferences. implementation("androidx.datastore:datastore-preferences:1.0.0") + // Gson JSON parser. + implementation 'com.google.code.gson:gson:2.10.1' // Coil Image loading library. implementation "io.coil-kt:coil-compose:2.2.2" // Material 3 calender / Date picker. @@ -128,7 +131,7 @@ dependencies { testImplementation 'junit:junit:4.13.2' androidTestImplementation 'androidx.test.ext:junit:1.1.5' androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' - androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_version" - debugImplementation "androidx.compose.ui:ui-tooling:$compose_version" - debugImplementation "androidx.compose.ui:ui-test-manifest:$compose_version" + androidTestImplementation "androidx.compose.ui:ui-test-junit4" + debugImplementation "androidx.compose.ui:ui-tooling" + debugImplementation "androidx.compose.ui:ui-test-manifest" } \ No newline at end of file diff --git a/app/src/main/java/com/starry/greenstash/MainActivity.kt b/app/src/main/java/com/starry/greenstash/MainActivity.kt index 116cb2ef..185f1afb 100644 --- a/app/src/main/java/com/starry/greenstash/MainActivity.kt +++ b/app/src/main/java/com/starry/greenstash/MainActivity.kt @@ -25,9 +25,7 @@ package com.starry.greenstash -import android.content.Intent import android.os.Bundle -import android.widget.Toast import androidx.activity.compose.setContent import androidx.appcompat.app.AppCompatActivity import androidx.biometric.BiometricManager @@ -49,7 +47,6 @@ import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen import androidx.lifecycle.ViewModelProvider import com.google.accompanist.navigation.animation.rememberAnimatedNavController import com.google.accompanist.systemuicontroller.rememberSystemUiController -import com.starry.greenstash.database.core.AppDatabase import com.starry.greenstash.ui.navigation.NavGraph import com.starry.greenstash.ui.screens.settings.viewmodels.SettingsViewModel import com.starry.greenstash.ui.screens.settings.viewmodels.ThemeMode @@ -58,10 +55,10 @@ import com.starry.greenstash.utils.PreferenceUtils import com.starry.greenstash.utils.Utils import com.starry.greenstash.utils.toToast import dagger.hilt.android.AndroidEntryPoint -import de.raphaelebner.roomdatabasebackup.core.RoomBackup +import kotlinx.coroutines.ExperimentalCoroutinesApi import java.util.concurrent.Executor -import javax.inject.Inject +@ExperimentalCoroutinesApi @ExperimentalMaterialApi @ExperimentalFoundationApi @AndroidEntryPoint @@ -77,11 +74,6 @@ class MainActivity : AppCompatActivity() { private lateinit var biometricPrompt: BiometricPrompt private lateinit var promptInfo: BiometricPrompt.PromptInfo - private lateinit var roomBackup: RoomBackup - - @Inject - lateinit var appDatabase: AppDatabase - override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) @@ -147,26 +139,6 @@ class MainActivity : AppCompatActivity() { } else { setAppContents() } - - // initialize & setup room backup instance - roomBackup = RoomBackup(this) - .database(appDatabase) - .enableLogDebug(true) - .backupLocation(RoomBackup.BACKUP_FILE_LOCATION_CUSTOM_DIALOG) - .customBackupFileName("GreenStash-${System.currentTimeMillis()}.backup") - .apply { - onCompleteListener { success, message, _ -> - if (success) restartApp( - Intent( - this@MainActivity, - MainActivity::class.java - ) - ) else Toast.makeText( - this@MainActivity, - message, Toast.LENGTH_SHORT, - ).show() - } - } } fun setAppContents() { @@ -194,20 +166,4 @@ class MainActivity : AppCompatActivity() { } } } - - fun backupDatabase() { - try { - roomBackup.backup() - } catch (exc: NullPointerException) { - exc.printStackTrace() - } - } - - fun restoreDatabase() { - try { - roomBackup.restore() - } catch (exc: NullPointerException) { - exc.printStackTrace() - } - } } \ No newline at end of file diff --git a/app/src/main/java/com/starry/greenstash/backup/BackupManager.kt b/app/src/main/java/com/starry/greenstash/backup/BackupManager.kt index a9bd16bd..0a68a45a 100644 --- a/app/src/main/java/com/starry/greenstash/backup/BackupManager.kt +++ b/app/src/main/java/com/starry/greenstash/backup/BackupManager.kt @@ -1,4 +1,19 @@ package com.starry.greenstash.backup -class BackupManager { +import com.google.gson.Gson +import com.starry.greenstash.database.goal.GoalDao +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.withContext + +class BackupManager(private val goalDao: GoalDao) { + + private val gsonInstance = Gson() + suspend fun createDatabaseBackup() = withContext(Dispatchers.IO) { + val goalsWithTransactions = goalDao.getAllGoals() + + } + + suspend fun restoreDatabaseBackup(): Nothing = withContext(Dispatchers.IO) { + TODO() + } } \ No newline at end of file diff --git a/app/src/main/java/com/starry/greenstash/ui/navigation/NavGraph.kt b/app/src/main/java/com/starry/greenstash/ui/navigation/NavGraph.kt index c6051d27..932bc05e 100644 --- a/app/src/main/java/com/starry/greenstash/ui/navigation/NavGraph.kt +++ b/app/src/main/java/com/starry/greenstash/ui/navigation/NavGraph.kt @@ -53,7 +53,9 @@ import com.starry.greenstash.ui.screens.settings.composables.AboutScreen import com.starry.greenstash.ui.screens.settings.composables.OSLScreen import com.starry.greenstash.ui.screens.settings.composables.SettingsScreen import com.starry.greenstash.ui.screens.welcome.composables.WelcomeScreen +import kotlinx.coroutines.ExperimentalCoroutinesApi +@ExperimentalCoroutinesApi @ExperimentalMaterialApi @ExperimentalFoundationApi @ExperimentalComposeUiApi diff --git a/app/src/main/java/com/starry/greenstash/ui/screens/backups/BackupScreen.kt b/app/src/main/java/com/starry/greenstash/ui/screens/backups/BackupScreen.kt index 5dc665bf..524e8f90 100644 --- a/app/src/main/java/com/starry/greenstash/ui/screens/backups/BackupScreen.kt +++ b/app/src/main/java/com/starry/greenstash/ui/screens/backups/BackupScreen.kt @@ -25,8 +25,6 @@ package com.starry.greenstash.ui.screens.backups -import androidx.compose.animation.ExperimentalAnimationApi -import androidx.compose.foundation.ExperimentalFoundationApi import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.PaddingValues @@ -39,7 +37,6 @@ import androidx.compose.foundation.layout.size import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.foundation.verticalScroll -import androidx.compose.material.ExperimentalMaterialApi import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.ArrowBack import androidx.compose.material3.Button @@ -55,7 +52,6 @@ import androidx.compose.material3.surfaceColorAtElevation import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.ui.Alignment -import androidx.compose.ui.ExperimentalComposeUiApi import androidx.compose.ui.Modifier import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.stringResource @@ -70,19 +66,13 @@ import com.airbnb.lottie.compose.LottieCompositionSpec import com.airbnb.lottie.compose.LottieConstants import com.airbnb.lottie.compose.animateLottieCompositionAsState import com.airbnb.lottie.compose.rememberLottieComposition -import com.starry.greenstash.MainActivity import com.starry.greenstash.R -import com.starry.greenstash.utils.getActivity + @ExperimentalMaterial3Api -@ExperimentalAnimationApi -@ExperimentalComposeUiApi -@ExperimentalFoundationApi -@ExperimentalMaterialApi @Composable fun BackupScreen(navController: NavController) { val context = LocalContext.current - val activity = (context.getActivity() as MainActivity) Scaffold( modifier = Modifier.fillMaxSize(), @@ -107,8 +97,8 @@ fun BackupScreen(navController: NavController) { content = { BackupScreenContent( paddingValues = it, - onBackupClicked = { activity.backupDatabase() }, - onRestoreClicked = { activity.restoreDatabase() }) + onBackupClicked = { /* TODO */ }, + onRestoreClicked = { /* TODO */ }) }) } diff --git a/app/src/main/java/com/starry/greenstash/ui/screens/input/composables/InputScreen.kt b/app/src/main/java/com/starry/greenstash/ui/screens/input/composables/InputScreen.kt index 2f9329ab..6e64dfde 100644 --- a/app/src/main/java/com/starry/greenstash/ui/screens/input/composables/InputScreen.kt +++ b/app/src/main/java/com/starry/greenstash/ui/screens/input/composables/InputScreen.kt @@ -140,11 +140,13 @@ import com.starry.greenstash.utils.getActivity import com.starry.greenstash.utils.toToast import com.starry.greenstash.utils.validateAmount import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.delay import kotlinx.coroutines.launch import java.time.format.DateTimeFormatter +@ExperimentalCoroutinesApi @ExperimentalAnimationApi @ExperimentalMaterialApi @ExperimentalFoundationApi @@ -597,6 +599,7 @@ fun GoalPriorityMenu(viewModel: InputViewModel) { } } +@ExperimentalCoroutinesApi @ExperimentalMaterial3Api @ExperimentalAnimationApi @ExperimentalComposeUiApi @@ -675,6 +678,7 @@ fun GoalReminderMenu( } } +@ExperimentalCoroutinesApi @ExperimentalMaterialApi @ExperimentalAnimationApi @ExperimentalFoundationApi diff --git a/build.gradle b/build.gradle index 550a4595..bec16efa 100644 --- a/build.gradle +++ b/build.gradle @@ -1,15 +1,15 @@ buildscript { ext { - compose_version = '1.4.3' - hilt_version = '2.44.2' + kotlin_version = '1.9.0' + hilt_version = '2.48' } repositories { google() mavenCentral() } dependencies { - classpath 'com.android.tools.build:gradle:7.4.2' - classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.21' + classpath 'com.android.tools.build:gradle:8.0.2' + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath "com.google.dagger:hilt-android-gradle-plugin:$hilt_version" // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files @@ -20,5 +20,6 @@ buildscript { plugins { id 'com.android.application' version '7.4.0' apply false id 'com.android.library' version '7.4.0' apply false - id 'org.jetbrains.kotlin.android' version '1.8.21' apply false + id 'org.jetbrains.kotlin.android' version "$kotlin_version" apply false + id 'com.google.devtools.ksp' version '1.9.0-1.0.13' apply false } \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 3c5031eb..a2e90d87 100644 --- a/gradle.properties +++ b/gradle.properties @@ -20,4 +20,6 @@ kotlin.code.style=official # Enables namespacing of each library's R class so that its R class includes only the # resources declared in the library itself and none from the library's dependencies, # thereby reducing the size of the R class for that library -android.nonTransitiveRClass=true \ No newline at end of file +android.nonTransitiveRClass=true +android.defaults.buildfeatures.buildconfig=true +android.nonFinalResIds=false \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 44ca76d3..d779f701 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ #Mon Jan 23 11:16:57 IST 2023 distributionBase=GRADLE_USER_HOME -distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip distributionPath=wrapper/dists zipStorePath=wrapper/dists zipStoreBase=GRADLE_USER_HOME