Fix code style issues found by ktlint

This commit is contained in:
cketti 2019-11-26 21:54:43 +01:00
parent 88d863c4c2
commit 93d0e14b68
204 changed files with 728 additions and 931 deletions

View file

@ -6,14 +6,14 @@ import com.fsck.k9.autodiscovery.ConnectionSettingsDiscovery
import com.fsck.k9.backend.BackendManager
import com.fsck.k9.helper.EmailHelper
import com.fsck.k9.helper.UrlEncodingHelper
import org.xmlpull.v1.XmlPullParser
import timber.log.Timber
import java.net.URI
import java.net.URISyntaxException
import org.xmlpull.v1.XmlPullParser
import timber.log.Timber
class ProvidersXmlDiscovery(
private val backendManager: BackendManager,
private val xmlProvider: ProvidersXmlProvider
private val backendManager: BackendManager,
private val xmlProvider: ProvidersXmlProvider
) : ConnectionSettingsDiscovery {
override fun discover(email: String): ConnectionSettings? {
@ -108,11 +108,10 @@ class ProvidersXmlDiscovery(
}
}
internal data class Provider(
val incomingUriTemplate: String,
val incomingUsernameTemplate: String,
val outgoingUriTemplate: String,
val outgoingUsernameTemplate: String?
val incomingUriTemplate: String,
val incomingUsernameTemplate: String,
val outgoingUriTemplate: String,
val outgoingUsernameTemplate: String?
)
}

View file

@ -1,10 +1,10 @@
package com.fsck.k9.autodiscovery.thunderbird
import com.fsck.k9.helper.EmailHelper
import java.io.InputStream
import okhttp3.HttpUrl
import okhttp3.OkHttpClient
import okhttp3.Request
import java.io.InputStream
class ThunderbirdAutoconfigFetcher(private val okHttpClient: OkHttpClient) {
@ -21,7 +21,6 @@ class ThunderbirdAutoconfigFetcher(private val okHttpClient: OkHttpClient) {
}
}
companion object {
// address described at:
// https://developer.mozilla.org/en-US/docs/Mozilla/Thunderbird/Autoconfiguration#Configuration_server_at_ISP

View file

@ -4,12 +4,12 @@ import com.fsck.k9.autodiscovery.ConnectionSettings
import com.fsck.k9.mail.AuthType
import com.fsck.k9.mail.ConnectionSecurity
import com.fsck.k9.mail.ServerSettings
import org.xmlpull.v1.XmlPullParser
import org.xmlpull.v1.XmlPullParserException
import org.xmlpull.v1.XmlPullParserFactory
import java.io.IOException
import java.io.InputStream
import java.io.InputStreamReader
import org.xmlpull.v1.XmlPullParser
import org.xmlpull.v1.XmlPullParserException
import org.xmlpull.v1.XmlPullParserFactory
/**
* Parser for Thunderbird's

View file

@ -4,9 +4,9 @@ import com.fsck.k9.autodiscovery.ConnectionSettings
import com.fsck.k9.autodiscovery.ConnectionSettingsDiscovery
class ThunderbirdDiscovery(
private val fetcher: ThunderbirdAutoconfigFetcher,
private val parser: ThunderbirdAutoconfigParser
): ConnectionSettingsDiscovery {
private val fetcher: ThunderbirdAutoconfigFetcher,
private val parser: ThunderbirdAutoconfigParser
) : ConnectionSettingsDiscovery {
override fun discover(email: String): ConnectionSettings? {
val autoconfigInputStream = fetcher.fetchAutoconfigFile(email) ?: return null

View file

@ -13,7 +13,6 @@ import org.junit.Test
import org.mockito.ArgumentMatchers.anyString
import org.robolectric.RuntimeEnvironment
class ProvidersXmlDiscoveryTest : RobolectricTest() {
val backendManager = mock<BackendManager> {
on { decodeStoreUri(anyString()) } doAnswer { mock -> ImapStoreUriDecoder.decode(mock.getArgument(0)) }
@ -24,7 +23,6 @@ class ProvidersXmlDiscoveryTest : RobolectricTest() {
val xmlProvider = ProvidersXmlProvider(RuntimeEnvironment.application)
val providersXmlDiscovery = ProvidersXmlDiscovery(backendManager, xmlProvider)
@Test
fun discover_withGmailDomain_shouldReturnCorrectSettings() {
val connectionSettings = providersXmlDiscovery.discover("user@gmail.com")

View file

@ -1,6 +1,20 @@
package com.fsck.k9
import com.fsck.k9.Account.*
import com.fsck.k9.Account.DEFAULT_SORT_ASCENDING
import com.fsck.k9.Account.DEFAULT_SORT_TYPE
import com.fsck.k9.Account.DeletePolicy
import com.fsck.k9.Account.Expunge
import com.fsck.k9.Account.FolderMode
import com.fsck.k9.Account.INBOX
import com.fsck.k9.Account.INTERVAL_MINUTES_NEVER
import com.fsck.k9.Account.MessageFormat
import com.fsck.k9.Account.NO_OPENPGP_KEY
import com.fsck.k9.Account.QuoteStyle
import com.fsck.k9.Account.Searchable
import com.fsck.k9.Account.ShowPictures
import com.fsck.k9.Account.SortType
import com.fsck.k9.Account.SpecialFolderSelection
import com.fsck.k9.Account.UNASSIGNED_ACCOUNT_NUMBER
import com.fsck.k9.helper.Utility
import com.fsck.k9.mail.NetworkType
import com.fsck.k9.mail.filter.Base64
@ -8,23 +22,22 @@ import com.fsck.k9.mailstore.StorageManager
import com.fsck.k9.preferences.Storage
import com.fsck.k9.preferences.StorageEditor
import timber.log.Timber
import java.util.*
class AccountPreferenceSerializer(
private val storageManager: StorageManager,
private val resourceProvider: CoreResourceProvider
private val storageManager: StorageManager,
private val resourceProvider: CoreResourceProvider
) {
@Synchronized
fun loadAccount(account: Account, storage: Storage) {
val accountUuid = account.uuid
with (account) {
with(account) {
storeUri = Base64.decode(storage.getString("$accountUuid.storeUri", null))
localStorageProviderId = storage.getString("$accountUuid.localStorageProvider", storageManager.defaultProviderId)
transportUri = Base64.decode(storage.getString("$accountUuid.transportUri", null))
description = storage.getString("$accountUuid.description", null)
alwaysBcc = storage.getString("$accountUuid.alwaysBcc", alwaysBcc)
automaticCheckIntervalMinutes = storage.getInt("$accountUuid.automaticCheckIntervalMinutes", Account.INTERVAL_MINUTES_NEVER)
automaticCheckIntervalMinutes = storage.getInt("$accountUuid.automaticCheckIntervalMinutes", INTERVAL_MINUTES_NEVER)
idleRefreshMinutes = storage.getInt("$accountUuid.idleRefreshMinutes", 24)
isPushPollOnConnect = storage.getBoolean("$accountUuid.pushPollOnConnect", true)
displayCount = storage.getInt("$accountUuid.displayCount", K9.DEFAULT_VISIBLE_LIMIT)
@ -203,7 +216,7 @@ class AccountPreferenceSerializer(
editor.putString("accountUuids", accountUuids)
}
with (account) {
with(account) {
editor.putString("$accountUuid.storeUri", Base64.encode(storeUri))
editor.putString("$accountUuid.localStorageProvider", localStorageProviderId)
editor.putString("$accountUuid.transportUri", Base64.encode(transportUri))
@ -250,10 +263,10 @@ class AccountPreferenceSerializer(
editor.putBoolean("$accountUuid.subscribedFoldersOnly", isSubscribedFoldersOnly)
editor.putInt("$accountUuid.maximumPolledMessageAge", maximumPolledMessageAge)
editor.putInt("$accountUuid.maximumAutoDownloadMessageSize", maximumAutoDownloadMessageSize)
val messageFormatAuto = if (Account.MessageFormat.AUTO == messageFormat) {
val messageFormatAuto = if (MessageFormat.AUTO == messageFormat) {
// saving MessageFormat.AUTO as is to the database will cause downgrades to crash on
// startup, so we save as MessageFormat.TEXT instead with a separate flag for auto.
editor.putString("$accountUuid.messageFormat", Account.MessageFormat.TEXT.name)
editor.putString("$accountUuid.messageFormat", MessageFormat.TEXT.name)
true
} else {
editor.putString("$accountUuid.messageFormat", messageFormat.name)
@ -299,7 +312,6 @@ class AccountPreferenceSerializer(
saveIdentities(account, storage, editor)
}
@Synchronized
fun delete(editor: StorageEditor, storage: Storage, account: Account) {
val accountUuid = account.uuid
@ -413,7 +425,7 @@ class AccountPreferenceSerializer(
deleteIdentities(account, storage, editor)
var ident = 0
with (account) {
with(account) {
for (identity in identities) {
editor.putString("$uuid.$IDENTITY_NAME_KEY.$ident", identity.name)
editor.putString("$uuid.$IDENTITY_EMAIL_KEY.$ident", identity.email)
@ -488,14 +500,13 @@ class AccountPreferenceSerializer(
defaultEnum
}
}
}
fun loadDefaults(account: Account) {
with (account) {
with(account) {
localStorageProviderId = storageManager.defaultProviderId
automaticCheckIntervalMinutes = Account.INTERVAL_MINUTES_NEVER
automaticCheckIntervalMinutes = INTERVAL_MINUTES_NEVER
idleRefreshMinutes = 24
isPushPollOnConnect = true
displayCount = K9.DEFAULT_VISIBLE_LIMIT
@ -557,7 +568,7 @@ class AccountPreferenceSerializer(
)
identities.add(identity)
with (notificationSetting) {
with(notificationSetting) {
isVibrateEnabled = false
vibratePattern = 0
vibrateTimes = 5

View file

@ -1,8 +1,8 @@
package com.fsck.k9
import android.app.Activity
import androidx.annotation.StringRes
import android.widget.Toast
import androidx.annotation.StringRes
fun Activity.finishWithErrorToast(@StringRes errorRes: Int, vararg formatArgs: String) {
val text = getString(errorRes, *formatArgs)

View file

@ -1,5 +1,5 @@
package com.fsck.k9
data class AppConfig(
val componentsToDisable: List<Class<*>>
val componentsToDisable: List<Class<*>>
)

View file

@ -13,8 +13,8 @@ import com.fsck.k9.mail.internet.BinaryTempFileBody
import com.fsck.k9.service.BootReceiver
import com.fsck.k9.service.ShutdownReceiver
import com.fsck.k9.service.StorageGoneReceiver
import timber.log.Timber
import java.util.concurrent.SynchronousQueue
import timber.log.Timber
object Core : EarlyInit {
private val context: Context by inject()
@ -83,7 +83,6 @@ object Core : EarlyInit {
if (enabled) {
jobManager.scheduleAllMailJobs()
}
}
/**

View file

@ -8,8 +8,8 @@ import org.koin.core.context.startKoin
import org.koin.core.module.Module
import org.koin.core.parameter.ParametersDefinition
import org.koin.core.qualifier.Qualifier
import org.koin.java.KoinJavaComponent.getKoin
import org.koin.java.KoinJavaComponent.get as koinGet
import org.koin.java.KoinJavaComponent.getKoin
object DI {
private const val DEBUG = false
@ -35,6 +35,6 @@ interface EarlyInit
// Copied from ComponentCallbacks.inject()
inline fun <reified T : Any> EarlyInit.inject(
qualifier: Qualifier? = null,
noinline parameters: ParametersDefinition? = null
qualifier: Qualifier? = null,
noinline parameters: ParametersDefinition? = null
) = lazy { getKoin().get<T>(qualifier, parameters) }

View file

@ -2,7 +2,6 @@ package com.fsck.k9
import android.text.util.Rfc822Tokenizer
import android.widget.AutoCompleteTextView.Validator
import java.util.regex.Pattern
class EmailAddressValidator : Validator {
@ -15,8 +14,8 @@ class EmailAddressValidator : Validator {
companion object {
//https://www.rfc-editor.org/rfc/rfc2396.txt (3.2.2)
//https://www.rfc-editor.org/rfc/rfc5321.txt (4.1.2)
// https://www.rfc-editor.org/rfc/rfc2396.txt (3.2.2)
// https://www.rfc-editor.org/rfc/rfc5321.txt (4.1.2)
private const val ALPHA = "[a-zA-Z]"
private const val ALPHANUM = "[a-zA-Z0-9]"

View file

@ -5,12 +5,12 @@ import kotlinx.android.parcel.Parcelize
@Parcelize
data class Identity(
val description: String? = null,
val name: String? = null,
val email: String? = null,
val signature: String? = null,
val signatureUse: Boolean = false,
val replyTo: String? = null
val description: String? = null,
val name: String? = null,
val email: String? = null,
val signature: String? = null,
val signatureUse: Boolean = false,
val replyTo: String? = null
) : Parcelable {
// TODO remove when callers are converted to Kotlin
fun withName(name: String?) = copy(name = name)

View file

@ -15,14 +15,12 @@ import timber.log.Timber.DebugTree
object K9 : EarlyInit {
private val preferences: Preferences by inject()
/**
* If this is `true`, various development settings will be enabled.
*/
@JvmField
val DEVELOPER_MODE = BuildConfig.DEBUG
private const val VERSION_MIGRATE_OPENPGP_TO_ACCOUNTS = 63
/**
@ -53,7 +51,6 @@ object K9 : EarlyInit {
*/
private var databasesUpToDate = false
/**
* Check if we already know whether all databases are using the current database schema.
*
@ -132,7 +129,6 @@ object K9 : EarlyInit {
.commit()
}
@JvmStatic
var isDebugLoggingEnabled: Boolean = DEVELOPER_MODE
set(debug) {
@ -319,7 +315,6 @@ object K9 : EarlyInit {
K9.sortAscending[sortType] = sortAscending
}
fun init(context: Context) {
K9MailLib.setDebugStatus(object : K9MailLib.DebugStatus {
override fun enabled(): Boolean = isDebugLoggingEnabled
@ -554,7 +549,6 @@ object K9 : EarlyInit {
const val MAIL_SERVICE_WAKE_LOCK_TIMEOUT = 60000
const val BOOT_RECEIVER_WAKE_LOCK_TIMEOUT = 60000
enum class AppTheme {
LIGHT,
DARK,

View file

@ -7,7 +7,7 @@ import java.security.cert.CertificateException
import java.security.cert.X509Certificate
class LocalKeyStoreManager(
private val localKeyStore: LocalKeyStore
private val localKeyStore: LocalKeyStore
) {
/**
* Add a new certificate for the incoming or outgoing server to the local key store.
@ -60,4 +60,4 @@ class LocalKeyStoreManager(
localKeyStore.deleteCertificate(uri.host, uri.port)
}
}
}
}

View file

@ -2,13 +2,14 @@ package com.fsck.k9.autocrypt
import com.fsck.k9.message.CryptoStatus
data class AutocryptDraftStateHeader(val isEncrypt: Boolean,
val isSignOnly: Boolean,
val isReply: Boolean,
val isByChoice: Boolean,
val isPgpInline: Boolean,
val parameters: Map<String, String> = mapOf()) {
data class AutocryptDraftStateHeader(
val isEncrypt: Boolean,
val isSignOnly: Boolean,
val isReply: Boolean,
val isByChoice: Boolean,
val isPgpInline: Boolean,
val parameters: Map<String, String> = mapOf()
) {
fun toHeaderValue(): String {
val builder = StringBuilder()
@ -42,7 +43,7 @@ data class AutocryptDraftStateHeader(val isEncrypt: Boolean,
const val PARAM_PGP_INLINE = "_pgp-inline"
const val PARAM_SIGN_ONLY = "_sign-only"
const val VALUE_YES = "yes";
const val VALUE_YES = "yes"
@JvmStatic
fun fromCryptoStatus(cryptoStatus: CryptoStatus): AutocryptDraftStateHeader {

View file

@ -1,9 +1,7 @@
package com.fsck.k9.autocrypt
import com.fsck.k9.mail.internet.MimeUtility
class AutocryptDraftStateHeaderParser internal constructor() {
fun parseAutocryptDraftStateHeader(headerValue: String): AutocryptDraftStateHeader? {

View file

@ -1,11 +1,9 @@
package com.fsck.k9.autocrypt
import com.fsck.k9.K9
import com.fsck.k9.mail.Address
import com.fsck.k9.mail.Flag
import com.fsck.k9.mail.Message
import com.fsck.k9.mail.Message.RecipientType
import com.fsck.k9.mail.MessagingException
import com.fsck.k9.mail.internet.MimeBodyPart
import com.fsck.k9.mail.internet.MimeHeader
@ -16,7 +14,6 @@ import com.fsck.k9.mail.internet.TextBody
import com.fsck.k9.mailstore.BinaryMemoryBody
import java.util.Date
class AutocryptTransferMessageCreator(private val stringProvider: AutocryptStringProvider) {
fun createAutocryptTransferMessage(data: ByteArray, address: Address): Message {
try {

View file

@ -7,9 +7,8 @@ import com.fsck.k9.mail.ServerSettings
class BackendManager(private val backendFactories: Map<String, BackendFactory>) {
private val backendCache = mutableMapOf<String, BackendContainer>()
fun getBackend(account: Account): Backend {
synchronized (backendCache) {
synchronized(backendCache) {
val container = backendCache[account.uuid]
return if (container != null && isBackendStillValid(container, account)) {
container.backend
@ -26,7 +25,7 @@ class BackendManager(private val backendFactories: Map<String, BackendFactory>)
}
fun removeBackend(account: Account) {
synchronized (backendCache) {
synchronized(backendCache) {
backendCache.remove(account.uuid)
}
}
@ -82,6 +81,5 @@ class BackendManager(private val backendFactories: Map<String, BackendFactory>)
throw IllegalArgumentException("Unsupported ServerSettings type")
}
private data class BackendContainer(val backend: Backend, val storeUri: String, val transportUri: String)
}

View file

@ -5,7 +5,6 @@ import com.fsck.k9.backend.BackendManager
interface ControllerExtension {
fun init(controller: MessagingController, backendManager: BackendManager, controllerInternals: ControllerInternals)
interface ControllerInternals {
fun put(description: String, listener: MessagingListener?, runnable: Runnable)
fun putBackground(description: String, listener: MessagingListener?, runnable: Runnable)

View file

@ -16,10 +16,10 @@ interface UnreadMessageCountProvider {
}
internal class DefaultUnreadMessageCountProvider(
private val context: Context,
private val preferences: Preferences,
private val accountSearchConditions: AccountSearchConditions,
private val localStoreProvider: LocalStoreProvider
private val context: Context,
private val preferences: Preferences,
private val accountSearchConditions: AccountSearchConditions,
private val localStoreProvider: LocalStoreProvider
) : UnreadMessageCountProvider {
override fun getUnreadMessageCount(account: Account): Int {
if (!account.isAvailable(context)) {

View file

@ -9,9 +9,9 @@ interface EncryptionExtractor {
}
data class EncryptionResult(
val encryptionType: String,
val attachmentCount: Int,
val previewResult: PreviewResult = PreviewResult.encrypted(),
val textForSearchIndex: String? = null,
val extraContentValues: ContentValues? = null
val encryptionType: String,
val attachmentCount: Int,
val previewResult: PreviewResult = PreviewResult.encrypted(),
val textForSearchIndex: String? = null,
val extraContentValues: ContentValues? = null
)

View file

@ -3,7 +3,6 @@ package com.fsck.k9.helper
import android.content.ClipData
import android.content.Context
/**
* Access the system clipboard
*/

View file

@ -5,7 +5,6 @@ import com.fsck.k9.Identity
import com.fsck.k9.mail.Message
import com.fsck.k9.mail.Message.RecipientType
object IdentityHelper {
private val RECIPIENT_TYPES = listOf(
RecipientType.TO,

View file

@ -5,9 +5,9 @@ import com.fsck.k9.Preferences
import timber.log.Timber
class K9JobManager(
private val workManager: WorkManager,
private val preferences: Preferences,
private val mailSyncWorkerManager: MailSyncWorkerManager
private val workManager: WorkManager,
private val preferences: Preferences,
private val mailSyncWorkerManager: MailSyncWorkerManager
) {
fun scheduleAllMailJobs() {
Timber.v("scheduling all jobs")

View file

@ -8,13 +8,13 @@ import com.fsck.k9.Preferences
import com.fsck.k9.controller.MessagingController
class K9WorkerFactory(
private val messagingController: MessagingController,
private val preferences: Preferences
private val messagingController: MessagingController,
private val preferences: Preferences
) : WorkerFactory() {
override fun createWorker(
appContext: Context,
workerClassName: String,
workerParameters: WorkerParameters
appContext: Context,
workerClassName: String,
workerParameters: WorkerParameters
): ListenableWorker? {
return when (workerClassName) {
MailSyncWorker::class.java.canonicalName -> {

View file

@ -9,10 +9,10 @@ import com.fsck.k9.service.CoreService
import timber.log.Timber
class MailSyncWorker(
private val messagingController: MessagingController,
private val preferences: Preferences,
context: Context,
parameters: WorkerParameters
private val messagingController: MessagingController,
private val preferences: Preferences,
context: Context,
parameters: WorkerParameters
) : Worker(context, parameters) {
override fun doWork(): Result {

View file

@ -7,8 +7,8 @@ import androidx.work.PeriodicWorkRequestBuilder
import androidx.work.WorkManager
import androidx.work.workDataOf
import com.fsck.k9.Account
import timber.log.Timber
import java.util.concurrent.TimeUnit
import timber.log.Timber
class MailSyncWorkerManager(private val workManager: WorkManager) {

View file

@ -7,9 +7,9 @@ import com.fsck.k9.mail.Folder.FolderClass
import com.fsck.k9.mail.Folder.FolderType as RemoteFolderType
class FolderRepository(
private val localStoreProvider: LocalStoreProvider,
private val specialFolderSelectionStrategy: SpecialFolderSelectionStrategy,
private val account: Account
private val localStoreProvider: LocalStoreProvider,
private val specialFolderSelectionStrategy: SpecialFolderSelectionStrategy,
private val account: Account
) {
private val sortForDisplay =
compareByDescending<DisplayFolder> { it.folder.serverId == account.inboxFolder }
@ -18,7 +18,6 @@ class FolderRepository(
.thenByDescending { it.isInTopGroup }
.thenBy(String.CASE_INSENSITIVE_ORDER) { it.folder.name }
fun getRemoteFolderInfo(): RemoteFolderInfo {
val folders = getRemoteFolders()
val automaticSpecialFolders = mapOf(
@ -104,7 +103,6 @@ class FolderRepository(
}
}
private fun folderTypeOf(serverId: String) = when (serverId) {
account.inboxFolder -> FolderType.INBOX
account.outboxFolder -> FolderType.OUTBOX
@ -119,7 +117,7 @@ class FolderRepository(
private fun RemoteFolderType.toFolderType(): FolderType = when (this) {
RemoteFolderType.REGULAR -> FolderType.REGULAR
RemoteFolderType.INBOX -> FolderType.INBOX
RemoteFolderType.OUTBOX -> FolderType.REGULAR // We currently don't support remote Outbox folders
RemoteFolderType.OUTBOX -> FolderType.REGULAR // We currently don't support remote Outbox folders
RemoteFolderType.DRAFTS -> FolderType.DRAFTS
RemoteFolderType.SENT -> FolderType.SENT
RemoteFolderType.TRASH -> FolderType.TRASH
@ -131,9 +129,9 @@ class FolderRepository(
data class Folder(val id: Long, val serverId: String, val name: String, val type: FolderType)
data class DisplayFolder(
val folder: Folder,
val isInTopGroup: Boolean,
val unreadCount: Int
val folder: Folder,
val isInTopGroup: Boolean,
val unreadCount: Int
)
data class RemoteFolderInfo(val folders: List<Folder>, val automaticSpecialFolders: Map<FolderType, Folder?>)

View file

@ -3,8 +3,8 @@ package com.fsck.k9.mailstore
import com.fsck.k9.Account
class FolderRepositoryManager(
private val localStoreProvider: LocalStoreProvider,
private val specialFolderSelectionStrategy: SpecialFolderSelectionStrategy
private val localStoreProvider: LocalStoreProvider,
private val specialFolderSelectionStrategy: SpecialFolderSelectionStrategy
) {
fun getFolderRepository(account: Account) = FolderRepository(localStoreProvider, specialFolderSelectionStrategy, account)
}

View file

@ -3,7 +3,6 @@ package com.fsck.k9.mailstore
import com.fsck.k9.mail.Folder.FolderType
@JvmName("fromDatabaseFolderType")
fun String.toFolderType(): FolderType {
return when (this) {

View file

@ -14,10 +14,10 @@ import com.fsck.k9.mail.Message
import java.util.Date
class K9BackendFolder(
private val preferences: Preferences,
private val account: Account,
private val localStore: LocalStore,
private val folderServerId: String
private val preferences: Preferences,
private val account: Account,
private val localStore: LocalStore,
private val folderServerId: String
) : BackendFolder {
private val database = localStore.database
private val databaseId: String
@ -25,7 +25,6 @@ class K9BackendFolder(
override val name: String
override val visibleLimit: Int
init {
data class Init(val databaseId: String, val name: String, val visibleLimit: Int)
@ -283,12 +282,11 @@ class K9BackendFolder(
}
}
private fun LockableDatabase.getString(
table: String = "folders",
column: String,
selection: String = "id = ?",
vararg selectionArgs: String = arrayOf(databaseId)
table: String = "folders",
column: String,
selection: String = "id = ?",
vararg selectionArgs: String = arrayOf(databaseId)
): String? {
return execute(false) { db ->
val cursor = db.query(table, arrayOf(column), selection, selectionArgs, null, null, null)
@ -303,10 +301,10 @@ class K9BackendFolder(
}
private fun LockableDatabase.getStringOrNull(
table: String = "folders",
column: String,
selection: String = "id = ?",
vararg selectionArgs: String = arrayOf(databaseId)
table: String = "folders",
column: String,
selection: String = "id = ?",
vararg selectionArgs: String = arrayOf(databaseId)
): String? {
return execute(false) { db ->
val cursor = db.query(table, arrayOf(column), selection, selectionArgs, null, null, null)
@ -321,11 +319,11 @@ class K9BackendFolder(
}
private fun LockableDatabase.setString(
table: String = "folders",
column: String,
value: String?,
selection: String = "id = ?",
vararg selectionArgs: String = arrayOf(databaseId)
table: String = "folders",
column: String,
value: String?,
selection: String = "id = ?",
vararg selectionArgs: String = arrayOf(databaseId)
) {
execute(false) { db ->
val contentValues = ContentValues().apply {
@ -336,9 +334,9 @@ class K9BackendFolder(
}
private fun LockableDatabase.setMessagesBoolean(
messageServerId: String,
column: String,
value: Boolean
messageServerId: String,
column: String,
value: Boolean
) {
execute(false) { db ->
val contentValues = ContentValues().apply {
@ -349,10 +347,10 @@ class K9BackendFolder(
}
private fun LockableDatabase.getLongOrNull(
table: String = "folders",
column: String,
selection: String = "id = ?",
vararg selectionArgs: String = arrayOf(databaseId)
table: String = "folders",
column: String,
selection: String = "id = ?",
vararg selectionArgs: String = arrayOf(databaseId)
): Long? {
return execute(false) { db ->
val cursor = db.query(table, arrayOf(column), selection, selectionArgs, null, null, null)
@ -367,11 +365,11 @@ class K9BackendFolder(
}
private fun LockableDatabase.setLong(
table: String = "folders",
column: String,
value: Long,
selection: String = "id = ?",
vararg selectionArgs: String = arrayOf(databaseId)
table: String = "folders",
column: String,
value: Long,
selection: String = "id = ?",
vararg selectionArgs: String = arrayOf(databaseId)
) {
execute(false) { db ->
val contentValues = ContentValues().apply {

View file

@ -11,14 +11,13 @@ import com.fsck.k9.backend.api.FolderInfo
import com.fsck.k9.mail.Folder.FolderType as RemoteFolderType
class K9BackendStorage(
private val preferences: Preferences,
private val account: Account,
private val localStore: LocalStore,
private val specialFolderUpdater: SpecialFolderUpdater
private val preferences: Preferences,
private val account: Account,
private val localStore: LocalStore,
private val specialFolderUpdater: SpecialFolderUpdater
) : BackendStorage {
private val database = localStore.database
override fun getFolder(folderServerId: String): BackendFolder {
return K9BackendFolder(preferences, account, localStore, folderServerId)
}

View file

@ -4,9 +4,9 @@ import com.fsck.k9.Account
import com.fsck.k9.Preferences
class K9BackendStorageFactory(
private val preferences: Preferences,
private val folderRepositoryManager: FolderRepositoryManager,
private val localStoreProvider: LocalStoreProvider
private val preferences: Preferences,
private val folderRepositoryManager: FolderRepositoryManager,
private val localStoreProvider: LocalStoreProvider
) {
fun createBackendStorage(account: Account): K9BackendStorage {
val folderRepository = folderRepositoryManager.getFolderRepository(account)

View file

@ -27,4 +27,4 @@ class LocalStoreProvider {
val accountUuid = account.uuid
localStores.remove(accountUuid)
}
}
}

View file

@ -2,13 +2,12 @@ package com.fsck.k9.mailstore
import android.database.Cursor
internal fun <T> LockableDatabase.query(
table: String,
columns: Array<String>,
selection: String?,
vararg selectionArgs: String,
block: (Cursor) -> T
table: String,
columns: Array<String>,
selection: String?,
vararg selectionArgs: String,
block: (Cursor) -> T
): T {
return execute(false) { db ->
val cursor = db.query(table, columns, selection, selectionArgs, null, null, null)

View file

@ -6,9 +6,9 @@ import com.fsck.k9.message.html.HtmlProcessorFactory
import com.fsck.k9.message.html.HtmlSettings
class MessageViewInfoExtractorFactory(
private val attachmentInfoExtractor: AttachmentInfoExtractor,
private val htmlProcessorFactory: HtmlProcessorFactory,
private val resourceProvider: CoreResourceProvider
private val attachmentInfoExtractor: AttachmentInfoExtractor,
private val htmlProcessorFactory: HtmlProcessorFactory,
private val resourceProvider: CoreResourceProvider
) {
fun create(settings: HtmlSettings): MessageViewInfoExtractor {
val htmlProcessor = htmlProcessorFactory.create(settings)

View file

@ -1,8 +1,8 @@
package com.fsck.k9.mailstore
data class OutboxState(
val sendState: SendState,
val numberOfSendAttempts: Int,
val sendError: String?,
val sendErrorTimestamp: Long
val sendState: SendState,
val numberOfSendAttempts: Int,
val sendError: String?,
val sendErrorTimestamp: Long
)

View file

@ -95,7 +95,6 @@ class OutboxStateRepository(private val database: LockableDatabase, private val
}
}
companion object {
private const val TABLE_NAME = "outbox_state"
private const val COLUMN_MESSAGE_ID = "message_id"

View file

@ -9,9 +9,9 @@ import com.fsck.k9.Preferences
* as [SpecialFolderSelection.MANUAL] but have been deleted from the server.
*/
class SpecialFolderUpdater(
private val preferences: Preferences,
private val folderRepository: FolderRepository,
private val account: Account
private val preferences: Preferences,
private val folderRepository: FolderRepository,
private val account: Account
) {
fun updateSpecialFolders() {
val (folders, automaticSpecialFolders) = folderRepository.getRemoteFolderInfo()
@ -31,9 +31,9 @@ class SpecialFolderUpdater(
}
private fun updateSpecialFolder(
type: FolderType,
folders: List<Folder>,
automaticSpecialFolders: Map<FolderType, Folder?>
type: FolderType,
folders: List<Folder>,
automaticSpecialFolders: Map<FolderType, Folder?>
) {
when (getSpecialFolderSelection(type)) {
SpecialFolderSelection.AUTOMATIC -> {

View file

@ -7,7 +7,6 @@ interface Attachment {
val name: String?
val size: Long?
enum class LoadingState {
URI_ONLY,
METADATA,

View file

@ -11,14 +11,12 @@ internal object DividerReplacer : TextToHtml.HtmlModifier {
"(?:\\n|$)" +
")+")
override fun findModifications(text: CharSequence): List<HtmlModification> {
return PATTERN.findAll(text).map { matchResult ->
Divider(matchResult.range.start, matchResult.range.endInclusive + 1)
}.toList()
}
class Divider(startIndex: Int, endIndex: Int) : HtmlModification.Replace(startIndex, endIndex) {
override fun replace(textToHtml: TextToHtml) {
textToHtml.appendHtml("<hr>")

View file

@ -90,7 +90,6 @@ class EmailSection private constructor(builder: Builder) : CharSequence {
}
}.toString()
internal data class Segment(val startIndex: Int, val endIndex: Int)
class Builder(val text: String, val quoteDepth: Int) {
@ -114,4 +113,3 @@ class EmailSection private constructor(builder: Builder) : CharSequence {
fun build() = EmailSection(this)
}
}

View file

@ -55,7 +55,6 @@ class EmailTextToHtml private constructor(private val text: String) {
else -> "#ccc"
}
companion object {
private const val EXTRA_BUFFER_LENGTH = 2048
const val K9MAIL_CSS_CLASS = "k9mail"

View file

@ -1,6 +1,5 @@
package com.fsck.k9.message.html
import org.jsoup.Jsoup
/**
@ -13,15 +12,14 @@ object HtmlConverter {
* define the object character and the replacement character.
*/
private const val PREVIEW_OBJECT_CHARACTER = 0xfffc.toChar()
private const val PREVIEW_OBJECT_REPLACEMENT = 0x20.toChar() // space
private const val PREVIEW_OBJECT_REPLACEMENT = 0x20.toChar() // space
/**
* toHtml() converts non-breaking spaces into the UTF-8 non-breaking space, which doesn't get
* rendered properly in some clients. Replace it with a simple space.
*/
private const val NBSP_CHARACTER = 0x00a0.toChar() // utf-8 non-breaking space
private const val NBSP_REPLACEMENT = 0x20.toChar() // space
private const val NBSP_CHARACTER = 0x00a0.toChar() // utf-8 non-breaking space
private const val NBSP_REPLACEMENT = 0x20.toChar() // space
/**
* Convert an HTML string to a plain text string.

View file

@ -1,8 +1,8 @@
package com.fsck.k9.message.html
class HtmlProcessorFactory(
private val htmlSanitizer: HtmlSanitizer,
private val displayHtmlFactory: DisplayHtmlFactory
private val htmlSanitizer: HtmlSanitizer,
private val displayHtmlFactory: DisplayHtmlFactory
) {
fun create(settings: HtmlSettings): HtmlProcessor {
val displayHtml = displayHtmlFactory.create(settings)

View file

@ -1,6 +1,6 @@
package com.fsck.k9.message.html
data class HtmlSettings(
val useDarkMode: Boolean,
val useFixedWidthFont: Boolean
val useDarkMode: Boolean,
val useFixedWidthFont: Boolean
)

View file

@ -117,7 +117,6 @@ private class FormattingVisitor : NodeVisitor {
return output.substring(0, lastIndex + 1)
}
companion object {
private const val MAX_WIDTH = 76
}

View file

@ -7,11 +7,10 @@ internal object UriLinkifier : TextToHtml.HtmlModifier {
}
}
class LinkifyUri(
startIndex: Int,
endIndex: Int,
val uri: CharSequence
startIndex: Int,
endIndex: Int,
val uri: CharSequence
) : HtmlModification.Wrap(startIndex, endIndex) {
override fun appendPrefix(textToHtml: TextToHtml) {

View file

@ -1,7 +1,7 @@
package com.fsck.k9.message.html
data class UriMatch(
val startIndex: Int,
val endIndex: Int,
val uri: CharSequence
val startIndex: Int,
val endIndex: Int,
val uri: CharSequence
)

View file

@ -1,6 +1,6 @@
package com.fsck.k9.message.html
import java.util.*
import java.util.Locale
object UriMatcher {
private val SUPPORTED_URIS = { httpUriParser: HttpUriParser ->
@ -20,7 +20,6 @@ object UriMatcher {
RegexOption.IGNORE_CASE
)
fun findUris(text: CharSequence): List<UriMatch> {
return URI_SCHEME.findAll(text).map { matchResult ->
val matchGroup = matchResult.groups[1]!!

View file

@ -1,6 +1,5 @@
package com.fsck.k9.message.html
internal interface UriParser {
/**
* Parse scheme specific URI beginning from given position.

View file

@ -1,16 +1,12 @@
package com.fsck.k9.message.quote
import android.content.res.Resources
import com.fsck.k9.K9
import com.fsck.k9.mail.Message
import java.text.DateFormat
import java.util.Locale
import java.util.TimeZone
import android.content.res.Resources
import com.fsck.k9.K9
import com.fsck.k9.mail.Message
class QuoteHelper(private val resources: Resources) {
/**
@ -41,7 +37,6 @@ class QuoteHelper(private val resources: Resources) {
}
}
companion object {
// amount of extra buffer to allocate to accommodate quoting headers or prefixes
const val QUOTE_BUFFER_LENGTH = 512

View file

@ -1,6 +1,5 @@
package com.fsck.k9.message.quote
import com.fsck.k9.Account.QuoteStyle
import com.fsck.k9.CoreResourceProvider
import com.fsck.k9.mail.Address
@ -8,16 +7,14 @@ import com.fsck.k9.mail.Message
import com.fsck.k9.mail.Message.RecipientType
import com.fsck.k9.message.quote.QuoteHelper.Companion.QUOTE_BUFFER_LENGTH
class TextQuoteCreator(private val quoteHelper: QuoteHelper, private val resourceProvider: CoreResourceProvider) {
private val prefixInsertionRegex = Regex("(?m)^")
fun quoteOriginalTextMessage(
originalMessage: Message,
messageBody: String?,
quoteStyle: QuoteStyle,
prefix: String
originalMessage: Message,
messageBody: String?,
quoteStyle: QuoteStyle,
prefix: String
): String {
val body = messageBody ?: ""
return when (quoteStyle) {
@ -96,7 +93,6 @@ class TextQuoteCreator(private val quoteHelper: QuoteHelper, private val resourc
private fun Array<Address>.displayString() = Address.toString(this)?.let { if (it.isEmpty()) null else it }
companion object {
private const val CRLF = "\r\n"
}

View file

@ -4,8 +4,8 @@ import android.app.NotificationManager
import android.content.Context
import androidx.core.app.NotificationManagerCompat
import com.fsck.k9.AccountPreferenceSerializer
import org.koin.dsl.module
import java.util.concurrent.Executors
import org.koin.dsl.module
val coreNotificationModule = module {
single { NotificationController(get(), get(), get(), get(), get()) }

View file

@ -1,6 +1,5 @@
package com.fsck.k9.notification
import android.app.NotificationChannel
import android.app.NotificationChannelGroup
import android.app.NotificationManager
@ -11,10 +10,10 @@ import com.fsck.k9.Preferences
import java.util.concurrent.Executor
class NotificationChannelManager(
private val preferences: Preferences,
private val backgroundExecutor: Executor,
private val notificationManager: NotificationManager,
private val resourceProvider: NotificationResourceProvider
private val preferences: Preferences,
private val backgroundExecutor: Executor,
private val notificationManager: NotificationManager,
private val resourceProvider: NotificationResourceProvider
) {
enum class ChannelType {
@ -36,12 +35,13 @@ class NotificationChannelManager(
removeChannelsForNonExistingOrChangedAccounts(notificationManager, accounts)
addChannelsForAccounts(notificationManager, accounts)
}
}
@RequiresApi(api = Build.VERSION_CODES.O)
private fun addChannelsForAccounts(
notificationManager: NotificationManager, accounts: List<Account>) {
notificationManager: NotificationManager,
accounts: List<Account>
) {
for (account in accounts) {
val groupId = account.uuid
val group = NotificationChannelGroup(groupId, account.displayName)
@ -57,7 +57,9 @@ class NotificationChannelManager(
@RequiresApi(api = Build.VERSION_CODES.O)
private fun removeChannelsForNonExistingOrChangedAccounts(
notificationManager: NotificationManager, accounts: List<Account>) {
notificationManager: NotificationManager,
accounts: List<Account>
) {
val existingAccounts = HashMap<String, Account>()
for (account in accounts) {
existingAccounts[account.uuid] = account

View file

@ -2,23 +2,25 @@ package com.fsck.k9.notification
import android.content.Context
import android.net.Uri
import android.text.TextUtils
import androidx.core.app.NotificationCompat
import androidx.core.app.NotificationManagerCompat
import android.text.TextUtils
import com.fsck.k9.Account
import com.fsck.k9.K9
class NotificationHelper(
private val context: Context,
private val notificationManager: NotificationManagerCompat,
private val channelUtils: NotificationChannelManager
private val context: Context,
private val notificationManager: NotificationManagerCompat,
private val channelUtils: NotificationChannelManager
) {
fun configureNotification(
builder: NotificationCompat.Builder,
ringtone: String?,
vibrationPattern: LongArray?,
ledColor: Int?, ledSpeed: Int,
ringAndVibrate: Boolean) {
builder: NotificationCompat.Builder,
ringtone: String?,
vibrationPattern: LongArray?,
ledColor: Int?,
ledSpeed: Int,
ringAndVibrate: Boolean
) {
if (K9.isQuietTime) {
return
@ -63,14 +65,13 @@ class NotificationHelper(
}
fun createNotificationBuilder(
account: Account,
channelType: NotificationChannelManager.ChannelType
account: Account,
channelType: NotificationChannelManager.ChannelType
): NotificationCompat.Builder {
return NotificationCompat.Builder(context,
channelUtils.getChannelIdFor(account, channelType))
}
companion object {
private const val NOTIFICATION_LED_ON_TIME = 500
private const val NOTIFICATION_LED_OFF_TIME = 2000

View file

@ -1,17 +1,15 @@
package com.fsck.k9.notification
import com.fsck.k9.Account
import com.fsck.k9.K9
import com.fsck.k9.helper.Contacts
import com.fsck.k9.mail.Flag
import com.fsck.k9.mail.Folder
import com.fsck.k9.mailstore.LocalFolder
import com.fsck.k9.mail.Message
import com.fsck.k9.mailstore.LocalFolder
interface NotificationStrategy {
fun shouldNotifyForMessage(account: Account,
localFolder: LocalFolder,
message: Message,
isOldMessage:Boolean):Boolean
}
fun shouldNotifyForMessage(
account: Account,
localFolder: LocalFolder,
message: Message,
isOldMessage: Boolean
): Boolean
}

View file

@ -2,7 +2,6 @@ package com.fsck.k9.preferences
import android.content.SharedPreferences
interface StorageEditor {
fun copy(input: SharedPreferences)

View file

@ -2,7 +2,6 @@ package com.fsck.k9.preferences
import androidx.annotation.CheckResult
interface StoragePersister {
@CheckResult
fun loadValues(): Map<String, String>

View file

@ -4,7 +4,9 @@ import com.fsck.k9.Account
import com.fsck.k9.Account.FolderMode
import com.fsck.k9.BaseAccount
import com.fsck.k9.mail.Folder.FolderClass
import com.fsck.k9.search.SearchSpecification.*
import com.fsck.k9.search.SearchSpecification.Attribute
import com.fsck.k9.search.SearchSpecification.SearchCondition
import com.fsck.k9.search.SearchSpecification.SearchField
class AccountSearchConditions {
/**
@ -31,7 +33,8 @@ class AccountSearchConditions {
// TODO: Create a proper interface for creating arbitrary condition trees
val searchCondition = SearchCondition(
SearchField.DISPLAY_CLASS, Attribute.EQUALS, FolderClass.SECOND_CLASS.name)
SearchField.DISPLAY_CLASS, Attribute.EQUALS, FolderClass.SECOND_CLASS.name
)
val root = search.conditions
if (root.mRight != null) {
root.mRight.or(searchCondition)
@ -121,4 +124,4 @@ class AccountSearchConditions {
return search
}
}
}

View file

@ -1,6 +1,5 @@
package com.fsck.k9.service
import android.app.AlarmManager
import android.app.PendingIntent
import android.content.Context
@ -22,8 +21,8 @@ class BootReceiver : CoreReceiver(), EarlyInit {
val action = intent.action
if (Intent.ACTION_BOOT_COMPLETED == action) {
//K9.setServicesEnabled(context, tmpWakeLockId);
//tmpWakeLockId = null;
// K9.setServicesEnabled(context, tmpWakeLockId);
// tmpWakeLockId = null;
} else if ("com.android.sync.SYNC_CONN_STATUS_CHANGED" == action) {
val bOps = K9.backgroundOps
if (bOps == K9.BACKGROUND_OPS.WHEN_CHECKED_AUTO_SYNC) {
@ -47,7 +46,6 @@ class BootReceiver : CoreReceiver(), EarlyInit {
alarmMgr.set(AlarmManager.RTC_WAKEUP, atTime, pi)
}
return tmpWakeLockId
}
@ -98,5 +96,4 @@ class BootReceiver : CoreReceiver(), EarlyInit {
}, 0))
}
}
}

View file

@ -2,7 +2,6 @@ package com.fsck.k9.setup
import com.fsck.k9.preferences.Protocols
class ServerNameSuggester {
fun suggestServerName(serverType: String, domainPart: String): String = when (serverType) {
Protocols.IMAP -> "imap.$domainPart"

View file

@ -7,7 +7,7 @@ class EmailAddressValidatorTest {
@Test
fun testEmailValidation() {
//Most of the tests based on https://en.wikipedia.org/wiki/Email_address#Examples
// Most of the tests based on https://en.wikipedia.org/wiki/Email_address#Examples
val validator = EmailAddressValidator()
Assert.assertTrue(validator.isValidAddressOnly("simple@example.com"))
Assert.assertTrue(validator.isValidAddressOnly("very.common@example.com"))

View file

@ -1,13 +1,11 @@
package com.fsck.k9
import com.nhaarman.mockito_kotlin.whenever
import java.util.Calendar
import org.junit.Assert.assertFalse
import org.junit.Assert.assertTrue
import org.junit.Test
import org.mockito.Mockito.mock
import java.util.Calendar
class QuietTimeCheckerTest {
private val clock = mock(Clock::class.java)
@ -108,7 +106,6 @@ class QuietTimeCheckerTest {
assertFalse(quietTimeChecker.isQuietTime)
}
private fun setClockTo(time: String) {
val (hourOfDay, minute) = time.split(':').map { it.toInt() }

View file

@ -1,11 +1,9 @@
package com.fsck.k9.autocrypt
import com.fsck.k9.RobolectricTest
import com.google.common.truth.Truth.assertThat
import org.junit.Test
class AutocryptDraftStateHeaderParserTest : RobolectricTest() {
internal var autocryptHeaderParser = AutocryptDraftStateHeaderParser()
@ -18,18 +16,18 @@ class AutocryptDraftStateHeaderParserTest : RobolectricTest() {
assertThat(parsedHeader).isEqualTo(draftStateHeader)
}
@Test
fun testSignOnly() {
val parsedHeader = autocryptHeaderParser.parseAutocryptDraftStateHeader("encrypt=no; _by-choice=yes; _sign-only=yes")
@Test
fun testSignOnly() {
val parsedHeader = autocryptHeaderParser.parseAutocryptDraftStateHeader("encrypt=no; _by-choice=yes; _sign-only=yes")
with(parsedHeader!!) {
assertThat(isEncrypt).isFalse()
assertThat(isByChoice).isTrue()
assertThat(isSignOnly).isTrue()
assertThat(isPgpInline).isFalse()
assertThat(isReply).isFalse()
}
}
with(parsedHeader!!) {
assertThat(isEncrypt).isFalse()
assertThat(isByChoice).isTrue()
assertThat(isSignOnly).isTrue()
assertThat(isPgpInline).isFalse()
assertThat(isReply).isFalse()
}
}
@Test
fun badCritical() {

View file

@ -1,12 +1,13 @@
package com.fsck.k9.autocrypt
import com.fsck.k9.mail.filter.Base64
import com.fsck.k9.mailstore.MimePartStreamParser
import org.junit.Assert.*
import org.junit.Assert.assertArrayEquals
import org.junit.Assert.assertEquals
import org.junit.Assert.assertNotNull
import org.junit.Assert.assertNull
import org.junit.Test
class AutocryptGossipHeaderParserTest {
val GOSSIP_DATA_BOB = Base64.decodeBase64(
"""mQGNBFoBt74BDAC8AMsjPY17kxodbfmHah38ZQipY0yfuo97WUBs2jeiFYlQdunPANi5VMgbAX+H
@ -93,4 +94,4 @@ Alice
assertNull(gossipHeader)
}
}
}

View file

@ -1,11 +1,9 @@
package com.fsck.k9.crypto
import com.fsck.k9.Identity
import org.junit.Assert.assertEquals
import org.junit.Test
class OpenPgpApiHelperTest {
@Test
@ -30,5 +28,4 @@ class OpenPgpApiHelperTest {
assertEquals("<user@domain.com>", result)
}
}

View file

@ -1,6 +1,5 @@
package com.fsck.k9.helper
import com.fsck.k9.Account
import com.fsck.k9.Identity
import com.fsck.k9.RobolectricTest
@ -10,8 +9,8 @@ import com.fsck.k9.mail.Message.RecipientType
import com.fsck.k9.mail.internet.AddressHeaderBuilder
import com.fsck.k9.mail.internet.MimeMessage
import com.google.common.truth.Truth.assertThat
import java.util.UUID
import org.junit.Test
import java.util.*
class IdentityHelperTest : RobolectricTest() {
private val account = createDummyAccount()
@ -109,7 +108,6 @@ class IdentityHelperTest : RobolectricTest() {
assertThat(identity.email).isEqualTo(DEFAULT_ADDRESS)
}
private fun createDummyAccount() = Account(UUID.randomUUID().toString()).apply {
identities = listOf(
newIdentity("Default", DEFAULT_ADDRESS),

View file

@ -31,7 +31,6 @@ class K9BackendFolderTest : K9RobolectricTest() {
val backendFolder = createBackendFolder()
val database: LockableDatabase = localStoreProvider.getInstance(account).database
@Before
fun setUp() {
// Set EmailProvider.CONTENT_URI so LocalStore.notifyChange() won't crash
@ -84,9 +83,8 @@ class K9BackendFolderTest : K9RobolectricTest() {
assertEquals(200L, lastUid)
}
fun createAccount(): Account {
//FIXME: This is a hack to get Preferences into a state where it's safe to call newAccount()
// FIXME: This is a hack to get Preferences into a state where it's safe to call newAccount()
preferences.clearAccounts()
return preferences.newAccount()
@ -136,7 +134,6 @@ class K9BackendFolderTest : K9RobolectricTest() {
private fun dbOperation(action: (SQLiteDatabase) -> Unit) = database.execute(false, action)
companion object {
const val FOLDER_SERVER_ID = "testFolder"
const val FOLDER_NAME = "Test Folder"

View file

@ -1,16 +1,13 @@
package com.fsck.k9.mailstore
import java.io.ByteArrayInputStream
import com.fsck.k9.mail.internet.MimeBodyPart
import com.fsck.k9.mail.internet.MimeMessage
import com.fsck.k9.mail.internet.MimeMultipart
import java.io.ByteArrayInputStream
import org.junit.Assert.assertEquals
import org.junit.Assert.assertTrue
import org.junit.Test
import org.junit.Assert.*
class MimePartStreamParserTest {
@Test
fun innerMessage_DispositionInline() {
@ -72,4 +69,4 @@ inner text
assertEquals("message/rfc822", messagePart.mimeType)
assertTrue(messagePart.body is DeferredFileBody)
}
}
}

View file

@ -7,7 +7,6 @@ import org.junit.Test
class DisplayHtmlTest {
val displayHtml = DisplayHtml(HtmlSettings(useDarkMode = false, useFixedWidthFont = false))
@Test
fun wrapMessageContent_addsViewportMetaElement() {
val html = displayHtml.wrapMessageContent("Some text")

View file

@ -1,10 +1,8 @@
package com.fsck.k9.message.html
import com.google.common.truth.Truth.assertThat
import org.junit.Test
class EmailSectionExtractorTest {
@Test
fun simpleMessageWithoutQuotes() {

View file

@ -1,10 +1,8 @@
package com.fsck.k9.message.html
import com.google.common.truth.Truth.assertThat
import org.junit.Test
class EmailSectionTest {
@Test
fun charAt() {
@ -65,7 +63,6 @@ class EmailSectionTest {
assertThat(section.subSequence(6, 11).asString()).isEqualTo("Three")
}
private fun CharSequence.asString() = StringBuilder(length).apply {
this@asString.forEach { append(it) }
}.toString()

View file

@ -1,6 +1,5 @@
package com.fsck.k9.message.quote
import android.content.res.Configuration
import android.content.res.Resources
import com.fsck.k9.Account.QuoteStyle
@ -14,11 +13,10 @@ import com.fsck.k9.mail.Message.RecipientType
import com.google.common.truth.Truth.assertThat
import com.nhaarman.mockito_kotlin.doReturn
import com.nhaarman.mockito_kotlin.mock
import org.junit.Before
import org.junit.Test
import java.util.Date
import java.util.Locale
import org.junit.Before
import org.junit.Test
class TextQuoteCreatorTest : RobolectricTest() {
val resources = mock<Resources> {
@ -33,7 +31,6 @@ class TextQuoteCreatorTest : RobolectricTest() {
}
val textQuoteCreator = TextQuoteCreator(QuoteHelper(resources), TestCoreResourceProvider())
@Before
fun setUp() {
K9.isHideTimeZone = true

View file

@ -1,10 +1,10 @@
package com.fsck.k9.preferences
import org.junit.Assert.*
import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
import org.junit.Assert.assertTrue
import org.junit.Test
private const val TEST_STRING_KEY = "s"
private const val TEST_STRING_VALUE = "y"
private const val TEST_INT_KEY = "i"
@ -76,4 +76,4 @@ class StorageTest {
// TODO is this good behavior?
assertEquals(TEST_INT_DEFAULT, storage.getInt(TEST_STRING_KEY, TEST_INT_DEFAULT))
}
}
}

View file

@ -6,7 +6,7 @@ import com.fsck.k9.mail.Message
import com.fsck.k9.message.extractors.TextPartFinder
class OpenPgpEncryptionExtractor internal constructor(
private val encryptionDetector: EncryptionDetector
private val encryptionDetector: EncryptionDetector
) : EncryptionExtractor {
override fun extractEncryption(message: Message): EncryptionResult? {
@ -17,7 +17,6 @@ class OpenPgpEncryptionExtractor internal constructor(
}
}
companion object {
const val ENCRYPTION_TYPE = "openpgp"

View file

@ -12,7 +12,6 @@ class App : Application() {
private val messagingListenerProvider: MessagingListenerProvider by inject()
private val themeManager: ThemeManager by inject()
override fun onCreate() {
Core.earlyInit(this)
@ -30,7 +29,6 @@ class App : Application() {
}
}
companion object {
val appConfig = AppConfig(
componentsToDisable = listOf(MessageCompose::class.java)

View file

@ -19,10 +19,10 @@ import com.fsck.k9.mail.transport.smtp.SmtpTransportUriDecoder
import com.fsck.k9.mailstore.K9BackendStorageFactory
class ImapBackendFactory(
private val context: Context,
private val powerManager: PowerManager,
private val backendStorageFactory: K9BackendStorageFactory,
private val trustedSocketFactory: TrustedSocketFactory
private val context: Context,
private val powerManager: PowerManager,
private val backendStorageFactory: K9BackendStorageFactory,
private val trustedSocketFactory: TrustedSocketFactory
) : BackendFactory {
override val transportUriPrefix = "smtp"

View file

@ -16,8 +16,8 @@ import com.fsck.k9.mail.transport.smtp.SmtpTransportUriDecoder
import com.fsck.k9.mailstore.K9BackendStorageFactory
class Pop3BackendFactory(
private val backendStorageFactory: K9BackendStorageFactory,
private val trustedSocketFactory: TrustedSocketFactory
private val backendStorageFactory: K9BackendStorageFactory,
private val trustedSocketFactory: TrustedSocketFactory
) : BackendFactory {
override val transportUriPrefix = "smtp"

View file

@ -14,8 +14,8 @@ import com.fsck.k9.mail.transport.WebDavTransport
import com.fsck.k9.mailstore.K9BackendStorageFactory
class WebDavBackendFactory(
private val backendStorageFactory: K9BackendStorageFactory,
private val trustManagerFactory: TrustManagerFactory
private val backendStorageFactory: K9BackendStorageFactory,
private val trustManagerFactory: TrustManagerFactory
) : BackendFactory {
override val transportUriPrefix = "webdav"

View file

@ -9,10 +9,12 @@ import com.fsck.k9.mailstore.LocalFolder
class K9NotificationStrategy(val contacts: Contacts) : NotificationStrategy {
override fun shouldNotifyForMessage(account: Account,
localFolder: LocalFolder,
message: Message,
isOldMessage:Boolean):Boolean {
override fun shouldNotifyForMessage(
account: Account,
localFolder: LocalFolder,
message: Message,
isOldMessage: Boolean
): Boolean {
// If we don't even have an account name, don't show the notification.
// (This happens during initial account setup)
@ -50,10 +52,10 @@ class K9NotificationStrategy(val contacts: Contacts) : NotificationStrategy {
val folder = message.folder
if (folder != null) {
val folderServerId = folder.serverId
if (folderServerId != account.inboxFolder && (folderServerId == account.trashFolder
|| folderServerId == account.draftsFolder
|| folderServerId == account.spamFolder
|| folderServerId == account.sentFolder)) {
if (folderServerId != account.inboxFolder && (folderServerId == account.trashFolder ||
folderServerId == account.draftsFolder ||
folderServerId == account.spamFolder ||
folderServerId == account.sentFolder)) {
return false
}
}
@ -63,7 +65,5 @@ class K9NotificationStrategy(val contacts: Contacts) : NotificationStrategy {
return if (account.isAnIdentity(message.from) && !account.isNotifySelfNewMail) {
false
} else !account.isNotifyContactsMailOnly || contacts.isAnyInContacts(message.from)
}
}

View file

@ -27,7 +27,6 @@ import timber.log.Timber
class UnreadWidgetProvider : AppWidgetProvider(), EarlyInit {
private val repository: UnreadWidgetRepository by inject()
override fun onUpdate(context: Context, appWidgetManager: AppWidgetManager, appWidgetIds: IntArray) {
for (widgetId in appWidgetIds) {
val widgetData = repository.getWidgetData(widgetId)

View file

@ -1,8 +1,8 @@
package com.fsck.k9.resources
import android.content.Context
import com.fsck.k9.autocrypt.AutocryptStringProvider
import com.fsck.k9.R
import com.fsck.k9.autocrypt.AutocryptStringProvider
class K9AutocryptStringProvider(private val context: Context) : AutocryptStringProvider {
override fun transferMessageSubject(): String = context.getString(R.string.ac_transfer_msg_subject)

View file

@ -9,7 +9,6 @@ import android.preference.Preference
import android.view.Menu
import android.view.MenuItem
import android.widget.Toast
import com.fsck.k9.Preferences
import com.fsck.k9.R
import com.fsck.k9.activity.ChooseAccount
@ -17,10 +16,8 @@ import com.fsck.k9.activity.ChooseFolder
import com.fsck.k9.activity.K9PreferenceActivity
import com.fsck.k9.search.SearchAccount
import org.koin.android.ext.android.inject
import timber.log.Timber
/**
* Activity to select an account for the unread widget.
*/

View file

@ -3,8 +3,8 @@ package com.fsck.k9.widget.unread
import android.content.Intent
data class UnreadWidgetData(
val configuration: UnreadWidgetConfiguration,
val title: String,
val unreadCount: Int,
val clickIntent: Intent
val configuration: UnreadWidgetConfiguration,
val title: String,
val unreadCount: Int,
val clickIntent: Intent
)

View file

@ -11,9 +11,9 @@ import com.fsck.k9.search.LocalSearch
import com.fsck.k9.search.SearchAccount
class UnreadWidgetDataProvider(
private val context: Context,
private val preferences: Preferences,
private val messagingController: MessagingController
private val context: Context,
private val preferences: Preferences,
private val messagingController: MessagingController
) {
fun loadUnreadWidgetData(configuration: UnreadWidgetConfiguration): UnreadWidgetData? = with(configuration) {
if (SearchAccount.UNIFIED_INBOX == accountUuid) {
@ -59,7 +59,7 @@ class UnreadWidgetDataProvider(
val folderServerId = configuration.folderServerId ?: return null
val accountName = account.description
//FIXME: Use folder display name instead of folderServerId for title
// FIXME: Use folder display name instead of folderServerId for title
val title = context.getString(R.string.unread_widget_title, accountName, folderServerId)
val unreadCount = messagingController.getFolderUnreadMessageCount(account, folderServerId)

View file

@ -3,8 +3,8 @@ package com.fsck.k9.widget.unread
import android.content.Context
class UnreadWidgetRepository(
private val context: Context,
private val dataRetriever: UnreadWidgetDataProvider
private val context: Context,
private val dataRetriever: UnreadWidgetDataProvider
) {
fun saveWidgetConfiguration(configuration: UnreadWidgetConfiguration) {

View file

@ -9,7 +9,6 @@ import com.fsck.k9.provider.UnreadWidgetProvider
class UnreadWidgetUpdater(private val context: Context) {
private val appWidgetManager = AppWidgetManager.getInstance(context)
fun updateAll() {
val thisWidget = ComponentName(context, UnreadWidgetProvider::class.java)
val widgetIds = appWidgetManager.getAppWidgetIds(thisWidget)

View file

@ -2,8 +2,8 @@ package com.fsck.k9.widget.unread
import android.content.Context
import com.fsck.k9.Account
import com.fsck.k9.Preferences
import com.fsck.k9.AppRobolectricTest
import com.fsck.k9.Preferences
import com.fsck.k9.controller.MessagingController
import com.fsck.k9.search.SearchAccount
import com.google.common.truth.Truth.assertThat
@ -14,7 +14,6 @@ import org.junit.Test
import org.mockito.ArgumentMatchers.eq
import org.robolectric.RuntimeEnvironment
class UnreadWidgetDataProviderTest : AppRobolectricTest() {
val context: Context = RuntimeEnvironment.application
val account = createAccount()
@ -22,7 +21,6 @@ class UnreadWidgetDataProviderTest : AppRobolectricTest() {
val messagingController = createMessagingController()
val provider = UnreadWidgetDataProvider(context, preferences, messagingController)
@Test
fun unifiedInbox() {
val configuration = UnreadWidgetConfiguration(
@ -71,7 +69,6 @@ class UnreadWidgetDataProviderTest : AppRobolectricTest() {
assertThat(widgetData).isNull()
}
fun createAccount(): Account = mock {
on { uuid } doReturn ACCOUNT_UUID
on { description } doReturn ACCOUNT_DESCRIPTION

View file

@ -6,8 +6,8 @@ import android.database.sqlite.SQLiteDatabase
* Rewrite folder name values of "-NONE-" to `null`
*/
class StorageMigrationTo3(
private val db: SQLiteDatabase,
private val migrationsHelper: StorageMigrationsHelper
private val db: SQLiteDatabase,
private val migrationsHelper: StorageMigrationsHelper
) {
fun rewriteFolderNone() {
val accountUuidsListValue = migrationsHelper.readValue(db, "accountUuids")
@ -37,7 +37,6 @@ class StorageMigrationTo3(
}
}
companion object {
private const val OLD_FOLDER_VALUE = "-NONE-"
private val NEW_FOLDER_VALUE = null

View file

@ -6,8 +6,8 @@ import android.database.sqlite.SQLiteDatabase
* Add `*FolderSelection` values of "MANUAL" for existing accounts (default for new accounts is "AUTOMATIC").
*/
class StorageMigrationTo4(
private val db: SQLiteDatabase,
private val migrationsHelper: StorageMigrationsHelper
private val db: SQLiteDatabase,
private val migrationsHelper: StorageMigrationsHelper
) {
fun insertSpecialFolderSelectionValues() {
val accountUuidsListValue = migrationsHelper.readValue(db, "accountUuids")

View file

@ -6,8 +6,8 @@ import android.database.sqlite.SQLiteDatabase
* Rewrite frequencies lower than LOWEST_FREQUENCY_SUPPORTED
*/
class StorageMigrationTo5(
private val db: SQLiteDatabase,
private val migrationsHelper: StorageMigrationsHelper
private val db: SQLiteDatabase,
private val migrationsHelper: StorageMigrationsHelper
) {
fun fixMailCheckFrequencies() {
val accountUuidsListValue = migrationsHelper.readValue(db, "accountUuids")
@ -29,7 +29,6 @@ class StorageMigrationTo5(
}
}
companion object {
// see: https://github.com/evernote/android-job/wiki/FAQ#why-cant-an-interval-be-smaller-than-15-minutes-for-periodic-jobs
private const val LOWEST_FREQUENCY_SUPPORTED = 15

View file

@ -6,8 +6,8 @@ import android.database.sqlite.SQLiteDatabase
* Perform legacy conversions that previously lived in `K9`.
*/
class StorageMigrationTo6(
private val db: SQLiteDatabase,
private val migrationsHelper: StorageMigrationsHelper
private val db: SQLiteDatabase,
private val migrationsHelper: StorageMigrationsHelper
) {
fun performLegacyMigrations() {
rewriteKeyguardPrivacy()

View file

@ -6,8 +6,8 @@ import android.database.sqlite.SQLiteDatabase
* Rewrite settings to use enum names instead of ordinals.
*/
class StorageMigrationTo7(
private val db: SQLiteDatabase,
private val migrationsHelper: StorageMigrationsHelper
private val db: SQLiteDatabase,
private val migrationsHelper: StorageMigrationsHelper
) {
fun rewriteEnumOrdinalsToNames() {
rewriteTheme()

View file

@ -6,8 +6,8 @@ import android.database.sqlite.SQLiteDatabase
* Rewrite theme setting to use `FOLLOW_SYSTEM` when it's currently set to `LIGHT`.
*/
class StorageMigrationTo8(
private val db: SQLiteDatabase,
private val migrationsHelper: StorageMigrationsHelper
private val db: SQLiteDatabase,
private val migrationsHelper: StorageMigrationsHelper
) {
fun rewriteTheme() {
val theme = migrationsHelper.readValue(db, "theme")

View file

@ -9,8 +9,8 @@ import android.database.sqlite.SQLiteDatabase
* configure "poll folders" so folders that have previously used Push will now be polled.
*/
class StorageMigrationTo9(
private val db: SQLiteDatabase,
private val migrationsHelper: StorageMigrationsHelper
private val db: SQLiteDatabase,
private val migrationsHelper: StorageMigrationsHelper
) {
fun disablePush() {
val accountUuidsListValue = migrationsHelper.readValue(db, "accountUuids")

View file

@ -1,6 +1,5 @@
package com.fsck.k9.storage.migrations
import android.content.ContentValues
import android.database.sqlite.SQLiteDatabase
import com.fsck.k9.mail.FetchProfile
@ -9,7 +8,6 @@ import com.fsck.k9.mailstore.LocalFolder
import com.fsck.k9.mailstore.LocalStore
import timber.log.Timber
internal class FullTextIndexer(val localStore: LocalStore, val database: SQLiteDatabase) {
private val fulltextCreator = localStore.messageFulltextCreator
private val fetchProfile = FetchProfile().apply { add(FetchProfile.Item.BODY) }

View file

@ -1,9 +1,7 @@
package com.fsck.k9.storage.migrations
import android.database.sqlite.SQLiteDatabase
internal object MigrationTo64 {
@JvmStatic
fun addExtraValuesTables(db: SQLiteDatabase) {

View file

@ -3,7 +3,6 @@ package com.fsck.k9.storage.migrations
import android.database.sqlite.SQLiteDatabase
import com.fsck.k9.mailstore.MigrationsHelper
internal object MigrationTo65 {
@JvmStatic
fun addLocalOnlyColumnToFoldersTable(db: SQLiteDatabase, migrationsHelper: MigrationsHelper) {

View file

@ -2,7 +2,6 @@ package com.fsck.k9.storage.migrations
import android.database.sqlite.SQLiteDatabase
internal object MigrationTo66 {
@JvmStatic
fun addEncryptionTypeColumnToMessagesTable(db: SQLiteDatabase) {

Some files were not shown because too many files have changed in this diff Show more