Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
51 changes: 34 additions & 17 deletions FlowCrypt/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@


import com.android.build.api.artifact.SingleArtifact
import com.android.build.api.dsl.ApplicationBuildType
import com.android.build.api.variant.ResValue
import com.android.ddmlib.DdmPreferences
import java.io.FileInputStream
Expand All @@ -21,9 +22,18 @@ plugins {
id("com.starter.easylauncher")
id("kotlin-parcelize")
id("com.google.devtools.ksp")
id("org.ajoberstar.grgit")
}

val gitCommitId = providers.exec {
workingDir(rootProject.rootDir)
commandLine("git", "rev-parse", "HEAD")
}.standardOutput.asText.map { it.trim().take(7) }

val gitBranchName = providers.exec {
workingDir(rootProject.rootDir)
commandLine("git", "rev-parse", "--abbrev-ref", "HEAD")
}.standardOutput.asText.map { it.trim() }

val keystoreProperties = Properties()
val propertiesFile = project.file("keystore.properties")
if (propertiesFile.exists()) {
Expand Down Expand Up @@ -105,25 +115,33 @@ android {
signingConfig = signingConfigs.getByName("release")
}

getByName("debug") {
// Shared by debug and uiTests. uiTests doesn't use initWith(debug) because overriding
// inherited resValues triggers the AGP RES_VALUE_REPLACED warning.
fun ApplicationBuildType.configureDebuggable(isHttpLogEnabled: Boolean) {
isDebuggable = true
versionNameSuffix = "_" +
defaultConfig.versionCode +
"__" + SimpleDateFormat("yyyy_MM_dd").format(Date()) +
"__" + grgit.head().id.substring(0, 7)
isCrunchPngs = false
applicationIdSuffix = ".debug"
signingConfig = signingConfigs.getByName("debug")

val httpLogLevel = if (isHttpLogEnabled) "BODY" else "NONE"
buildConfigField("boolean", "IS_ACRA_ENABLED", "false")
buildConfigField("boolean", "IS_HTTP_LOG_ENABLED", "true")
buildConfigField("String", "HTTP_LOG_LEVEL", "\"BODY\"")
buildConfigField("boolean", "IS_HTTP_LOG_ENABLED", isHttpLogEnabled.toString())
buildConfigField("String", "HTTP_LOG_LEVEL", "\"$httpLogLevel\"")
resValue("string", "gradle_is_acra_enabled", "false")
resValue("string", "gradle_is_http_log_enabled", "true")
resValue("string", "gradle_http_log_level", "BODY")
resValue("string", "gradle_is_http_log_enabled", isHttpLogEnabled.toString())
resValue("string", "gradle_http_log_level", httpLogLevel)
}

getByName("debug") {
configureDebuggable(isHttpLogEnabled = true)
versionNameSuffix = "_" +
defaultConfig.versionCode +
"__" + SimpleDateFormat("yyyy_MM_dd").format(Date()) +
"__" + gitCommitId.get()
}

create("uiTests") {
initWith(getByName("debug"))
configureDebuggable(isHttpLogEnabled = false)
versionNameSuffix =
"_test_" + defaultConfig.versionCode + "__" + SimpleDateFormat("yyyy_MM_dd").format(Date())
buildConfigField("String", "ATTESTER_URL", "\"https://flowcrypt.test/attester/\"")
Expand All @@ -132,10 +150,6 @@ android {
"SHARED_TENANT_FES_URL",
"\"https://flowcrypt.test/shared-tenant-fes/\""
)
buildConfigField("boolean", "IS_HTTP_LOG_ENABLED", "false")
buildConfigField("String", "HTTP_LOG_LEVEL", "\"NONE\"")
resValue("string", "gradle_is_http_log_enabled", "false")
resValue("string", "gradle_http_log_level", "NONE")
}
}

Expand Down Expand Up @@ -419,8 +433,11 @@ easylauncher {
}

tasks.register("checkCorrectBranch") {
if (!grgit.branch.current().name.equals("master")) {
throw GradleException("Please use 'master' branch to generate a release build")
val branchName = gitBranchName
doLast {
if (branchName.get() != "master") {
throw GradleException("Please use 'master' branch to generate a release build")
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ class ComposeScreenDisallowUpdateRevokedKeyFlowTest : BaseComposeScreenTest() {
val existingRecipientAfter = roomDatabase.recipientDao()
.getRecipientWithPubKeysByEmail(userWithRevokedKey)
assertNotNull(existingRecipientAfter)
val pubKeyAfter = requireNotNull(existingRecipientBefore?.publicKeys?.first()?.publicKey)
val pubKeyAfter = requireNotNull(existingRecipientAfter).publicKeys.first().publicKey
val pgpKeyDetailsAfter = PgpKey.parseKeys(pubKeyAfter)
.pgpKeyRingCollection.pgpPublicKeyRingCollection.first().toPgpKeyRingDetails()
assertTrue(pgpKeyDetailsAfter.isRevoked)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class ComposeScreenReplyAllFlowTest : BaseTest() {
private val account = AccountDaoManager.getDefaultAccountDao()
private val accountAliasesEntity = AccountAliasesEntity(
email = account.email,
accountType = account.accountType ?: "",
accountType = account.accountType,
sendAsEmail = "alias@flowcrypt.test",
displayName = "Alias",
isDefault = true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ abstract class BaseGmailApiTest(val accountEntity: AccountEntity = BASE_ACCOUNT_
append(it.first + ": " + it.second + "\n")
}
append("\n")
append(response.body?.string())
append(response.body.string())
}

responseMimeMultipart.addBodyPart(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class LoggingInFileInterceptor constructor(context: Context, fileName: String) :
var requestStartMsg =
"--> " + request.method + ' '.toString() + request.url + ' '.toString() + protocol
if (!logHeaders && hasRequestBody) {
requestStartMsg += " (" + requestBody!!.contentLength() + "-byte body)"
requestStartMsg += " (" + requestBody.contentLength() + "-byte body)"
}
logger.log(requestStartMsg)

Expand All @@ -82,7 +82,7 @@ class LoggingInFileInterceptor constructor(context: Context, fileName: String) :
// Request body headers are only present when installed as a network interceptor.
// Force
// them to be included (when available) so there values are known.
if (requestBody!!.contentType() != null) {
if (requestBody.contentType() != null) {
logger.log("Content-Type: " + requestBody.contentType()!!)
}
if (requestBody.contentLength() != (-1).toLong()) {
Expand Down Expand Up @@ -110,7 +110,7 @@ class LoggingInFileInterceptor constructor(context: Context, fileName: String) :
logger.log("--> END " + request.method + " (encoded body omitted)")
} else {
val buffer = Buffer()
requestBody!!.writeTo(buffer)
requestBody.writeTo(buffer)

var charset: Charset? = UTF8
val contentType = requestBody.contentType()
Expand Down Expand Up @@ -146,7 +146,7 @@ class LoggingInFileInterceptor constructor(context: Context, fileName: String) :
val tookMs = TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - startNs)

val responseBody = response.body
val contentLength = responseBody?.contentLength() ?: 0
val contentLength = responseBody.contentLength()
val bodySize = if (contentLength != (-1).toLong()) "$contentLength-byte" else "unknown-length"
logger.log(
"<-- " + response.code + ' '.toString() + response.message
Expand All @@ -168,7 +168,7 @@ class LoggingInFileInterceptor constructor(context: Context, fileName: String) :
} else if (isBodyEncoded(response.headers)) {
logger.log("<-- END HTTP (encoded body omitted)")
} else {
val source = responseBody!!.source()
val source = responseBody.source()
source.request(java.lang.Long.MAX_VALUE) // Buffer the entire body.
val buffer = source.buffer

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ interface AccountAliasesDao : BaseDao<AccountAliasesEntity> {
}.toSet()
val existingAliases = getAliases(
account = accountEntity.email,
accountType = accountEntity.accountType ?: ""
accountType = accountEntity.accountType
)
val existingUniqueSendAsSet = existingAliases.map { entity ->
entity.sendAsEmail?.lowercase()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ package com.flowcrypt.email.extensions.com.google.api.services.gmail.model

import android.accounts.Account
import com.flowcrypt.email.database.entity.AccountAliasesEntity
import com.flowcrypt.email.database.entity.AccountEntity
import com.google.api.services.gmail.model.SendAs

/**
Expand All @@ -16,7 +15,7 @@ import com.google.api.services.gmail.model.SendAs
fun SendAs.toAccountAliasesEntity(account: Account): AccountAliasesEntity {
return AccountAliasesEntity(
email = account.name.lowercase(),
accountType = account.type ?: AccountEntity.ACCOUNT_TYPE_GOOGLE,
accountType = account.type,
sendAsEmail = sendAsEmail?.lowercase(),
displayName = displayName,
replyToAddress = replyToAddress,
Expand All @@ -26,4 +25,4 @@ fun SendAs.toAccountAliasesEntity(account: Account): AccountAliasesEntity {
treatAsAlias = treatAsAlias,
verificationStatus = verificationStatus
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class AccountAliasesViewModel(application: Application) : AccountViewModel(appli

val hasAliasesSignature = roomDatabase.accountAliasesDao().getAliases(
account = accountEntity.email,
accountType = accountEntity.accountType ?: ""
accountType = accountEntity.accountType
).any { it.signature?.isNotEmpty() == true }

if (!hasAliasesSignature) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -398,9 +398,7 @@ class MessagesViewModel(application: Application) : AccountViewModel(application

if (isOnlyPgpModeEnabled == true) {
foundMsgs = imapFolder.search(EmailUtil.genPgpThingsSearchTerm(accountEntity))
foundMsgs?.let {
msgsCount = foundMsgs.size
}
msgsCount = foundMsgs.size
} else {
msgsCount = imapFolder.messageCount
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,10 @@ class RefreshPrivateKeysFromEkmViewModel(application: Application) : AccountView
}
}

requireNotNull(ekmPrivateResult.data?.privateKeys)
val privateKeys = requireNotNull(ekmPrivateResult.data?.privateKeys)

val pgpKeyRingDetailsList = mutableListOf<PgpKeyRingDetails>()
ekmPrivateResult.data?.privateKeys?.forEach { key ->
privateKeys.forEach { key ->
val parsedList = PgpKey.parsePrivateKeys(requireNotNull(key.decryptedPrivateKey))
.map {
it.copy(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,7 @@ class ThreadDetailsViewModel(
return@collectLatest
} else {
loadMessagesManuallyMutableStateFlow.update {
val existingValue = existingResult.data ?: Data(false, emptyList())
val existingValue = existingResult.data
val updatedList = existingValue.list.toMutableList().apply {
replaceAll { item ->
if (item.type == MessagesInThreadListAdapter.Type.HEADER) {
Expand Down Expand Up @@ -732,4 +732,4 @@ class ThreadDetailsViewModel(
companion object {
val FROM = FROM()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ class EmbeddedAttachmentsProvider : DocumentsProvider() {
val maxMemory = Runtime.getRuntime().maxMemory()
val cacheSize = max(maxMemory / 4, FileUtils.ONE_MB * 25).toInt()
lruCache = object : LruCache<String, AttachmentInfo>(cacheSize) {
override fun sizeOf(key: String, attachmentInfo: AttachmentInfo): Int {
return attachmentInfo.rawData?.size ?: attachmentInfo.encodedSize.toInt()
override fun sizeOf(key: String, value: AttachmentInfo): Int {
return value.rawData?.size ?: value.encodedSize.toInt()
}
}
}
Expand Down Expand Up @@ -177,4 +177,4 @@ class EmbeddedAttachmentsProvider : DocumentsProvider() {
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1984,7 +1984,7 @@ class CreateMessageFragment : BaseFragment<FragmentCreateMessageBinding>(),
"unknown RecipientType: ${autoCompleteResults?.recipientType}"
)
}
val pattern = it.data?.pattern?.lowercase() ?: ""
val pattern = autoCompleteResults.pattern.lowercase()

val autoCompleteList = results.map { recipientWithPubKeys ->
AutoCompleteResultRecyclerViewAdapter.AutoCompleteItem(
Expand Down Expand Up @@ -2017,12 +2017,12 @@ class CreateMessageFragment : BaseFragment<FragmentCreateMessageBinding>(),
}
}

val adapter = when (autoCompleteResults?.recipientType) {
val adapter = when (autoCompleteResults.recipientType) {
Message.RecipientType.TO -> toAutoCompleteResultRecyclerViewAdapter
Message.RecipientType.CC -> ccAutoCompleteResultRecyclerViewAdapter
Message.RecipientType.BCC -> bccAutoCompleteResultRecyclerViewAdapter
else -> throw InvalidObjectException(
"unknown RecipientType: ${autoCompleteResults?.recipientType}"
"unknown RecipientType: ${autoCompleteResults.recipientType}"
)
}
adapter.submitList(finalList)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -638,9 +638,9 @@ class ThreadDetailsFragment : BaseFragment<FragmentThreadDetailsBinding>(), Prog
val hasUnverifiedSignatures =
message.incomingMessageInfo?.verificationResult?.hasUnverifiedSignatures == true
val hasActiveSignatureVerification = if (hasUnverifiedSignatures) {
val messageFromAddresses = message.incomingMessageInfo?.getFrom()?.map {
val messageFromAddresses = message.incomingMessageInfo.getFrom().map {
it.address.lowercase()
} ?: emptyList()
}

val alreadyCheckedFromAddresses =
threadDetailsViewModel.sessionFromRecipientsStateFlow.value.filter {
Expand Down Expand Up @@ -1592,4 +1592,4 @@ class ThreadDetailsFragment : BaseFragment<FragmentThreadDetailsBinding>(), Prog

private const val CONTENT_MAX_ALLOWED_LENGTH = 50000
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class InfoDialogFragment : BaseDialogFragment() {
override fun onResume() {
super.onResume()
if (!args.useWebViewToRender) {
val textView = dialog?.window?.decorView?.findViewById(android.R.id.message) as? TextView
val textView = dialog?.window?.decorView?.findViewById<TextView>(android.R.id.message)
textView?.setTextIsSelectable(true)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -443,9 +443,6 @@ class MsgsPagedListAdapter(private val onMessageClickListener: OnMessageClickLis

MessageState.ERROR_PASSWORD_PROTECTED ->
state = context.getString(R.string.can_not_send_password_protected)

else -> {
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import java.io.OutputStream
*
* @author Denys Bondarenko
*/
class ProgressOutputStream(val out: OutputStream) : BufferedOutputStream(out) {
class ProgressOutputStream(out: OutputStream) : BufferedOutputStream(out) {
override fun write(b: ByteArray) {
if (Thread.interrupted()) {
throw SyncTaskTerminatedException()
Expand Down
5 changes: 3 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ apply(from = "$rootDir/ext.gradle.kts")

plugins {
id("com.android.application") version "9.5.1" apply false
// Safe Args still emits casts suppressed as CAST_NEVER_SUCCEEDS; Kotlin reports them as
// UNSAFE_CAST_RELYING_ON_NULL. Keep these warnings visible until the generator is fixed.
id("androidx.navigation.safeargs.kotlin") version "2.10.2" apply false
id("com.starter.easylauncher") version "6.4.1" apply false
id("org.jetbrains.kotlin.plugin.parcelize") version "2.4.21" apply false
id("com.google.devtools.ksp") version "2.3.13" apply false
id("org.ajoberstar.grgit") version "5.3.3" apply false
id("com.google.devtools.ksp") version "2.3.14" apply false
}
Loading