From 29f701512a4fb8ccf199f1e15f1af127e10a936c Mon Sep 17 00:00:00 2001 From: Denys Bondarenko Date: Sun, 19 Mar 2023 16:47:30 +0200 Subject: [PATCH 1/7] Switched to use Gmail API for all users. Refactored code.| #2122 --- .../flowcrypt/email/database/MigrationTest.kt | 1 + .../com/flowcrypt/email/util/FlavorSettings.kt | 2 -- .../com/flowcrypt/email/util/FlavorSettings.kt | 1 - .../com/flowcrypt/email/util/FlavorSettings.kt | 1 - .../com/flowcrypt/email/util/FlavorSettings.kt | 1 - .../email/database/FlowCryptRoomDatabase.kt | 18 +++++++++++++++++- .../email/database/entity/AccountEntity.kt | 3 +-- .../email/util/EnvironmentSettings.kt | 1 - 8 files changed, 19 insertions(+), 9 deletions(-) diff --git a/FlowCrypt/src/androidTest/java/com/flowcrypt/email/database/MigrationTest.kt b/FlowCrypt/src/androidTest/java/com/flowcrypt/email/database/MigrationTest.kt index 399b6ea86a..8811d1a3df 100644 --- a/FlowCrypt/src/androidTest/java/com/flowcrypt/email/database/MigrationTest.kt +++ b/FlowCrypt/src/androidTest/java/com/flowcrypt/email/database/MigrationTest.kt @@ -43,6 +43,7 @@ class MigrationTest { FlowCryptRoomDatabase.MIGRATION_32_33, FlowCryptRoomDatabase.MIGRATION_33_34, FlowCryptRoomDatabase.MIGRATION_34_35, + FlowCryptRoomDatabase.MIGRATION_35_36, ) @get:Rule diff --git a/FlowCrypt/src/consumerUiTests/java/com/flowcrypt/email/util/FlavorSettings.kt b/FlowCrypt/src/consumerUiTests/java/com/flowcrypt/email/util/FlavorSettings.kt index 50505ccb0b..d54516a4d9 100644 --- a/FlowCrypt/src/consumerUiTests/java/com/flowcrypt/email/util/FlavorSettings.kt +++ b/FlowCrypt/src/consumerUiTests/java/com/flowcrypt/email/util/FlavorSettings.kt @@ -17,8 +17,6 @@ object FlavorSettings : EnvironmentSettings { GeneralUtil.genIdlingResourcesName(this::class.java), GeneralUtil.isDebugBuild() ) - - override fun isGMailAPIEnabled(): Boolean = true override fun configure(context: Context) {} override fun getCountingIdlingResource() = countingIdlingResource override fun getGoogleIdToken(): String = UUID.randomUUID().toString() diff --git a/FlowCrypt/src/enterpriseDebug/java/com/flowcrypt/email/util/FlavorSettings.kt b/FlowCrypt/src/enterpriseDebug/java/com/flowcrypt/email/util/FlavorSettings.kt index 656de58d03..4331f78a3d 100644 --- a/FlowCrypt/src/enterpriseDebug/java/com/flowcrypt/email/util/FlavorSettings.kt +++ b/FlowCrypt/src/enterpriseDebug/java/com/flowcrypt/email/util/FlavorSettings.kt @@ -11,6 +11,5 @@ import android.content.Context * @author Denys Bondarenko */ object FlavorSettings : EnvironmentSettings { - override fun isGMailAPIEnabled(): Boolean = true override fun configure(context: Context) {} } diff --git a/FlowCrypt/src/enterpriseRelease/java/com/flowcrypt/email/util/FlavorSettings.kt b/FlowCrypt/src/enterpriseRelease/java/com/flowcrypt/email/util/FlavorSettings.kt index 656de58d03..4331f78a3d 100644 --- a/FlowCrypt/src/enterpriseRelease/java/com/flowcrypt/email/util/FlavorSettings.kt +++ b/FlowCrypt/src/enterpriseRelease/java/com/flowcrypt/email/util/FlavorSettings.kt @@ -11,6 +11,5 @@ import android.content.Context * @author Denys Bondarenko */ object FlavorSettings : EnvironmentSettings { - override fun isGMailAPIEnabled(): Boolean = true override fun configure(context: Context) {} } diff --git a/FlowCrypt/src/enterpriseUiTests/java/com/flowcrypt/email/util/FlavorSettings.kt b/FlowCrypt/src/enterpriseUiTests/java/com/flowcrypt/email/util/FlavorSettings.kt index 50505ccb0b..7d19536241 100644 --- a/FlowCrypt/src/enterpriseUiTests/java/com/flowcrypt/email/util/FlavorSettings.kt +++ b/FlowCrypt/src/enterpriseUiTests/java/com/flowcrypt/email/util/FlavorSettings.kt @@ -18,7 +18,6 @@ object FlavorSettings : EnvironmentSettings { GeneralUtil.isDebugBuild() ) - override fun isGMailAPIEnabled(): Boolean = true override fun configure(context: Context) {} override fun getCountingIdlingResource() = countingIdlingResource override fun getGoogleIdToken(): String = UUID.randomUUID().toString() diff --git a/FlowCrypt/src/main/java/com/flowcrypt/email/database/FlowCryptRoomDatabase.kt b/FlowCrypt/src/main/java/com/flowcrypt/email/database/FlowCryptRoomDatabase.kt index a735d2e1db..8022421620 100644 --- a/FlowCrypt/src/main/java/com/flowcrypt/email/database/FlowCryptRoomDatabase.kt +++ b/FlowCrypt/src/main/java/com/flowcrypt/email/database/FlowCryptRoomDatabase.kt @@ -87,7 +87,7 @@ abstract class FlowCryptRoomDatabase : RoomDatabase() { companion object { const val DB_NAME = "flowcrypt.db" - const val DB_VERSION = 35 + const val DB_VERSION = 36 private val MIGRATION_1_3 = object : FlowCryptMigration(1, 3) { override fun doMigration(database: SupportSQLiteDatabase) { @@ -1216,6 +1216,21 @@ abstract class FlowCryptRoomDatabase : RoomDatabase() { } } + @VisibleForTesting + val MIGRATION_35_36 = object : FlowCryptMigration(35, 36) { + override fun doMigration(database: SupportSQLiteDatabase) { + val contentValues = ContentValues() + contentValues.put("use_api", "1") + database.update( + "accounts", + SQLiteDatabase.CONFLICT_IGNORE, + contentValues, + "account_type = ? ", + arrayOf(AccountEntity.ACCOUNT_TYPE_GOOGLE) + ) + } + } + // Singleton prevents multiple instances of database opening at the same time. @Volatile private var INSTANCE: FlowCryptRoomDatabase? = null @@ -1265,6 +1280,7 @@ abstract class FlowCryptRoomDatabase : RoomDatabase() { MIGRATION_32_33, MIGRATION_33_34, MIGRATION_34_35, + MIGRATION_35_36, ).build() INSTANCE = instance return instance diff --git a/FlowCrypt/src/main/java/com/flowcrypt/email/database/entity/AccountEntity.kt b/FlowCrypt/src/main/java/com/flowcrypt/email/database/entity/AccountEntity.kt index d2d70f4f7b..effac2f477 100644 --- a/FlowCrypt/src/main/java/com/flowcrypt/email/database/entity/AccountEntity.kt +++ b/FlowCrypt/src/main/java/com/flowcrypt/email/database/entity/AccountEntity.kt @@ -18,7 +18,6 @@ import com.flowcrypt.email.api.email.gmail.GmailConstants import com.flowcrypt.email.api.email.model.AuthCredentials import com.flowcrypt.email.api.email.model.SecurityType import com.flowcrypt.email.api.retrofit.response.model.ClientConfiguration -import com.flowcrypt.email.util.FlavorSettings import com.google.android.gms.auth.api.signin.GoogleSignInAccount import kotlinx.parcelize.IgnoredOnParcel import kotlinx.parcelize.Parcelize @@ -128,7 +127,7 @@ data class AccountEntity constructor( contactsLoaded = false, showOnlyEncrypted = false, clientConfiguration = clientConfiguration, - useAPI = FlavorSettings.isGMailAPIEnabled(), + useAPI = true, useCustomerFesUrl = useCustomerFesUrl ) diff --git a/FlowCrypt/src/main/java/com/flowcrypt/email/util/EnvironmentSettings.kt b/FlowCrypt/src/main/java/com/flowcrypt/email/util/EnvironmentSettings.kt index 51c049e6b5..7ae47eaf8f 100644 --- a/FlowCrypt/src/main/java/com/flowcrypt/email/util/EnvironmentSettings.kt +++ b/FlowCrypt/src/main/java/com/flowcrypt/email/util/EnvironmentSettings.kt @@ -15,7 +15,6 @@ import java.util.Properties interface EnvironmentSettings { fun sslTrustedDomains(): List = emptyList() fun getFlavorPropertiesForSession(): Properties = Properties() - fun isGMailAPIEnabled(): Boolean = false fun configure(context: Context) fun getCountingIdlingResource(): CountingIdlingResource? = null fun getGoogleIdToken(): String? = null From 4c7e9f67c61cdaf85213e40a7ad7afbbaa943e33 Mon Sep 17 00:00:00 2001 From: Denys Bondarenko Date: Mon, 20 Mar 2023 18:58:00 +0200 Subject: [PATCH 2/7] Reverted back the database migration.| #2122 --- .../flowcrypt/email/database/MigrationTest.kt | 1 - .../email/database/FlowCryptRoomDatabase.kt | 18 +----------------- 2 files changed, 1 insertion(+), 18 deletions(-) diff --git a/FlowCrypt/src/androidTest/java/com/flowcrypt/email/database/MigrationTest.kt b/FlowCrypt/src/androidTest/java/com/flowcrypt/email/database/MigrationTest.kt index 8811d1a3df..399b6ea86a 100644 --- a/FlowCrypt/src/androidTest/java/com/flowcrypt/email/database/MigrationTest.kt +++ b/FlowCrypt/src/androidTest/java/com/flowcrypt/email/database/MigrationTest.kt @@ -43,7 +43,6 @@ class MigrationTest { FlowCryptRoomDatabase.MIGRATION_32_33, FlowCryptRoomDatabase.MIGRATION_33_34, FlowCryptRoomDatabase.MIGRATION_34_35, - FlowCryptRoomDatabase.MIGRATION_35_36, ) @get:Rule diff --git a/FlowCrypt/src/main/java/com/flowcrypt/email/database/FlowCryptRoomDatabase.kt b/FlowCrypt/src/main/java/com/flowcrypt/email/database/FlowCryptRoomDatabase.kt index 8022421620..a735d2e1db 100644 --- a/FlowCrypt/src/main/java/com/flowcrypt/email/database/FlowCryptRoomDatabase.kt +++ b/FlowCrypt/src/main/java/com/flowcrypt/email/database/FlowCryptRoomDatabase.kt @@ -87,7 +87,7 @@ abstract class FlowCryptRoomDatabase : RoomDatabase() { companion object { const val DB_NAME = "flowcrypt.db" - const val DB_VERSION = 36 + const val DB_VERSION = 35 private val MIGRATION_1_3 = object : FlowCryptMigration(1, 3) { override fun doMigration(database: SupportSQLiteDatabase) { @@ -1216,21 +1216,6 @@ abstract class FlowCryptRoomDatabase : RoomDatabase() { } } - @VisibleForTesting - val MIGRATION_35_36 = object : FlowCryptMigration(35, 36) { - override fun doMigration(database: SupportSQLiteDatabase) { - val contentValues = ContentValues() - contentValues.put("use_api", "1") - database.update( - "accounts", - SQLiteDatabase.CONFLICT_IGNORE, - contentValues, - "account_type = ? ", - arrayOf(AccountEntity.ACCOUNT_TYPE_GOOGLE) - ) - } - } - // Singleton prevents multiple instances of database opening at the same time. @Volatile private var INSTANCE: FlowCryptRoomDatabase? = null @@ -1280,7 +1265,6 @@ abstract class FlowCryptRoomDatabase : RoomDatabase() { MIGRATION_32_33, MIGRATION_33_34, MIGRATION_34_35, - MIGRATION_35_36, ).build() INSTANCE = instance return instance From 84dc40fce61191be22faeff2c522f665448b7a5a Mon Sep 17 00:00:00 2001 From: Denys Bondarenko Date: Mon, 20 Mar 2023 19:28:46 +0200 Subject: [PATCH 3/7] Updated RetryRule.| #2122 --- .../src/androidTest/java/com/flowcrypt/email/rules/RetryRule.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FlowCrypt/src/androidTest/java/com/flowcrypt/email/rules/RetryRule.kt b/FlowCrypt/src/androidTest/java/com/flowcrypt/email/rules/RetryRule.kt index 4839079ca6..09863d53ea 100644 --- a/FlowCrypt/src/androidTest/java/com/flowcrypt/email/rules/RetryRule.kt +++ b/FlowCrypt/src/androidTest/java/com/flowcrypt/email/rules/RetryRule.kt @@ -46,7 +46,7 @@ class RetryRule(private val retryCount: Int = 0) : BaseRule() { .onSuccess { return } .onFailure { TestGeneralUtil.clearApp(targetContext) - Thread.sleep(1000) + Thread.sleep(1000 * (times + 1).toLong()) caughtThrowable = it System.err.println(description.displayName.toString() + ": run ${times + 1} failed") } From e0678d5c413618ef2bd7734ab3abed774741e45d Mon Sep 17 00:00:00 2001 From: DenBond7 Date: Wed, 22 Mar 2023 17:05:35 +0200 Subject: [PATCH 4/7] Updated the database version to 36. Added a migration.| #2122 --- .../flowcrypt/email/database/MigrationTest.kt | 1 + .../email/database/FlowCryptRoomDatabase.kt | 49 ++++++++++++++++++- .../email/database/entity/AccountEntity.kt | 3 +- .../email/database/entity/AttachmentEntity.kt | 4 +- .../email/database/entity/LabelEntity.kt | 4 +- 5 files changed, 56 insertions(+), 5 deletions(-) diff --git a/FlowCrypt/src/androidTest/java/com/flowcrypt/email/database/MigrationTest.kt b/FlowCrypt/src/androidTest/java/com/flowcrypt/email/database/MigrationTest.kt index 399b6ea86a..8811d1a3df 100644 --- a/FlowCrypt/src/androidTest/java/com/flowcrypt/email/database/MigrationTest.kt +++ b/FlowCrypt/src/androidTest/java/com/flowcrypt/email/database/MigrationTest.kt @@ -43,6 +43,7 @@ class MigrationTest { FlowCryptRoomDatabase.MIGRATION_32_33, FlowCryptRoomDatabase.MIGRATION_33_34, FlowCryptRoomDatabase.MIGRATION_34_35, + FlowCryptRoomDatabase.MIGRATION_35_36, ) @get:Rule diff --git a/FlowCrypt/src/main/java/com/flowcrypt/email/database/FlowCryptRoomDatabase.kt b/FlowCrypt/src/main/java/com/flowcrypt/email/database/FlowCryptRoomDatabase.kt index a735d2e1db..c7e8b857b3 100644 --- a/FlowCrypt/src/main/java/com/flowcrypt/email/database/FlowCryptRoomDatabase.kt +++ b/FlowCrypt/src/main/java/com/flowcrypt/email/database/FlowCryptRoomDatabase.kt @@ -87,7 +87,7 @@ abstract class FlowCryptRoomDatabase : RoomDatabase() { companion object { const val DB_NAME = "flowcrypt.db" - const val DB_VERSION = 35 + const val DB_VERSION = 36 private val MIGRATION_1_3 = object : FlowCryptMigration(1, 3) { override fun doMigration(database: SupportSQLiteDatabase) { @@ -1216,6 +1216,52 @@ abstract class FlowCryptRoomDatabase : RoomDatabase() { } } + @VisibleForTesting + val MIGRATION_35_36 = object : FlowCryptMigration(35, 36) { + override fun doMigration(database: SupportSQLiteDatabase) { + //we need to clean old cache for some 'com.google' users: messages, attachments, labels + + val commonWhereClause = "email IN (SELECT email FROM " + AccountEntity.TABLE_NAME + + " WHERE account_type = ? AND use_api = ?)" + val commonWhereArgs = arrayOf( + AccountEntity.ACCOUNT_TYPE_GOOGLE, + "0", + JavaEmailConstants.FOLDER_OUTBOX + ) + //delete messages for predefined 'com.google' users, except outgoing + database.delete( + MessageEntity.TABLE_NAME, + "$commonWhereClause AND folder != ?", + commonWhereArgs + ) + + //delete attachments for predefined 'com.google' users, except outgoing + database.delete( + AttachmentEntity.TABLE_NAME, + "$commonWhereClause AND folder != ?", + commonWhereArgs + ) + + //delete all labels for 'com.google' users + database.delete( + LabelEntity.TABLE_NAME, + commonWhereClause, + commonWhereArgs.copyOf(2) + ) + + //in the and we need to force using Gmail API by 'com.google' users via 'use_api = 1' + val contentValues = ContentValues() + contentValues.put("use_api", "1") + database.update( + AccountEntity.TABLE_NAME, + SQLiteDatabase.CONFLICT_IGNORE, + contentValues, + "account_type = ?", + arrayOf(AccountEntity.ACCOUNT_TYPE_GOOGLE) + ) + } + } + // Singleton prevents multiple instances of database opening at the same time. @Volatile private var INSTANCE: FlowCryptRoomDatabase? = null @@ -1265,6 +1311,7 @@ abstract class FlowCryptRoomDatabase : RoomDatabase() { MIGRATION_32_33, MIGRATION_33_34, MIGRATION_34_35, + MIGRATION_35_36, ).build() INSTANCE = instance return instance diff --git a/FlowCrypt/src/main/java/com/flowcrypt/email/database/entity/AccountEntity.kt b/FlowCrypt/src/main/java/com/flowcrypt/email/database/entity/AccountEntity.kt index effac2f477..365454d2b9 100644 --- a/FlowCrypt/src/main/java/com/flowcrypt/email/database/entity/AccountEntity.kt +++ b/FlowCrypt/src/main/java/com/flowcrypt/email/database/entity/AccountEntity.kt @@ -26,7 +26,7 @@ import kotlinx.parcelize.Parcelize * @author Denys Bondarenko */ @Entity( - tableName = "accounts", + tableName = AccountEntity.TABLE_NAME, indices = [ Index(name = "email_account_type_in_accounts", value = ["email", "account_type"], unique = true) ] @@ -228,6 +228,7 @@ data class AccountEntity constructor( } companion object { + const val TABLE_NAME = "accounts" const val ACCOUNT_TYPE_GOOGLE = "com.google" const val ACCOUNT_TYPE_OUTLOOK = "outlook.com" } diff --git a/FlowCrypt/src/main/java/com/flowcrypt/email/database/entity/AttachmentEntity.kt b/FlowCrypt/src/main/java/com/flowcrypt/email/database/entity/AttachmentEntity.kt index 714f38e632..472c6903e1 100644 --- a/FlowCrypt/src/main/java/com/flowcrypt/email/database/entity/AttachmentEntity.kt +++ b/FlowCrypt/src/main/java/com/flowcrypt/email/database/entity/AttachmentEntity.kt @@ -19,7 +19,7 @@ import com.flowcrypt.email.api.email.model.AttachmentInfo * @author Denys Bondarenko */ @Entity( - tableName = "attachment", + tableName = AttachmentEntity.TABLE_NAME, indices = [ Index( name = "email_uid_folder_path_in_attachment", @@ -75,6 +75,8 @@ data class AttachmentEntity( } companion object { + const val TABLE_NAME = "attachment" + fun fromAttInfo(attachmentInfo: AttachmentInfo): AttachmentEntity? { with(attachmentInfo) { val email = email ?: return null diff --git a/FlowCrypt/src/main/java/com/flowcrypt/email/database/entity/LabelEntity.kt b/FlowCrypt/src/main/java/com/flowcrypt/email/database/entity/LabelEntity.kt index 941e189fa9..cf4593e87d 100644 --- a/FlowCrypt/src/main/java/com/flowcrypt/email/database/entity/LabelEntity.kt +++ b/FlowCrypt/src/main/java/com/flowcrypt/email/database/entity/LabelEntity.kt @@ -19,7 +19,7 @@ import com.google.android.gms.common.util.CollectionUtils * @author Denys Bondarenko */ @Entity( - tableName = "labels", + tableName = LabelEntity.TABLE_NAME, indices = [ Index( name = "email_account_type_name_in_labels", @@ -52,7 +52,7 @@ data class LabelEntity( val attributesList: List = parseAttributes(attributes) companion object { - + const val TABLE_NAME = "labels" fun genLabel(accountEntity: AccountEntity, localFolder: LocalFolder): LabelEntity { return with(localFolder) { LabelEntity( From 93feac72039924519f1d239fe643f2e3946be06b Mon Sep 17 00:00:00 2001 From: DenBond7 Date: Wed, 22 Mar 2023 17:49:01 +0200 Subject: [PATCH 5/7] Modified DraftViewModel.| #2122 --- .../flowcrypt/email/jetpack/viewmodel/DraftViewModel.kt | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/FlowCrypt/src/main/java/com/flowcrypt/email/jetpack/viewmodel/DraftViewModel.kt b/FlowCrypt/src/main/java/com/flowcrypt/email/jetpack/viewmodel/DraftViewModel.kt index 6e53b51819..6d34643b5d 100644 --- a/FlowCrypt/src/main/java/com/flowcrypt/email/jetpack/viewmodel/DraftViewModel.kt +++ b/FlowCrypt/src/main/java/com/flowcrypt/email/jetpack/viewmodel/DraftViewModel.kt @@ -8,6 +8,8 @@ package com.flowcrypt.email.jetpack.viewmodel import android.app.Application import android.content.Context import androidx.lifecycle.viewModelScope +import com.flowcrypt.email.BuildConfig +import com.flowcrypt.email.Constants import com.flowcrypt.email.R import com.flowcrypt.email.api.email.EmailUtil import com.flowcrypt.email.api.email.FlowCryptMimeMessage @@ -82,8 +84,11 @@ class DraftViewModel( if (isDeleted) return@launch val activeAccount = roomDatabase.accountDao().getActiveAccountSuspend() ?: return@launch - //here we enable 'drafts' functionality only for Google users who use Gmail API. - if (!activeAccount.isGoogleSignInAccount || !activeAccount.useAPI) { + //here we enable 'drafts' functionality only for Google enterprise users who use Gmail API. + if (!activeAccount.isGoogleSignInAccount + || !activeAccount.useAPI + || BuildConfig.FLAVOR != Constants.FLAVOR_NAME_ENTERPRISE + ) { return@launch } From 5db7fb3c07e1204b50b172dbd056fc95e5012233 Mon Sep 17 00:00:00 2001 From: DenBond7 Date: Thu, 23 Mar 2023 11:12:35 +0200 Subject: [PATCH 6/7] Fixed DraftsGmailAPITestCorrectCreatingAndUpdatingFlowTest.| #2122 --- .../ui/DraftsGmailAPITestCorrectCreatingAndUpdatingFlowTest.kt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/FlowCrypt/src/androidTest/java/com/flowcrypt/email/ui/DraftsGmailAPITestCorrectCreatingAndUpdatingFlowTest.kt b/FlowCrypt/src/androidTest/java/com/flowcrypt/email/ui/DraftsGmailAPITestCorrectCreatingAndUpdatingFlowTest.kt index acc2d1e375..fcd314d578 100644 --- a/FlowCrypt/src/androidTest/java/com/flowcrypt/email/ui/DraftsGmailAPITestCorrectCreatingAndUpdatingFlowTest.kt +++ b/FlowCrypt/src/androidTest/java/com/flowcrypt/email/ui/DraftsGmailAPITestCorrectCreatingAndUpdatingFlowTest.kt @@ -22,6 +22,7 @@ import androidx.test.filters.MediumTest import com.flowcrypt.email.R import com.flowcrypt.email.TestConstants import com.flowcrypt.email.jetpack.viewmodel.DraftViewModel +import com.flowcrypt.email.junit.annotations.EnterpriseTest import com.flowcrypt.email.matchers.CustomMatchers.Companion.withRecyclerViewItemCount import com.flowcrypt.email.rules.ClearAppSettingsRule import com.flowcrypt.email.rules.FlowCryptMockWebServerRule @@ -45,6 +46,7 @@ import java.net.HttpURLConnection * https://github.com/FlowCrypt/flowcrypt-android/issues/2050 */ @MediumTest +@EnterpriseTest @RunWith(AndroidJUnit4::class) class DraftsGmailAPITestCorrectCreatingAndUpdatingFlowTest : BaseDraftsGmailAPIFlowTest() { override val mockWebServerRule = From 62d070958ad4f8bdbb42d67d86bc46e3599ea14c Mon Sep 17 00:00:00 2001 From: DenBond7 Date: Thu, 23 Mar 2023 12:14:00 +0200 Subject: [PATCH 7/7] Reverted back some changes.| #2122 --- ...aftsGmailAPITestCorrectCreatingAndUpdatingFlowTest.kt | 2 -- .../flowcrypt/email/jetpack/viewmodel/DraftViewModel.kt | 9 ++------- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/FlowCrypt/src/androidTest/java/com/flowcrypt/email/ui/DraftsGmailAPITestCorrectCreatingAndUpdatingFlowTest.kt b/FlowCrypt/src/androidTest/java/com/flowcrypt/email/ui/DraftsGmailAPITestCorrectCreatingAndUpdatingFlowTest.kt index fcd314d578..acc2d1e375 100644 --- a/FlowCrypt/src/androidTest/java/com/flowcrypt/email/ui/DraftsGmailAPITestCorrectCreatingAndUpdatingFlowTest.kt +++ b/FlowCrypt/src/androidTest/java/com/flowcrypt/email/ui/DraftsGmailAPITestCorrectCreatingAndUpdatingFlowTest.kt @@ -22,7 +22,6 @@ import androidx.test.filters.MediumTest import com.flowcrypt.email.R import com.flowcrypt.email.TestConstants import com.flowcrypt.email.jetpack.viewmodel.DraftViewModel -import com.flowcrypt.email.junit.annotations.EnterpriseTest import com.flowcrypt.email.matchers.CustomMatchers.Companion.withRecyclerViewItemCount import com.flowcrypt.email.rules.ClearAppSettingsRule import com.flowcrypt.email.rules.FlowCryptMockWebServerRule @@ -46,7 +45,6 @@ import java.net.HttpURLConnection * https://github.com/FlowCrypt/flowcrypt-android/issues/2050 */ @MediumTest -@EnterpriseTest @RunWith(AndroidJUnit4::class) class DraftsGmailAPITestCorrectCreatingAndUpdatingFlowTest : BaseDraftsGmailAPIFlowTest() { override val mockWebServerRule = diff --git a/FlowCrypt/src/main/java/com/flowcrypt/email/jetpack/viewmodel/DraftViewModel.kt b/FlowCrypt/src/main/java/com/flowcrypt/email/jetpack/viewmodel/DraftViewModel.kt index 6d34643b5d..6e53b51819 100644 --- a/FlowCrypt/src/main/java/com/flowcrypt/email/jetpack/viewmodel/DraftViewModel.kt +++ b/FlowCrypt/src/main/java/com/flowcrypt/email/jetpack/viewmodel/DraftViewModel.kt @@ -8,8 +8,6 @@ package com.flowcrypt.email.jetpack.viewmodel import android.app.Application import android.content.Context import androidx.lifecycle.viewModelScope -import com.flowcrypt.email.BuildConfig -import com.flowcrypt.email.Constants import com.flowcrypt.email.R import com.flowcrypt.email.api.email.EmailUtil import com.flowcrypt.email.api.email.FlowCryptMimeMessage @@ -84,11 +82,8 @@ class DraftViewModel( if (isDeleted) return@launch val activeAccount = roomDatabase.accountDao().getActiveAccountSuspend() ?: return@launch - //here we enable 'drafts' functionality only for Google enterprise users who use Gmail API. - if (!activeAccount.isGoogleSignInAccount - || !activeAccount.useAPI - || BuildConfig.FLAVOR != Constants.FLAVOR_NAME_ENTERPRISE - ) { + //here we enable 'drafts' functionality only for Google users who use Gmail API. + if (!activeAccount.isGoogleSignInAccount || !activeAccount.useAPI) { return@launch }