Skip to content

Commit fa28437

Browse files
authored
Issue 2712 add email signatures support (#2769)
* Updated AccountAliasesEntity.| #2712 * wip * wip * wip * wip * wip * wip * wip * wip * Added UpdateSignatureDialogFragment.| #2712 * Added appending a signature to outgoing messages.| #2712 * wip * wip * wip * wip * wip * Added some tests.| #2712 * Added some tests for Gmail API.| #2712 * Added some tests.| #2712 * Fixed the database migration.| #2712 * Fixed lint warnings.| #2712
1 parent 59c3ec0 commit fa28437

File tree

44 files changed

+3134
-190
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+3134
-190
lines changed

FlowCrypt/schemas/com.flowcrypt.email.database.FlowCryptRoomDatabase/45.json

Lines changed: 1200 additions & 0 deletions
Large diffs are not rendered by default.

FlowCrypt/src/androidTest/java/com/flowcrypt/email/database/MigrationTest.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ class MigrationTest {
4949
FlowCryptRoomDatabase.MIGRATION_41_42,
5050
FlowCryptRoomDatabase.Migration42to43(InstrumentationRegistry.getInstrumentation().targetContext),
5151
FlowCryptRoomDatabase.MIGRATION_43_44,
52+
FlowCryptRoomDatabase.MIGRATION_44_45,
5253
)
5354

5455
@get:Rule

FlowCrypt/src/androidTest/java/com/flowcrypt/email/rules/AddAccountAliasToDatabaseRule.kt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,20 @@ package com.flowcrypt.email.rules
77

88
import com.flowcrypt.email.database.FlowCryptRoomDatabase
99
import com.flowcrypt.email.database.entity.AccountAliasesEntity
10+
import kotlinx.coroutines.runBlocking
1011

1112
/**
1213
* @author Denys Bondarenko
1314
*/
14-
class AddAccountAliasToDatabaseRule constructor(val alias: AccountAliasesEntity) : BaseRule() {
15+
class AddAccountAliasToDatabaseRule(private val aliases: List<AccountAliasesEntity>) : BaseRule() {
1516
override fun execute() {
1617
saveAliasToDatabase()
1718
}
1819

1920
private fun saveAliasToDatabase() {
20-
FlowCryptRoomDatabase.getDatabase(targetContext).accountAliasesDao().insert(alias)
21+
runBlocking {
22+
FlowCryptRoomDatabase.getDatabase(targetContext).accountAliasesDao()
23+
.insertSuspend(aliases)
24+
}
2125
}
2226
}

FlowCrypt/src/androidTest/java/com/flowcrypt/email/rules/AddGmailAliasToDatabaseRule.kt

Lines changed: 0 additions & 28 deletions
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
/*
2+
* © 2016-present FlowCrypt a.s. Limitations apply. Contact [email protected]
3+
* Contributors: DenBond7
4+
*/
5+
6+
package com.flowcrypt.email.ui
7+
8+
9+
import androidx.test.espresso.Espresso.onView
10+
import androidx.test.espresso.action.ViewActions.scrollTo
11+
import androidx.test.espresso.assertion.ViewAssertions.matches
12+
import androidx.test.espresso.matcher.ViewMatchers.withId
13+
import androidx.test.espresso.matcher.ViewMatchers.withText
14+
import androidx.test.ext.junit.runners.AndroidJUnit4
15+
import androidx.test.filters.MediumTest
16+
import com.flowcrypt.email.R
17+
import com.flowcrypt.email.model.MessageType
18+
import com.flowcrypt.email.rules.ClearAppSettingsRule
19+
import com.flowcrypt.email.rules.GrantPermissionRuleChooser
20+
import com.flowcrypt.email.rules.RetryRule
21+
import com.flowcrypt.email.rules.ScreenshotTestRule
22+
import com.flowcrypt.email.ui.activity.fragment.CreateMessageFragmentArgs
23+
import com.flowcrypt.email.ui.base.BaseComposeScreenWithCustomSignatureFlowTest
24+
import org.hamcrest.core.StringStartsWith
25+
import org.junit.Rule
26+
import org.junit.Test
27+
import org.junit.rules.RuleChain
28+
import org.junit.rules.TestRule
29+
import org.junit.runner.RunWith
30+
31+
/**
32+
* @author Denys Bondarenko
33+
*/
34+
@MediumTest
35+
@RunWith(AndroidJUnit4::class)
36+
class ComposeScreenForwardWithCustomSignatureFlowTest :
37+
BaseComposeScreenWithCustomSignatureFlowTest() {
38+
override val createMessageFragmentArgs: CreateMessageFragmentArgs
39+
get() = CreateMessageFragmentArgs(
40+
incomingMessageInfo = getMsgInfo(
41+
path = "messages/info/standard_msg_reply_to_header.json",
42+
mimeMsgPath = "messages/mime/standard_msg_reply_to_header.txt",
43+
accountEntity = BASE_ADD_ACCOUNT_RULE.apply { execute() }.accountEntityWithDecryptedInfo
44+
),
45+
encryptedByDefault = false,
46+
messageType = MessageType.FORWARD
47+
)
48+
49+
@get:Rule
50+
var ruleChain: TestRule = RuleChain
51+
.outerRule(RetryRule.DEFAULT)
52+
.around(ClearAppSettingsRule())
53+
.around(GrantPermissionRuleChooser.grant(android.Manifest.permission.POST_NOTIFICATIONS))
54+
.around(addAccountToDatabaseRule)
55+
.around(addPrivateKeyToDatabaseRule)
56+
.around(activityScenarioRule)
57+
.around(ScreenshotTestRule())
58+
59+
@Test
60+
fun testAddingSignatureAfterStart() {
61+
Thread.sleep(1000)
62+
onView(withId(R.id.editTextEmailMessage))
63+
.perform(scrollTo())
64+
.check(matches(withText(StringStartsWith.startsWith("\n\n$SIGNATURE"))))
65+
}
66+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
/*
2+
* © 2016-present FlowCrypt a.s. Limitations apply. Contact [email protected]
3+
* Contributors: DenBond7
4+
*/
5+
6+
package com.flowcrypt.email.ui
7+
8+
import androidx.test.espresso.Espresso.onView
9+
import androidx.test.espresso.action.ViewActions.scrollTo
10+
import androidx.test.espresso.assertion.ViewAssertions.matches
11+
import androidx.test.espresso.matcher.ViewMatchers.withId
12+
import androidx.test.espresso.matcher.ViewMatchers.withText
13+
import androidx.test.ext.junit.runners.AndroidJUnit4
14+
import androidx.test.filters.MediumTest
15+
import com.flowcrypt.email.R
16+
import com.flowcrypt.email.junit.annotations.FlowCryptTestSettings
17+
import com.flowcrypt.email.model.MessageType
18+
import com.flowcrypt.email.rules.ClearAppSettingsRule
19+
import com.flowcrypt.email.rules.GrantPermissionRuleChooser
20+
import com.flowcrypt.email.rules.RetryRule
21+
import com.flowcrypt.email.rules.ScreenshotTestRule
22+
import com.flowcrypt.email.ui.activity.fragment.CreateMessageFragmentArgs
23+
import com.flowcrypt.email.ui.base.BaseComposeScreenWithCustomSignatureFlowTest
24+
import org.junit.Rule
25+
import org.junit.Test
26+
import org.junit.rules.RuleChain
27+
import org.junit.rules.TestRule
28+
import org.junit.runner.RunWith
29+
30+
/**
31+
* @author Denys Bondarenko
32+
*/
33+
@MediumTest
34+
@RunWith(AndroidJUnit4::class)
35+
@FlowCryptTestSettings(useCommonIdling = false)
36+
class ComposeScreenNewMessageWithCustomSignatureFlowTest :
37+
BaseComposeScreenWithCustomSignatureFlowTest() {
38+
override val createMessageFragmentArgs: CreateMessageFragmentArgs
39+
get() = CreateMessageFragmentArgs(
40+
encryptedByDefault = true,
41+
messageType = MessageType.NEW
42+
)
43+
44+
@get:Rule
45+
var ruleChain: TestRule = RuleChain
46+
.outerRule(RetryRule.DEFAULT)
47+
.around(ClearAppSettingsRule())
48+
.around(GrantPermissionRuleChooser.grant(android.Manifest.permission.POST_NOTIFICATIONS))
49+
.around(addAccountToDatabaseRule)
50+
.around(addPrivateKeyToDatabaseRule)
51+
.around(activityScenarioRule)
52+
.around(ScreenshotTestRule())
53+
54+
@Test
55+
fun testAddingSignatureAfterStart() {
56+
Thread.sleep(1000)
57+
58+
onView(withId(R.id.editTextEmailMessage))
59+
.perform(scrollTo())
60+
.check(matches(withText("\n\n$SIGNATURE")))
61+
}
62+
63+
companion object {
64+
const val SIGNATURE = "My great signature"
65+
}
66+
}
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/*
2+
* © 2016-present FlowCrypt a.s. Limitations apply. Contact [email protected]
3+
* Contributors: DenBond7
4+
*/
5+
6+
package com.flowcrypt.email.ui
7+
8+
9+
import androidx.test.espresso.Espresso.onView
10+
import androidx.test.espresso.action.ViewActions.scrollTo
11+
import androidx.test.espresso.assertion.ViewAssertions.matches
12+
import androidx.test.espresso.matcher.ViewMatchers.withId
13+
import androidx.test.espresso.matcher.ViewMatchers.withText
14+
import androidx.test.ext.junit.runners.AndroidJUnit4
15+
import androidx.test.filters.MediumTest
16+
import com.flowcrypt.email.R
17+
import com.flowcrypt.email.model.MessageType
18+
import com.flowcrypt.email.rules.ClearAppSettingsRule
19+
import com.flowcrypt.email.rules.GrantPermissionRuleChooser
20+
import com.flowcrypt.email.rules.RetryRule
21+
import com.flowcrypt.email.rules.ScreenshotTestRule
22+
import com.flowcrypt.email.ui.activity.fragment.CreateMessageFragmentArgs
23+
import com.flowcrypt.email.ui.base.BaseComposeScreenWithCustomSignatureFlowTest
24+
import org.junit.Rule
25+
import org.junit.Test
26+
import org.junit.rules.RuleChain
27+
import org.junit.rules.TestRule
28+
import org.junit.runner.RunWith
29+
30+
/**
31+
* @author Denys Bondarenko
32+
*/
33+
@MediumTest
34+
@RunWith(AndroidJUnit4::class)
35+
class ComposeScreenReplyWithCustomSignatureFlowTest :
36+
BaseComposeScreenWithCustomSignatureFlowTest() {
37+
override val createMessageFragmentArgs: CreateMessageFragmentArgs
38+
get() = CreateMessageFragmentArgs(
39+
incomingMessageInfo = getMsgInfo(
40+
path = "messages/info/standard_msg_reply_to_header.json",
41+
mimeMsgPath = "messages/mime/standard_msg_reply_to_header.txt",
42+
accountEntity = BASE_ADD_ACCOUNT_RULE.apply { execute() }.accountEntityWithDecryptedInfo
43+
),
44+
encryptedByDefault = false,
45+
messageType = MessageType.REPLY
46+
)
47+
48+
@get:Rule
49+
var ruleChain: TestRule = RuleChain
50+
.outerRule(RetryRule.DEFAULT)
51+
.around(ClearAppSettingsRule())
52+
.around(GrantPermissionRuleChooser.grant(android.Manifest.permission.POST_NOTIFICATIONS))
53+
.around(addAccountToDatabaseRule)
54+
.around(addPrivateKeyToDatabaseRule)
55+
.around(activityScenarioRule)
56+
.around(ScreenshotTestRule())
57+
58+
@Test
59+
fun testAddingSignatureAfterStart() {
60+
Thread.sleep(1000)
61+
onView(withId(R.id.editTextEmailMessage))
62+
.perform(scrollTo())
63+
.check(matches(withText("\n\n$SIGNATURE")))
64+
}
65+
}

FlowCrypt/src/androidTest/java/com/flowcrypt/email/ui/CreateMessageTestRecipientsDuringReplyAllFlowTest.kt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import com.flowcrypt.email.matchers.CustomMatchers.Companion.hasItem
2222
import com.flowcrypt.email.matchers.CustomMatchers.Companion.withRecyclerViewItemCount
2323
import com.flowcrypt.email.model.MessageEncryptionType
2424
import com.flowcrypt.email.model.MessageType
25-
import com.flowcrypt.email.rules.AddGmailAliasToDatabaseRule
25+
import com.flowcrypt.email.rules.AddAccountAliasToDatabaseRule
2626
import com.flowcrypt.email.rules.AddPrivateKeyToDatabaseRule
2727
import com.flowcrypt.email.rules.ClearAppSettingsRule
2828
import com.flowcrypt.email.rules.GrantPermissionRuleChooser
@@ -45,14 +45,16 @@ import org.junit.runner.RunWith
4545
@RunWith(AndroidJUnit4::class)
4646
class CreateMessageTestRecipientsDuringReplyAllFlowTest : BaseComposeScreenTest() {
4747
private val addPrivateKeyToDatabaseRule = AddPrivateKeyToDatabaseRule()
48-
private val addGmailAliasToDatabaseRule = AddGmailAliasToDatabaseRule(
49-
AccountAliasesEntity(
48+
private val addAccountAliasToDatabaseRule = AddAccountAliasToDatabaseRule(
49+
listOf(
50+
AccountAliasesEntity(
5051
email = addAccountToDatabaseRule.account.email,
5152
accountType = requireNotNull(addAccountToDatabaseRule.account.accountType),
5253
sendAsEmail = ALIAS.lowercase(),
5354
displayName = ALIAS,
5455
isDefault = false,
5556
verificationStatus = "accepted"
57+
)
5658
)
5759
)
5860
private val INBOX = LocalFolder(
@@ -70,7 +72,7 @@ class CreateMessageTestRecipientsDuringReplyAllFlowTest : BaseComposeScreenTest(
7072
.around(GrantPermissionRuleChooser.grant(android.Manifest.permission.POST_NOTIFICATIONS))
7173
.around(addAccountToDatabaseRule)
7274
.around(addPrivateKeyToDatabaseRule)
73-
.around(addGmailAliasToDatabaseRule)
75+
.around(addAccountAliasToDatabaseRule)
7476
.around(activeActivityRule)
7577
.around(ScreenshotTestRule())
7678

0 commit comments

Comments
 (0)