Cleanup remaining code style issues for Kotlin sources

This commit is contained in:
Wolf Montwé 2023-02-14 12:28:43 +01:00
parent eb510ff02a
commit cab1c71524
No known key found for this signature in database
GPG key ID: 6D45B21512ACBF72
48 changed files with 438 additions and 232 deletions

View file

@ -37,10 +37,17 @@ class AccountPreferenceSerializer(
storage.getString("$accountUuid.$OUTGOING_SERVER_SETTINGS_KEY", ""),
)
oAuthState = storage.getString("$accountUuid.oAuthState", null)
localStorageProviderId = storage.getString("$accountUuid.localStorageProvider", storageManager.defaultProviderId)
localStorageProviderId = storage.getString(
"$accountUuid.localStorageProvider",
storageManager.defaultProviderId,
)
name = storage.getString("$accountUuid.description", null)
alwaysBcc = storage.getString("$accountUuid.alwaysBcc", alwaysBcc)
automaticCheckIntervalMinutes = storage.getInt("$accountUuid.automaticCheckIntervalMinutes", DEFAULT_SYNC_INTERVAL)
automaticCheckIntervalMinutes = storage.getInt(
"" +
"$accountUuid.automaticCheckIntervalMinutes",
DEFAULT_SYNC_INTERVAL,
)
idleRefreshMinutes = storage.getInt("$accountUuid.idleRefreshMinutes", 24)
displayCount = storage.getInt("$accountUuid.displayCount", K9.DEFAULT_VISIBLE_LIMIT)
if (displayCount < 0) {
@ -48,7 +55,11 @@ class AccountPreferenceSerializer(
}
isNotifyNewMail = storage.getBoolean("$accountUuid.notifyNewMail", false)
folderNotifyNewMailMode = getEnumStringPref<FolderMode>(storage, "$accountUuid.folderNotifyNewMailMode", FolderMode.ALL)
folderNotifyNewMailMode = getEnumStringPref<FolderMode>(
storage,
"$accountUuid.folderNotifyNewMailMode",
FolderMode.ALL,
)
isNotifySelfNewMail = storage.getBoolean("$accountUuid.notifySelfNewMail", true)
isNotifyContactsMailOnly = storage.getBoolean("$accountUuid.notifyContactsMailOnly", false)
isIgnoreChatMessages = storage.getBoolean("$accountUuid.ignoreChatMessages", false)
@ -107,14 +118,14 @@ class AccountPreferenceSerializer(
autoExpandFolderId = storage.getString("$accountUuid.autoExpandFolderId", null)?.toLongOrNull()
expungePolicy = getEnumStringPref<Expunge>(storage, "$accountUuid.expungePolicy", Expunge.EXPUNGE_IMMEDIATELY)
expungePolicy = getEnumStringPref(storage, "$accountUuid.expungePolicy", Expunge.EXPUNGE_IMMEDIATELY)
isSyncRemoteDeletions = storage.getBoolean("$accountUuid.syncRemoteDeletions", true)
maxPushFolders = storage.getInt("$accountUuid.maxPushFolders", 10)
isSubscribedFoldersOnly = storage.getBoolean("$accountUuid.subscribedFoldersOnly", false)
maximumPolledMessageAge = storage.getInt("$accountUuid.maximumPolledMessageAge", -1)
maximumAutoDownloadMessageSize = storage.getInt("$accountUuid.maximumAutoDownloadMessageSize", 32768)
messageFormat = getEnumStringPref<MessageFormat>(storage, "$accountUuid.messageFormat", DEFAULT_MESSAGE_FORMAT)
messageFormat = getEnumStringPref(storage, "$accountUuid.messageFormat", DEFAULT_MESSAGE_FORMAT)
val messageFormatAuto = storage.getBoolean("$accountUuid.messageFormatAuto", DEFAULT_MESSAGE_FORMAT_AUTO)
if (messageFormatAuto && messageFormat == MessageFormat.TEXT) {
messageFormat = MessageFormat.AUTO
@ -122,7 +133,10 @@ class AccountPreferenceSerializer(
isMessageReadReceipt = storage.getBoolean("$accountUuid.messageReadReceipt", DEFAULT_MESSAGE_READ_RECEIPT)
quoteStyle = getEnumStringPref<QuoteStyle>(storage, "$accountUuid.quoteStyle", DEFAULT_QUOTE_STYLE)
quotePrefix = storage.getString("$accountUuid.quotePrefix", DEFAULT_QUOTE_PREFIX)
isDefaultQuotedTextShown = storage.getBoolean("$accountUuid.defaultQuotedTextShown", DEFAULT_QUOTED_TEXT_SHOWN)
isDefaultQuotedTextShown = storage.getBoolean(
"$accountUuid.defaultQuotedTextShown",
DEFAULT_QUOTED_TEXT_SHOWN,
)
isReplyAfterQuote = storage.getBoolean("$accountUuid.replyAfterQuote", DEFAULT_REPLY_AFTER_QUOTE)
isStripSignature = storage.getBoolean("$accountUuid.stripSignature", DEFAULT_STRIP_SIGNATURE)
useCompression = storage.getBoolean("$accountUuid.useCompression", true)
@ -152,13 +166,16 @@ class AccountPreferenceSerializer(
)
}
folderDisplayMode = getEnumStringPref<FolderMode>(storage, "$accountUuid.folderDisplayMode", FolderMode.NOT_SECOND_CLASS)
folderDisplayMode =
getEnumStringPref<FolderMode>(storage, "$accountUuid.folderDisplayMode", FolderMode.NOT_SECOND_CLASS)
folderSyncMode = getEnumStringPref<FolderMode>(storage, "$accountUuid.folderSyncMode", FolderMode.FIRST_CLASS)
folderSyncMode =
getEnumStringPref<FolderMode>(storage, "$accountUuid.folderSyncMode", FolderMode.FIRST_CLASS)
folderPushMode = getEnumStringPref<FolderMode>(storage, "$accountUuid.folderPushMode", FolderMode.NONE)
folderTargetMode = getEnumStringPref<FolderMode>(storage, "$accountUuid.folderTargetMode", FolderMode.NOT_SECOND_CLASS)
folderTargetMode =
getEnumStringPref<FolderMode>(storage, "$accountUuid.folderTargetMode", FolderMode.NOT_SECOND_CLASS)
searchableFolders = getEnumStringPref<Searchable>(storage, "$accountUuid.searchableFolders", Searchable.ALL)
@ -172,7 +189,8 @@ class AccountPreferenceSerializer(
isOpenPgpEncryptAllDrafts = storage.getBoolean("$accountUuid.openPgpEncryptAllDrafts", true)
autocryptPreferEncryptMutual = storage.getBoolean("$accountUuid.autocryptMutualMode", false)
isRemoteSearchFullText = storage.getBoolean("$accountUuid.remoteSearchFullText", false)
remoteSearchNumResults = storage.getInt("$accountUuid.remoteSearchNumResults", DEFAULT_REMOTE_SEARCH_NUM_RESULTS)
remoteSearchNumResults =
storage.getInt("$accountUuid.remoteSearchNumResults", DEFAULT_REMOTE_SEARCH_NUM_RESULTS)
isUploadSentMessages = storage.getBoolean("$accountUuid.uploadSentMessages", true)
isMarkMessageAsReadOnView = storage.getBoolean("$accountUuid.markMessageAsReadOnView", true)
@ -247,8 +265,14 @@ class AccountPreferenceSerializer(
}
with(account) {
editor.putString("$accountUuid.$INCOMING_SERVER_SETTINGS_KEY", serverSettingsSerializer.serialize(incomingServerSettings))
editor.putString("$accountUuid.$OUTGOING_SERVER_SETTINGS_KEY", serverSettingsSerializer.serialize(outgoingServerSettings))
editor.putString(
"$accountUuid.$INCOMING_SERVER_SETTINGS_KEY",
serverSettingsSerializer.serialize(incomingServerSettings),
)
editor.putString(
"$accountUuid.$OUTGOING_SERVER_SETTINGS_KEY",
serverSettingsSerializer.serialize(outgoingServerSettings),
)
editor.putString("$accountUuid.oAuthState", oAuthState)
editor.putString("$accountUuid.localStorageProvider", localStorageProviderId)
editor.putString("$accountUuid.description", name)
@ -351,7 +375,8 @@ class AccountPreferenceSerializer(
val accountUuid = account.uuid
// Get the list of account UUIDs
val uuids = storage.getString("accountUuids", "").split(",".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()
val uuids =
storage.getString("accountUuids", "").split(",".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()
// Create a list of all account UUIDs excluding this account
val newUuids = ArrayList<String>(uuids.size)

View file

@ -14,7 +14,8 @@ import org.koin.java.KoinJavaComponent.get as koinGet
object DI {
private const val DEBUG = false
@JvmStatic fun start(application: Application, modules: List<Module>) {
@JvmStatic
fun start(application: Application, modules: List<Module>) {
startKoin {
if (BuildConfig.DEBUG && DEBUG) {
androidLogger()

View file

@ -287,11 +287,13 @@ object K9 : EarlyInit {
}
fun init(context: Context) {
K9MailLib.setDebugStatus(object : K9MailLib.DebugStatus {
override fun enabled(): Boolean = isDebugLoggingEnabled
K9MailLib.setDebugStatus(
object : K9MailLib.DebugStatus {
override fun enabled(): Boolean = isDebugLoggingEnabled
override fun debugSensitive(): Boolean = isSensitiveDebugLoggingEnabled
})
override fun debugSensitive(): Boolean = isSensitiveDebugLoggingEnabled
},
)
com.fsck.k9.logging.Timber.logger = TimberLogger()
checkCachedDatabaseVersion(context)

View file

@ -8,7 +8,6 @@ import com.fsck.k9.preferences.AccountManager
import com.fsck.k9.preferences.Storage
import com.fsck.k9.preferences.StorageEditor
import com.fsck.k9.preferences.StoragePersister
import java.util.HashMap
import java.util.LinkedList
import java.util.UUID
import java.util.concurrent.CopyOnWriteArraySet

View file

@ -23,7 +23,10 @@ class AutocryptTransferMessageCreator(private val stringProvider: AutocryptStrin
val textBodyPart = MimeBodyPart.create(TextBody(messageText))
val dataBodyPart = MimeBodyPart.create(BinaryMemoryBody(data, "7bit"))
dataBodyPart.setHeader(MimeHeader.HEADER_CONTENT_TYPE, "application/autocrypt-setup")
dataBodyPart.setHeader(MimeHeader.HEADER_CONTENT_DISPOSITION, "attachment; filename=\"autocrypt-setup-message\"")
dataBodyPart.setHeader(
MimeHeader.HEADER_CONTENT_DISPOSITION,
"attachment; filename=\"autocrypt-setup-message\"",
)
val messageBody = MimeMultipart.newInstance()
messageBody.addBodyPart(textBodyPart)

View file

@ -12,7 +12,6 @@ import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.cancel
import kotlinx.coroutines.flow.collect
import kotlinx.coroutines.launch
import timber.log.Timber

View file

@ -7,7 +7,6 @@ import android.content.Intent
import android.content.pm.PackageManager.COMPONENT_ENABLED_STATE_DISABLED
import android.content.pm.PackageManager.COMPONENT_ENABLED_STATE_ENABLED
import android.content.pm.PackageManager.DONT_KILL_APP
import java.lang.Exception
import org.koin.core.component.KoinComponent
import org.koin.core.component.inject
import timber.log.Timber

View file

@ -214,6 +214,7 @@ class PushController internal constructor(
account.folderPushMode != FolderMode.NONE && backendManager.getBackend(account).isPushCapable
}
}
private fun setPushNotificationState(notificationState: PushNotificationState) {
pushNotificationManager.notificationState = notificationState
}

View file

@ -5,5 +5,5 @@ import java.util.concurrent.ThreadFactory
class NamedThreadFactory(private val threadNamePrefix: String) : ThreadFactory {
var counter: Int = 0
override fun newThread(runnable: Runnable) = Thread(runnable, "$threadNamePrefix-${ counter++ }")
override fun newThread(runnable: Runnable) = Thread(runnable, "$threadNamePrefix-${counter++}")
}

View file

@ -20,7 +20,11 @@ class K9BackendStorageFactory(
account,
)
val specialFolderListener = SpecialFolderBackendFoldersRefreshListener(specialFolderUpdater)
val autoExpandFolderListener = AutoExpandFolderBackendFoldersRefreshListener(preferences, account, folderRepository)
val autoExpandFolderListener = AutoExpandFolderBackendFoldersRefreshListener(
preferences,
account,
folderRepository,
)
val listeners = listOf(specialFolderListener, autoExpandFolderListener)
return K9BackendStorage(messageStore, folderSettingsProvider, saveMessageDataCreator, listeners)
}

View file

@ -4,7 +4,10 @@ import com.fsck.k9.Account
import com.fsck.k9.preferences.AccountManager
import java.util.concurrent.ConcurrentHashMap
class MessageStoreManager(private val accountManager: AccountManager, private val messageStoreFactory: MessageStoreFactory) {
class MessageStoreManager(
private val accountManager: AccountManager,
private val messageStoreFactory: MessageStoreFactory,
) {
private val messageStores = ConcurrentHashMap<String, ListenableMessageStore>()
init {

View file

@ -17,7 +17,7 @@ object UriMatcher {
private const val SCHEME_SEPARATORS = "\\s(\\n<"
private const val ALLOWED_SEPARATORS_PATTERN = "(?:^|[$SCHEME_SEPARATORS])"
private val URI_SCHEME = Regex(
"$ALLOWED_SEPARATORS_PATTERN(${ SUPPORTED_URIS.keys.joinToString("|") })",
"$ALLOWED_SEPARATORS_PATTERN(${SUPPORTED_URIS.keys.joinToString("|")})",
RegexOption.IGNORE_CASE,
)

View file

@ -19,7 +19,12 @@ val coreNotificationModule = module {
}
single { NotificationManagerCompat.from(get()) }
single {
NotificationHelper(context = get(), notificationManager = get(), notificationChannelManager = get(), resourceProvider = get())
NotificationHelper(
context = get(),
notificationManager = get(),
notificationChannelManager = get(),
resourceProvider = get(),
)
}
single {
NotificationChannelManager(

View file

@ -18,7 +18,8 @@ class AutocryptDraftStateHeaderParserTest : RobolectricTest() {
@Test
fun testSignOnly() {
val parsedHeader = autocryptHeaderParser.parseAutocryptDraftStateHeader("encrypt=no; _by-choice=yes; _sign-only=yes")
val parsedHeader =
autocryptHeaderParser.parseAutocryptDraftStateHeader("encrypt=no; _by-choice=yes; _sign-only=yes")
with(parsedHeader!!) {
assertThat(isEncrypt).isFalse()
@ -38,7 +39,8 @@ class AutocryptDraftStateHeaderParserTest : RobolectricTest() {
@Test
fun missingEncrypt() {
val parsedHeader = autocryptHeaderParser.parseAutocryptDraftStateHeader("encrpt-with-typo=no; _non_critical=value")
val parsedHeader =
autocryptHeaderParser.parseAutocryptDraftStateHeader("encrpt-with-typo=no; _non_critical=value")
assertThat(parsedHeader).isNull()
}

View file

@ -383,25 +383,27 @@ class MessageListRepositoryTest {
private fun runMessageMapper(messages: Array<out MessageData>, mapper: MessageMapper<Any?>): List<Any> {
return messages.mapNotNull { message ->
mapper.map(object : MessageDetailsAccessor {
override val id = message.messageId
override val messageServerId = "irrelevant"
override val folderId = message.folderId
override val fromAddresses = emptyList<Address>()
override val toAddresses = emptyList<Address>()
override val ccAddresses = emptyList<Address>()
override val messageDate = 0L
override val internalDate = 0L
override val subject = "irrelevant"
override val preview = PreviewResult.error()
override val isRead = message.isRead
override val isStarred = message.isStarred
override val isAnswered = message.isAnswered
override val isForwarded = message.isForwarded
override val hasAttachments = false
override val threadRoot = message.threadRoot
override val threadCount = 0
})
mapper.map(
object : MessageDetailsAccessor {
override val id = message.messageId
override val messageServerId = "irrelevant"
override val folderId = message.folderId
override val fromAddresses = emptyList<Address>()
override val toAddresses = emptyList<Address>()
override val ccAddresses = emptyList<Address>()
override val messageDate = 0L
override val internalDate = 0L
override val subject = "irrelevant"
override val preview = PreviewResult.error()
override val isRead = message.isRead
override val isStarred = message.isStarred
override val isAnswered = message.isAnswered
override val isForwarded = message.isForwarded
override val hasAttachments = false
override val threadRoot = message.threadRoot
override val threadCount = 0
},
)
}
}

View file

@ -35,7 +35,11 @@ fun createOAuthConfigurationProvider(): OAuthConfigurationProvider {
),
listOf("outlook.office365.com", "smtp.office365.com") to OAuthConfiguration(
clientId = BuildConfig.OAUTH_MICROSOFT_CLIENT_ID,
scopes = listOf("https://outlook.office.com/IMAP.AccessAsUser.All", "https://outlook.office.com/SMTP.Send", "offline_access"),
scopes = listOf(
"https://outlook.office.com/IMAP.AccessAsUser.All",
"https://outlook.office.com/SMTP.Send",
"offline_access",
),
authorizationEndpoint = "https://login.microsoftonline.com/common/oauth2/v2.0/authorize",
tokenEndpoint = "https://login.microsoftonline.com/common/oauth2/v2.0/token",
redirectUri = BuildConfig.OAUTH_MICROSOFT_REDIRECT_URI,

View file

@ -104,9 +104,10 @@ internal class K9NotificationActionCreator(
messageReferences: List<MessageReference>,
): PendingIntent {
val accountUuid = account.uuid
val intent = NotificationActionService.createMarkAllAsReadIntent(context, accountUuid, messageReferences).apply {
data = Uri.parse("data:,markAllAsRead/$accountUuid/${System.currentTimeMillis()}")
}
val intent =
NotificationActionService.createMarkAllAsReadIntent(context, accountUuid, messageReferences).apply {
data = Uri.parse("data:,markAllAsRead/$accountUuid/${System.currentTimeMillis()}")
}
return PendingIntent.getService(context, 0, intent, FLAG_UPDATE_CURRENT or FLAG_IMMUTABLE)
}
@ -165,9 +166,10 @@ internal class K9NotificationActionCreator(
messageReferences: List<MessageReference>,
): PendingIntent {
val accountUuid = account.uuid
val intent = NotificationActionService.createDeleteAllMessagesIntent(context, accountUuid, messageReferences).apply {
data = Uri.parse("data:,deleteAll/$accountUuid/${System.currentTimeMillis()}")
}
val intent =
NotificationActionService.createDeleteAllMessagesIntent(context, accountUuid, messageReferences).apply {
data = Uri.parse("data:,deleteAll/$accountUuid/${System.currentTimeMillis()}")
}
return PendingIntent.getService(context, 0, intent, FLAG_UPDATE_CURRENT or FLAG_IMMUTABLE)
}

View file

@ -18,7 +18,8 @@ internal class MoveMessageOperations(
Timber.d("Moving message [ID: $messageId] to folder [ID: $destinationFolderId]")
return database.execute(true) { database ->
val threadInfo = threadMessageOperations.createOrUpdateParentThreadEntries(database, messageId, destinationFolderId)
val threadInfo =
threadMessageOperations.createOrUpdateParentThreadEntries(database, messageId, destinationFolderId)
val destinationMessageId = createMessageEntry(database, messageId, destinationFolderId, threadInfo)
threadMessageOperations.createThreadEntryIfNecessary(database, destinationMessageId, threadInfo)

View file

@ -30,7 +30,8 @@ internal class MigrationTo76(private val db: SQLiteDatabase, private val migrati
val account = migrationsHelper.account
Timber.v("Cleaning up Outbox folder")
val outboxFolderId = account.outboxFolderId ?: createFolder("Outbox", "K9MAIL_INTERNAL_OUTBOX", OUTBOX_FOLDER_TYPE)
val outboxFolderId =
account.outboxFolderId ?: createFolder("Outbox", "K9MAIL_INTERNAL_OUTBOX", OUTBOX_FOLDER_TYPE)
deleteOtherOutboxFolders(outboxFolderId)
account.outboxFolderId = outboxFolderId

View file

@ -104,17 +104,19 @@ class StoragePersisterTest : K9RobolectricTest() {
persistOp: ((StoragePersistOperations) -> Unit)? = null,
before: ((MutableMap<String, String>) -> Unit)? = null,
onSuccess: ((Map<String, String>) -> Unit)? = null,
): StoragePersistOperationCallback = spy(object : StoragePersistOperationCallback {
override fun beforePersistTransaction(workingStorage: MutableMap<String, String>) {
before?.invoke(workingStorage)
}
): StoragePersistOperationCallback = spy(
object : StoragePersistOperationCallback {
override fun beforePersistTransaction(workingStorage: MutableMap<String, String>) {
before?.invoke(workingStorage)
}
override fun persist(ops: StoragePersistOperations) {
persistOp?.invoke(ops)
}
override fun persist(ops: StoragePersistOperations) {
persistOp?.invoke(ops)
}
override fun onPersistTransactionSuccess(workingStorage: Map<String, String>) {
onSuccess?.invoke(workingStorage)
}
})
override fun onPersistTransactionSuccess(workingStorage: Map<String, String>) {
onSuccess?.invoke(workingStorage)
}
},
)
}

View file

@ -61,7 +61,10 @@ class RetrieveMessageListOperationsTest : RobolectricTest() {
assertThat(message.folderId).isEqualTo(folderId)
assertThat(message.fromAddresses).containsExactly(Address("from@domain.example"))
assertThat(message.toAddresses).containsExactly(Address("to@domain.example"))
assertThat(message.ccAddresses).containsExactly(Address("cc1@domain.example"), Address("cc2@domain.example"))
assertThat(message.ccAddresses).containsExactly(
Address("cc1@domain.example"),
Address("cc2@domain.example"),
)
assertThat(message.messageDate).isEqualTo(123L)
assertThat(message.internalDate).isEqualTo(456L)
assertThat(message.subject).isEqualTo("subject")
@ -175,7 +178,10 @@ class RetrieveMessageListOperationsTest : RobolectricTest() {
assertThat(message.folderId).isEqualTo(folderId)
assertThat(message.fromAddresses).containsExactly(Address("from@domain.example"))
assertThat(message.toAddresses).containsExactly(Address("to@domain.example"))
assertThat(message.ccAddresses).containsExactly(Address("cc1@domain.example"), Address("cc2@domain.example"))
assertThat(message.ccAddresses).containsExactly(
Address("cc1@domain.example"),
Address("cc2@domain.example"),
)
assertThat(message.messageDate).isEqualTo(123L)
assertThat(message.internalDate).isEqualTo(456L)
assertThat(message.subject).isEqualTo("subject")

View file

@ -124,11 +124,13 @@ class AuthenticatedPasswordToggleViewModel : ViewModel() {
set(value) {
field = value
value?.lifecycle?.addObserver(object : DefaultLifecycleObserver {
override fun onDestroy(owner: LifecycleOwner) {
textInputLayout = null
field = null
}
})
value?.lifecycle?.addObserver(
object : DefaultLifecycleObserver {
override fun onDestroy(owner: LifecycleOwner) {
textInputLayout = null
field = null
}
},
)
}
}

View file

@ -11,13 +11,17 @@ class FolderInfoHolder(
localFolder: LocalFolder,
account: Account,
) {
@JvmField val databaseId = localFolder.databaseId
@JvmField
val databaseId = localFolder.databaseId
@JvmField val displayName = getDisplayName(account, localFolder)
@JvmField
val displayName = getDisplayName(account, localFolder)
@JvmField var loading = false
@JvmField
var loading = false
@JvmField var moreMessages = localFolder.hasMoreMessages()
@JvmField
var moreMessages = localFolder.hasMoreMessages()
private fun getDisplayName(account: Account, localFolder: LocalFolder): String {
val folderId = localFolder.databaseId

View file

@ -226,7 +226,10 @@ open class MessageList :
setIntent(intent)
// Start with a fresh fragment back stack
supportFragmentManager.popBackStackImmediate(FIRST_FRAGMENT_TRANSACTION, FragmentManager.POP_BACK_STACK_INCLUSIVE)
supportFragmentManager.popBackStackImmediate(
FIRST_FRAGMENT_TRANSACTION,
FragmentManager.POP_BACK_STACK_INCLUSIVE,
)
removeMessageListFragment()
removeMessageViewContainerFragment()
@ -906,17 +909,19 @@ open class MessageList :
searchView.queryHint = resources.getString(R.string.search_action)
val searchManager = getSystemService(SEARCH_SERVICE) as SearchManager
searchView.setSearchableInfo(searchManager.getSearchableInfo(componentName))
searchView.setOnQueryTextListener(object : SearchView.OnQueryTextListener {
override fun onQueryTextSubmit(query: String): Boolean {
messageListFragment?.onSearchRequested(query)
collapseSearchView()
return true
}
searchView.setOnQueryTextListener(
object : SearchView.OnQueryTextListener {
override fun onQueryTextSubmit(query: String): Boolean {
messageListFragment?.onSearchRequested(query)
collapseSearchView()
return true
}
override fun onQueryTextChange(s: String): Boolean {
return false
}
})
override fun onQueryTextChange(s: String): Boolean {
return false
}
},
)
searchView.setQuery(initialSearchViewQuery, false)
searchView.isIconified = initialSearchViewIconified

View file

@ -38,9 +38,15 @@ data class ComposeCryptoStatus(
isEncryptSubject: Boolean,
cryptoMode: CryptoMode,
) : this(
openPgpProviderState, openPgpKeyId,
openPgpProviderState,
openPgpKeyId,
recipientAddresses.map { it.address.address },
isPgpInlineModeEnabled, isSenderPreferEncryptMutual, isReplyToEncrypted, isEncryptAllDrafts, isEncryptSubject, cryptoMode,
isPgpInlineModeEnabled,
isSenderPreferEncryptMutual,
isReplyToEncrypted,
isEncryptAllDrafts,
isEncryptSubject,
cryptoMode,
)
private val recipientAutocryptStatusType = recipientAutocryptStatus?.type
@ -132,7 +138,8 @@ data class ComposeCryptoStatus(
fun allRecipientsCanEncrypt() = recipientAutocryptStatus?.type?.canEncrypt() == true
fun canEncryptAndIsMutualDefault() = allRecipientsCanEncrypt() && isSenderPreferEncryptMutual && isRecipientsPreferEncryptMutual
fun canEncryptAndIsMutualDefault() =
allRecipientsCanEncrypt() && isSenderPreferEncryptMutual && isRecipientsPreferEncryptMutual
fun hasAutocryptPendingIntent() = recipientAutocryptStatus?.hasPendingIntent() == true

View file

@ -79,35 +79,41 @@ class RecipientMvpView(private val activity: MessageCompose) : View.OnFocusChang
fun setPresenter(presenter: RecipientPresenter) {
this.presenter = presenter
toView.setTokenListener(object : RecipientSelectView.TokenListener<Recipient> {
override fun onTokenAdded(recipient: Recipient) = presenter.onToTokenAdded()
toView.setTokenListener(
object : RecipientSelectView.TokenListener<Recipient> {
override fun onTokenAdded(recipient: Recipient) = presenter.onToTokenAdded()
override fun onTokenRemoved(recipient: Recipient) = presenter.onToTokenRemoved()
override fun onTokenRemoved(recipient: Recipient) = presenter.onToTokenRemoved()
override fun onTokenChanged(recipient: Recipient) = presenter.onToTokenChanged()
override fun onTokenChanged(recipient: Recipient) = presenter.onToTokenChanged()
override fun onTokenIgnored(token: Recipient) = Unit
})
override fun onTokenIgnored(token: Recipient) = Unit
},
)
ccView.setTokenListener(object : RecipientSelectView.TokenListener<Recipient> {
override fun onTokenAdded(recipient: Recipient) = presenter.onCcTokenAdded()
ccView.setTokenListener(
object : RecipientSelectView.TokenListener<Recipient> {
override fun onTokenAdded(recipient: Recipient) = presenter.onCcTokenAdded()
override fun onTokenRemoved(recipient: Recipient) = presenter.onCcTokenRemoved()
override fun onTokenRemoved(recipient: Recipient) = presenter.onCcTokenRemoved()
override fun onTokenChanged(recipient: Recipient) = presenter.onCcTokenChanged()
override fun onTokenChanged(recipient: Recipient) = presenter.onCcTokenChanged()
override fun onTokenIgnored(token: Recipient) = Unit
})
override fun onTokenIgnored(token: Recipient) = Unit
},
)
bccView.setTokenListener(object : RecipientSelectView.TokenListener<Recipient> {
override fun onTokenAdded(recipient: Recipient) = presenter.onBccTokenAdded()
bccView.setTokenListener(
object : RecipientSelectView.TokenListener<Recipient> {
override fun onTokenAdded(recipient: Recipient) = presenter.onBccTokenAdded()
override fun onTokenRemoved(recipient: Recipient) = presenter.onBccTokenRemoved()
override fun onTokenRemoved(recipient: Recipient) = presenter.onBccTokenRemoved()
override fun onTokenChanged(recipient: Recipient) = presenter.onBccTokenChanged()
override fun onTokenChanged(recipient: Recipient) = presenter.onBccTokenChanged()
override fun onTokenIgnored(token: Recipient) = Unit
})
override fun onTokenIgnored(token: Recipient) = Unit
},
)
}
fun addTextChangedListener(textWatcher: TextWatcher) {

View file

@ -608,7 +608,8 @@ class RecipientPresenter(
}
private fun isContactPickerAvailable(): Boolean {
val resolveInfoList = context.packageManager.queryIntentActivities(ContactIntentHelper.getContactPickerIntent(), 0)
val resolveInfoList =
context.packageManager.queryIntentActivities(ContactIntentHelper.getContactPickerIntent(), 0)
return resolveInfoList.isNotEmpty()
}

View file

@ -51,7 +51,6 @@ import com.mikepenz.materialdrawer.util.getDrawerItem
import com.mikepenz.materialdrawer.util.removeAllItems
import com.mikepenz.materialdrawer.widget.AccountHeaderView
import com.mikepenz.materialdrawer.widget.MaterialDrawerSliderView
import java.util.ArrayList
import org.koin.androidx.viewmodel.ext.android.viewModel
import org.koin.core.component.KoinComponent
import org.koin.core.component.inject
@ -141,19 +140,21 @@ class K9Drawer(private val parent: MessageList, savedInstanceState: Bundle?) : K
}
private fun initializeImageLoader() {
DrawerImageLoader.init(object : AbstractDrawerImageLoader() {
override fun set(imageView: ImageView, uri: Uri, placeholder: Drawable, tag: String?) {
val email = uri.getQueryParameter(QUERY_EMAIL) ?: error("Missing '$QUERY_EMAIL' parameter in $uri")
val color = uri.getQueryParameter(QUERY_COLOR)?.toInt()
?: error("Missing '$QUERY_COLOR' parameter in $uri")
DrawerImageLoader.init(
object : AbstractDrawerImageLoader() {
override fun set(imageView: ImageView, uri: Uri, placeholder: Drawable, tag: String?) {
val email = uri.getQueryParameter(QUERY_EMAIL) ?: error("Missing '$QUERY_EMAIL' parameter in $uri")
val color = uri.getQueryParameter(QUERY_COLOR)?.toInt()
?: error("Missing '$QUERY_COLOR' parameter in $uri")
accountImageLoader.setAccountImage(imageView, email, color)
}
accountImageLoader.setAccountImage(imageView, email, color)
}
override fun cancel(imageView: ImageView) {
accountImageLoader.cancel(imageView)
}
}).apply {
override fun cancel(imageView: ImageView) {
accountImageLoader.cancel(imageView)
}
},
).apply {
handledProtocols = listOf(INTERNAL_URI_SCHEME)
}
}
@ -545,7 +546,8 @@ private fun Context.obtainDrawerTextColor(): Int {
MaterialDrawerR.attr.materialDrawerStyle,
MaterialDrawerR.style.Widget_MaterialDrawerStyle,
)
val textColor = styledAttributes.getColor(MaterialDrawerR.styleable.MaterialDrawerSliderView_materialDrawerPrimaryText, 0)
val textColor =
styledAttributes.getColor(MaterialDrawerR.styleable.MaterialDrawerSliderView_materialDrawerPrimaryText, 0)
styledAttributes.recycle()
return textColor

View file

@ -193,20 +193,24 @@ class SimpleHighlightView private constructor(context: Context, style: Int) : Fr
}
private inline fun ObjectAnimator.onAnimationStart(crossinline block: () -> Unit): ObjectAnimator {
addListener(object : AnimatorListenerAdapter() {
override fun onAnimationStart(animation: Animator) {
block()
}
})
addListener(
object : AnimatorListenerAdapter() {
override fun onAnimationStart(animation: Animator) {
block()
}
},
)
return this
}
private inline fun ObjectAnimator.onAnimationEnd(crossinline block: () -> Unit): ObjectAnimator {
addListener(object : AnimatorListenerAdapter() {
override fun onAnimationEnd(animation: Animator) {
block()
}
})
addListener(
object : AnimatorListenerAdapter() {
override fun onAnimationEnd(animation: Animator) {
block()
}
},
)
return this
}

View file

@ -71,7 +71,10 @@ class AutocryptKeyTransferPresenter internal constructor(
view.uxDelay()
view.setLoadingStateGenerating()
viewModel.autocryptSetupMessageLiveEvent.loadAutocryptSetupMessageAsync(openPgpApiManager.openPgpApi, account)
viewModel.autocryptSetupMessageLiveEvent.loadAutocryptSetupMessageAsync(
openPgpApiManager.openPgpApi,
account,
)
}
}

View file

@ -15,7 +15,9 @@ import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import org.openintents.openpgp.util.OpenPgpApi
class AutocryptSetupMessageLiveEvent(val messageCreator: AutocryptTransferMessageCreator) : SingleLiveEvent<AutocryptSetupMessage>() {
class AutocryptSetupMessageLiveEvent(
val messageCreator: AutocryptTransferMessageCreator,
) : SingleLiveEvent<AutocryptSetupMessage>() {
fun loadAutocryptSetupMessageAsync(openPgpApi: OpenPgpApi, account: Account) {
GlobalScope.launch(Dispatchers.Main) {
value = withContext(Dispatchers.IO) {

View file

@ -103,17 +103,19 @@ class ManageFoldersFragment : Fragment() {
val folderMenuItem = menu.findItem(R.id.filter_folders)
val folderSearchView = folderMenuItem.actionView as SearchView
folderSearchView.queryHint = getString(R.string.folder_list_filter_hint)
folderSearchView.setOnQueryTextListener(object : SearchView.OnQueryTextListener {
override fun onQueryTextSubmit(query: String): Boolean {
itemAdapter.filter(query)
return true
}
folderSearchView.setOnQueryTextListener(
object : SearchView.OnQueryTextListener {
override fun onQueryTextSubmit(query: String): Boolean {
itemAdapter.filter(query)
return true
}
override fun onQueryTextChange(newText: String): Boolean {
itemAdapter.filter(newText)
return true
}
})
override fun onQueryTextChange(newText: String): Boolean {
itemAdapter.filter(newText)
return true
}
},
)
}
override fun onOptionsItemSelected(item: MenuItem): Boolean {

View file

@ -88,11 +88,13 @@ class MessageDetailsFragment : ToolbarBottomSheetDialogFragment() {
// Don't allow dragging down the bottom sheet (by dragging the toolbar) unless the list is scrolled all the way
// to the top.
recyclerView.addOnScrollListener(object : OnScrollListener() {
override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
dialog.behavior.isDraggable = !recyclerView.canScrollVertically(-1)
}
})
recyclerView.addOnScrollListener(
object : OnScrollListener() {
override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
dialog.behavior.isDraggable = !recyclerView.canScrollVertically(-1)
}
},
)
viewModel.uiEvents.observe(this) { event ->
when (event) {

View file

@ -61,9 +61,11 @@ class MessageListAdapter internal constructor(
alphaFractionAttrId = R.attr.messageListSelectedBackgroundAlphaFraction,
backgroundColorAttrId = R.attr.messageListSelectedBackgroundAlphaBackground,
)
private val regularItemBackgroundColor: Int = theme.resolveColorAttribute(R.attr.messageListRegularItemBackgroundColor)
private val regularItemBackgroundColor: Int =
theme.resolveColorAttribute(R.attr.messageListRegularItemBackgroundColor)
private val readItemBackgroundColor: Int = theme.resolveColorAttribute(R.attr.messageListReadItemBackgroundColor)
private val unreadItemBackgroundColor: Int = theme.resolveColorAttribute(R.attr.messageListUnreadItemBackgroundColor)
private val unreadItemBackgroundColor: Int =
theme.resolveColorAttribute(R.attr.messageListUnreadItemBackgroundColor)
var messages: List<MessageListItem> = emptyList()
@SuppressLint("NotifyDataSetChanged")
@ -267,7 +269,10 @@ class MessageListAdapter internal constructor(
// 1 preview line is needed even if it is set to 0, because subject is part of the same text view
holder.preview.maxLines = max(appearance.previewLines, 1)
appearance.fontSizes.setViewTextSize(holder.preview, appearance.fontSizes.messageListPreview)
appearance.fontSizes.setViewTextSize(holder.threadCount, appearance.fontSizes.messageListSubject) // thread count is next to subject
appearance.fontSizes.setViewTextSize(
holder.threadCount,
appearance.fontSizes.messageListSubject,
) // thread count is next to subject
holder.star.isVisible = appearance.stars
holder.star.tag = holder

View file

@ -369,13 +369,15 @@ class MessageListFragment :
recentChangesSnackbar = Snackbar
.make(coordinatorLayout, R.string.changelog_snackbar_text, Snackbar.LENGTH_INDEFINITE)
.setAction(R.string.okay_action) { launchRecentChangesActivity() }
.addCallback(object : BaseCallback<Snackbar>() {
override fun onDismissed(transientBottomBar: Snackbar?, event: Int) {
if (event == DISMISS_EVENT_SWIPE) {
recentChangesViewModel.onRecentChangesHintDismissed()
.addCallback(
object : BaseCallback<Snackbar>() {
override fun onDismissed(transientBottomBar: Snackbar?, event: Int) {
if (event == DISMISS_EVENT_SWIPE) {
recentChangesViewModel.onRecentChangesHintDismissed()
}
}
}
})
},
)
recentChangesViewModel.shouldShowRecentChangesHint
.observe(viewLifecycleOwner, shouldShowRecentChangesHintObserver)

View file

@ -229,7 +229,7 @@ class MessageContainerView(context: Context, attrs: AttributeSet?) :
context.getString(R.string.webview_contextmenu_image_save_action)
} else {
context.getString(R.string.webview_contextmenu_image_download_action)
}
},
).setOnMenuItemClickListener(listener)
}

View file

@ -282,11 +282,13 @@ class MessageTopView(
progressBar.progress,
PROGRESS_MAX,
)
animator.addListener(object : AnimatorListenerAdapter() {
override fun onAnimationEnd(animator: Animator) {
viewAnimator.displayedChild = 2
}
})
animator.addListener(
object : AnimatorListenerAdapter() {
override fun onAnimationEnd(animator: Animator) {
viewAnimator.displayedChild = 2
}
},
)
animator.duration = PROGRESS_STEP_DURATION.toLong()
animator.start()
}

View file

@ -99,21 +99,23 @@ class MessageViewContainerFragment : Fragment() {
viewPager.isUserInputEnabled = true
viewPager.offscreenPageLimit = ViewPager2.OFFSCREEN_PAGE_LIMIT_DEFAULT
viewPager.setPageTransformer(MarginPageTransformer(pageMargin))
viewPager.registerOnPageChangeCallback(object : ViewPager2.OnPageChangeCallback() {
// The message list is updated each time the active message is changed. To avoid message list updates
// during the animation, we only set the active message after the animation has finished.
override fun onPageScrollStateChanged(state: Int) {
if (state == ViewPager2.SCROLL_STATE_IDLE) {
setActiveMessage(viewPager.currentItem)
viewPager.registerOnPageChangeCallback(
object : ViewPager2.OnPageChangeCallback() {
// The message list is updated each time the active message is changed. To avoid message list updates
// during the animation, we only set the active message after the animation has finished.
override fun onPageScrollStateChanged(state: Int) {
if (state == ViewPager2.SCROLL_STATE_IDLE) {
setActiveMessage(viewPager.currentItem)
}
}
}
override fun onPageSelected(position: Int) {
if (viewPager.scrollState == ViewPager2.SCROLL_STATE_IDLE) {
setActiveMessage(position)
override fun onPageSelected(position: Int) {
if (viewPager.scrollState == ViewPager2.SCROLL_STATE_IDLE) {
setActiveMessage(position)
}
}
}
})
},
)
return view
}

View file

@ -33,7 +33,8 @@ class OnboardingActivity : K9Activity() {
}
companion object {
@JvmStatic fun launch(activity: Activity) {
@JvmStatic
fun launch(activity: Activity) {
val intent = Intent(activity, OnboardingActivity::class.java).apply {
flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK
}

View file

@ -94,8 +94,16 @@ class AboutFragment : Fragment() {
companion object {
private val USED_LIBRARIES = arrayOf(
Library("Android Jetpack libraries", "https://developer.android.com/jetpack", "Apache License, Version 2.0"),
Library("AndroidX Preference eXtended", "https://github.com/takisoft/preferencex-android", "Apache License, Version 2.0"),
Library(
"Android Jetpack libraries",
"https://developer.android.com/jetpack",
"Apache License, Version 2.0",
),
Library(
"AndroidX Preference eXtended",
"https://github.com/takisoft/preferencex-android",
"Apache License, Version 2.0",
),
Library("AppAuth for Android", "https://github.com/openid/AppAuth-Android", "Apache License, Version 2.0"),
Library("CircleImageView", "https://github.com/hdodenhof/CircleImageView", "Apache License, Version 2.0"),
Library("ckChangeLog", "https://github.com/cketti/ckChangeLog", "Apache License, Version 2.0"),
@ -106,19 +114,39 @@ class AboutFragment : Fragment() {
Library("jutf7", "http://jutf7.sourceforge.net/", "MIT License"),
Library("JZlib", "http://www.jcraft.com/jzlib/", "BSD-style License"),
Library("Koin", "https://insert-koin.io/", "Apache License, Version 2.0"),
Library("Kotlin Standard Library", "https://kotlinlang.org/api/latest/jvm/stdlib/", "Apache License, Version 2.0"),
Library("KotlinX coroutines", "https://github.com/Kotlin/kotlinx.coroutines", "Apache License, Version 2.0"),
Library("Material Components for Android", "https://github.com/material-components/material-components-android", "Apache License, Version 2.0"),
Library(
"Kotlin Standard Library",
"https://kotlinlang.org/api/latest/jvm/stdlib/",
"Apache License, Version 2.0",
),
Library(
"KotlinX coroutines",
"https://github.com/Kotlin/kotlinx.coroutines",
"Apache License, Version 2.0",
),
Library(
"Material Components for Android",
"https://github.com/material-components/material-components-android",
"Apache License, Version 2.0",
),
Library("Material Drawer", "https://github.com/mikepenz/MaterialDrawer", "Apache License, Version 2.0"),
Library("Mime4j", "https://james.apache.org/mime4j/", "Apache License, Version 2.0"),
Library("MiniDNS", "https://github.com/MiniDNS/minidns", "Multiple, Apache License, Version 2.0"),
Library("Moshi", "https://github.com/square/moshi", "Apache License, Version 2.0"),
Library("OkHttp", "https://github.com/square/okhttp", "Apache License, Version 2.0"),
Library("Okio", "https://github.com/square/okio", "Apache License, Version 2.0"),
Library("SafeContentResolver", "https://github.com/cketti/SafeContentResolver", "Apache License, Version 2.0"),
Library(
"SafeContentResolver",
"https://github.com/cketti/SafeContentResolver",
"Apache License, Version 2.0",
),
Library("SearchPreference", "https://github.com/ByteHamster/SearchPreference", "MIT License"),
Library("Timber", "https://github.com/JakeWharton/timber", "Apache License, Version 2.0"),
Library("TokenAutoComplete", "https://github.com/splitwise/TokenAutoComplete/", "Apache License, Version 2.0"),
Library(
"TokenAutoComplete",
"https://github.com/splitwise/TokenAutoComplete/",
"Apache License, Version 2.0",
),
)
}
}

View file

@ -38,7 +38,8 @@ class SettingsActivity : K9Activity() {
}
companion object {
@JvmStatic fun launch(activity: Activity) {
@JvmStatic
fun launch(activity: Activity) {
val intent = Intent(activity, SettingsActivity::class.java)
activity.startActivity(intent)
}

View file

@ -61,7 +61,8 @@ constructor(
).italicize()
entries = (listOf(automaticFolderOption) + noFolderSelectedName + getFolderDisplayNames(folders)).toTypedArray()
entryValues = (listOf(automaticFolderValue) + NO_FOLDER_SELECTED_VALUE + getFolderValues(folders)).toTypedArray()
entryValues =
(listOf(automaticFolderValue) + NO_FOLDER_SELECTED_VALUE + getFolderValues(folders)).toTypedArray()
isEnabled = true
}

View file

@ -180,18 +180,20 @@ class VibrationDialogFragment : PreferenceDialogFragmentCompat() {
vibrationTimesSeekBar.progress = progress
}
vibrationTimesSeekBar.setOnSeekBarChangeListener(object : OnSeekBarChangeListener {
override fun onProgressChanged(seekBar: SeekBar, progress: Int, fromUser: Boolean) {
vibrationTimes = progress + 1
vibrationTimesValue.text = vibrationTimes.toString()
}
vibrationTimesSeekBar.setOnSeekBarChangeListener(
object : OnSeekBarChangeListener {
override fun onProgressChanged(seekBar: SeekBar, progress: Int, fromUser: Boolean) {
vibrationTimes = progress + 1
vibrationTimesValue.text = vibrationTimes.toString()
}
override fun onStartTrackingTouch(seekBar: SeekBar) = Unit
override fun onStartTrackingTouch(seekBar: SeekBar) = Unit
override fun onStopTrackingTouch(seekBar: SeekBar) {
playVibration()
}
})
override fun onStopTrackingTouch(seekBar: SeekBar) {
playVibration()
}
},
)
}
}

View file

@ -82,16 +82,18 @@ class GeneralSettingsActivity : K9Activity(), OnPreferenceStartScreenCallback, S
index(R.xml.general_settings)
}
searchPreferenceMenuItem.setOnActionExpandListener(object : MenuItem.OnActionExpandListener {
override fun onMenuItemActionCollapse(item: MenuItem): Boolean {
searchPreferenceActionView.cancelSearch()
return true
}
searchPreferenceMenuItem.setOnActionExpandListener(
object : MenuItem.OnActionExpandListener {
override fun onMenuItemActionCollapse(item: MenuItem): Boolean {
searchPreferenceActionView.cancelSearch()
return true
}
override fun onMenuItemActionExpand(item: MenuItem): Boolean {
return true
}
})
override fun onMenuItemActionExpand(item: MenuItem): Boolean {
return true
}
},
)
if (searchEnabled) {
Handler().post {

View file

@ -76,7 +76,8 @@ class PgpMessageBuilderTest : K9RobolectricTest() {
private val resourceProvider: CoreResourceProvider by inject()
private val openPgpApi = mock(OpenPgpApi::class.java)
private val autocryptOpenPgpApiInteractor = mock(AutocryptOpenPgpApiInteractor::class.java)
private val pgpMessageBuilder = createDefaultPgpMessageBuilder(openPgpApi, autocryptOpenPgpApiInteractor, resourceProvider)
private val pgpMessageBuilder =
createDefaultPgpMessageBuilder(openPgpApi, autocryptOpenPgpApiInteractor, resourceProvider)
@Before
@Throws(Exception::class)
@ -169,7 +170,9 @@ class PgpMessageBuilderTest : K9RobolectricTest() {
val returnIntent = Intent()
returnIntent.putExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_SUCCESS)
`when`(openPgpApi.executeApi(any<Intent>(), any<OpenPgpDataSource>(), any<OutputStream>())).thenReturn(returnIntent)
`when`(openPgpApi.executeApi(any<Intent>(), any<OpenPgpDataSource>(), any<OutputStream>())).thenReturn(
returnIntent,
)
val mockCallback = mock(Callback::class.java)
pgpMessageBuilder.buildAsync(mockCallback)
@ -259,7 +262,9 @@ class PgpMessageBuilderTest : K9RobolectricTest() {
`when`<Parcelable>(returnIntent.getParcelableExtra<Parcelable>(eq(OpenPgpApi.RESULT_INTENT)))
.thenReturn(mockPendingIntent)
`when`(openPgpApi.executeApi(any<Intent>(), any<OpenPgpDataSource>(), any<OutputStream>())).thenReturn(returnIntent)
`when`(openPgpApi.executeApi(any<Intent>(), any<OpenPgpDataSource>(), any<OutputStream>())).thenReturn(
returnIntent,
)
val mockCallback = mock(Callback::class.java)
pgpMessageBuilder.buildAsync(mockCallback)
@ -287,7 +292,9 @@ class PgpMessageBuilderTest : K9RobolectricTest() {
`when`<Parcelable>(returnIntent.getParcelableExtra<Parcelable>(eq(OpenPgpApi.RESULT_INTENT)))
.thenReturn(mockPendingIntent)
`when`(openPgpApi.executeApi(any<Intent>(), any<OpenPgpDataSource>(), any<OutputStream>())).thenReturn(returnIntent)
`when`(openPgpApi.executeApi(any<Intent>(), any<OpenPgpDataSource>(), any<OutputStream>())).thenReturn(
returnIntent,
)
val mockCallback = mock(Callback::class.java)
pgpMessageBuilder.buildAsync(mockCallback)
@ -307,7 +314,9 @@ class PgpMessageBuilderTest : K9RobolectricTest() {
returnIntent.putExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_SUCCESS)
val mockReturnIntent = mock(Intent::class.java)
`when`(openPgpApi.executeApi(any<Intent>(), any<OpenPgpDataSource>(), any<OutputStream>())).thenReturn(returnIntent)
`when`(openPgpApi.executeApi(any<Intent>(), any<OpenPgpDataSource>(), any<OutputStream>())).thenReturn(
returnIntent,
)
val mockCallback = mock(Callback::class.java)
pgpMessageBuilder.onActivityResult(returnedRequestCode, Activity.RESULT_OK, mockReturnIntent, mockCallback)
@ -324,7 +333,13 @@ class PgpMessageBuilderTest : K9RobolectricTest() {
val returnIntent = spy(Intent())
returnIntent.putExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_SUCCESS)
`when`(openPgpApi.executeApi(any(Intent::class.java), any(OpenPgpDataSource::class.java), any(OutputStream::class.java)))
`when`(
openPgpApi.executeApi(
any(Intent::class.java),
any(OpenPgpDataSource::class.java),
any(OutputStream::class.java),
),
)
.thenReturn(returnIntent)
val mockCallback = mock(Callback::class.java)
@ -391,13 +406,22 @@ class PgpMessageBuilderTest : K9RobolectricTest() {
val mimeMessage = buildMessage()
assertEquals("encrypt=no; _sign-only=yes; _by-choice=yes; ", mimeMessage.getHeader("Autocrypt-Draft-State").get(0))
assertEquals(
"encrypt=no; _sign-only=yes; _by-choice=yes; ",
mimeMessage.getHeader("Autocrypt-Draft-State").get(0),
)
}
private fun buildMessage(): MimeMessage {
val returnIntent = spy(Intent())
returnIntent.putExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_SUCCESS)
`when`(openPgpApi.executeApi(any(Intent::class.java), any(OpenPgpDataSource::class.java), any(OutputStream::class.java)))
`when`(
openPgpApi.executeApi(
any(Intent::class.java),
any(OpenPgpDataSource::class.java),
any(OutputStream::class.java),
),
)
.thenReturn(returnIntent)
val mockCallback = mock(Callback::class.java)
@ -422,7 +446,13 @@ class PgpMessageBuilderTest : K9RobolectricTest() {
val returnIntent = Intent()
returnIntent.putExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_SUCCESS)
`when`(openPgpApi.executeApi(any(Intent::class.java), any(OpenPgpDataSource::class.java), any(OutputStream::class.java)))
`when`(
openPgpApi.executeApi(
any(Intent::class.java),
any(OpenPgpDataSource::class.java),
any(OutputStream::class.java),
),
)
.thenReturn(returnIntent)
pgpMessageBuilder.buildAsync(mock(Callback::class.java))
@ -442,11 +472,21 @@ class PgpMessageBuilderTest : K9RobolectricTest() {
val returnIntent = Intent()
returnIntent.putExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_SUCCESS)
`when`(openPgpApi.executeApi(any(Intent::class.java), any(OpenPgpDataSource::class.java), any(OutputStream::class.java)))
`when`(
openPgpApi.executeApi(
any(Intent::class.java),
any(OpenPgpDataSource::class.java),
any(OutputStream::class.java),
),
)
.thenReturn(returnIntent)
pgpMessageBuilder.buildAsync(mock(Callback::class.java))
verify(autocryptOpenPgpApiInteractor).getKeyMaterialForKeyId(same(openPgpApi), eq(TEST_KEY_ID), eq(SENDER_EMAIL))
verify(autocryptOpenPgpApiInteractor).getKeyMaterialForKeyId(
same(openPgpApi),
eq(TEST_KEY_ID),
eq(SENDER_EMAIL),
)
verify(autocryptOpenPgpApiInteractor).getKeyMaterialForUserId(same(openPgpApi), eq("alice@example.org"))
verify(autocryptOpenPgpApiInteractor).getKeyMaterialForUserId(same(openPgpApi), eq("bob@example.org"))
}
@ -464,11 +504,21 @@ class PgpMessageBuilderTest : K9RobolectricTest() {
val returnIntent = Intent()
returnIntent.putExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_SUCCESS)
`when`(openPgpApi.executeApi(any(Intent::class.java), any(OpenPgpDataSource::class.java), any(OutputStream::class.java)))
`when`(
openPgpApi.executeApi(
any(Intent::class.java),
any(OpenPgpDataSource::class.java),
any(OutputStream::class.java),
),
)
.thenReturn(returnIntent)
pgpMessageBuilder.buildAsync(mock(Callback::class.java))
verify(autocryptOpenPgpApiInteractor).getKeyMaterialForKeyId(any(OpenPgpApi::class.java), any(Long::class.java), any(String::class.java))
verify(autocryptOpenPgpApiInteractor).getKeyMaterialForKeyId(
any(OpenPgpApi::class.java),
any(Long::class.java),
any(String::class.java),
)
verifyNoMoreInteractions(autocryptOpenPgpApiInteractor)
}
@ -648,7 +698,8 @@ class PgpMessageBuilderTest : K9RobolectricTest() {
@Test
@Throws(MessagingException::class)
fun buildEncryptWithAttach__withInlineEnabled__shouldThrow() {
val cryptoStatus = defaultCryptoStatus.copy(cryptoMode = CryptoMode.CHOICE_ENABLED, isPgpInlineModeEnabled = true)
val cryptoStatus =
defaultCryptoStatus.copy(cryptoMode = CryptoMode.CHOICE_ENABLED, isPgpInlineModeEnabled = true)
pgpMessageBuilder.setCryptoStatus(cryptoStatus)
pgpMessageBuilder.setAttachments(listOf(Attachment.createAttachment(null, 0, null, true, true)))
@ -674,7 +725,13 @@ class PgpMessageBuilderTest : K9RobolectricTest() {
OpenPgpError(OpenPgpError.OPPORTUNISTIC_MISSING_KEYS, "Missing keys"),
)
`when`(openPgpApi.executeApi(any(Intent::class.java), any(OpenPgpDataSource::class.java), any(OutputStream::class.java)))
`when`(
openPgpApi.executeApi(
any(Intent::class.java),
any(OpenPgpDataSource::class.java),
any(OutputStream::class.java),
),
)
.thenReturn(returnIntent)
val mockCallback = mock(Callback::class.java)
@ -698,7 +755,9 @@ class PgpMessageBuilderTest : K9RobolectricTest() {
returnIntentSigned.putExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_SUCCESS)
// no OpenPgpApi.EXTRA_DETACHED_SIGNATURE!
`when`(openPgpApi.executeApi(any<Intent>(), any<OpenPgpDataSource>(), any<OutputStream>())).thenReturn(returnIntentSigned)
`when`(openPgpApi.executeApi(any<Intent>(), any<OpenPgpDataSource>(), any<OutputStream>())).thenReturn(
returnIntentSigned,
)
val mockCallback = mock(Callback::class.java)
pgpMessageBuilder.buildAsync(mockCallback)

View file

@ -16,7 +16,7 @@ import org.robolectric.annotation.Config
@Config(
qualifiers = "en",
sdk = [Build.VERSION_CODES.S]
sdk = [Build.VERSION_CODES.S],
)
class RelativeDateTimeFormatterTest : RobolectricTest() {

View file

@ -16,7 +16,7 @@ android {
isMinifyEnabled = false
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
"proguard-rules.pro",
)
}
}

View file

@ -35,17 +35,17 @@ include(
":app:autodiscovery:providersxml",
":app:autodiscovery:srvrecords",
":app:autodiscovery:thunderbird",
":app:html-cleaner"
":app:html-cleaner",
)
include(
":core:ui:compose:demo"
":core:ui:compose:demo",
)
include(
":ui-utils:LinearLayoutManager",
":ui-utils:ItemTouchHelper",
":ui-utils:ToolbarBottomSheet"
":ui-utils:ToolbarBottomSheet",
)
include(
@ -54,7 +54,7 @@ include(
":mail:protocols:imap",
":mail:protocols:pop3",
":mail:protocols:webdav",
":mail:protocols:smtp"
":mail:protocols:smtp",
)
include(
@ -64,7 +64,7 @@ include(
":backend:pop3",
":backend:webdav",
":backend:jmap",
":backend:demo"
":backend:demo",
)
include(":plugins:openpgp-api-lib:openpgp-api")