Skip to content

Commit

Permalink
Bump target SDK, upgrade AGP version, switch from KAPT to KSP & more
Browse files Browse the repository at this point in the history
Signed-off-by: starry-shivam <[email protected]>
  • Loading branch information
starry-shivam committed Sep 24, 2023
1 parent 103e532 commit 01f7f5e
Show file tree
Hide file tree
Showing 10 changed files with 76 additions and 103 deletions.
2 changes: 1 addition & 1 deletion .idea/kotlinc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

73 changes: 38 additions & 35 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@ 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"
}

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"

Expand All @@ -24,11 +24,8 @@ android {
useSupportLibrary true
}

javaCompileOptions {
annotationProcessorOptions {
arguments += ["room.schemaLocation":
"$projectDir/schemas".toString()]
}
ksp {
arg('room.schemaLocation', "$projectDir/schemas")
}
}

Expand All @@ -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 {
Expand All @@ -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.
Expand All @@ -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"
}
48 changes: 2 additions & 46 deletions app/src/main/java/com/starry/greenstash/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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)

Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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()
}
}
}
17 changes: 16 additions & 1 deletion app/src/main/java/com/starry/greenstash/backup/BackupManager.kt
Original file line number Diff line number Diff line change
@@ -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()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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(),
Expand All @@ -107,8 +97,8 @@ fun BackupScreen(navController: NavController) {
content = {
BackupScreenContent(
paddingValues = it,
onBackupClicked = { activity.backupDatabase() },
onRestoreClicked = { activity.restoreDatabase() })
onBackupClicked = { /* TODO */ },
onRestoreClicked = { /* TODO */ })
})
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -597,6 +599,7 @@ fun GoalPriorityMenu(viewModel: InputViewModel) {
}
}

@ExperimentalCoroutinesApi
@ExperimentalMaterial3Api
@ExperimentalAnimationApi
@ExperimentalComposeUiApi
Expand Down Expand Up @@ -675,6 +678,7 @@ fun GoalReminderMenu(
}
}

@ExperimentalCoroutinesApi
@ExperimentalMaterialApi
@ExperimentalAnimationApi
@ExperimentalFoundationApi
Expand Down
11 changes: 6 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
}
4 changes: 3 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
android.nonTransitiveRClass=true
android.defaults.buildfeatures.buildconfig=true
android.nonFinalResIds=false
Loading

0 comments on commit 01f7f5e

Please sign in to comment.