From c66f9ce5c31485c22e9d00ec56b7b26675195f9f Mon Sep 17 00:00:00 2001 From: iliyangermanov Date: Sat, 2 Sep 2023 16:35:22 +0300 Subject: [PATCH 1/4] WIP: Migrate to Version Catalog and delete some legacy code --- app/build.gradle.kts | 2 ++ .../main/java/com/ivy/wallet/AppModuleDI.kt | 7 ----- .../com/ivy/wallet/io/network/FCMClient.kt | 30 ------------------- .../viewmodel/OnboardingViewModel.kt | 11 ++++--- .../wallet/ui/settings/SettingsViewModel.kt | 4 +-- .../com/ivy/wallet/buildsrc/dependencies.kt | 23 -------------- gradle/libs.versions.toml | 19 ++++++++++++ 7 files changed, 29 insertions(+), 67 deletions(-) delete mode 100644 app/src/main/java/com/ivy/wallet/io/network/FCMClient.kt diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 2e46e81002..43ff1b4eec 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -150,6 +150,8 @@ dependencies { implementation(libs.bundles.compose) implementation(libs.bundles.glance) implementation(libs.bundles.activity) + implementation(libs.bundles.google) + implementation(libs.bundles.firebase) implementation(libs.datastore) implementation(libs.androidx.security) implementation(libs.androidx.biometrics) diff --git a/app/src/main/java/com/ivy/wallet/AppModuleDI.kt b/app/src/main/java/com/ivy/wallet/AppModuleDI.kt index d4f4f0c2f6..79a2a25fdd 100644 --- a/app/src/main/java/com/ivy/wallet/AppModuleDI.kt +++ b/app/src/main/java/com/ivy/wallet/AppModuleDI.kt @@ -85,13 +85,6 @@ object AppModuleDI { return RestClient.initialize(appContext, ivySession, gson) } - @Provides - fun provideFCMClient( - sharedPrefs: SharedPrefs - ): FCMClient { - return FCMClient(sharedPrefs) - } - @Provides @Singleton fun provideIvyRoomDatabase( diff --git a/app/src/main/java/com/ivy/wallet/io/network/FCMClient.kt b/app/src/main/java/com/ivy/wallet/io/network/FCMClient.kt deleted file mode 100644 index 17ca9f600a..0000000000 --- a/app/src/main/java/com/ivy/wallet/io/network/FCMClient.kt +++ /dev/null @@ -1,30 +0,0 @@ -package com.ivy.wallet.io.network - -import com.google.firebase.messaging.FirebaseMessaging -import com.ivy.wallet.io.persistence.SharedPrefs -import kotlinx.coroutines.tasks.await - -class FCMClient(private val sharedPrefs: SharedPrefs) { - companion object { - const val NA = "n/a" - } - - suspend fun fcmToken(): String { - return try { - sharedPrefs.getString(SharedPrefs.FCM_TOKEN, null) - ?: fetchFCMTokenFromServer() - } catch (e: Exception) { - e.printStackTrace() - NA - } - } - - private suspend fun fetchFCMTokenFromServer(): String { - return try { - FirebaseMessaging.getInstance().token.await() - } catch (e: Exception) { - e.printStackTrace() - NA - } - } -} \ No newline at end of file diff --git a/app/src/main/java/com/ivy/wallet/ui/onboarding/viewmodel/OnboardingViewModel.kt b/app/src/main/java/com/ivy/wallet/ui/onboarding/viewmodel/OnboardingViewModel.kt index 3d2a6dd6b3..789cda3d1c 100644 --- a/app/src/main/java/com/ivy/wallet/ui/onboarding/viewmodel/OnboardingViewModel.kt +++ b/app/src/main/java/com/ivy/wallet/ui/onboarding/viewmodel/OnboardingViewModel.kt @@ -13,13 +13,16 @@ import com.ivy.wallet.domain.data.IvyCurrency import com.ivy.wallet.domain.data.core.Account import com.ivy.wallet.domain.data.core.Category import com.ivy.wallet.domain.data.core.Settings -import com.ivy.wallet.domain.deprecated.logic.* +import com.ivy.wallet.domain.deprecated.logic.AccountCreator +import com.ivy.wallet.domain.deprecated.logic.CategoryCreator +import com.ivy.wallet.domain.deprecated.logic.LogoutLogic +import com.ivy.wallet.domain.deprecated.logic.PreloadDataLogic +import com.ivy.wallet.domain.deprecated.logic.WalletAccountLogic import com.ivy.wallet.domain.deprecated.logic.currency.ExchangeRatesLogic import com.ivy.wallet.domain.deprecated.logic.model.CreateAccountData import com.ivy.wallet.domain.deprecated.logic.model.CreateCategoryData import com.ivy.wallet.domain.deprecated.logic.notification.TransactionReminderLogic import com.ivy.wallet.domain.deprecated.sync.IvySync -import com.ivy.wallet.io.network.FCMClient import com.ivy.wallet.io.network.IvyAnalytics import com.ivy.wallet.io.network.IvySession import com.ivy.wallet.io.network.RestClient @@ -48,7 +51,6 @@ class OnboardingViewModel @Inject constructor( private val accountDao: AccountDao, private val settingsDao: SettingsDao, private val restClient: RestClient, - private val fcmClient: FCMClient, private val session: IvySession, private val accountLogic: WalletAccountLogic, private val categoryCreator: CategoryCreator, @@ -188,10 +190,11 @@ class OnboardingViewModel @Inject constructor( private suspend fun loginWithGoogleOnServer(idToken: String) { TestIdlingResource.increment() + // TODO: Delete this legacy code val authResponse = restClient.authService.googleSignIn( GoogleSignInRequest( googleIdToken = idToken, - fcmToken = fcmClient.fcmToken() + fcmToken = "" ) ) diff --git a/app/src/main/java/com/ivy/wallet/ui/settings/SettingsViewModel.kt b/app/src/main/java/com/ivy/wallet/ui/settings/SettingsViewModel.kt index 3340b23a1a..543df2b7da 100644 --- a/app/src/main/java/com/ivy/wallet/ui/settings/SettingsViewModel.kt +++ b/app/src/main/java/com/ivy/wallet/ui/settings/SettingsViewModel.kt @@ -18,7 +18,6 @@ import com.ivy.wallet.domain.deprecated.logic.csv.ExportCSVLogic import com.ivy.wallet.domain.deprecated.logic.currency.ExchangeRatesLogic import com.ivy.wallet.domain.deprecated.logic.zip.BackupLogic import com.ivy.wallet.domain.deprecated.sync.IvySync -import com.ivy.wallet.io.network.FCMClient import com.ivy.wallet.io.network.IvyAnalytics import com.ivy.wallet.io.network.IvySession import com.ivy.wallet.io.network.RestClient @@ -55,7 +54,6 @@ class SettingsViewModel @Inject constructor( private val ivySync: IvySync, private val exportCSVLogic: ExportCSVLogic, private val restClient: RestClient, - private val fcmClient: FCMClient, private val ivyAnalytics: IvyAnalytics, private val exchangeRatesLogic: ExchangeRatesLogic, private val logoutLogic: LogoutLogic, @@ -285,7 +283,7 @@ class SettingsViewModel @Inject constructor( val authResponse = restClient.authService.googleSignIn( GoogleSignInRequest( googleIdToken = idToken, - fcmToken = fcmClient.fcmToken() + fcmToken = "" ) ) diff --git a/buildSrc/src/main/java/com/ivy/wallet/buildsrc/dependencies.kt b/buildSrc/src/main/java/com/ivy/wallet/buildsrc/dependencies.kt index b00e207c5f..0ab9e70913 100644 --- a/buildSrc/src/main/java/com/ivy/wallet/buildsrc/dependencies.kt +++ b/buildSrc/src/main/java/com/ivy/wallet/buildsrc/dependencies.kt @@ -58,8 +58,6 @@ fun DependencyHandler.appModuleDependencies( // Compose(version = GlobalVersions.compose) - Google() - Firebase() Hilt( hiltVersion = "2.47", @@ -92,27 +90,6 @@ fun DependencyHandler.ivyDesignModuleDependencies( } //--------------------------------------------------------------------------------- -fun DependencyHandler.DataStore() { - implementation("androidx.datastore:datastore-preferences:1.0.0") -} - -fun DependencyHandler.Google() { - //URL: https://mvnrepository.com/artifact/com.google.android.gms/play-services-auth - implementation("com.google.android.gms:play-services-auth:19.2.0") - - //URL: https://developer.android.com/google/play/billing/getting-ready - implementation("com.android.billingclient:billing-ktx:6.0.1") - - //In-App Reviews SDK - implementation("com.google.android.play:core:1.10.0") - implementation("com.google.android.play:core-ktx:1.8.1") -} - -fun DependencyHandler.Firebase() { - implementation("com.google.firebase:firebase-crashlytics:17.3.0") - implementation("com.google.firebase:firebase-analytics:18.0.0") - implementation("com.google.firebase:firebase-messaging:21.0.0") -} /** * Hilt DI diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 12bd83f5cd..0af22146f0 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -17,6 +17,11 @@ androidx-security = "1.0.0" androidx-activity = "1.8.0-alpha07" appcompat-activity = "1.7.0-alpha03" androidx-biometrics = "1.2.0-alpha05" +google-playservices-auth = "20.7.0" +google-billing = "6.0.1" +google-play-core = "1.10.0" +google-play-core-ktx = "1.8.1" +firebase-crashlytics = "17.3.0" [libraries] kotlin-stdlib = { module = "org.jetbrains.kotlin:kotlin-stdlib", version.ref = "kotlin" } @@ -58,6 +63,11 @@ androidx-security = { module = "androidx.security:security-crypto", version.ref androidx-biometrics = { module = "androidx.biometric:biometric", version.ref = "androidx-biometrics" } androidx-activity = { module = "androidx.activity:activity-ktx", version.ref = "androidx-activity" } appcompat-activity = { module = "androidx.appcompat:appcompat", version.ref = "appcompat-activity" } +google-playservices-auth = { module = "com.google.android.gms:play-services-auth", version.ref = "google-playservices-auth" } +google-billing = { module = "com.android.billingclient:billing-ktx", version.ref = "google-billing" } +google-play-core = { module = "com.google.android.play:core", version.ref = "google-play-core" } +google-play-core-ktx = { module = "com.google.android.play:core-ktx", version.ref = "google-play-core-ktx" } +firebase-crashlytics = { module = "com.google.firebase:firebase-crashlytics", version.ref = "firebase-crashlytics" } [bundles] kotlin = [ @@ -110,6 +120,15 @@ glance = [ "glance-appwidget", "glance-material3" ] +google = [ + "google-playservices-auth", + "google-billing", + "google-play-core", + "google-play-core-ktx" +] +firebase = [ + "firebase-crashlytics" +] [plugins] kotlinx-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" } From 8d1168eba3746a372469f4c11e72d86480876d12 Mon Sep 17 00:00:00 2001 From: iliyangermanov Date: Sat, 2 Sep 2023 16:37:12 +0300 Subject: [PATCH 2/4] Trigger CI checks on PR --- .github/workflows/apk.yml | 2 ++ .github/workflows/lint.yml | 2 ++ .github/workflows/test.yml | 2 ++ 3 files changed, 6 insertions(+) diff --git a/.github/workflows/apk.yml b/.github/workflows/apk.yml index af410edd45..8c67d74dd9 100644 --- a/.github/workflows/apk.yml +++ b/.github/workflows/apk.yml @@ -4,6 +4,8 @@ on: # Triggers the workflow on push or pull request events push: + pull_request: + jobs: assemble_demo_apk: runs-on: ubuntu-latest diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 5a406d84ea..34ee3430a9 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -5,6 +5,8 @@ on: # Triggers the workflow on push or pull request events push: + pull_request: + # A workflow run is made up of one or more jobs that can run sequentially or in parallel jobs: lint: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4938318e23..f1be40c55e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -5,6 +5,8 @@ on: # Triggers the workflow on push or pull request events push: + pull_request: + # A workflow run is made up of one or more jobs that can run sequentially or in parallel jobs: test: From 7f7fd84537fd52f51bfb39e12eba6242d1482d3c Mon Sep 17 00:00:00 2001 From: iliyangermanov Date: Sat, 2 Sep 2023 16:39:44 +0300 Subject: [PATCH 3/4] Add CODEOWNERS --- .github/CODEOWNERS | 1 + 1 file changed, 1 insertion(+) create mode 100644 .github/CODEOWNERS diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 0000000000..27120decd6 --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1 @@ +* @ILIYANGERMANOV \ No newline at end of file From f6f6da6dc143fa3218cb2ff5e407093b0ddf712d Mon Sep 17 00:00:00 2001 From: iliyangermanov Date: Sat, 2 Sep 2023 16:40:52 +0300 Subject: [PATCH 4/4] Update PR template --- .github/PULL_REQUEST_TEMPLATE.md | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 694380066c..9183edc32b 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -4,7 +4,6 @@ Please check if your pull request fulfills the following requirements: - [ ] I've read the **[Contribution Guidelines](https://github.com/Ivy-Apps/ivy-wallet/blob/main/CONTRIBUTING.md)**. - [ ] The code builds and is tested on a real Android device. - [ ] I confirm that I've run the code locally and everything works as expected. -- [ ] Request a review from **@ILIYANGERMANOV**. _Put an `x` in the boxes that apply._ - [x] Demo: Checking checkbox using `[x]`