Skip to content

Commit

Permalink
Improve code quality & Update dependencies
Browse files Browse the repository at this point in the history
Signed-off-by: starry-shivam <[email protected]>
  • Loading branch information
starry-shivam committed Dec 25, 2023
1 parent b31214c commit 7375e5c
Show file tree
Hide file tree
Showing 32 changed files with 379 additions and 431 deletions.
45 changes: 45 additions & 0 deletions .idea/appInsightsSettings.xml

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

17 changes: 5 additions & 12 deletions .idea/deploymentTargetDropDown.xml

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

5 changes: 2 additions & 3 deletions .idea/gradle.xml

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

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.

10 changes: 10 additions & 0 deletions .idea/migrations.xml

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

25 changes: 12 additions & 13 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ android {

}
composeOptions {
kotlinCompilerExtensionVersion '1.5.2'
kotlinCompilerExtensionVersion '1.5.6'
}
packagingOptions {
resources {
Expand All @@ -75,16 +75,18 @@ aboutLibraries {

dependencies {

def composeBom = platform('androidx.compose:compose-bom:2023.08.00')
def composeBom = platform('androidx.compose:compose-bom:2023.10.01')
implementation composeBom
androidTestImplementation composeBom

// Android core components.
implementation 'androidx.core:core-ktx:1.12.0'
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.6.2'
implementation 'androidx.activity:activity-compose:1.8.0'
implementation 'androidx.activity:activity-compose:1.8.2'
implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.6.2"
implementation "androidx.lifecycle:lifecycle-viewmodel-compose:2.6.2"
implementation "androidx.navigation:navigation-compose:2.7.6"
// Jetpack compose.
implementation "androidx.compose.ui:ui"
implementation "androidx.compose.ui:ui-tooling-preview"
Expand All @@ -94,22 +96,19 @@ dependencies {
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.10.0'
implementation 'com.google.android.material:material:1.11.0'
// Android 12+ splash API.
implementation 'androidx.core:core-splashscreen:1.0.1'
// Room database
implementation "androidx.room:room-ktx:2.5.2"
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'androidx.core:core-ktx:1.12.0'
ksp "androidx.room:room-compiler:2.5.2"
androidTestImplementation "androidx.room:room-testing:2.5.2"
implementation "androidx.room:room-ktx:$room_version"
ksp "androidx.room:room-compiler:$room_version"
androidTestImplementation "androidx.room:room-testing:$room_version"
// Dagger - Hilt.
implementation "com.google.dagger:hilt-android:$hilt_version"
implementation "androidx.hilt:hilt-navigation-compose:1.0.0"
implementation "androidx.hilt:hilt-navigation-compose:1.1.0"
ksp "com.google.dagger:hilt-android-compiler:$hilt_version"
ksp "androidx.hilt:hilt-compiler:1.0.0"
ksp "androidx.hilt:hilt-compiler:1.1.0"
// DataStore Preferences.
implementation("androidx.datastore:datastore-preferences:1.0.0")
// Gson JSON parser.
Expand All @@ -129,7 +128,7 @@ dependencies {
// Crash Handler.
implementation 'cat.ereza:customactivityoncrash:2.4.0'
// Oreo back-ports for API 24 (N)
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.0.3'
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.0.4'
// Testing components.
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
Expand Down
15 changes: 8 additions & 7 deletions app/src/main/java/com/starry/greenstash/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,12 @@ import androidx.compose.ui.unit.dp
import androidx.core.content.ContextCompat
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
import androidx.lifecycle.ViewModelProvider
import com.google.accompanist.navigation.animation.rememberAnimatedNavController
import androidx.navigation.compose.rememberNavController
import com.google.accompanist.systemuicontroller.rememberSystemUiController
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
import com.starry.greenstash.ui.theme.GreenStashTheme
import com.starry.greenstash.utils.PreferenceUtils
import com.starry.greenstash.utils.Utils
import com.starry.greenstash.utils.toToast
import dagger.hilt.android.AndroidEntryPoint
Expand All @@ -77,12 +76,14 @@ class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

PreferenceUtils.initialize(this)
settingsViewModel = ViewModelProvider(this)[SettingsViewModel::class.java]
mainViewModel = ViewModelProvider(this)[MainViewModel::class.java]

// Setup app theme according to user's settings.
settingsViewModel.setUpAppTheme()
ThemeMode.entries.find { it.ordinal == settingsViewModel.getThemeValue() }
?.let { settingsViewModel.setTheme(it) }
settingsViewModel.setMaterialYou(settingsViewModel.getMaterialYouValue())


// show splash screen until we figure out start nav destination.
installSplashScreen().setKeepOnScreenCondition {
Expand All @@ -92,7 +93,7 @@ class MainActivity : AppCompatActivity() {
// refresh reminders
mainViewModel.refreshReminders()

val appLockStatus = PreferenceUtils.getBoolean(PreferenceUtils.APP_LOCK, false)
val appLockStatus = settingsViewModel.getAppLockValue()

if (appLockStatus && !mainViewModel.appUnlocked) {
executor = ContextCompat.getMainExecutor(this)
Expand Down Expand Up @@ -121,7 +122,7 @@ class MainActivity : AppCompatActivity() {
if (biometricManager.canAuthenticate(Utils.getAuthenticators()) != BiometricManager.BIOMETRIC_SUCCESS) {
setAppContents()
mainViewModel.appUnlocked = true
PreferenceUtils.putBoolean(PreferenceUtils.APP_LOCK, false)
settingsViewModel.setAppLock(false)
} else {
finish() // close the app.
}
Expand Down Expand Up @@ -159,7 +160,7 @@ class MainActivity : AppCompatActivity() {
modifier = Modifier.fillMaxSize(),
color = MaterialTheme.colorScheme.background
) {
val navController = rememberAnimatedNavController()
val navController = rememberNavController()
val screen by mainViewModel.startDestination
NavGraph(navController = navController, screen)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@
package com.starry.greenstash.database.core

import android.content.Context
import androidx.room.*
import androidx.room.AutoMigration
import androidx.room.Database
import androidx.room.Room
import androidx.room.RoomDatabase
import androidx.room.TypeConverters
import com.starry.greenstash.database.goal.Goal
import com.starry.greenstash.database.goal.GoalDao
import com.starry.greenstash.database.transaction.Transaction
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@
package com.starry.greenstash.database.goal

import androidx.lifecycle.LiveData
import androidx.room.*
import androidx.room.Dao
import androidx.room.Insert
import androidx.room.Query
import androidx.room.Transaction
import androidx.room.Update
import com.starry.greenstash.database.core.GoalWithTransactions
import kotlinx.coroutines.flow.Flow

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,12 @@

package com.starry.greenstash.database.widget

import androidx.room.*
import androidx.room.Dao
import androidx.room.Delete
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Query
import androidx.room.Update

@Dao
interface WidgetDao {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,24 @@ import com.starry.greenstash.database.goal.GoalDao
import com.starry.greenstash.other.WelcomeDataStore
import com.starry.greenstash.reminder.ReminderManager
import com.starry.greenstash.reminder.ReminderNotificationSender
import com.starry.greenstash.utils.PreferenceUtil
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.android.qualifiers.ApplicationContext
import dagger.hilt.components.SingletonComponent
import kotlinx.coroutines.ExperimentalCoroutinesApi
import javax.inject.Singleton

@ExperimentalCoroutinesApi
@ExperimentalMaterialApi
@ExperimentalFoundationApi
@ExperimentalComposeUiApi
@ExperimentalAnimationApi
@ExperimentalMaterial3Api
@InstallIn(SingletonComponent::class)
@Module
class MianModule {
class MainModule {

@Singleton
@Provides
Expand All @@ -66,6 +69,9 @@ class MianModule {
@Provides
fun provideWidgetDao(appDatabase: AppDatabase) = appDatabase.getWidgetDao()

@Provides
fun providePreferenceUtil(@ApplicationContext context: Context) = PreferenceUtil(context)

@Provides
@Singleton
fun provideDataStoreRepository(
Expand All @@ -78,11 +84,14 @@ class MianModule {

@Provides
@Singleton
fun provideReminderNotificationSender(@ApplicationContext context: Context) =
ReminderNotificationSender(context)
fun provideReminderNotificationSender(
@ApplicationContext context: Context,
preferenceUtil: PreferenceUtil
) =
ReminderNotificationSender(context, preferenceUtil)

@Provides
@Singleton
fun providebackupmanager(@ApplicationContext context: Context, goalDao: GoalDao) =
fun provideBackupManager(@ApplicationContext context: Context, goalDao: GoalDao) =
BackupManager(context = context, goalDao = goalDao)
}
Loading

0 comments on commit 7375e5c

Please sign in to comment.