Skip to content

Commit e336f06

Browse files
authored
Refactored code.| #1264 (#1265)
* Refactored code.| #1264 * Fixed missed import.| #1264 * Fixed EOL at EOF.| #1264 * Fixed some formatting issues.| #1264 * Fixed EOL at EOF in resources.| #1264 * Fixed compilation bug.| #1264
1 parent 620b213 commit e336f06

File tree

592 files changed

+13949
-8908
lines changed

Some content is hidden

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

592 files changed

+13949
-8908
lines changed

Diff for: .gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,3 @@ local.properties
3333
/compile.sh
3434
/ctest.sh
3535
/test.sh
36-

Diff for: .idea/codeStyles/Project.xml

+5-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: FlowCrypt/lint.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@
2020
<!-- This file is needed for debug purposes -->
2121
<ignore path="res/raw/debug_certificate.crt" />
2222
</issue>
23-
</lint>
23+
</lint>

Diff for: FlowCrypt/src/androidTest/assets/messages/mime/8bit-utf8.txt

-1
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,3 @@ Content-Transfer-Encoding: 8bit
1717
Text: Ваше оголошення
1818
</body>
1919
</html>
20-

Diff for: FlowCrypt/src/androidTest/assets/messages/mime/encrypted_msg_info_plain_text_error_badly_formatted.txt

-1
Original file line numberDiff line numberDiff line change
@@ -71,4 +71,3 @@ vT56K5RcJnyZkFMaxqqKa6qBJ7XXL3nn2ePquNwj3zO59yVoF2AeoipJCTLE
7171
C/jf1vpjTJlbneWAjUWjm8+SlfCY1V/oERo=
7272
=UCCQ
7373
-----END PGP MESSAGE-----
74-

Diff for: FlowCrypt/src/androidTest/assets/pgp/keys/10_prv_and_pub_keys_armored_own_header.asc

-1
Original file line numberDiff line numberDiff line change
@@ -161,4 +161,3 @@ YHAmeAIbDAUWAgMBAAQLCQgHBRUKCQgLAh4BAAoJEMyEq3t0m4PryFkA/jZ7HuJK
161161
qH98S9dQSRizw3hxAg==
162162
=g+Is
163163
-----END PGP PRIVATE KEY BLOCK-----
164-

Diff for: FlowCrypt/src/androidTest/assets/pgp/keys/10_prv_and_pub_keys_armored_own_with_single_header.asc

-1
Original file line numberDiff line numberDiff line change
@@ -121,4 +121,3 @@ q00PAwEIB4h1BBgWCgAdBQJgcCU5AhsMBRYCAwEABAsJCAcFFQoJCAsCHgEACgkQ
121121
0oMmO25amIOvw4zoOJDypIQ+wNp+62iNde0pukwP
122122
=8kgY
123123
-----END PGP PUBLIC KEY BLOCK-----
124-

Diff for: FlowCrypt/src/androidTest/assets/pgp/keys/10_prv_keys_armored_own_header.asc

-1
Original file line numberDiff line numberDiff line change
@@ -177,4 +177,3 @@ oPnfUupWCMKXM3PN/Sw6Zn5Zja3DRuFxrSXIAQCOXPE4EOucuOmMCi2JcfkVmpfE
177177
ReZjtUMWEusItbv4Cg==
178178
=I9MB
179179
-----END PGP PRIVATE KEY BLOCK-----
180-

Diff for: FlowCrypt/src/androidTest/assets/pgp/keys/10_prv_keys_armored_own_with_single_header.asc

-1
Original file line numberDiff line numberDiff line change
@@ -142,4 +142,3 @@ z++0ULA1AQDAfGX9fWSFkFJeUEMf3wdtH4f7uBnpHFed9T7ccHh1hgD/YkNbtpMI
142142
EdJrIZnU/alchpAYC5JRJuaoyuaOgWxAgQI=
143143
=E5rK
144144
-----END PGP PRIVATE KEY BLOCK-----
145-

Diff for: FlowCrypt/src/androidTest/assets/pgp/keys/10_pub_keys_armored_own_header.asc

-1
Original file line numberDiff line numberDiff line change
@@ -137,4 +137,3 @@ CAsCHgEACgkQCW1r0sdsyuuVRQD/TsQc21Kg+d9S6lYIwpczc839LDpmflmNrcNG
137137
4XGtJcgBAI5c8TgQ65y46YwKLYlx+RWal8RF5mO1QxYS6wi1u/gK
138138
=tPlZ
139139
-----END PGP PUBLIC KEY BLOCK-----
140-

Diff for: FlowCrypt/src/androidTest/assets/pgp/keys/10_pub_keys_armored_own_with_single_header.asc

-1
Original file line numberDiff line numberDiff line change
@@ -107,4 +107,3 @@ YHADnhIKKwYBBAGXVQEFAQEHQCL+4AjWCMUzWCsMmSJGF3WcUNOLFNR4zWsLtJl2
107107
W7aTCBHSayGZ1P2pXIaQGAuSUSbmqMrmjoFsQIEC
108108
=wEh7
109109
-----END PGP PUBLIC KEY BLOCK-----
110-

Diff for: FlowCrypt/src/androidTest/java/com/flowcrypt/email/DebugTestingTest.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,4 @@ class DebugTestingTest {
2828
@Test
2929
fun alwaysSuccessTestSecond() {
3030
}
31-
}
31+
}

Diff for: FlowCrypt/src/androidTest/java/com/flowcrypt/email/base/BaseActivityTestImplementation.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,4 @@ interface BaseActivityTestImplementation {
2727

2828
val useIntents: Boolean
2929
get() = false
30-
}
30+
}

Diff for: FlowCrypt/src/androidTest/java/com/flowcrypt/email/base/BaseTest.kt

+27-19
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,8 @@ abstract class BaseTest : BaseActivityTestImplementation {
122122
*/
123123
protected fun isToastDisplayed(decorView: View?, message: String) {
124124
onView(withText(message))
125-
.inRoot(withDecorView(not(`is`(decorView))))
126-
.check(matches(isDisplayed()))
125+
.inRoot(withDecorView(not(`is`(decorView))))
126+
.check(matches(isDisplayed()))
127127
}
128128

129129
/**
@@ -133,8 +133,8 @@ abstract class BaseTest : BaseActivityTestImplementation {
133133
*/
134134
protected fun isDialogWithTextDisplayed(decorView: View?, message: String) {
135135
onView(withText(message))
136-
.inRoot(withDecorView(not(`is`(decorView))))
137-
.check(matches(isDisplayed()))
136+
.inRoot(withDecorView(not(`is`(decorView))))
137+
.check(matches(isDisplayed()))
138138
}
139139

140140
/**
@@ -143,15 +143,15 @@ abstract class BaseTest : BaseActivityTestImplementation {
143143
//todo-denbond7 - fix me
144144
protected fun testHelpScreen() {
145145
onView(withId(R.id.menuActionHelp))
146-
.check(matches(isDisplayed()))
147-
.perform(click())
146+
.check(matches(isDisplayed()))
147+
.perform(click())
148148

149149
onView(withId(R.id.textViewAuthorHint))
150-
.check(matches(isDisplayed()))
151-
.check(matches(withText(R.string.i_will_usually_reply_within_an_hour_except_when_i_sleep_tom)))
150+
.check(matches(isDisplayed()))
151+
.check(matches(withText(R.string.i_will_usually_reply_within_an_hour_except_when_i_sleep_tom)))
152152

153153
onView(withText(R.string.help_feedback_or_question))
154-
.check(matches(isDisplayed()))
154+
.check(matches(isDisplayed()))
155155
}
156156

157157
/**
@@ -163,8 +163,8 @@ abstract class BaseTest : BaseActivityTestImplementation {
163163
onView(withText(message)).check(matches(isDisplayed()))
164164

165165
onView(withId(com.google.android.material.R.id.snackbar_action))
166-
.check(matches(isDisplayed()))
167-
.perform(click())
166+
.check(matches(isDisplayed()))
167+
.perform(click())
168168
}
169169

170170
/**
@@ -173,11 +173,11 @@ abstract class BaseTest : BaseActivityTestImplementation {
173173
protected fun checkIsSnackBarDisplayed(text: String? = null) {
174174
if (text.isNullOrEmpty()) {
175175
onView(withId(com.google.android.material.R.id.snackbar_action))
176-
.check(matches(isDisplayed()))
176+
.check(matches(isDisplayed()))
177177
} else {
178178
onView(withId(com.google.android.material.R.id.snackbar_text))
179-
.check(matches(isDisplayed()))
180-
.check(matches(withText(text)))
179+
.check(matches(isDisplayed()))
180+
.check(matches(withText(text)))
181181
}
182182
}
183183

@@ -186,7 +186,7 @@ abstract class BaseTest : BaseActivityTestImplementation {
186186
*/
187187
protected fun checkIsSnackBarNotDisplayed() {
188188
onView(withId(com.google.android.material.R.id.snackbar_action))
189-
.check(doesNotExist())
189+
.check(doesNotExist())
190190
}
191191

192192
/**
@@ -198,14 +198,16 @@ abstract class BaseTest : BaseActivityTestImplementation {
198198
*/
199199
protected fun addTextToClipboard(label: String, text: String) {
200200
runOnUiThread {
201-
val clipboard = getTargetContext().getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
201+
val clipboard =
202+
getTargetContext().getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
202203
val clip = ClipData.newPlainText(label, text)
203204
clipboard.setPrimaryClip(clip)
204205
}
205206
}
206207

207208
protected fun checkClipboardText(text: CharSequence) {
208-
val clipboardManager = getTargetContext().getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
209+
val clipboardManager =
210+
getTargetContext().getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
209211
val primaryClip: ClipData? = clipboardManager.primaryClip
210212

211213
var clipboardText: CharSequence? = null
@@ -239,14 +241,20 @@ abstract class BaseTest : BaseActivityTestImplementation {
239241
return InstrumentationRegistry.getInstrumentation().context
240242
}
241243

242-
fun getMsgInfo(path: String, mimeMsgPath: String, vararg atts: AttachmentInfo?): IncomingMessageInfo? {
244+
fun getMsgInfo(
245+
path: String,
246+
mimeMsgPath: String,
247+
vararg atts: AttachmentInfo?
248+
): IncomingMessageInfo? {
243249
val incomingMsgInfo = TestGeneralUtil.getObjectFromJson(path, IncomingMessageInfo::class.java)
244250
incomingMsgInfo?.msgEntity?.let {
245251
val uri = roomDatabase.msgDao().insert(it)
246252
val attEntities = mutableListOf<AttachmentEntity>()
247253

248254
for (attInfo in atts) {
249-
attInfo?.let { info -> AttachmentEntity.fromAttInfo(info)?.let { candidate -> attEntities.add(candidate) } }
255+
attInfo?.let { info ->
256+
AttachmentEntity.fromAttInfo(info)?.let { candidate -> attEntities.add(candidate) }
257+
}
250258
}
251259

252260
roomDatabase.attachmentDao().insert(attEntities)

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

+6-6
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ class MigrationTest {
4040

4141
@get:Rule
4242
val migrationTestHelper: MigrationTestHelper = MigrationTestHelper(
43-
InstrumentationRegistry.getInstrumentation(),
44-
FlowCryptRoomDatabase::class.java.canonicalName,
45-
FrameworkSQLiteOpenHelperFactory()
43+
InstrumentationRegistry.getInstrumentation(),
44+
FlowCryptRoomDatabase::class.java.canonicalName,
45+
FrameworkSQLiteOpenHelperFactory()
4646
)
4747

4848
@Test
@@ -55,8 +55,8 @@ class MigrationTest {
5555

5656
// Open latest version of the DB. Room will validate the schema once all migrations execute.
5757
Room.databaseBuilder(
58-
InstrumentationRegistry.getInstrumentation().targetContext,
59-
FlowCryptRoomDatabase::class.java, FlowCryptRoomDatabase.DB_NAME
58+
InstrumentationRegistry.getInstrumentation().targetContext,
59+
FlowCryptRoomDatabase::class.java, FlowCryptRoomDatabase.DB_NAME
6060
).addMigrations(*arrayOfMigrations).build().apply {
6161
openHelper.writableDatabase
6262
close()
@@ -66,4 +66,4 @@ class MigrationTest {
6666
companion object {
6767
const val INIT_DATABASE_VERSION = 19
6868
}
69-
}
69+
}

Diff for: FlowCrypt/src/androidTest/java/com/flowcrypt/email/junit/annotations/DebugTest.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ package com.flowcrypt.email.junit.annotations
1414
1515
*/
1616
@Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION)
17-
annotation class DebugTest
17+
annotation class DebugTest

Diff for: FlowCrypt/src/androidTest/java/com/flowcrypt/email/junit/annotations/DependsOnMailServer.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ package com.flowcrypt.email.junit.annotations
1515
1616
*/
1717
@Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION)
18-
annotation class DependsOnMailServer
18+
annotation class DependsOnMailServer

Diff for: FlowCrypt/src/androidTest/java/com/flowcrypt/email/junit/annotations/NotReadyForCI.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ package com.flowcrypt.email.junit.annotations
1515
1616
*/
1717
@Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION)
18-
annotation class NotReadyForCI
18+
annotation class NotReadyForCI

Diff for: FlowCrypt/src/androidTest/java/com/flowcrypt/email/junit/filters/DependsOnMailServerFilter.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@ class DependsOnMailServerFilter : ReadyForCIFilter() {
2323
}
2424

2525
override fun describe() = "Filter tests that depend on an email server"
26-
}
26+
}

Diff for: FlowCrypt/src/androidTest/java/com/flowcrypt/email/junit/filters/DoesNotNeedMailServerFilter.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@ class DoesNotNeedMailServerFilter : ReadyForCIFilter() {
2323
}
2424

2525
override fun describe() = "Filter tests that don't need an email server"
26-
}
26+
}

Diff for: FlowCrypt/src/androidTest/java/com/flowcrypt/email/junit/filters/NotReadyForCIFilter.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@ open class NotReadyForCIFilter : ParentFilter() {
2323
}
2424

2525
override fun describe() = "Filter tests that can't be run on CI yet"
26-
}
26+
}

Diff for: FlowCrypt/src/androidTest/java/com/flowcrypt/email/junit/filters/OtherTestsFilter.kt

+4-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@ class OtherTestsFilter : ParentFilter() {
1919
private val doesNotNeedMailServerFilter = DoesNotNeedMailServerFilter()
2020

2121
override fun evaluateTest(description: Description?): Boolean {
22-
return (!dependsOnMailServerFilter.shouldRun(description) && !doesNotNeedMailServerFilter.shouldRun(description))
22+
return (!dependsOnMailServerFilter.shouldRun(description) && !doesNotNeedMailServerFilter.shouldRun(
23+
description
24+
))
2325
}
2426

2527
override fun describe() = "Filter tests that are not related to any conditions"
26-
}
28+
}

Diff for: FlowCrypt/src/androidTest/java/com/flowcrypt/email/junit/filters/ReadyForCIFilter.kt

+4-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@ import org.junit.runner.Description
1818
open class ReadyForCIFilter : ParentFilter() {
1919
override fun evaluateTest(description: Description?): Boolean {
2020
val annotationClass = NotReadyForCI::class.java
21-
return (description?.testClass?.isAnnotationPresent(annotationClass) == false && description.getAnnotation(annotationClass) == null)
21+
return (description?.testClass?.isAnnotationPresent(annotationClass) == false && description.getAnnotation(
22+
annotationClass
23+
) == null)
2224
}
2325

2426
override fun describe() = "Filter tests that are ready to be run on a CI server"
25-
}
27+
}

Diff for: FlowCrypt/src/androidTest/java/com/flowcrypt/email/matchers/AppBarLayoutBackgroundColorMatcher.kt

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ import org.hamcrest.Description
1717
* Time: 3:17 PM
1818
1919
*/
20-
class AppBarLayoutBackgroundColorMatcher(val color: Int)
21-
: BoundedMatcher<View, AppBarLayout>(AppBarLayout::class.java) {
20+
class AppBarLayoutBackgroundColorMatcher(val color: Int) :
21+
BoundedMatcher<View, AppBarLayout>(AppBarLayout::class.java) {
2222
public override fun matchesSafely(appBarLayout: AppBarLayout): Boolean {
2323
return if (appBarLayout.background is ColorDrawable) {
2424
color == (appBarLayout.background as ColorDrawable).color
@@ -28,4 +28,4 @@ class AppBarLayoutBackgroundColorMatcher(val color: Int)
2828
override fun describeTo(description: Description) {
2929
description.appendText("Background color AppBarLayout: $color")
3030
}
31-
}
31+
}

Diff for: FlowCrypt/src/androidTest/java/com/flowcrypt/email/matchers/DrawableMatcher.kt

+8-3
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ class DrawableMatcher(private val expectedId: Int) : TypeSafeMatcher<View>(View:
4545
ANY -> return target.drawable != null
4646
else -> {
4747
val resources = target.getContext().resources
48-
val expectedDrawable = resources.getDrawable(expectedId, target.getContext().theme) ?: return false
48+
val expectedDrawable =
49+
resources.getDrawable(expectedId, target.getContext().theme) ?: return false
4950
resourceName = resources.getResourceEntryName(expectedId)
5051

5152
val bitmap = getBitmap(target.drawable)
@@ -56,7 +57,11 @@ class DrawableMatcher(private val expectedId: Int) : TypeSafeMatcher<View>(View:
5657
}
5758

5859
private fun getBitmap(drawable: Drawable): Bitmap {
59-
val bitmap = Bitmap.createBitmap(drawable.intrinsicWidth, drawable.intrinsicHeight, Bitmap.Config.ARGB_8888)
60+
val bitmap = Bitmap.createBitmap(
61+
drawable.intrinsicWidth,
62+
drawable.intrinsicHeight,
63+
Bitmap.Config.ARGB_8888
64+
)
6065
val canvas = Canvas(bitmap)
6166
drawable.setBounds(0, 0, canvas.width, canvas.height)
6267
drawable.draw(canvas)
@@ -67,4 +72,4 @@ class DrawableMatcher(private val expectedId: Int) : TypeSafeMatcher<View>(View:
6772
const val EMPTY = -1
6873
const val ANY = -2
6974
}
70-
}
75+
}

Diff for: FlowCrypt/src/androidTest/java/com/flowcrypt/email/matchers/EmptyListViewMather.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,4 @@ class EmptyListViewMather<T : View> : BaseMatcher<T>() {
2828
override fun describeTo(description: Description) {
2929
description.appendText("List is not empty")
3030
}
31-
}
31+
}

Diff for: FlowCrypt/src/androidTest/java/com/flowcrypt/email/matchers/EmptyRecyclerViewMatcher.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,4 @@ class EmptyRecyclerViewMatcher<T : View> : BaseMatcher<T>() {
2828
override fun describeTo(description: Description) {
2929
description.appendText("RecyclerView is not empty")
3030
}
31-
}
31+
}

Diff for: FlowCrypt/src/androidTest/java/com/flowcrypt/email/matchers/ListViewItemCountMatcher.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,4 @@ class ListViewItemCountMatcher<T : View>(val itemCount: Int) : BaseMatcher<T>()
3535
override fun describeTo(description: Description) {
3636
description.appendText("The size of the list is not equal = $itemCount")
3737
}
38-
}
38+
}

Diff for: FlowCrypt/src/androidTest/java/com/flowcrypt/email/matchers/NachoTextViewChipBackgroundColorMatcher.kt

+5-4
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@ import org.hamcrest.Description
1717
* Time: 10:19 AM
1818
1919
*/
20-
class NachoTextViewChipBackgroundColorMatcher(private val chipText: String,
21-
private val backgroundColor: Int)
22-
: BoundedMatcher<View, NachoTextView>(NachoTextView::class.java) {
20+
class NachoTextViewChipBackgroundColorMatcher(
21+
private val chipText: String,
22+
private val backgroundColor: Int
23+
) : BoundedMatcher<View, NachoTextView>(NachoTextView::class.java) {
2324
public override fun matchesSafely(nachoTextView: NachoTextView): Boolean {
2425
val expectedChip = nachoTextView.allChips.firstOrNull { it.text == chipText } ?: return false
2526
val pgpContactChipSpan = expectedChip as? PGPContactChipSpan ?: return false
@@ -29,4 +30,4 @@ class NachoTextViewChipBackgroundColorMatcher(private val chipText: String,
2930
override fun describeTo(description: Description) {
3031
description.appendText("Chip details: text = $chipText, color = $backgroundColor")
3132
}
32-
}
33+
}

Diff for: FlowCrypt/src/androidTest/java/com/flowcrypt/email/matchers/RecyclerViewItemCountMatcher.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,4 @@ class RecyclerViewItemCountMatcher<T : View>(private val itemCount: Int) : BaseM
2828
override fun describeTo(description: Description) {
2929
description.appendText("The count of the RecyclerView is not equal = $itemCount")
3030
}
31-
}
31+
}

0 commit comments

Comments
 (0)