Skip to content

Commit 421187a

Browse files
Bump com.android.application from 8.13.2 to 9.0.0 (#3179)
* Bump com.android.application from 8.13.2 to 9.0.0 Bumps com.android.application from 8.13.2 to 9.0.0. --- updated-dependencies: - dependency-name: com.android.application dependency-version: 9.0.0 dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> * Fixed compilation issues * Fixed compilation issues * Fixed compilation issues * wip * wip * wip * wip --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Denys Bondarenko <denbond7@gmail.com>
1 parent 91aa90f commit 421187a

34 files changed

Lines changed: 190 additions & 168 deletions

File tree

.idea/codeStyles/Project.xml

Lines changed: 34 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

FlowCrypt/build.gradle.kts

Lines changed: 80 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
*/
55

66

7+
import com.android.build.api.artifact.SingleArtifact
8+
import com.android.build.api.variant.ResValue
9+
import org.gradle.api.GradleException
10+
import java.io.File
711
import com.android.ddmlib.DdmPreferences
812
import java.io.FileInputStream
913
import java.text.SimpleDateFormat
@@ -15,7 +19,6 @@ DdmPreferences.setTimeOut(10 * 60 * 1000)
1519

1620
plugins {
1721
id("com.android.application")
18-
id("kotlin-android")
1922
id("androidx.navigation.safeargs.kotlin")
2023
id("com.starter.easylauncher")
2124
id("kotlin-parcelize")
@@ -30,7 +33,7 @@ if (propertiesFile.exists()) {
3033
}
3134

3235
android {
33-
compileSdk = extra["compileSdkVersion"] as Int
36+
compileSdk = rootProject.extra["compileSdkVersion"] as Int
3437
namespace = "com.flowcrypt.email"
3538

3639
defaultConfig {
@@ -42,10 +45,10 @@ android {
4245
testInstrumentationRunnerArguments += mapOf("clearPackageData" to "true")
4346

4447
applicationId = "com.flowcrypt.email"
45-
minSdk = extra["minSdkVersion"] as Int
46-
targetSdk = extra["targetSdkVersion"] as Int
47-
versionCode = extra["appVersionCode"] as Int
48-
versionName = extra["appVersionName"] as String
48+
minSdk = rootProject.extra["minSdkVersion"] as Int
49+
targetSdk = rootProject.extra["targetSdkVersion"] as Int
50+
versionCode = rootProject.extra["appVersionCode"] as Int
51+
versionName = rootProject.extra["appVersionName"] as String
4952
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
5053
buildConfigField("int", "MIN_SDK_VERSION", "$minSdk")
5154
multiDexEnabled = true
@@ -191,6 +194,7 @@ android {
191194
buildFeatures {
192195
buildConfig = true
193196
viewBinding = true
197+
resValues = true
194198
}
195199

196200
packaging {
@@ -264,23 +268,89 @@ ksp {
264268
}
265269

266270
androidComponents {
271+
267272
beforeVariants { variantBuilder ->
268-
if (variantBuilder.name in listOf("devRelease", "devUiTests")) {
269-
// Gradle ignores any variants that satisfy the conditions above.
273+
if (variantBuilder.name in setOf("devRelease", "devUiTests")) {
270274
println("INFO: Excluded \"${variantBuilder.name}\" from build variant list as unused")
271275
variantBuilder.enable = false
272276
}
273277
}
274278

279+
// --- Applies to ALL variants ---
275280
onVariants { variant ->
276-
//we share applicationId as a res value
281+
// Share applicationId as a res value
277282
variant.resValues.put(
278283
variant.makeResValueKey("string", "application_id"),
279-
com.android.build.api.variant.ResValue(variant.applicationId.get())
284+
ResValue(variant.applicationId.get())
280285
)
281286
}
287+
288+
val releaseSelector = selector().withBuildType("release")
289+
290+
// --- Release-only tasks ---
291+
onVariants(releaseSelector) { variant ->
292+
val cap = variant.name.replaceFirstChar { it.uppercase() }
293+
294+
// APK output directory provider
295+
val apkDirProvider = variant.artifacts.get(SingleArtifact.APK)
296+
297+
fun listApks(): List<java.io.File> {
298+
val dir = apkDirProvider.get().asFile
299+
return dir.walkTopDown().filter { it.isFile && it.extension == "apk" }.toList()
300+
}
301+
302+
val checkTask = tasks.register("check${cap}ApkSize") {
303+
doLast {
304+
val apks = listApks()
305+
if (apks.isEmpty()) {
306+
throw GradleException("No APK files found in: ${apkDirProvider.get().asFile.absolutePath}")
307+
}
308+
309+
val maxExpected = 50L * 1024L * 1024L
310+
apks.forEach { apk ->
311+
val size = apk.length()
312+
if (size > maxExpected) {
313+
throw GradleException(
314+
"Release APK is bigger than expected. max=$maxExpected, actual=$size, file=${apk.name}"
315+
)
316+
}
317+
}
318+
}
319+
}
320+
321+
val renameTask = tasks.register("rename${cap}Builds") {
322+
doLast {
323+
val apks = listApks()
324+
if (apks.isEmpty()) {
325+
logger.lifecycle("No APK files found to rename in: ${apkDirProvider.get().asFile.absolutePath}")
326+
return@doLast
327+
}
328+
329+
val ts = SimpleDateFormat("yyyy_MM_dd_HH_mm").format(Date())
330+
331+
// If multiple outputs exist (splits), versionCode/versionName can differ;
332+
// fallback to defaultConfig if not available.
333+
val vCode =
334+
variant.outputs.singleOrNull()?.versionCode?.orNull ?: android.defaultConfig.versionCode
335+
val vName =
336+
variant.outputs.singleOrNull()?.versionName?.orNull ?: android.defaultConfig.versionName
337+
338+
apks.forEach { apk ->
339+
val newName = apk.name.removeSuffix(".apk") + "_${vCode}_${vName}_${ts}.apk"
340+
val target = apk.parentFile.resolve(newName)
341+
342+
if (!apk.renameTo(target)) {
343+
throw GradleException("Failed to rename ${apk.absolutePath} -> ${target.absolutePath}")
344+
} else {
345+
logger.lifecycle("Renamed: ${apk.name} -> ${target.name}")
346+
}
347+
}
348+
}
349+
}
350+
}
282351
}
283352

353+
284354
easylauncher {
285355
buildTypes {
286356
register("debug") {
@@ -345,44 +415,6 @@ tasks.register("checkCorrectBranch") {
345415
}
346416
}
347417

348-
tasks.register("checkReleaseBuildsSize") {
349-
doLast {
350-
android.applicationVariants.forEach { applicationVariant ->
351-
if (applicationVariant.buildType.name == "release") {
352-
applicationVariant.outputs.forEach { variantOutput ->
353-
val apkFile = variantOutput.outputFile
354-
//for now apk up to 50Mb is normal
355-
val maxExpectedSizeInBytes = 50 * 1024 * 1024
356-
if (apkFile.length() > maxExpectedSizeInBytes) {
357-
throw GradleException(
358-
"The generated release build is bigger then expected: " +
359-
"expected = not big then $maxExpectedSizeInBytes, actual = ${apkFile.length()}"
360-
)
361-
}
362-
}
363-
}
364-
}
365-
}
366-
}
367-
368-
tasks.register("renameReleaseBuilds") {
369-
doLast {
370-
android.applicationVariants.forEach { applicationVariant ->
371-
if (applicationVariant.buildType.name == "release") {
372-
applicationVariant.outputs.forEach { variantOutput ->
373-
val file = variantOutput.outputFile
374-
val newName = file.name.replace(
375-
".apk", "_" + android.defaultConfig.versionCode +
376-
"_" + android.defaultConfig.versionName + "_"
377-
+ SimpleDateFormat("yyyy_MM_dd_HH_mm").format(Date()) + ".apk"
378-
)
379-
variantOutput.outputFile.renameTo(File(file.parent, newName))
380-
}
381-
}
382-
}
383-
}
384-
}
385-
386418
tasks.register<Copy>("copyReleaseApks") {
387419
includeEmptyDirs = false
388420

FlowCrypt/src/androidTest/java/com/flowcrypt/email/SendMsgTest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ import com.flowcrypt.email.security.pgp.PgpDecryptAndOrVerify
3535
import com.flowcrypt.email.security.pgp.PgpKey
3636
import com.flowcrypt.email.util.AccountDaoManager
3737
import com.flowcrypt.email.util.PrivateKeysManager
38-
import org.eclipse.angus.mail.imap.IMAPFolder
3938
import jakarta.mail.Flags
4039
import jakarta.mail.Folder
4140
import jakarta.mail.Message
@@ -52,8 +51,9 @@ import kotlinx.coroutines.runBlocking
5251
import kotlinx.coroutines.withContext
5352
import org.bouncycastle.openpgp.PGPSecretKeyRing
5453
import org.bouncycastle.openpgp.PGPSecretKeyRingCollection
55-
import org.hamcrest.CoreMatchers.`is`
54+
import org.eclipse.angus.mail.imap.IMAPFolder
5655
import org.hamcrest.MatcherAssert.assertThat
56+
import org.hamcrest.Matchers.`is`
5757
import org.junit.Assert.assertArrayEquals
5858
import org.junit.Assert.assertEquals
5959
import org.junit.Assert.assertFalse

FlowCrypt/src/androidTest/java/com/flowcrypt/email/matchers/ToolBarTitleMatcher.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* © 2016-present FlowCrypt a.s. Limitations apply. Contact human@flowcrypt.com
3-
* Contributors: DenBond7
3+
* Contributors: denbond7
44
*/
55

66
package com.flowcrypt.email.matchers
@@ -9,9 +9,9 @@ import android.view.View
99
import androidx.appcompat.widget.Toolbar
1010
import androidx.test.espresso.matcher.BoundedMatcher
1111
import com.google.android.gms.common.internal.Preconditions.checkNotNull
12-
import org.hamcrest.CoreMatchers.`is`
1312
import org.hamcrest.Description
1413
import org.hamcrest.Matcher
14+
import org.hamcrest.Matchers.`is`
1515

1616
/**
1717
* @author Denys Bondarenko

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ import com.flowcrypt.email.ui.activity.MainActivity
2929
import com.flowcrypt.email.ui.base.AddOtherAccountBaseTest
3030
import com.flowcrypt.email.util.AuthCredentialsManager
3131
import com.flowcrypt.email.util.TestGeneralUtil
32-
import org.hamcrest.CoreMatchers.anyOf
33-
import org.hamcrest.CoreMatchers.startsWith
32+
import org.hamcrest.Matchers.anyOf
33+
import org.hamcrest.Matchers.startsWith
3434
import org.junit.Rule
3535
import org.junit.Test
3636
import org.junit.rules.RuleChain

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

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* © 2016-present FlowCrypt a.s. Limitations apply. Contact human@flowcrypt.com
3-
* Contributors: DenBond7
3+
* Contributors: denbond7
44
*/
55

66
package com.flowcrypt.email.ui
@@ -42,9 +42,6 @@ import okhttp3.mockwebserver.Dispatcher
4242
import okhttp3.mockwebserver.MockResponse
4343
import okhttp3.mockwebserver.RecordedRequest
4444
import org.hamcrest.Matchers.allOf
45-
import org.hamcrest.Matchers.emptyString
46-
import org.hamcrest.Matchers.`is`
47-
import org.hamcrest.Matchers.not
4845
import org.junit.After
4946
import org.junit.Before
5047
import org.junit.Rule
@@ -463,7 +460,8 @@ class ComposeScreenExternalIntentsFlowTest : BaseTest() {
463460
.check(matches(withText(getRidOfCharacterSubstitutes(body.toString()))))
464461
} else {
465462
onView(withId(R.id.editTextEmailMessage))
466-
.check(matches(isDisplayed())).check(matches(withText(`is`(emptyString()))))
463+
.check(matches(isDisplayed()))
464+
.check(matches(withText("")))
467465
}
468466
}
469467

@@ -474,7 +472,8 @@ class ComposeScreenExternalIntentsFlowTest : BaseTest() {
474472
.check(matches(withText(getRidOfCharacterSubstitutes(subject))))
475473
} else {
476474
onView(withId(R.id.editTextEmailSubject))
477-
.check(matches(isDisplayed())).check(matches(withText(`is`(emptyString()))))
475+
.check(matches(isDisplayed()))
476+
.check(matches(withText("")))
478477
}
479478
}
480479

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ import org.apache.commons.io.FileUtils
7272
import org.hamcrest.Description
7373
import org.hamcrest.Matcher
7474
import org.hamcrest.Matchers.allOf
75-
import org.hamcrest.Matchers.emptyString
7675
import org.hamcrest.Matchers.`is`
7776
import org.hamcrest.Matchers.not
7877
import org.junit.Assert.assertEquals
@@ -152,7 +151,7 @@ class ComposeScreenFlowTest : BaseComposeScreenTest() {
152151
)
153152
onView(withId(R.id.editTextEmailSubject))
154153
.perform(scrollTo(), click(), typeText("subject"), clearText())
155-
.check(matches(withText(`is`(emptyString()))))
154+
.check(matches(withText("")))
156155
onView(withId(R.id.menuActionSend))
157156
.check(matches(isDisplayed()))
158157
.perform(click())
@@ -177,7 +176,7 @@ class ComposeScreenFlowTest : BaseComposeScreenTest() {
177176
.perform(scrollTo(), click(), replaceText(EMAIL_SUBJECT))
178177
onView(withId(R.id.editTextEmailMessage))
179178
.perform(scrollTo(), click(), replaceText(""))
180-
.check(matches(withText(`is`(emptyString()))))
179+
.check(matches(withText("")))
181180
Espresso.closeSoftKeyboard()
182181
onView(withId(R.id.menuActionSend))
183182
.check(matches(isDisplayed()))
@@ -259,13 +258,13 @@ class ComposeScreenFlowTest : BaseComposeScreenTest() {
259258
.check(matches(isDisplayed()))
260259
onView(withId(R.id.editTextFrom))
261260
.perform(scrollTo())
262-
.check(matches(withText(not(`is`(emptyString())))))
261+
.check(matches(withText(not(""))))
263262
onView(withId(R.id.recyclerViewChipsTo))
264263
.check(matches(isDisplayed()))
265264
.check(matches(withRecyclerViewItemCount(1)))
266265
onView(withId(R.id.editTextEmailSubject))
267266
.perform(scrollTo())
268-
.check(matches(withText(`is`(emptyString()))))
267+
.check(matches(withText("")))
269268
}
270269

271270
@Test
@@ -921,7 +920,8 @@ class ComposeScreenFlowTest : BaseComposeScreenTest() {
921920

922921
@get:ClassRule
923922
@JvmStatic
924-
val mockWebServerRule = FlowCryptMockWebServerRule(TestConstants.MOCK_WEB_SERVER_PORT,
923+
val mockWebServerRule = FlowCryptMockWebServerRule(
924+
TestConstants.MOCK_WEB_SERVER_PORT,
925925
object : Dispatcher() {
926926
override fun dispatch(request: RecordedRequest): MockResponse {
927927
if (request.path?.startsWith("/attester/pub", ignoreCase = true) == true) {

0 commit comments

Comments
 (0)