Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
5753fcf
wip
DenBond7 Jul 9, 2022
4af48ce
wip
DenBond7 Jul 12, 2022
859408d
wip
DenBond7 Jul 12, 2022
ecfc8a2
wip
DenBond7 Jul 12, 2022
6345f58
Added AutoCompleteResultRecyclerViewAdapter.kt| #234
DenBond7 Jul 14, 2022
d721b38
Modifed RecipientChipRecyclerViewAdapter.| #243
DenBond7 Jul 14, 2022
6f140a8
Modifed AutoCompleteResultRecyclerViewAdapter to mark already added r…
DenBond7 Jul 14, 2022
f19c965
Added styling chips depend on recipient info.| #243
DenBond7 Jul 14, 2022
6a6b5df
Modified RecipientsAutoCompleteViewModel to share a search pattern wi…
DenBond7 Jul 14, 2022
a55ed88
Removed 'com.hootsuite.android:nachos:1.2.0' dependency.| #243
DenBond7 Jul 15, 2022
3a24bde
Improved updating autocomplete results.| #243
DenBond7 Jul 15, 2022
7021c2d
wip
DenBond7 Jul 19, 2022
d2857ab
wip
DenBond7 Jul 20, 2022
ebdc18e
wip
DenBond7 Jul 20, 2022
8ba9005
wip
DenBond7 Jul 21, 2022
de81fc3
Added ability to add new emails from list.| #243
DenBond7 Jul 21, 2022
8a98ba8
Merge branch 'master' into issue_243_custom_chips
DenBond7 Jul 21, 2022
f1c418f
Fixed updating recipients list.| #243
DenBond7 Jul 22, 2022
44b2062
Added "more" label for recipients.| #243
DenBond7 Jul 22, 2022
877d2d8
Updated circular progress in recipients chips.| #243
DenBond7 Jul 25, 2022
a952467
Added ability to use new chips for "cc" and "bcc". Removed unused res…
DenBond7 Jul 25, 2022
6f40e2b
Improved UI.| #243
DenBond7 Jul 25, 2022
c4598e0
Restored broken functionality.| #243
DenBond7 Jul 26, 2022
7017f33
Added showing progress when has updating in hidden items.| #243
DenBond7 Jul 27, 2022
69ba35a
Fixed a bug in RecipientChipRecyclerViewAdapter.| #243
DenBond7 Jul 27, 2022
207b6a9
Fixed some tests.| #243
DenBond7 Jul 28, 2022
264c3e9
Fixed some more tests.| #243
DenBond7 Jul 28, 2022
02c6f98
Fixed more tests.| #243
DenBond7 Jul 29, 2022
e0fbf73
Fixed lint warnings.| #243
DenBond7 Jul 29, 2022
2457270
Fixed compilation issue in SelectRecipientsActivityTest.| #243
DenBond7 Jul 29, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions FlowCrypt/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -393,12 +393,10 @@ dependencies {
implementation 'androidx.navigation:navigation-runtime-ktx:2.5.0'
implementation 'androidx.webkit:webkit:1.4.0'

//https://developers.google.com/android/guides/setup
implementation 'com.google.android.gms:play-services-base:18.1.0'
implementation 'com.google.android.gms:play-services-auth:20.2.0'

//https://mvnrepository.com/artifact/com.google.android.material/material
implementation 'com.google.android.material:material:1.6.1'
implementation 'com.google.android.flexbox:flexbox:3.0.0'

//https://mvnrepository.com/artifact/com.google.code.gson/gson
implementation 'com.google.code.gson:gson:2.9.0'
Expand All @@ -421,7 +419,6 @@ dependencies {
}

implementation 'com.github.bumptech.glide:glide:4.13.2'
implementation 'com.hootsuite.android:nachos:1.2.0'
implementation 'com.nulab-inc:zxcvbn:1.7.0'
implementation 'commons-io:commons-io:2.11.0'
implementation 'ja.burhanrashid52:photoeditor:1.1.1'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* © 2016-present FlowCrypt a.s. Limitations apply. Contact human@flowcrypt.com
* Contributors: DenBond7
*/

package com.flowcrypt.email.matchers

import android.view.View
import androidx.test.espresso.matcher.BoundedMatcher
import com.google.android.material.chip.Chip
import org.hamcrest.Description

/**
* @author Denis Bondarenko
* Date: 4/22/21
* Time: 10:19 AM
* E-mail: DenBond7@gmail.com
*/
class ChipBackgroundColorMatcher(
private val color: Int
) : BoundedMatcher<View, Chip>(Chip::class.java) {
public override fun matchesSafely(chip: Chip): Boolean {
return color == chip.chipBackgroundColor?.defaultColor
}

override fun describeTo(description: Description) {
description.appendText("Chip details: color = $color")
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* © 2016-present FlowCrypt a.s. Limitations apply. Contact human@flowcrypt.com
* Contributors: denbond7
*/

package com.flowcrypt.email.matchers

import android.view.View
import androidx.test.espresso.matcher.BoundedMatcher
import com.google.android.material.chip.Chip
import org.hamcrest.Description

class ChipCloseIconAvailabilityMatcher(
private val isCloseIconVisible: Boolean
) : BoundedMatcher<View, Chip>(Chip::class.java) {
public override fun matchesSafely(chip: Chip): Boolean {
return chip.isCloseIconVisible == isCloseIconVisible
}

override fun describeTo(description: Description) {
description.appendText("Chip details: isCloseIconVisible = $isCloseIconVisible")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ package com.flowcrypt.email.matchers

import android.content.Context
import android.view.View
import android.widget.ListView
import androidx.annotation.ColorRes
import androidx.annotation.DrawableRes
import androidx.core.content.ContextCompat
Expand All @@ -16,9 +15,8 @@ import androidx.test.espresso.Root
import androidx.test.espresso.matcher.BoundedMatcher
import com.flowcrypt.email.api.email.model.SecurityType
import com.flowcrypt.email.ui.adapter.PgpBadgeListAdapter
import com.flowcrypt.email.ui.widget.PGPContactChipSpan
import com.google.android.material.appbar.AppBarLayout
import com.hootsuite.nachos.NachoTextView
import com.google.android.material.chip.Chip
import org.hamcrest.BaseMatcher
import org.hamcrest.Matcher

Expand Down Expand Up @@ -67,14 +65,6 @@ class CustomMatchers {
return AppBarLayoutBackgroundColorMatcher(color)
}

/**
* Match is [ListView] empty.
*/
@JvmStatic
fun withEmptyListView(): BaseMatcher<View> {
return EmptyListViewMather()
}

/**
* Match is [androidx.recyclerview.widget.RecyclerView] empty.
*/
Expand All @@ -83,14 +73,6 @@ class CustomMatchers {
return EmptyRecyclerViewMatcher()
}

/**
* Match is an items count of [ListView] empty.
*/
@JvmStatic
fun withListViewItemCount(itemCount: Int): BaseMatcher<View> {
return ListViewItemCountMatcher(itemCount)
}

/**
* Match is an items count of [RecyclerView] empty.
*/
Expand All @@ -99,17 +81,12 @@ class CustomMatchers {
return RecyclerViewItemCountMatcher(itemCount)
}

/**
* Match a color of the given [PGPContactChipSpan] in [NachoTextView].
*
* @param chipText The given chip text.
* @param backgroundColor The given chip background color.
* @return true if matched, otherwise false
*/
@JvmStatic
fun withChipsBackgroundColor(chipText: String, backgroundColor: Int):
BoundedMatcher<View, NachoTextView> {
return NachoTextViewChipBackgroundColorMatcher(chipText, backgroundColor)
fun withChipsBackgroundColor(context: Context, resourceId: Int): BoundedMatcher<View, Chip> {
return ChipBackgroundColorMatcher(ContextCompat.getColor(context, resourceId))
}

fun withChipCloseIconAvailability(isCloseIconVisible: Boolean): BoundedMatcher<View, Chip> {
return ChipCloseIconAvailabilityMatcher(isCloseIconVisible)
}

fun withPgpBadge(pgpBadge: PgpBadgeListAdapter.PgpBadge): PgpBadgeMatcher {
Expand All @@ -127,6 +104,10 @@ class CustomMatchers {
return TextViewDrawableMatcher(resourceId, drawablePosition)
}

fun hasItem(matcher: Matcher<View>): Matcher<View> {
return RecyclerViewItemMatcher(matcher)
}

fun withTextViewBackgroundTint(
context: Context,
@ColorRes resourceId: Int
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* © 2016-present FlowCrypt a.s. Limitations apply. Contact human@flowcrypt.com
* Contributors: DenBond7
*/

package com.flowcrypt.email.matchers

import android.view.View
import androidx.recyclerview.widget.RecyclerView
import androidx.test.espresso.matcher.BoundedMatcher
import org.hamcrest.Description
import org.hamcrest.Matcher

/**
* @author Denis Bondarenko
* Date: 7/29/22
* Time: 1:20 PM
* E-mail: DenBond7@gmail.com
*/
class RecyclerViewItemMatcher(val matcher: Matcher<View>) :
BoundedMatcher<View, RecyclerView>(RecyclerView::class.java) {
public override fun matchesSafely(recyclerView: RecyclerView): Boolean {
val adapter = recyclerView.adapter ?: throw IllegalStateException("adapter is not present")
for (position in 0 until adapter.itemCount) {
val type = adapter.getItemViewType(position)
val holder = adapter.createViewHolder(recyclerView, type)
adapter.onBindViewHolder(holder, position)
if (matcher.matches(holder.itemView)) {
return true
}
}
return false
}

override fun describeTo(description: Description) {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@

package com.flowcrypt.email.ui

import androidx.recyclerview.widget.RecyclerView
import androidx.test.core.app.ActivityScenario
import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.assertion.ViewAssertions.matches
import androidx.test.espresso.contrib.RecyclerViewActions.scrollTo
import androidx.test.espresso.matcher.ViewMatchers.withId
import androidx.test.espresso.matcher.ViewMatchers.withText
import androidx.test.ext.junit.rules.activityScenarioRule
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.MediumTest
Expand All @@ -28,14 +30,15 @@ import com.flowcrypt.email.rules.RetryRule
import com.flowcrypt.email.rules.ScreenshotTestRule
import com.flowcrypt.email.security.pgp.PgpKey
import com.flowcrypt.email.ui.activity.CreateMessageActivity
import com.flowcrypt.email.ui.adapter.RecipientChipRecyclerViewAdapter
import com.flowcrypt.email.ui.base.BaseComposeScreenTest
import com.flowcrypt.email.util.AccountDaoManager
import com.flowcrypt.email.util.PrivateKeysManager
import com.flowcrypt.email.util.TestGeneralUtil
import com.flowcrypt.email.util.UIUtil
import okhttp3.mockwebserver.Dispatcher
import okhttp3.mockwebserver.MockResponse
import okhttp3.mockwebserver.RecordedRequest
import org.hamcrest.Matchers.allOf
import org.junit.Assert.assertNotNull
import org.junit.Assert.assertTrue
import org.junit.ClassRule
Expand Down Expand Up @@ -107,12 +110,15 @@ class ComposeScreenDisallowUpdateRevokedKeyFlowTest : BaseComposeScreenTest() {
fillInAllFields(userWithRevokedKey)

//check that UI shows a revoked key after call lookupEmail
onView(withId(R.id.editTextRecipientTo))
.check(
matches(
withChipsBackgroundColor(
userWithRevokedKey,
UIUtil.getColor(getTargetContext(), R.color.red)
onView(withId(R.id.recyclerViewChipsTo))
.perform(
scrollTo<RecyclerView.ViewHolder>(
allOf(
withText(userWithRevokedKey),
withChipsBackgroundColor(
getTargetContext(),
RecipientChipRecyclerViewAdapter.CHIP_COLOR_RES_ID_HAS_PUB_KEY_BUT_REVOKED
)
)
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ import android.content.Intent
import android.net.Uri
import androidx.core.content.FileProvider
import androidx.core.net.MailTo
import androidx.recyclerview.widget.RecyclerView
import androidx.test.core.app.ActivityScenario
import androidx.test.core.app.ApplicationProvider
import androidx.test.espresso.Espresso.closeSoftKeyboard
import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.assertion.ViewAssertions.matches
import androidx.test.espresso.contrib.RecyclerViewActions.scrollTo
import androidx.test.espresso.matcher.ViewMatchers.hasChildCount
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
import androidx.test.espresso.matcher.ViewMatchers.withId
Expand All @@ -24,6 +26,7 @@ import com.flowcrypt.email.Constants
import com.flowcrypt.email.R
import com.flowcrypt.email.TestConstants
import com.flowcrypt.email.base.BaseTest
import com.flowcrypt.email.matchers.CustomMatchers.Companion.withRecyclerViewItemCount
import com.flowcrypt.email.rules.AddAccountToDatabaseRule
import com.flowcrypt.email.rules.ClearAppSettingsRule
import com.flowcrypt.email.rules.FlowCryptMockWebServerRule
Expand All @@ -35,7 +38,6 @@ import com.flowcrypt.email.util.TestGeneralUtil
import okhttp3.mockwebserver.Dispatcher
import okhttp3.mockwebserver.MockResponse
import okhttp3.mockwebserver.RecordedRequest
import org.hamcrest.Matchers.containsString
import org.hamcrest.Matchers.isEmptyString
import org.hamcrest.Matchers.not
import org.junit.After
Expand Down Expand Up @@ -438,13 +440,18 @@ class ComposeScreenExternalIntentsFlowTest : BaseTest() {

private fun checkRecipients(recipientsCount: Int) {
if (recipientsCount > 0) {
onView(withId(R.id.recyclerViewChipsTo))
.check(matches(isDisplayed()))
.check(matches(withRecyclerViewItemCount(recipientsCount + 1)))

for (i in 0 until recipientsCount) {
onView(withId(R.id.editTextRecipientTo))
.check(matches(isDisplayed())).check(matches(withText(containsString(recipients[i]))))
onView(withId(R.id.recyclerViewChipsTo))
.perform(scrollTo<RecyclerView.ViewHolder>(withText(recipients[i])))
}
} else {
onView(withId(R.id.editTextRecipientTo))
.check(matches(isDisplayed())).check(matches(withText(isEmptyString())))
onView(withId(R.id.recyclerViewChipsTo))
.check(matches(isDisplayed()))
.check(matches(withRecyclerViewItemCount(1)))
}
}

Expand Down
Loading