From 93d0e14b68354448aa05a6dcd8e182802f74ccea Mon Sep 17 00:00:00 2001 From: cketti Date: Tue, 26 Nov 2019 21:54:43 +0100 Subject: [PATCH] Fix code style issues found by ktlint --- .../providersxml/ProvidersXmlDiscovery.kt | 17 +++-- .../ThunderbirdAutoconfigFetcher.kt | 3 +- .../ThunderbirdAutoconfigParser.kt | 6 +- .../thunderbird/ThunderbirdDiscovery.kt | 6 +- .../providersxml/ProvidersXmlDiscoveryTest.kt | 2 - .../fsck/k9/AccountPreferenceSerializer.kt | 41 +++++++---- .../java/com/fsck/k9/ActivityExtensions.kt | 2 +- .../src/main/java/com/fsck/k9/AppConfig.kt | 2 +- app/core/src/main/java/com/fsck/k9/Core.kt | 3 +- app/core/src/main/java/com/fsck/k9/DI.kt | 6 +- .../java/com/fsck/k9/EmailAddressValidator.kt | 5 +- .../src/main/java/com/fsck/k9/Identity.kt | 12 ++-- app/core/src/main/java/com/fsck/k9/K9.kt | 6 -- .../java/com/fsck/k9/LocalKeyStoreManager.kt | 4 +- .../k9/autocrypt/AutocryptDraftStateHeader.kt | 17 ++--- .../AutocryptDraftStateHeaderParser.kt | 2 - .../AutocryptTransferMessageCreator.kt | 3 - .../com/fsck/k9/backend/BackendManager.kt | 6 +- .../fsck/k9/controller/ControllerExtension.kt | 1 - .../controller/UnreadMessageCountProvider.kt | 8 +-- .../com/fsck/k9/crypto/EncryptionExtractor.kt | 10 +-- .../com/fsck/k9/helper/ClipboardManager.kt | 1 - .../java/com/fsck/k9/helper/IdentityHelper.kt | 1 - .../main/java/com/fsck/k9/job/K9JobManager.kt | 6 +- .../java/com/fsck/k9/job/K9WorkerFactory.kt | 10 +-- .../java/com/fsck/k9/job/MailSyncWorker.kt | 8 +-- .../com/fsck/k9/job/MailSyncWorkerManager.kt | 2 +- .../com/fsck/k9/mailstore/FolderRepository.kt | 16 ++--- .../k9/mailstore/FolderRepositoryManager.kt | 4 +- .../fsck/k9/mailstore/FolderTypeConverter.kt | 1 - .../com/fsck/k9/mailstore/K9BackendFolder.kt | 60 ++++++++-------- .../com/fsck/k9/mailstore/K9BackendStorage.kt | 9 ++- .../k9/mailstore/K9BackendStorageFactory.kt | 6 +- .../fsck/k9/mailstore/LocalStoreProvider.kt | 2 +- .../mailstore/LockableDatabaseExtensions.kt | 11 ++- .../MessageViewInfoExtractorFactory.kt | 6 +- .../java/com/fsck/k9/mailstore/OutboxState.kt | 8 +-- .../k9/mailstore/OutboxStateRepository.kt | 1 - .../fsck/k9/mailstore/SpecialFolderUpdater.kt | 12 ++-- .../java/com/fsck/k9/message/Attachment.kt | 1 - .../fsck/k9/message/html/DividerReplacer.kt | 2 - .../com/fsck/k9/message/html/EmailSection.kt | 2 - .../fsck/k9/message/html/EmailTextToHtml.kt | 1 - .../com/fsck/k9/message/html/HtmlConverter.kt | 8 +-- .../k9/message/html/HtmlProcessorFactory.kt | 4 +- .../com/fsck/k9/message/html/HtmlSettings.kt | 4 +- .../fsck/k9/message/html/HtmlToPlainText.kt | 1 - .../com/fsck/k9/message/html/UriLinkifier.kt | 7 +- .../java/com/fsck/k9/message/html/UriMatch.kt | 6 +- .../com/fsck/k9/message/html/UriMatcher.kt | 3 +- .../com/fsck/k9/message/html/UriParser.kt | 1 - .../com/fsck/k9/message/quote/QuoteHelper.kt | 11 +-- .../fsck/k9/message/quote/TextQuoteCreator.kt | 12 ++-- .../fsck/k9/notification/CoreKoinModule.kt | 2 +- .../NotificationChannelManager.kt | 18 ++--- .../k9/notification/NotificationHelper.kt | 25 +++---- .../k9/notification/NotificationStrategy.kt | 18 +++-- .../com/fsck/k9/preferences/StorageEditor.kt | 1 - .../fsck/k9/preferences/StoragePersister.kt | 1 - .../fsck/k9/search/AccountSearchConditions.kt | 9 ++- .../java/com/fsck/k9/service/BootReceiver.kt | 7 +- .../com/fsck/k9/setup/ServerNameSuggester.kt | 1 - .../com/fsck/k9/EmailAddressValidatorTest.kt | 2 +- .../java/com/fsck/k9/QuietTimeCheckerTest.kt | 5 +- .../AutocryptDraftStateHeaderParserTest.kt | 24 +++---- .../AutocryptGossipHeaderParserTest.kt | 9 +-- .../fsck/k9/crypto/OpenPgpApiHelperTest.kt | 3 - .../com/fsck/k9/helper/IdentityHelperTest.kt | 4 +- .../fsck/k9/mailstore/K9BackendFolderTest.kt | 5 +- .../k9/mailstore/MimePartStreamParserTest.kt | 11 ++- .../fsck/k9/message/html/DisplayHtmlTest.kt | 1 - .../message/html/EmailSectionExtractorTest.kt | 2 - .../fsck/k9/message/html/EmailSectionTest.kt | 3 - .../k9/message/quote/TextQuoteCreatorTest.kt | 7 +- .../com/fsck/k9/preferences/StorageTest.kt | 8 +-- .../openpgp/OpenPgpEncryptionExtractor.kt | 3 +- app/k9mail/src/main/java/com/fsck/k9/App.kt | 2 - .../fsck/k9/backends/ImapBackendFactory.kt | 8 +-- .../fsck/k9/backends/Pop3BackendFactory.kt | 4 +- .../fsck/k9/backends/WebDavBackendFactory.kt | 4 +- .../k9/notification/K9NotificationStrategy.kt | 20 +++--- .../fsck/k9/provider/UnreadWidgetProvider.kt | 1 - .../k9/resources/K9AutocryptStringProvider.kt | 2 +- .../UnreadWidgetConfigurationActivity.kt | 3 - .../fsck/k9/widget/unread/UnreadWidgetData.kt | 8 +-- .../widget/unread/UnreadWidgetDataProvider.kt | 8 +-- .../widget/unread/UnreadWidgetRepository.kt | 4 +- .../k9/widget/unread/UnreadWidgetUpdater.kt | 1 - .../unread/UnreadWidgetDataProviderTest.kt | 5 +- .../migrations/StorageMigrationTo3.kt | 5 +- .../migrations/StorageMigrationTo4.kt | 4 +- .../migrations/StorageMigrationTo5.kt | 5 +- .../migrations/StorageMigrationTo6.kt | 4 +- .../migrations/StorageMigrationTo7.kt | 4 +- .../migrations/StorageMigrationTo8.kt | 4 +- .../migrations/StorageMigrationTo9.kt | 4 +- .../k9/storage/migrations/FullTextIndexer.kt | 2 - .../k9/storage/migrations/MigrationTo64.kt | 2 - .../k9/storage/migrations/MigrationTo65.kt | 1 - .../k9/storage/migrations/MigrationTo66.kt | 1 - .../k9/storage/migrations/MigrationTo67.kt | 1 - .../k9/storage/migrations/MigrationTo68.kt | 1 - .../k9/storage/migrations/MigrationTo69.kt | 2 - .../fsck/k9/preferences/StorageEditorTest.kt | 4 +- .../k9/preferences/StoragePersisterTest.kt | 8 +-- .../storage/migrations/MigrationTo51Test.kt | 13 ++-- .../preferences/InMemoryStoragePersister.kt | 3 - .../com/fsck/k9/account/AccountRemover.kt | 6 +- .../fsck/k9/account/AccountRemoverService.kt | 3 - .../k9/account/BackgroundAccountRemover.kt | 2 +- .../com/fsck/k9/activity/K9ActivityCommon.kt | 9 +-- .../k9/activity/MessageLoaderHelperFactory.kt | 20 +++--- .../activity/compose/ComposeCryptoStatus.kt | 42 +++++------ .../k9/contacts/ContactLetterBitmapCreator.kt | 4 +- .../k9/contacts/ContactLetterExtractor.kt | 2 +- .../fsck/k9/contacts/ContactPictureLoader.kt | 9 +-- .../fsck/k9/fragment/MessageListAdapter.kt | 48 ++++++------- .../com/fsck/k9/fragment/MessageViewHolder.kt | 5 +- .../fsck/k9/fragment/SortTypeToastProvider.kt | 8 ++- .../java/com/fsck/k9/ui/FragmentExtras.kt | 6 +- .../src/main/java/com/fsck/k9/ui/K9Drawer.kt | 9 +-- .../main/java/com/fsck/k9/ui/ThemeManager.kt | 3 +- .../endtoend/AutocryptKeyTransferActivity.kt | 4 +- .../endtoend/AutocryptKeyTransferPresenter.kt | 12 ++-- .../endtoend/AutocryptKeyTransferViewModel.kt | 5 +- .../AutocryptSetupMessageLiveEvent.kt | 4 +- .../AutocryptSetupTransferLiveEvent.kt | 2 +- .../fsck/k9/ui/folders/FolderNameFormatter.kt | 2 +- .../com/fsck/k9/ui/folders/FoldersLiveData.kt | 12 ++-- .../k9/ui/folders/FoldersLiveDataFactory.kt | 4 +- .../com/fsck/k9/ui/helper/HtmlToSpanned.kt | 1 - .../com/fsck/k9/ui/helper/MaterialColors.kt | 38 +++++----- .../ui/messagelist/MessageListAppearance.kt | 16 ++--- .../k9/ui/messagelist/MessageListViewModel.kt | 1 - .../MessageListViewModelFactory.kt | 1 - .../k9/ui/onboarding/OnboardingActivity.kt | 2 - .../fsck/k9/ui/onboarding/WelcomeFragment.kt | 1 - .../PermissionRationaleDialogFragment.kt | 3 +- .../com/fsck/k9/ui/settings/AboutActivity.kt | 8 +-- .../com/fsck/k9/ui/settings/KoinModule.kt | 2 +- .../fsck/k9/ui/settings/PreferenceExtras.kt | 3 +- .../fsck/k9/ui/settings/SettingsActionItem.kt | 4 +- .../fsck/k9/ui/settings/SettingsActivity.kt | 2 - .../k9/ui/settings/SettingsListFragment.kt | 1 - .../account/AccountSelectionSpinner.kt | 5 -- .../account/AccountSettingsActivity.kt | 10 +-- .../account/AccountSettingsDataStore.kt | 14 ++-- .../AccountSettingsDataStoreFactory.kt | 6 +- .../account/AccountSettingsFragment.kt | 2 - .../account/AccountSettingsViewModel.kt | 4 +- .../AutocryptPreferEncryptDialogFragment.kt | 11 ++- .../AutocryptPreferEncryptPreference.kt | 13 ++-- .../settings/account/FolderListPreference.kt | 15 ++-- .../account/NotificationsPreference.kt | 14 ++-- .../settings/export/SettingsExportFragment.kt | 5 +- .../export/SettingsExportListItems.kt | 4 -- .../settings/export/SettingsExportUiModel.kt | 10 +-- .../export/SettingsExportViewModel.kt | 7 +- .../general/GeneralSettingsActivity.kt | 8 +-- .../general/GeneralSettingsDataStore.kt | 8 +-- .../general/GeneralSettingsFragment.kt | 2 - .../ui/settings/general/LanguagePreference.kt | 18 +++-- .../k9/ui/settings/import/AccountActivator.kt | 14 ++-- .../import/PasswordPromptDialogFragment.kt | 27 ++++---- .../settings/import/PasswordPromptResult.kt | 7 +- .../settings/import/SettingsImportFragment.kt | 4 +- .../import/SettingsImportListItems.kt | 16 ++--- .../settings/import/SettingsImportUiModel.kt | 3 +- .../import/SettingsImportViewModel.kt | 50 +++++++------- .../java/com/fsck/k9/view/WebViewConfig.kt | 6 +- .../java/com/fsck/k9/ViewTestExtensions.kt | 1 - .../k9/contacts/ContactLetterExtractorTest.kt | 1 - .../k9/fragment/MessageListAdapterTest.kt | 69 +++++++++---------- .../fsck/k9/message/PgpMessageBuilderTest.kt | 47 +++++++------ .../java/com/fsck/k9/backend/api/Backend.kt | 22 +++--- .../com/fsck/k9/backend/api/BackendFolder.kt | 2 +- .../com/fsck/k9/backend/api/SyncConfig.kt | 12 ++-- .../fsck/k9/backend/imap/CommandDeleteAll.kt | 2 - .../k9/backend/imap/CommandFetchMessage.kt | 4 +- .../k9/backend/imap/CommandFindByMessageId.kt | 2 - .../backend/imap/CommandRefreshFolderList.kt | 6 +- .../com/fsck/k9/backend/imap/CommandSearch.kt | 10 ++- .../k9/backend/imap/CommandUploadMessage.kt | 2 - .../fsck/k9/backend/pop3/CommandDeleteAll.kt | 2 - .../k9/backend/pop3/CommandFetchMessage.kt | 2 - .../backend/pop3/CommandRefreshFolderList.kt | 2 - .../com/fsck/k9/backend/pop3/Pop3Backend.kt | 28 ++++---- .../k9/backend/webdav/CommandDeleteAll.kt | 2 - .../k9/backend/webdav/CommandFetchMessage.kt | 2 - .../webdav/CommandRefreshFolderList.kt | 6 +- .../k9/backend/webdav/CommandUploadMessage.kt | 2 - .../fsck/k9/backend/webdav/WebDavBackend.kt | 28 ++++---- .../k9/mail/AuthenticationFailedException.kt | 6 +- .../main/java/com/fsck/k9/mail/filter/Hex.kt | 4 +- .../main/java/com/fsck/k9/mail/helper/Utf8.kt | 34 ++++----- .../fsck/k9/mail/internet/MimeExtensions.kt | 3 - .../k9/mail/internet/MimeParameterDecoder.kt | 18 ++--- .../k9/mail/internet/MimeParameterEncoder.kt | 1 - .../com/fsck/k9/mail/internet/MimeValue.kt | 8 +-- .../fsck/k9/mail/internet/ParameterSection.kt | 34 ++++----- .../test/java/com/fsck/k9/mail/MessageTest.kt | 9 +-- .../mail/internet/AddressHeaderBuilderTest.kt | 2 - .../mail/internet/MimeParameterDecoderTest.kt | 2 - .../mail/internet/MimeParameterEncoderTest.kt | 1 - 204 files changed, 728 insertions(+), 931 deletions(-) diff --git a/app/autodiscovery/src/main/java/com/fsck/k9/autodiscovery/providersxml/ProvidersXmlDiscovery.kt b/app/autodiscovery/src/main/java/com/fsck/k9/autodiscovery/providersxml/ProvidersXmlDiscovery.kt index 1a0a718e4..f25fe0e79 100644 --- a/app/autodiscovery/src/main/java/com/fsck/k9/autodiscovery/providersxml/ProvidersXmlDiscovery.kt +++ b/app/autodiscovery/src/main/java/com/fsck/k9/autodiscovery/providersxml/ProvidersXmlDiscovery.kt @@ -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? ) } diff --git a/app/autodiscovery/src/main/java/com/fsck/k9/autodiscovery/thunderbird/ThunderbirdAutoconfigFetcher.kt b/app/autodiscovery/src/main/java/com/fsck/k9/autodiscovery/thunderbird/ThunderbirdAutoconfigFetcher.kt index a6867cda8..3b6ed0991 100644 --- a/app/autodiscovery/src/main/java/com/fsck/k9/autodiscovery/thunderbird/ThunderbirdAutoconfigFetcher.kt +++ b/app/autodiscovery/src/main/java/com/fsck/k9/autodiscovery/thunderbird/ThunderbirdAutoconfigFetcher.kt @@ -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 diff --git a/app/autodiscovery/src/main/java/com/fsck/k9/autodiscovery/thunderbird/ThunderbirdAutoconfigParser.kt b/app/autodiscovery/src/main/java/com/fsck/k9/autodiscovery/thunderbird/ThunderbirdAutoconfigParser.kt index cc91682cd..0b9407f1d 100644 --- a/app/autodiscovery/src/main/java/com/fsck/k9/autodiscovery/thunderbird/ThunderbirdAutoconfigParser.kt +++ b/app/autodiscovery/src/main/java/com/fsck/k9/autodiscovery/thunderbird/ThunderbirdAutoconfigParser.kt @@ -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 diff --git a/app/autodiscovery/src/main/java/com/fsck/k9/autodiscovery/thunderbird/ThunderbirdDiscovery.kt b/app/autodiscovery/src/main/java/com/fsck/k9/autodiscovery/thunderbird/ThunderbirdDiscovery.kt index 0092f243f..99b2e78be 100644 --- a/app/autodiscovery/src/main/java/com/fsck/k9/autodiscovery/thunderbird/ThunderbirdDiscovery.kt +++ b/app/autodiscovery/src/main/java/com/fsck/k9/autodiscovery/thunderbird/ThunderbirdDiscovery.kt @@ -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 diff --git a/app/autodiscovery/src/test/java/com/fsck/k9/autodiscovery/providersxml/ProvidersXmlDiscoveryTest.kt b/app/autodiscovery/src/test/java/com/fsck/k9/autodiscovery/providersxml/ProvidersXmlDiscoveryTest.kt index 20c1e640a..e1b70abbf 100644 --- a/app/autodiscovery/src/test/java/com/fsck/k9/autodiscovery/providersxml/ProvidersXmlDiscoveryTest.kt +++ b/app/autodiscovery/src/test/java/com/fsck/k9/autodiscovery/providersxml/ProvidersXmlDiscoveryTest.kt @@ -13,7 +13,6 @@ import org.junit.Test import org.mockito.ArgumentMatchers.anyString import org.robolectric.RuntimeEnvironment - class ProvidersXmlDiscoveryTest : RobolectricTest() { val backendManager = mock { 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") diff --git a/app/core/src/main/java/com/fsck/k9/AccountPreferenceSerializer.kt b/app/core/src/main/java/com/fsck/k9/AccountPreferenceSerializer.kt index c47634ed4..d616720c3 100644 --- a/app/core/src/main/java/com/fsck/k9/AccountPreferenceSerializer.kt +++ b/app/core/src/main/java/com/fsck/k9/AccountPreferenceSerializer.kt @@ -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 diff --git a/app/core/src/main/java/com/fsck/k9/ActivityExtensions.kt b/app/core/src/main/java/com/fsck/k9/ActivityExtensions.kt index eee9d0056..70ba09feb 100644 --- a/app/core/src/main/java/com/fsck/k9/ActivityExtensions.kt +++ b/app/core/src/main/java/com/fsck/k9/ActivityExtensions.kt @@ -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) diff --git a/app/core/src/main/java/com/fsck/k9/AppConfig.kt b/app/core/src/main/java/com/fsck/k9/AppConfig.kt index 41fe5cd0e..5609db88d 100644 --- a/app/core/src/main/java/com/fsck/k9/AppConfig.kt +++ b/app/core/src/main/java/com/fsck/k9/AppConfig.kt @@ -1,5 +1,5 @@ package com.fsck.k9 data class AppConfig( - val componentsToDisable: List> + val componentsToDisable: List> ) diff --git a/app/core/src/main/java/com/fsck/k9/Core.kt b/app/core/src/main/java/com/fsck/k9/Core.kt index 720423f47..d379eed5f 100644 --- a/app/core/src/main/java/com/fsck/k9/Core.kt +++ b/app/core/src/main/java/com/fsck/k9/Core.kt @@ -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() } - } /** diff --git a/app/core/src/main/java/com/fsck/k9/DI.kt b/app/core/src/main/java/com/fsck/k9/DI.kt index 19ec6526c..d2a336ef5 100644 --- a/app/core/src/main/java/com/fsck/k9/DI.kt +++ b/app/core/src/main/java/com/fsck/k9/DI.kt @@ -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 EarlyInit.inject( - qualifier: Qualifier? = null, - noinline parameters: ParametersDefinition? = null + qualifier: Qualifier? = null, + noinline parameters: ParametersDefinition? = null ) = lazy { getKoin().get(qualifier, parameters) } diff --git a/app/core/src/main/java/com/fsck/k9/EmailAddressValidator.kt b/app/core/src/main/java/com/fsck/k9/EmailAddressValidator.kt index 5b52e4aa7..c512040e6 100644 --- a/app/core/src/main/java/com/fsck/k9/EmailAddressValidator.kt +++ b/app/core/src/main/java/com/fsck/k9/EmailAddressValidator.kt @@ -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]" diff --git a/app/core/src/main/java/com/fsck/k9/Identity.kt b/app/core/src/main/java/com/fsck/k9/Identity.kt index fa6c55b94..b8cb03a21 100644 --- a/app/core/src/main/java/com/fsck/k9/Identity.kt +++ b/app/core/src/main/java/com/fsck/k9/Identity.kt @@ -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) diff --git a/app/core/src/main/java/com/fsck/k9/K9.kt b/app/core/src/main/java/com/fsck/k9/K9.kt index e2a2e0fbe..642a4fedc 100644 --- a/app/core/src/main/java/com/fsck/k9/K9.kt +++ b/app/core/src/main/java/com/fsck/k9/K9.kt @@ -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, diff --git a/app/core/src/main/java/com/fsck/k9/LocalKeyStoreManager.kt b/app/core/src/main/java/com/fsck/k9/LocalKeyStoreManager.kt index 14731aa02..c2bd87970 100644 --- a/app/core/src/main/java/com/fsck/k9/LocalKeyStoreManager.kt +++ b/app/core/src/main/java/com/fsck/k9/LocalKeyStoreManager.kt @@ -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) } } -} \ No newline at end of file +} diff --git a/app/core/src/main/java/com/fsck/k9/autocrypt/AutocryptDraftStateHeader.kt b/app/core/src/main/java/com/fsck/k9/autocrypt/AutocryptDraftStateHeader.kt index 13bdd56eb..c2bf1d71e 100644 --- a/app/core/src/main/java/com/fsck/k9/autocrypt/AutocryptDraftStateHeader.kt +++ b/app/core/src/main/java/com/fsck/k9/autocrypt/AutocryptDraftStateHeader.kt @@ -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 = mapOf()) { +data class AutocryptDraftStateHeader( + val isEncrypt: Boolean, + val isSignOnly: Boolean, + val isReply: Boolean, + val isByChoice: Boolean, + val isPgpInline: Boolean, + val parameters: Map = 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 { diff --git a/app/core/src/main/java/com/fsck/k9/autocrypt/AutocryptDraftStateHeaderParser.kt b/app/core/src/main/java/com/fsck/k9/autocrypt/AutocryptDraftStateHeaderParser.kt index ed9cc8b32..e91914f74 100644 --- a/app/core/src/main/java/com/fsck/k9/autocrypt/AutocryptDraftStateHeaderParser.kt +++ b/app/core/src/main/java/com/fsck/k9/autocrypt/AutocryptDraftStateHeaderParser.kt @@ -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? { diff --git a/app/core/src/main/java/com/fsck/k9/autocrypt/AutocryptTransferMessageCreator.kt b/app/core/src/main/java/com/fsck/k9/autocrypt/AutocryptTransferMessageCreator.kt index 07f4bc044..1d5fb11a0 100644 --- a/app/core/src/main/java/com/fsck/k9/autocrypt/AutocryptTransferMessageCreator.kt +++ b/app/core/src/main/java/com/fsck/k9/autocrypt/AutocryptTransferMessageCreator.kt @@ -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 { diff --git a/app/core/src/main/java/com/fsck/k9/backend/BackendManager.kt b/app/core/src/main/java/com/fsck/k9/backend/BackendManager.kt index 247b694df..c93452eb7 100644 --- a/app/core/src/main/java/com/fsck/k9/backend/BackendManager.kt +++ b/app/core/src/main/java/com/fsck/k9/backend/BackendManager.kt @@ -7,9 +7,8 @@ import com.fsck.k9.mail.ServerSettings class BackendManager(private val backendFactories: Map) { private val backendCache = mutableMapOf() - 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) } fun removeBackend(account: Account) { - synchronized (backendCache) { + synchronized(backendCache) { backendCache.remove(account.uuid) } } @@ -82,6 +81,5 @@ class BackendManager(private val backendFactories: Map) throw IllegalArgumentException("Unsupported ServerSettings type") } - private data class BackendContainer(val backend: Backend, val storeUri: String, val transportUri: String) } diff --git a/app/core/src/main/java/com/fsck/k9/controller/ControllerExtension.kt b/app/core/src/main/java/com/fsck/k9/controller/ControllerExtension.kt index b6e9c9b59..ef196df26 100644 --- a/app/core/src/main/java/com/fsck/k9/controller/ControllerExtension.kt +++ b/app/core/src/main/java/com/fsck/k9/controller/ControllerExtension.kt @@ -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) diff --git a/app/core/src/main/java/com/fsck/k9/controller/UnreadMessageCountProvider.kt b/app/core/src/main/java/com/fsck/k9/controller/UnreadMessageCountProvider.kt index 7450ad6a9..41bd98a1e 100644 --- a/app/core/src/main/java/com/fsck/k9/controller/UnreadMessageCountProvider.kt +++ b/app/core/src/main/java/com/fsck/k9/controller/UnreadMessageCountProvider.kt @@ -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)) { diff --git a/app/core/src/main/java/com/fsck/k9/crypto/EncryptionExtractor.kt b/app/core/src/main/java/com/fsck/k9/crypto/EncryptionExtractor.kt index 395d7430d..52e0ed59f 100644 --- a/app/core/src/main/java/com/fsck/k9/crypto/EncryptionExtractor.kt +++ b/app/core/src/main/java/com/fsck/k9/crypto/EncryptionExtractor.kt @@ -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 ) diff --git a/app/core/src/main/java/com/fsck/k9/helper/ClipboardManager.kt b/app/core/src/main/java/com/fsck/k9/helper/ClipboardManager.kt index a5bb5cdf6..ca0face38 100644 --- a/app/core/src/main/java/com/fsck/k9/helper/ClipboardManager.kt +++ b/app/core/src/main/java/com/fsck/k9/helper/ClipboardManager.kt @@ -3,7 +3,6 @@ package com.fsck.k9.helper import android.content.ClipData import android.content.Context - /** * Access the system clipboard */ diff --git a/app/core/src/main/java/com/fsck/k9/helper/IdentityHelper.kt b/app/core/src/main/java/com/fsck/k9/helper/IdentityHelper.kt index 43efc80f5..e0263fb1b 100644 --- a/app/core/src/main/java/com/fsck/k9/helper/IdentityHelper.kt +++ b/app/core/src/main/java/com/fsck/k9/helper/IdentityHelper.kt @@ -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, diff --git a/app/core/src/main/java/com/fsck/k9/job/K9JobManager.kt b/app/core/src/main/java/com/fsck/k9/job/K9JobManager.kt index b2aa01279..b1de21507 100644 --- a/app/core/src/main/java/com/fsck/k9/job/K9JobManager.kt +++ b/app/core/src/main/java/com/fsck/k9/job/K9JobManager.kt @@ -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") diff --git a/app/core/src/main/java/com/fsck/k9/job/K9WorkerFactory.kt b/app/core/src/main/java/com/fsck/k9/job/K9WorkerFactory.kt index a284cbdf7..adcb92588 100644 --- a/app/core/src/main/java/com/fsck/k9/job/K9WorkerFactory.kt +++ b/app/core/src/main/java/com/fsck/k9/job/K9WorkerFactory.kt @@ -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 -> { diff --git a/app/core/src/main/java/com/fsck/k9/job/MailSyncWorker.kt b/app/core/src/main/java/com/fsck/k9/job/MailSyncWorker.kt index f045c7d2d..95f7d3cac 100644 --- a/app/core/src/main/java/com/fsck/k9/job/MailSyncWorker.kt +++ b/app/core/src/main/java/com/fsck/k9/job/MailSyncWorker.kt @@ -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 { diff --git a/app/core/src/main/java/com/fsck/k9/job/MailSyncWorkerManager.kt b/app/core/src/main/java/com/fsck/k9/job/MailSyncWorkerManager.kt index f6abc2e30..b1c10a070 100644 --- a/app/core/src/main/java/com/fsck/k9/job/MailSyncWorkerManager.kt +++ b/app/core/src/main/java/com/fsck/k9/job/MailSyncWorkerManager.kt @@ -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) { diff --git a/app/core/src/main/java/com/fsck/k9/mailstore/FolderRepository.kt b/app/core/src/main/java/com/fsck/k9/mailstore/FolderRepository.kt index c1b7baae0..21b08b6cd 100644 --- a/app/core/src/main/java/com/fsck/k9/mailstore/FolderRepository.kt +++ b/app/core/src/main/java/com/fsck/k9/mailstore/FolderRepository.kt @@ -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 { 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, val automaticSpecialFolders: Map) diff --git a/app/core/src/main/java/com/fsck/k9/mailstore/FolderRepositoryManager.kt b/app/core/src/main/java/com/fsck/k9/mailstore/FolderRepositoryManager.kt index 88df8c6ac..30c9252aa 100644 --- a/app/core/src/main/java/com/fsck/k9/mailstore/FolderRepositoryManager.kt +++ b/app/core/src/main/java/com/fsck/k9/mailstore/FolderRepositoryManager.kt @@ -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) } diff --git a/app/core/src/main/java/com/fsck/k9/mailstore/FolderTypeConverter.kt b/app/core/src/main/java/com/fsck/k9/mailstore/FolderTypeConverter.kt index 33426ddbc..8f2f7365b 100644 --- a/app/core/src/main/java/com/fsck/k9/mailstore/FolderTypeConverter.kt +++ b/app/core/src/main/java/com/fsck/k9/mailstore/FolderTypeConverter.kt @@ -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) { diff --git a/app/core/src/main/java/com/fsck/k9/mailstore/K9BackendFolder.kt b/app/core/src/main/java/com/fsck/k9/mailstore/K9BackendFolder.kt index 90ea89271..e75f1b7c7 100644 --- a/app/core/src/main/java/com/fsck/k9/mailstore/K9BackendFolder.kt +++ b/app/core/src/main/java/com/fsck/k9/mailstore/K9BackendFolder.kt @@ -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 { diff --git a/app/core/src/main/java/com/fsck/k9/mailstore/K9BackendStorage.kt b/app/core/src/main/java/com/fsck/k9/mailstore/K9BackendStorage.kt index ff0863054..f4a93c0b0 100644 --- a/app/core/src/main/java/com/fsck/k9/mailstore/K9BackendStorage.kt +++ b/app/core/src/main/java/com/fsck/k9/mailstore/K9BackendStorage.kt @@ -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) } diff --git a/app/core/src/main/java/com/fsck/k9/mailstore/K9BackendStorageFactory.kt b/app/core/src/main/java/com/fsck/k9/mailstore/K9BackendStorageFactory.kt index dace63ed4..717db60e8 100644 --- a/app/core/src/main/java/com/fsck/k9/mailstore/K9BackendStorageFactory.kt +++ b/app/core/src/main/java/com/fsck/k9/mailstore/K9BackendStorageFactory.kt @@ -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) diff --git a/app/core/src/main/java/com/fsck/k9/mailstore/LocalStoreProvider.kt b/app/core/src/main/java/com/fsck/k9/mailstore/LocalStoreProvider.kt index 8f6474065..5305b1131 100644 --- a/app/core/src/main/java/com/fsck/k9/mailstore/LocalStoreProvider.kt +++ b/app/core/src/main/java/com/fsck/k9/mailstore/LocalStoreProvider.kt @@ -27,4 +27,4 @@ class LocalStoreProvider { val accountUuid = account.uuid localStores.remove(accountUuid) } -} \ No newline at end of file +} diff --git a/app/core/src/main/java/com/fsck/k9/mailstore/LockableDatabaseExtensions.kt b/app/core/src/main/java/com/fsck/k9/mailstore/LockableDatabaseExtensions.kt index 46324a6a7..9347f797c 100644 --- a/app/core/src/main/java/com/fsck/k9/mailstore/LockableDatabaseExtensions.kt +++ b/app/core/src/main/java/com/fsck/k9/mailstore/LockableDatabaseExtensions.kt @@ -2,13 +2,12 @@ package com.fsck.k9.mailstore import android.database.Cursor - internal fun LockableDatabase.query( - table: String, - columns: Array, - selection: String?, - vararg selectionArgs: String, - block: (Cursor) -> T + table: String, + columns: Array, + selection: String?, + vararg selectionArgs: String, + block: (Cursor) -> T ): T { return execute(false) { db -> val cursor = db.query(table, columns, selection, selectionArgs, null, null, null) diff --git a/app/core/src/main/java/com/fsck/k9/mailstore/MessageViewInfoExtractorFactory.kt b/app/core/src/main/java/com/fsck/k9/mailstore/MessageViewInfoExtractorFactory.kt index 1120a56d6..e72132c4a 100644 --- a/app/core/src/main/java/com/fsck/k9/mailstore/MessageViewInfoExtractorFactory.kt +++ b/app/core/src/main/java/com/fsck/k9/mailstore/MessageViewInfoExtractorFactory.kt @@ -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) diff --git a/app/core/src/main/java/com/fsck/k9/mailstore/OutboxState.kt b/app/core/src/main/java/com/fsck/k9/mailstore/OutboxState.kt index 5c39e9f7f..c024d01be 100644 --- a/app/core/src/main/java/com/fsck/k9/mailstore/OutboxState.kt +++ b/app/core/src/main/java/com/fsck/k9/mailstore/OutboxState.kt @@ -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 ) diff --git a/app/core/src/main/java/com/fsck/k9/mailstore/OutboxStateRepository.kt b/app/core/src/main/java/com/fsck/k9/mailstore/OutboxStateRepository.kt index 9f50cfd30..cd6d10864 100644 --- a/app/core/src/main/java/com/fsck/k9/mailstore/OutboxStateRepository.kt +++ b/app/core/src/main/java/com/fsck/k9/mailstore/OutboxStateRepository.kt @@ -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" diff --git a/app/core/src/main/java/com/fsck/k9/mailstore/SpecialFolderUpdater.kt b/app/core/src/main/java/com/fsck/k9/mailstore/SpecialFolderUpdater.kt index a5b9d4b60..f248277de 100644 --- a/app/core/src/main/java/com/fsck/k9/mailstore/SpecialFolderUpdater.kt +++ b/app/core/src/main/java/com/fsck/k9/mailstore/SpecialFolderUpdater.kt @@ -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, - automaticSpecialFolders: Map + type: FolderType, + folders: List, + automaticSpecialFolders: Map ) { when (getSpecialFolderSelection(type)) { SpecialFolderSelection.AUTOMATIC -> { diff --git a/app/core/src/main/java/com/fsck/k9/message/Attachment.kt b/app/core/src/main/java/com/fsck/k9/message/Attachment.kt index e62cf66f1..2bff7d851 100644 --- a/app/core/src/main/java/com/fsck/k9/message/Attachment.kt +++ b/app/core/src/main/java/com/fsck/k9/message/Attachment.kt @@ -7,7 +7,6 @@ interface Attachment { val name: String? val size: Long? - enum class LoadingState { URI_ONLY, METADATA, diff --git a/app/core/src/main/java/com/fsck/k9/message/html/DividerReplacer.kt b/app/core/src/main/java/com/fsck/k9/message/html/DividerReplacer.kt index 6eb0b925e..426c241a0 100644 --- a/app/core/src/main/java/com/fsck/k9/message/html/DividerReplacer.kt +++ b/app/core/src/main/java/com/fsck/k9/message/html/DividerReplacer.kt @@ -11,14 +11,12 @@ internal object DividerReplacer : TextToHtml.HtmlModifier { "(?:\\n|$)" + ")+") - override fun findModifications(text: CharSequence): List { 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("
") diff --git a/app/core/src/main/java/com/fsck/k9/message/html/EmailSection.kt b/app/core/src/main/java/com/fsck/k9/message/html/EmailSection.kt index 0cd35d1c6..c98a0b11f 100644 --- a/app/core/src/main/java/com/fsck/k9/message/html/EmailSection.kt +++ b/app/core/src/main/java/com/fsck/k9/message/html/EmailSection.kt @@ -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) } } - diff --git a/app/core/src/main/java/com/fsck/k9/message/html/EmailTextToHtml.kt b/app/core/src/main/java/com/fsck/k9/message/html/EmailTextToHtml.kt index bca3b7105..10d5c2c3c 100644 --- a/app/core/src/main/java/com/fsck/k9/message/html/EmailTextToHtml.kt +++ b/app/core/src/main/java/com/fsck/k9/message/html/EmailTextToHtml.kt @@ -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" diff --git a/app/core/src/main/java/com/fsck/k9/message/html/HtmlConverter.kt b/app/core/src/main/java/com/fsck/k9/message/html/HtmlConverter.kt index 58775409d..fc75cfd49 100644 --- a/app/core/src/main/java/com/fsck/k9/message/html/HtmlConverter.kt +++ b/app/core/src/main/java/com/fsck/k9/message/html/HtmlConverter.kt @@ -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. diff --git a/app/core/src/main/java/com/fsck/k9/message/html/HtmlProcessorFactory.kt b/app/core/src/main/java/com/fsck/k9/message/html/HtmlProcessorFactory.kt index b49485fa0..3ba32604d 100644 --- a/app/core/src/main/java/com/fsck/k9/message/html/HtmlProcessorFactory.kt +++ b/app/core/src/main/java/com/fsck/k9/message/html/HtmlProcessorFactory.kt @@ -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) diff --git a/app/core/src/main/java/com/fsck/k9/message/html/HtmlSettings.kt b/app/core/src/main/java/com/fsck/k9/message/html/HtmlSettings.kt index 9d65c6c49..5d6a0592b 100644 --- a/app/core/src/main/java/com/fsck/k9/message/html/HtmlSettings.kt +++ b/app/core/src/main/java/com/fsck/k9/message/html/HtmlSettings.kt @@ -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 ) diff --git a/app/core/src/main/java/com/fsck/k9/message/html/HtmlToPlainText.kt b/app/core/src/main/java/com/fsck/k9/message/html/HtmlToPlainText.kt index 8b816722e..dee5ed93f 100644 --- a/app/core/src/main/java/com/fsck/k9/message/html/HtmlToPlainText.kt +++ b/app/core/src/main/java/com/fsck/k9/message/html/HtmlToPlainText.kt @@ -117,7 +117,6 @@ private class FormattingVisitor : NodeVisitor { return output.substring(0, lastIndex + 1) } - companion object { private const val MAX_WIDTH = 76 } diff --git a/app/core/src/main/java/com/fsck/k9/message/html/UriLinkifier.kt b/app/core/src/main/java/com/fsck/k9/message/html/UriLinkifier.kt index e97a9099b..c9c9132ba 100644 --- a/app/core/src/main/java/com/fsck/k9/message/html/UriLinkifier.kt +++ b/app/core/src/main/java/com/fsck/k9/message/html/UriLinkifier.kt @@ -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) { diff --git a/app/core/src/main/java/com/fsck/k9/message/html/UriMatch.kt b/app/core/src/main/java/com/fsck/k9/message/html/UriMatch.kt index 3c6bdb686..6c6112423 100644 --- a/app/core/src/main/java/com/fsck/k9/message/html/UriMatch.kt +++ b/app/core/src/main/java/com/fsck/k9/message/html/UriMatch.kt @@ -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 ) diff --git a/app/core/src/main/java/com/fsck/k9/message/html/UriMatcher.kt b/app/core/src/main/java/com/fsck/k9/message/html/UriMatcher.kt index 711760622..db1df4c72 100644 --- a/app/core/src/main/java/com/fsck/k9/message/html/UriMatcher.kt +++ b/app/core/src/main/java/com/fsck/k9/message/html/UriMatcher.kt @@ -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 { return URI_SCHEME.findAll(text).map { matchResult -> val matchGroup = matchResult.groups[1]!! diff --git a/app/core/src/main/java/com/fsck/k9/message/html/UriParser.kt b/app/core/src/main/java/com/fsck/k9/message/html/UriParser.kt index c4cf7f446..89ca57017 100644 --- a/app/core/src/main/java/com/fsck/k9/message/html/UriParser.kt +++ b/app/core/src/main/java/com/fsck/k9/message/html/UriParser.kt @@ -1,6 +1,5 @@ package com.fsck.k9.message.html - internal interface UriParser { /** * Parse scheme specific URI beginning from given position. diff --git a/app/core/src/main/java/com/fsck/k9/message/quote/QuoteHelper.kt b/app/core/src/main/java/com/fsck/k9/message/quote/QuoteHelper.kt index bcb20b0bc..ff2218e12 100644 --- a/app/core/src/main/java/com/fsck/k9/message/quote/QuoteHelper.kt +++ b/app/core/src/main/java/com/fsck/k9/message/quote/QuoteHelper.kt @@ -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 diff --git a/app/core/src/main/java/com/fsck/k9/message/quote/TextQuoteCreator.kt b/app/core/src/main/java/com/fsck/k9/message/quote/TextQuoteCreator.kt index e5642ac4d..7cce38ac5 100644 --- a/app/core/src/main/java/com/fsck/k9/message/quote/TextQuoteCreator.kt +++ b/app/core/src/main/java/com/fsck/k9/message/quote/TextQuoteCreator.kt @@ -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
.displayString() = Address.toString(this)?.let { if (it.isEmpty()) null else it } - companion object { private const val CRLF = "\r\n" } diff --git a/app/core/src/main/java/com/fsck/k9/notification/CoreKoinModule.kt b/app/core/src/main/java/com/fsck/k9/notification/CoreKoinModule.kt index 9dd171dbd..399bb4dda 100644 --- a/app/core/src/main/java/com/fsck/k9/notification/CoreKoinModule.kt +++ b/app/core/src/main/java/com/fsck/k9/notification/CoreKoinModule.kt @@ -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()) } diff --git a/app/core/src/main/java/com/fsck/k9/notification/NotificationChannelManager.kt b/app/core/src/main/java/com/fsck/k9/notification/NotificationChannelManager.kt index 39d70c37e..92982e91b 100644 --- a/app/core/src/main/java/com/fsck/k9/notification/NotificationChannelManager.kt +++ b/app/core/src/main/java/com/fsck/k9/notification/NotificationChannelManager.kt @@ -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) { + notificationManager: NotificationManager, + accounts: List + ) { 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) { + notificationManager: NotificationManager, + accounts: List + ) { val existingAccounts = HashMap() for (account in accounts) { existingAccounts[account.uuid] = account diff --git a/app/core/src/main/java/com/fsck/k9/notification/NotificationHelper.kt b/app/core/src/main/java/com/fsck/k9/notification/NotificationHelper.kt index 7437c2b89..ffa21d37b 100644 --- a/app/core/src/main/java/com/fsck/k9/notification/NotificationHelper.kt +++ b/app/core/src/main/java/com/fsck/k9/notification/NotificationHelper.kt @@ -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 diff --git a/app/core/src/main/java/com/fsck/k9/notification/NotificationStrategy.kt b/app/core/src/main/java/com/fsck/k9/notification/NotificationStrategy.kt index 345d2888d..36c3069d4 100644 --- a/app/core/src/main/java/com/fsck/k9/notification/NotificationStrategy.kt +++ b/app/core/src/main/java/com/fsck/k9/notification/NotificationStrategy.kt @@ -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 -} \ No newline at end of file + fun shouldNotifyForMessage( + account: Account, + localFolder: LocalFolder, + message: Message, + isOldMessage: Boolean + ): Boolean +} diff --git a/app/core/src/main/java/com/fsck/k9/preferences/StorageEditor.kt b/app/core/src/main/java/com/fsck/k9/preferences/StorageEditor.kt index 494488d65..0fc600e1c 100644 --- a/app/core/src/main/java/com/fsck/k9/preferences/StorageEditor.kt +++ b/app/core/src/main/java/com/fsck/k9/preferences/StorageEditor.kt @@ -2,7 +2,6 @@ package com.fsck.k9.preferences import android.content.SharedPreferences - interface StorageEditor { fun copy(input: SharedPreferences) diff --git a/app/core/src/main/java/com/fsck/k9/preferences/StoragePersister.kt b/app/core/src/main/java/com/fsck/k9/preferences/StoragePersister.kt index d112dfa3c..9a01e28fe 100644 --- a/app/core/src/main/java/com/fsck/k9/preferences/StoragePersister.kt +++ b/app/core/src/main/java/com/fsck/k9/preferences/StoragePersister.kt @@ -2,7 +2,6 @@ package com.fsck.k9.preferences import androidx.annotation.CheckResult - interface StoragePersister { @CheckResult fun loadValues(): Map diff --git a/app/core/src/main/java/com/fsck/k9/search/AccountSearchConditions.kt b/app/core/src/main/java/com/fsck/k9/search/AccountSearchConditions.kt index 6a8c2191a..cb6e073b5 100644 --- a/app/core/src/main/java/com/fsck/k9/search/AccountSearchConditions.kt +++ b/app/core/src/main/java/com/fsck/k9/search/AccountSearchConditions.kt @@ -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 } -} \ No newline at end of file +} diff --git a/app/core/src/main/java/com/fsck/k9/service/BootReceiver.kt b/app/core/src/main/java/com/fsck/k9/service/BootReceiver.kt index 31f8c82c1..e9f26a317 100644 --- a/app/core/src/main/java/com/fsck/k9/service/BootReceiver.kt +++ b/app/core/src/main/java/com/fsck/k9/service/BootReceiver.kt @@ -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)) } } - } diff --git a/app/core/src/main/java/com/fsck/k9/setup/ServerNameSuggester.kt b/app/core/src/main/java/com/fsck/k9/setup/ServerNameSuggester.kt index e626492af..376b73cb8 100644 --- a/app/core/src/main/java/com/fsck/k9/setup/ServerNameSuggester.kt +++ b/app/core/src/main/java/com/fsck/k9/setup/ServerNameSuggester.kt @@ -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" diff --git a/app/core/src/test/java/com/fsck/k9/EmailAddressValidatorTest.kt b/app/core/src/test/java/com/fsck/k9/EmailAddressValidatorTest.kt index 4cbf8d236..f839dec1d 100644 --- a/app/core/src/test/java/com/fsck/k9/EmailAddressValidatorTest.kt +++ b/app/core/src/test/java/com/fsck/k9/EmailAddressValidatorTest.kt @@ -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")) diff --git a/app/core/src/test/java/com/fsck/k9/QuietTimeCheckerTest.kt b/app/core/src/test/java/com/fsck/k9/QuietTimeCheckerTest.kt index a60eb2dbb..f24000299 100644 --- a/app/core/src/test/java/com/fsck/k9/QuietTimeCheckerTest.kt +++ b/app/core/src/test/java/com/fsck/k9/QuietTimeCheckerTest.kt @@ -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() } diff --git a/app/core/src/test/java/com/fsck/k9/autocrypt/AutocryptDraftStateHeaderParserTest.kt b/app/core/src/test/java/com/fsck/k9/autocrypt/AutocryptDraftStateHeaderParserTest.kt index 5ad86bf16..696547b2b 100644 --- a/app/core/src/test/java/com/fsck/k9/autocrypt/AutocryptDraftStateHeaderParserTest.kt +++ b/app/core/src/test/java/com/fsck/k9/autocrypt/AutocryptDraftStateHeaderParserTest.kt @@ -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() { diff --git a/app/core/src/test/java/com/fsck/k9/autocrypt/AutocryptGossipHeaderParserTest.kt b/app/core/src/test/java/com/fsck/k9/autocrypt/AutocryptGossipHeaderParserTest.kt index 572add784..585e6faae 100644 --- a/app/core/src/test/java/com/fsck/k9/autocrypt/AutocryptGossipHeaderParserTest.kt +++ b/app/core/src/test/java/com/fsck/k9/autocrypt/AutocryptGossipHeaderParserTest.kt @@ -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) } -} \ No newline at end of file +} diff --git a/app/core/src/test/java/com/fsck/k9/crypto/OpenPgpApiHelperTest.kt b/app/core/src/test/java/com/fsck/k9/crypto/OpenPgpApiHelperTest.kt index 5703951fb..95538bdb5 100644 --- a/app/core/src/test/java/com/fsck/k9/crypto/OpenPgpApiHelperTest.kt +++ b/app/core/src/test/java/com/fsck/k9/crypto/OpenPgpApiHelperTest.kt @@ -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("", result) } - } diff --git a/app/core/src/test/java/com/fsck/k9/helper/IdentityHelperTest.kt b/app/core/src/test/java/com/fsck/k9/helper/IdentityHelperTest.kt index d7ade0cdd..5f403090c 100644 --- a/app/core/src/test/java/com/fsck/k9/helper/IdentityHelperTest.kt +++ b/app/core/src/test/java/com/fsck/k9/helper/IdentityHelperTest.kt @@ -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), diff --git a/app/core/src/test/java/com/fsck/k9/mailstore/K9BackendFolderTest.kt b/app/core/src/test/java/com/fsck/k9/mailstore/K9BackendFolderTest.kt index 56b539342..ce617b7c6 100644 --- a/app/core/src/test/java/com/fsck/k9/mailstore/K9BackendFolderTest.kt +++ b/app/core/src/test/java/com/fsck/k9/mailstore/K9BackendFolderTest.kt @@ -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" diff --git a/app/core/src/test/java/com/fsck/k9/mailstore/MimePartStreamParserTest.kt b/app/core/src/test/java/com/fsck/k9/mailstore/MimePartStreamParserTest.kt index f84467dbb..9e114297e 100644 --- a/app/core/src/test/java/com/fsck/k9/mailstore/MimePartStreamParserTest.kt +++ b/app/core/src/test/java/com/fsck/k9/mailstore/MimePartStreamParserTest.kt @@ -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) } -} \ No newline at end of file +} diff --git a/app/core/src/test/java/com/fsck/k9/message/html/DisplayHtmlTest.kt b/app/core/src/test/java/com/fsck/k9/message/html/DisplayHtmlTest.kt index 8d89262b7..3d31c2e93 100644 --- a/app/core/src/test/java/com/fsck/k9/message/html/DisplayHtmlTest.kt +++ b/app/core/src/test/java/com/fsck/k9/message/html/DisplayHtmlTest.kt @@ -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") diff --git a/app/core/src/test/java/com/fsck/k9/message/html/EmailSectionExtractorTest.kt b/app/core/src/test/java/com/fsck/k9/message/html/EmailSectionExtractorTest.kt index bce97ac1f..ef074b122 100644 --- a/app/core/src/test/java/com/fsck/k9/message/html/EmailSectionExtractorTest.kt +++ b/app/core/src/test/java/com/fsck/k9/message/html/EmailSectionExtractorTest.kt @@ -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() { diff --git a/app/core/src/test/java/com/fsck/k9/message/html/EmailSectionTest.kt b/app/core/src/test/java/com/fsck/k9/message/html/EmailSectionTest.kt index de828a2f1..3b907e698 100644 --- a/app/core/src/test/java/com/fsck/k9/message/html/EmailSectionTest.kt +++ b/app/core/src/test/java/com/fsck/k9/message/html/EmailSectionTest.kt @@ -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() diff --git a/app/core/src/test/java/com/fsck/k9/message/quote/TextQuoteCreatorTest.kt b/app/core/src/test/java/com/fsck/k9/message/quote/TextQuoteCreatorTest.kt index 0b98c093d..a05faf577 100644 --- a/app/core/src/test/java/com/fsck/k9/message/quote/TextQuoteCreatorTest.kt +++ b/app/core/src/test/java/com/fsck/k9/message/quote/TextQuoteCreatorTest.kt @@ -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 { @@ -33,7 +31,6 @@ class TextQuoteCreatorTest : RobolectricTest() { } val textQuoteCreator = TextQuoteCreator(QuoteHelper(resources), TestCoreResourceProvider()) - @Before fun setUp() { K9.isHideTimeZone = true diff --git a/app/core/src/test/java/com/fsck/k9/preferences/StorageTest.kt b/app/core/src/test/java/com/fsck/k9/preferences/StorageTest.kt index bb141b5c7..3cc3d9208 100644 --- a/app/core/src/test/java/com/fsck/k9/preferences/StorageTest.kt +++ b/app/core/src/test/java/com/fsck/k9/preferences/StorageTest.kt @@ -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)) } -} \ No newline at end of file +} diff --git a/app/crypto-openpgp/src/main/java/com/fsck/k9/crypto/openpgp/OpenPgpEncryptionExtractor.kt b/app/crypto-openpgp/src/main/java/com/fsck/k9/crypto/openpgp/OpenPgpEncryptionExtractor.kt index 64467b34b..079114e36 100644 --- a/app/crypto-openpgp/src/main/java/com/fsck/k9/crypto/openpgp/OpenPgpEncryptionExtractor.kt +++ b/app/crypto-openpgp/src/main/java/com/fsck/k9/crypto/openpgp/OpenPgpEncryptionExtractor.kt @@ -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" diff --git a/app/k9mail/src/main/java/com/fsck/k9/App.kt b/app/k9mail/src/main/java/com/fsck/k9/App.kt index de4ae074e..6260a4bdd 100644 --- a/app/k9mail/src/main/java/com/fsck/k9/App.kt +++ b/app/k9mail/src/main/java/com/fsck/k9/App.kt @@ -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) diff --git a/app/k9mail/src/main/java/com/fsck/k9/backends/ImapBackendFactory.kt b/app/k9mail/src/main/java/com/fsck/k9/backends/ImapBackendFactory.kt index 27de46614..6c9dcbe0e 100644 --- a/app/k9mail/src/main/java/com/fsck/k9/backends/ImapBackendFactory.kt +++ b/app/k9mail/src/main/java/com/fsck/k9/backends/ImapBackendFactory.kt @@ -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" diff --git a/app/k9mail/src/main/java/com/fsck/k9/backends/Pop3BackendFactory.kt b/app/k9mail/src/main/java/com/fsck/k9/backends/Pop3BackendFactory.kt index c15bcf284..86f5f730c 100644 --- a/app/k9mail/src/main/java/com/fsck/k9/backends/Pop3BackendFactory.kt +++ b/app/k9mail/src/main/java/com/fsck/k9/backends/Pop3BackendFactory.kt @@ -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" diff --git a/app/k9mail/src/main/java/com/fsck/k9/backends/WebDavBackendFactory.kt b/app/k9mail/src/main/java/com/fsck/k9/backends/WebDavBackendFactory.kt index eaea5dfb4..88e5d132a 100644 --- a/app/k9mail/src/main/java/com/fsck/k9/backends/WebDavBackendFactory.kt +++ b/app/k9mail/src/main/java/com/fsck/k9/backends/WebDavBackendFactory.kt @@ -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" diff --git a/app/k9mail/src/main/java/com/fsck/k9/notification/K9NotificationStrategy.kt b/app/k9mail/src/main/java/com/fsck/k9/notification/K9NotificationStrategy.kt index 31cf6d3b2..e04f21529 100644 --- a/app/k9mail/src/main/java/com/fsck/k9/notification/K9NotificationStrategy.kt +++ b/app/k9mail/src/main/java/com/fsck/k9/notification/K9NotificationStrategy.kt @@ -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) - } } - diff --git a/app/k9mail/src/main/java/com/fsck/k9/provider/UnreadWidgetProvider.kt b/app/k9mail/src/main/java/com/fsck/k9/provider/UnreadWidgetProvider.kt index 0926bfad3..a75546280 100644 --- a/app/k9mail/src/main/java/com/fsck/k9/provider/UnreadWidgetProvider.kt +++ b/app/k9mail/src/main/java/com/fsck/k9/provider/UnreadWidgetProvider.kt @@ -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) diff --git a/app/k9mail/src/main/java/com/fsck/k9/resources/K9AutocryptStringProvider.kt b/app/k9mail/src/main/java/com/fsck/k9/resources/K9AutocryptStringProvider.kt index abf81c4ae..a24958e15 100644 --- a/app/k9mail/src/main/java/com/fsck/k9/resources/K9AutocryptStringProvider.kt +++ b/app/k9mail/src/main/java/com/fsck/k9/resources/K9AutocryptStringProvider.kt @@ -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) diff --git a/app/k9mail/src/main/java/com/fsck/k9/widget/unread/UnreadWidgetConfigurationActivity.kt b/app/k9mail/src/main/java/com/fsck/k9/widget/unread/UnreadWidgetConfigurationActivity.kt index e2b157372..dc885767d 100644 --- a/app/k9mail/src/main/java/com/fsck/k9/widget/unread/UnreadWidgetConfigurationActivity.kt +++ b/app/k9mail/src/main/java/com/fsck/k9/widget/unread/UnreadWidgetConfigurationActivity.kt @@ -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. */ diff --git a/app/k9mail/src/main/java/com/fsck/k9/widget/unread/UnreadWidgetData.kt b/app/k9mail/src/main/java/com/fsck/k9/widget/unread/UnreadWidgetData.kt index dad5f24c7..bfcfeadb8 100644 --- a/app/k9mail/src/main/java/com/fsck/k9/widget/unread/UnreadWidgetData.kt +++ b/app/k9mail/src/main/java/com/fsck/k9/widget/unread/UnreadWidgetData.kt @@ -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 ) diff --git a/app/k9mail/src/main/java/com/fsck/k9/widget/unread/UnreadWidgetDataProvider.kt b/app/k9mail/src/main/java/com/fsck/k9/widget/unread/UnreadWidgetDataProvider.kt index 48c76c53e..85ab72d67 100644 --- a/app/k9mail/src/main/java/com/fsck/k9/widget/unread/UnreadWidgetDataProvider.kt +++ b/app/k9mail/src/main/java/com/fsck/k9/widget/unread/UnreadWidgetDataProvider.kt @@ -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) diff --git a/app/k9mail/src/main/java/com/fsck/k9/widget/unread/UnreadWidgetRepository.kt b/app/k9mail/src/main/java/com/fsck/k9/widget/unread/UnreadWidgetRepository.kt index 2f107682c..af75e2403 100644 --- a/app/k9mail/src/main/java/com/fsck/k9/widget/unread/UnreadWidgetRepository.kt +++ b/app/k9mail/src/main/java/com/fsck/k9/widget/unread/UnreadWidgetRepository.kt @@ -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) { diff --git a/app/k9mail/src/main/java/com/fsck/k9/widget/unread/UnreadWidgetUpdater.kt b/app/k9mail/src/main/java/com/fsck/k9/widget/unread/UnreadWidgetUpdater.kt index ea40e8e9e..b86f1155e 100644 --- a/app/k9mail/src/main/java/com/fsck/k9/widget/unread/UnreadWidgetUpdater.kt +++ b/app/k9mail/src/main/java/com/fsck/k9/widget/unread/UnreadWidgetUpdater.kt @@ -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) diff --git a/app/k9mail/src/test/java/com/fsck/k9/widget/unread/UnreadWidgetDataProviderTest.kt b/app/k9mail/src/test/java/com/fsck/k9/widget/unread/UnreadWidgetDataProviderTest.kt index 8610f168c..407c0f813 100644 --- a/app/k9mail/src/test/java/com/fsck/k9/widget/unread/UnreadWidgetDataProviderTest.kt +++ b/app/k9mail/src/test/java/com/fsck/k9/widget/unread/UnreadWidgetDataProviderTest.kt @@ -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 diff --git a/app/storage/src/main/java/com/fsck/k9/preferences/migrations/StorageMigrationTo3.kt b/app/storage/src/main/java/com/fsck/k9/preferences/migrations/StorageMigrationTo3.kt index 98e8cf391..e0e3062e9 100644 --- a/app/storage/src/main/java/com/fsck/k9/preferences/migrations/StorageMigrationTo3.kt +++ b/app/storage/src/main/java/com/fsck/k9/preferences/migrations/StorageMigrationTo3.kt @@ -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 diff --git a/app/storage/src/main/java/com/fsck/k9/preferences/migrations/StorageMigrationTo4.kt b/app/storage/src/main/java/com/fsck/k9/preferences/migrations/StorageMigrationTo4.kt index fadc37be9..066306bb4 100644 --- a/app/storage/src/main/java/com/fsck/k9/preferences/migrations/StorageMigrationTo4.kt +++ b/app/storage/src/main/java/com/fsck/k9/preferences/migrations/StorageMigrationTo4.kt @@ -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") diff --git a/app/storage/src/main/java/com/fsck/k9/preferences/migrations/StorageMigrationTo5.kt b/app/storage/src/main/java/com/fsck/k9/preferences/migrations/StorageMigrationTo5.kt index 923bf31b6..318c54a5a 100644 --- a/app/storage/src/main/java/com/fsck/k9/preferences/migrations/StorageMigrationTo5.kt +++ b/app/storage/src/main/java/com/fsck/k9/preferences/migrations/StorageMigrationTo5.kt @@ -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 diff --git a/app/storage/src/main/java/com/fsck/k9/preferences/migrations/StorageMigrationTo6.kt b/app/storage/src/main/java/com/fsck/k9/preferences/migrations/StorageMigrationTo6.kt index 870434ebe..a3ab14596 100644 --- a/app/storage/src/main/java/com/fsck/k9/preferences/migrations/StorageMigrationTo6.kt +++ b/app/storage/src/main/java/com/fsck/k9/preferences/migrations/StorageMigrationTo6.kt @@ -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() diff --git a/app/storage/src/main/java/com/fsck/k9/preferences/migrations/StorageMigrationTo7.kt b/app/storage/src/main/java/com/fsck/k9/preferences/migrations/StorageMigrationTo7.kt index 4939e895b..70c9675dd 100644 --- a/app/storage/src/main/java/com/fsck/k9/preferences/migrations/StorageMigrationTo7.kt +++ b/app/storage/src/main/java/com/fsck/k9/preferences/migrations/StorageMigrationTo7.kt @@ -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() diff --git a/app/storage/src/main/java/com/fsck/k9/preferences/migrations/StorageMigrationTo8.kt b/app/storage/src/main/java/com/fsck/k9/preferences/migrations/StorageMigrationTo8.kt index cd4e53513..7ac8e8ec2 100644 --- a/app/storage/src/main/java/com/fsck/k9/preferences/migrations/StorageMigrationTo8.kt +++ b/app/storage/src/main/java/com/fsck/k9/preferences/migrations/StorageMigrationTo8.kt @@ -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") diff --git a/app/storage/src/main/java/com/fsck/k9/preferences/migrations/StorageMigrationTo9.kt b/app/storage/src/main/java/com/fsck/k9/preferences/migrations/StorageMigrationTo9.kt index a8c28af48..dbb3e6b05 100644 --- a/app/storage/src/main/java/com/fsck/k9/preferences/migrations/StorageMigrationTo9.kt +++ b/app/storage/src/main/java/com/fsck/k9/preferences/migrations/StorageMigrationTo9.kt @@ -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") diff --git a/app/storage/src/main/java/com/fsck/k9/storage/migrations/FullTextIndexer.kt b/app/storage/src/main/java/com/fsck/k9/storage/migrations/FullTextIndexer.kt index 70440155f..ba1e680a9 100644 --- a/app/storage/src/main/java/com/fsck/k9/storage/migrations/FullTextIndexer.kt +++ b/app/storage/src/main/java/com/fsck/k9/storage/migrations/FullTextIndexer.kt @@ -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) } diff --git a/app/storage/src/main/java/com/fsck/k9/storage/migrations/MigrationTo64.kt b/app/storage/src/main/java/com/fsck/k9/storage/migrations/MigrationTo64.kt index 05234cef9..3d1c5fd5f 100644 --- a/app/storage/src/main/java/com/fsck/k9/storage/migrations/MigrationTo64.kt +++ b/app/storage/src/main/java/com/fsck/k9/storage/migrations/MigrationTo64.kt @@ -1,9 +1,7 @@ package com.fsck.k9.storage.migrations - import android.database.sqlite.SQLiteDatabase - internal object MigrationTo64 { @JvmStatic fun addExtraValuesTables(db: SQLiteDatabase) { diff --git a/app/storage/src/main/java/com/fsck/k9/storage/migrations/MigrationTo65.kt b/app/storage/src/main/java/com/fsck/k9/storage/migrations/MigrationTo65.kt index f095d84ba..9e18e06a1 100644 --- a/app/storage/src/main/java/com/fsck/k9/storage/migrations/MigrationTo65.kt +++ b/app/storage/src/main/java/com/fsck/k9/storage/migrations/MigrationTo65.kt @@ -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) { diff --git a/app/storage/src/main/java/com/fsck/k9/storage/migrations/MigrationTo66.kt b/app/storage/src/main/java/com/fsck/k9/storage/migrations/MigrationTo66.kt index 998d5e446..84be1a7b0 100644 --- a/app/storage/src/main/java/com/fsck/k9/storage/migrations/MigrationTo66.kt +++ b/app/storage/src/main/java/com/fsck/k9/storage/migrations/MigrationTo66.kt @@ -2,7 +2,6 @@ package com.fsck.k9.storage.migrations import android.database.sqlite.SQLiteDatabase - internal object MigrationTo66 { @JvmStatic fun addEncryptionTypeColumnToMessagesTable(db: SQLiteDatabase) { diff --git a/app/storage/src/main/java/com/fsck/k9/storage/migrations/MigrationTo67.kt b/app/storage/src/main/java/com/fsck/k9/storage/migrations/MigrationTo67.kt index a2209afed..a6879b5c7 100644 --- a/app/storage/src/main/java/com/fsck/k9/storage/migrations/MigrationTo67.kt +++ b/app/storage/src/main/java/com/fsck/k9/storage/migrations/MigrationTo67.kt @@ -3,7 +3,6 @@ package com.fsck.k9.storage.migrations import android.database.sqlite.SQLiteDatabase import com.fsck.k9.mailstore.MigrationsHelper - internal object MigrationTo67 { @JvmStatic fun addTypeColumnToFoldersTable(db: SQLiteDatabase, migrationsHelper: MigrationsHelper) { diff --git a/app/storage/src/main/java/com/fsck/k9/storage/migrations/MigrationTo68.kt b/app/storage/src/main/java/com/fsck/k9/storage/migrations/MigrationTo68.kt index 44291579e..4f56dc6d2 100644 --- a/app/storage/src/main/java/com/fsck/k9/storage/migrations/MigrationTo68.kt +++ b/app/storage/src/main/java/com/fsck/k9/storage/migrations/MigrationTo68.kt @@ -2,7 +2,6 @@ package com.fsck.k9.storage.migrations import android.database.sqlite.SQLiteDatabase - internal object MigrationTo68 { @JvmStatic fun addOutboxStateTable(db: SQLiteDatabase) { diff --git a/app/storage/src/main/java/com/fsck/k9/storage/migrations/MigrationTo69.kt b/app/storage/src/main/java/com/fsck/k9/storage/migrations/MigrationTo69.kt index 4ef11b9ab..d72dcda1a 100644 --- a/app/storage/src/main/java/com/fsck/k9/storage/migrations/MigrationTo69.kt +++ b/app/storage/src/main/java/com/fsck/k9/storage/migrations/MigrationTo69.kt @@ -7,11 +7,9 @@ import com.fsck.k9.controller.MessagingControllerCommands.PendingSetFlag import com.fsck.k9.controller.PendingCommandSerializer import com.fsck.k9.mail.Flag - internal class MigrationTo69(private val db: SQLiteDatabase) { private val serializer: PendingCommandSerializer = PendingCommandSerializer.getInstance() - fun createPendingDelete() { val pendingSetFlagsToConvert = mutableListOf() diff --git a/app/storage/src/test/java/com/fsck/k9/preferences/StorageEditorTest.kt b/app/storage/src/test/java/com/fsck/k9/preferences/StorageEditorTest.kt index c7d4eb777..26d6a1b32 100644 --- a/app/storage/src/test/java/com/fsck/k9/preferences/StorageEditorTest.kt +++ b/app/storage/src/test/java/com/fsck/k9/preferences/StorageEditorTest.kt @@ -1,6 +1,5 @@ package com.fsck.k9.preferences - import com.fsck.k9.storage.K9RobolectricTest import com.nhaarman.mockito_kotlin.verifyNoMoreInteractions import com.nhaarman.mockito_kotlin.whenever @@ -16,14 +15,13 @@ import org.mockito.Mockito.times import org.mockito.Mockito.verify import org.mockito.MockitoAnnotations - class StorageEditorTest : K9RobolectricTest() { @Mock private lateinit var storage: Storage @Mock private lateinit var storagePersister: K9StoragePersister @Mock private lateinit var storagePersisterOps: K9StoragePersister.StoragePersistOperations private lateinit var editor: K9StorageEditor - private val workingMap = mutableMapOf() + private val workingMap = mutableMapOf() private val storageMap = mapOf( "storage-key" to "storage-value" ) diff --git a/app/storage/src/test/java/com/fsck/k9/preferences/StoragePersisterTest.kt b/app/storage/src/test/java/com/fsck/k9/preferences/StoragePersisterTest.kt index 1e1b82772..44f3b6e8a 100644 --- a/app/storage/src/test/java/com/fsck/k9/preferences/StoragePersisterTest.kt +++ b/app/storage/src/test/java/com/fsck/k9/preferences/StoragePersisterTest.kt @@ -1,6 +1,5 @@ package com.fsck.k9.preferences - import android.content.Context import com.fsck.k9.preferences.K9StoragePersister.StoragePersistOperationCallback import com.fsck.k9.preferences.K9StoragePersister.StoragePersistOperations @@ -18,7 +17,6 @@ import org.junit.Assert.fail import org.junit.Test import org.robolectric.RuntimeEnvironment - class StoragePersisterTest : K9RobolectricTest() { private var context: Context = RuntimeEnvironment.application private var storagePersister = K9StoragePersister(context) @@ -103,9 +101,9 @@ class StoragePersisterTest : K9RobolectricTest() { } private fun prepareCallback( - persistOp: ((StoragePersistOperations) -> Unit)? = null, - before: ((MutableMap) -> Unit)? = null, - onSuccess: ((Map) -> Unit)? = null + persistOp: ((StoragePersistOperations) -> Unit)? = null, + before: ((MutableMap) -> Unit)? = null, + onSuccess: ((Map) -> Unit)? = null ): StoragePersistOperationCallback = spy(object : StoragePersistOperationCallback { override fun beforePersistTransaction(workingStorage: MutableMap) { before?.invoke(workingStorage) diff --git a/app/storage/src/test/java/com/fsck/k9/storage/migrations/MigrationTo51Test.kt b/app/storage/src/test/java/com/fsck/k9/storage/migrations/MigrationTo51Test.kt index 2427c5ba8..120693e45 100644 --- a/app/storage/src/test/java/com/fsck/k9/storage/migrations/MigrationTo51Test.kt +++ b/app/storage/src/test/java/com/fsck/k9/storage/migrations/MigrationTo51Test.kt @@ -7,6 +7,7 @@ import com.fsck.k9.mailstore.StorageManager import com.fsck.k9.storage.RobolectricTest import com.nhaarman.mockito_kotlin.doReturn import com.nhaarman.mockito_kotlin.mock +import java.io.ByteArrayInputStream import org.apache.commons.io.IOUtils import org.apache.james.mime4j.codec.QuotedPrintableInputStream import org.junit.Assert.assertEquals @@ -14,14 +15,11 @@ import org.junit.Assert.assertTrue import org.junit.Before import org.junit.Test import org.robolectric.RuntimeEnvironment -import java.io.ByteArrayInputStream - class MigrationTo51Test : RobolectricTest() { private lateinit var mockMigrationsHelper: MigrationsHelper private lateinit var database: SQLiteDatabase - @Before fun setUp() { val storageManager = StorageManager.getInstance(RuntimeEnvironment.application) @@ -108,7 +106,6 @@ class MigrationTo51Test : RobolectricTest() { assertEquals("", htmlMessagePartBody()) } - private fun createWithV50Table(): SQLiteDatabase { val database = SQLiteDatabase.create(null) database.execSQL(""" @@ -192,10 +189,10 @@ class MigrationTo51Test : RobolectricTest() { } private fun insertMessage( - mimeType: String, - htmlContent: String? = null, - textContent: String? = null, - attachmentCount: Int = 0 + mimeType: String, + htmlContent: String? = null, + textContent: String? = null, + attachmentCount: Int = 0 ) { database.execSQL( "INSERT INTO messages (flags, html_content, text_content, mime_type, attachment_count) " + diff --git a/app/testing/src/main/java/com/fsck/k9/preferences/InMemoryStoragePersister.kt b/app/testing/src/main/java/com/fsck/k9/preferences/InMemoryStoragePersister.kt index aec833bca..6eb8c8d9e 100644 --- a/app/testing/src/main/java/com/fsck/k9/preferences/InMemoryStoragePersister.kt +++ b/app/testing/src/main/java/com/fsck/k9/preferences/InMemoryStoragePersister.kt @@ -5,21 +5,18 @@ import android.content.SharedPreferences class InMemoryStoragePersister : StoragePersister { private val values = mutableMapOf() - override fun loadValues(): Map { return values.mapValues { (_, value) -> value?.toString() ?: "" } } override fun createStorageEditor(storage: Storage): StorageEditor = InMemoryStorageEditor(storage) - private inner class InMemoryStorageEditor(private val storage: Storage) : StorageEditor { private val snapshot = storage.all.toMutableMap() private val removals = mutableSetOf() private val changes = mutableMapOf() private var alreadyCommitted = false - override fun copy(input: SharedPreferences) = Unit override fun putBoolean(key: String, value: Boolean) = apply { diff --git a/app/ui/src/main/java/com/fsck/k9/account/AccountRemover.kt b/app/ui/src/main/java/com/fsck/k9/account/AccountRemover.kt index a5658e0b8..8e79e0165 100644 --- a/app/ui/src/main/java/com/fsck/k9/account/AccountRemover.kt +++ b/app/ui/src/main/java/com/fsck/k9/account/AccountRemover.kt @@ -10,9 +10,9 @@ import timber.log.Timber * Removes an account and all associated data. */ class AccountRemover( - private val localStoreProvider: LocalStoreProvider, - private val messagingController: MessagingController, - private val preferences: Preferences + private val localStoreProvider: LocalStoreProvider, + private val messagingController: MessagingController, + private val preferences: Preferences ) { fun removeAccount(accountUuid: String) { diff --git a/app/ui/src/main/java/com/fsck/k9/account/AccountRemoverService.kt b/app/ui/src/main/java/com/fsck/k9/account/AccountRemoverService.kt index ef8e94897..207ab9631 100644 --- a/app/ui/src/main/java/com/fsck/k9/account/AccountRemoverService.kt +++ b/app/ui/src/main/java/com/fsck/k9/account/AccountRemoverService.kt @@ -12,7 +12,6 @@ import org.koin.core.inject class AccountRemoverService : JobIntentService(), KoinComponent { private val accountRemover: AccountRemover by inject() - override fun onHandleWork(intent: Intent) { val accountUuid = intent.getStringExtra(ARG_ACCOUNT_UUID) ?: throw IllegalArgumentException("No account UUID provided") @@ -20,12 +19,10 @@ class AccountRemoverService : JobIntentService(), KoinComponent { accountRemover.removeAccount(accountUuid) } - companion object { private const val JOB_ID = 1 private const val ARG_ACCOUNT_UUID = "accountUuid" - fun enqueueRemoveAccountJob(context: Context, accountUuid: String) { val workIntent = Intent().apply { putExtra(ARG_ACCOUNT_UUID, accountUuid) diff --git a/app/ui/src/main/java/com/fsck/k9/account/BackgroundAccountRemover.kt b/app/ui/src/main/java/com/fsck/k9/account/BackgroundAccountRemover.kt index 48339aac4..3bca002a0 100644 --- a/app/ui/src/main/java/com/fsck/k9/account/BackgroundAccountRemover.kt +++ b/app/ui/src/main/java/com/fsck/k9/account/BackgroundAccountRemover.kt @@ -7,7 +7,7 @@ import android.content.Context */ class BackgroundAccountRemover(private val context: Context) { fun removeAccountAsync(accountUuid: String) { - //TODO: Add a mechanism to hide the account from the UI right away + // TODO: Add a mechanism to hide the account from the UI right away AccountRemoverService.enqueueRemoveAccountJob(context, accountUuid) } diff --git a/app/ui/src/main/java/com/fsck/k9/activity/K9ActivityCommon.kt b/app/ui/src/main/java/com/fsck/k9/activity/K9ActivityCommon.kt index a23e37709..22f6c72d6 100644 --- a/app/ui/src/main/java/com/fsck/k9/activity/K9ActivityCommon.kt +++ b/app/ui/src/main/java/com/fsck/k9/activity/K9ActivityCommon.kt @@ -10,10 +10,9 @@ import com.fsck.k9.activity.misc.SwipeGestureDetector import com.fsck.k9.activity.misc.SwipeGestureDetector.OnSwipeGestureListener import com.fsck.k9.ui.Theme import com.fsck.k9.ui.ThemeManager +import java.util.Locale import org.koin.core.KoinComponent import org.koin.core.inject -import java.util.Locale - /** * This class implements functionality common to most activities used in K-9 Mail. @@ -22,8 +21,8 @@ import java.util.Locale * @see K9PreferenceActivity */ class K9ActivityCommon( - private val activity: Activity, - private val themeType: ThemeType + private val activity: Activity, + private val themeType: ThemeType ) { private var gestureDetector: GestureDetector? = null private lateinit var currentLanguage: String @@ -31,7 +30,6 @@ class K9ActivityCommon( val themeManager = Companion.themeManager - /** * Call this before calling `super.onCreate(Bundle)`. */ @@ -88,7 +86,6 @@ class K9ActivityCommon( resources.updateConfiguration(config, resources.displayMetrics) } - companion object : KoinComponent { private val themeManager: ThemeManager by inject() } diff --git a/app/ui/src/main/java/com/fsck/k9/activity/MessageLoaderHelperFactory.kt b/app/ui/src/main/java/com/fsck/k9/activity/MessageLoaderHelperFactory.kt index efd458689..20e7c814b 100644 --- a/app/ui/src/main/java/com/fsck/k9/activity/MessageLoaderHelperFactory.kt +++ b/app/ui/src/main/java/com/fsck/k9/activity/MessageLoaderHelperFactory.kt @@ -8,14 +8,14 @@ import com.fsck.k9.mailstore.MessageViewInfoExtractorFactory import com.fsck.k9.ui.helper.HtmlSettingsProvider class MessageLoaderHelperFactory( - private val messageViewInfoExtractorFactory: MessageViewInfoExtractorFactory, - private val htmlSettingsProvider: HtmlSettingsProvider + private val messageViewInfoExtractorFactory: MessageViewInfoExtractorFactory, + private val htmlSettingsProvider: HtmlSettingsProvider ) { fun createForMessageView( - context: Context, - loaderManager: LoaderManager, - fragmentManager: FragmentManager, - callback: MessageLoaderCallbacks + context: Context, + loaderManager: LoaderManager, + fragmentManager: FragmentManager, + callback: MessageLoaderCallbacks ): MessageLoaderHelper { val htmlSettings = htmlSettingsProvider.createForMessageView() val messageViewInfoExtractor = messageViewInfoExtractorFactory.create(htmlSettings) @@ -23,10 +23,10 @@ class MessageLoaderHelperFactory( } fun createForMessageCompose( - context: Context, - loaderManager: LoaderManager, - fragmentManager: FragmentManager, - callback: MessageLoaderCallbacks + context: Context, + loaderManager: LoaderManager, + fragmentManager: FragmentManager, + callback: MessageLoaderCallbacks ): MessageLoaderHelper { val htmlSettings = htmlSettingsProvider.createForMessageCompose() val messageViewInfoExtractor = messageViewInfoExtractorFactory.create(htmlSettings) diff --git a/app/ui/src/main/java/com/fsck/k9/activity/compose/ComposeCryptoStatus.kt b/app/ui/src/main/java/com/fsck/k9/activity/compose/ComposeCryptoStatus.kt index a5483916a..822ec1592 100644 --- a/app/ui/src/main/java/com/fsck/k9/activity/compose/ComposeCryptoStatus.kt +++ b/app/ui/src/main/java/com/fsck/k9/activity/compose/ComposeCryptoStatus.kt @@ -1,6 +1,5 @@ package com.fsck.k9.activity.compose - import com.fsck.k9.activity.compose.RecipientMvpView.CryptoSpecialModeDisplayType import com.fsck.k9.activity.compose.RecipientMvpView.CryptoStatusDisplayType import com.fsck.k9.activity.compose.RecipientPresenter.CryptoMode @@ -16,27 +15,29 @@ import org.openintents.openpgp.OpenPgpApiManager.OpenPgpProviderState * or saving as draft. */ data class ComposeCryptoStatus( - private val openPgpProviderState: OpenPgpProviderState, - override val openPgpKeyId: Long?, - val recipientAddresses: List, - override val isPgpInlineModeEnabled: Boolean, - override val isSenderPreferEncryptMutual: Boolean, - override val isReplyToEncrypted: Boolean, - override val isEncryptAllDrafts: Boolean, - override val isEncryptSubject: Boolean, - private val cryptoMode: CryptoMode, - private val recipientAutocryptStatus: RecipientAutocryptStatus? = null + private val openPgpProviderState: OpenPgpProviderState, + override val openPgpKeyId: Long?, + val recipientAddresses: List, + override val isPgpInlineModeEnabled: Boolean, + override val isSenderPreferEncryptMutual: Boolean, + override val isReplyToEncrypted: Boolean, + override val isEncryptAllDrafts: Boolean, + override val isEncryptSubject: Boolean, + private val cryptoMode: CryptoMode, + private val recipientAutocryptStatus: RecipientAutocryptStatus? = null ) : CryptoStatus { - constructor(openPgpProviderState: OpenPgpProviderState, - openPgpKeyId: Long?, - recipientAddresses: List, - isPgpInlineModeEnabled: Boolean, - isSenderPreferEncryptMutual: Boolean, - isReplyToEncrypted: Boolean, - isEncryptAllDrafts: Boolean, - isEncryptSubject: Boolean, - cryptoMode: CryptoMode) : this( + constructor( + openPgpProviderState: OpenPgpProviderState, + openPgpKeyId: Long?, + recipientAddresses: List, + isPgpInlineModeEnabled: Boolean, + isSenderPreferEncryptMutual: Boolean, + isReplyToEncrypted: Boolean, + isEncryptAllDrafts: Boolean, + isEncryptSubject: Boolean, + cryptoMode: CryptoMode + ) : this( openPgpProviderState, openPgpKeyId, recipientAddresses.map { it.address.address }, isPgpInlineModeEnabled, isSenderPreferEncryptMutual, isReplyToEncrypted, isEncryptAllDrafts, isEncryptSubject, cryptoMode) @@ -160,5 +161,4 @@ data class ComposeCryptoStatus( enum class AttachErrorState { IS_INLINE } - } diff --git a/app/ui/src/main/java/com/fsck/k9/contacts/ContactLetterBitmapCreator.kt b/app/ui/src/main/java/com/fsck/k9/contacts/ContactLetterBitmapCreator.kt index 651cbf88f..af20da9a9 100644 --- a/app/ui/src/main/java/com/fsck/k9/contacts/ContactLetterBitmapCreator.kt +++ b/app/ui/src/main/java/com/fsck/k9/contacts/ContactLetterBitmapCreator.kt @@ -13,8 +13,8 @@ import com.fsck.k9.ui.helper.MaterialColors * Draw a `Bitmap` containing the "contact letter" obtained by [ContactLetterExtractor]. */ class ContactLetterBitmapCreator( - private val letterExtractor: ContactLetterExtractor, - val config: ContactLetterBitmapConfig + private val letterExtractor: ContactLetterExtractor, + val config: ContactLetterBitmapConfig ) { fun drawBitmap(bitmap: Bitmap, pictureSizeInPx: Int, address: Address): Bitmap { val canvas = Canvas(bitmap) diff --git a/app/ui/src/main/java/com/fsck/k9/contacts/ContactLetterExtractor.kt b/app/ui/src/main/java/com/fsck/k9/contacts/ContactLetterExtractor.kt index 0cf70b7d0..0664a5eb0 100644 --- a/app/ui/src/main/java/com/fsck/k9/contacts/ContactLetterExtractor.kt +++ b/app/ui/src/main/java/com/fsck/k9/contacts/ContactLetterExtractor.kt @@ -14,5 +14,5 @@ class ContactLetterExtractor { companion object { private val EXTRACT_LETTER_PATTERN = Regex("\\p{L}\\p{M}*") private const val FALLBACK_CONTACT_LETTER = "?" - } + } } diff --git a/app/ui/src/main/java/com/fsck/k9/contacts/ContactPictureLoader.kt b/app/ui/src/main/java/com/fsck/k9/contacts/ContactPictureLoader.kt index 6836dded7..f03ad1d32 100644 --- a/app/ui/src/main/java/com/fsck/k9/contacts/ContactPictureLoader.kt +++ b/app/ui/src/main/java/com/fsck/k9/contacts/ContactPictureLoader.kt @@ -1,6 +1,5 @@ package com.fsck.k9.contacts - import android.content.Context import android.graphics.Bitmap import android.graphics.BitmapFactory @@ -21,12 +20,12 @@ import com.fsck.k9.helper.Contacts import com.fsck.k9.mail.Address import com.fsck.k9.ui.R import com.fsck.k9.view.RecipientSelectView.Recipient -import timber.log.Timber import kotlin.math.max +import timber.log.Timber class ContactPictureLoader( - private val context: Context, - private val contactLetterBitmapCreator: ContactLetterBitmapCreator + private val context: Context, + private val contactLetterBitmapCreator: ContactLetterBitmapCreator ) { private val contactsHelper: Contacts = Contacts.getInstance(context) private val pictureSizeInPx: Int = PICTURE_SIZE.toDip(context) @@ -34,7 +33,6 @@ class ContactPictureLoader( if (hasDefaultBackgroundColor) defaultBackgroundColor.toString() else "*" } - fun setContactPicture(imageView: ImageView, address: Address) { Glide.with(imageView.context) .using(AddressModelLoader(backgroundCacheId), Address::class.java) @@ -178,7 +176,6 @@ class ContactPictureLoader( private fun Int.toDip(context: Context): Int = (this * context.resources.displayMetrics.density).toInt() - companion object { /** * Resize the pictures to the following value (device-independent pixels). diff --git a/app/ui/src/main/java/com/fsck/k9/fragment/MessageListAdapter.kt b/app/ui/src/main/java/com/fsck/k9/fragment/MessageListAdapter.kt index 2b644de55..6993fd2a7 100644 --- a/app/ui/src/main/java/com/fsck/k9/fragment/MessageListAdapter.kt +++ b/app/ui/src/main/java/com/fsck/k9/fragment/MessageListAdapter.kt @@ -1,6 +1,5 @@ package com.fsck.k9.fragment - import android.content.Context import android.content.res.Resources import android.database.Cursor @@ -20,18 +19,11 @@ import android.widget.CursorAdapter import android.widget.TextView import androidx.core.graphics.drawable.DrawableCompat import androidx.core.view.isVisible - import com.fsck.k9.Account import com.fsck.k9.FontSizes -import com.fsck.k9.ui.R import com.fsck.k9.Preferences import com.fsck.k9.contacts.ContactPictureLoader import com.fsck.k9.controller.MessageReference -import com.fsck.k9.helper.MessageHelper -import com.fsck.k9.mail.Address -import com.fsck.k9.mailstore.DatabasePreviewType -import com.fsck.k9.ui.messagelist.MessageListAppearance - import com.fsck.k9.fragment.MLFProjectionInfo.ACCOUNT_UUID_COLUMN import com.fsck.k9.fragment.MLFProjectionInfo.ANSWERED_COLUMN import com.fsck.k9.fragment.MLFProjectionInfo.ATTACHMENT_COUNT_COLUMN @@ -48,20 +40,24 @@ import com.fsck.k9.fragment.MLFProjectionInfo.SUBJECT_COLUMN import com.fsck.k9.fragment.MLFProjectionInfo.THREAD_COUNT_COLUMN import com.fsck.k9.fragment.MLFProjectionInfo.TO_LIST_COLUMN import com.fsck.k9.fragment.MLFProjectionInfo.UID_COLUMN +import com.fsck.k9.helper.MessageHelper +import com.fsck.k9.mail.Address +import com.fsck.k9.mailstore.DatabasePreviewType import com.fsck.k9.ui.ContactBadge - +import com.fsck.k9.ui.R +import com.fsck.k9.ui.messagelist.MessageListAppearance import kotlin.math.max class MessageListAdapter internal constructor( - context: Context, - theme: Resources.Theme, - private val res: Resources, - private val layoutInflater: LayoutInflater, - private val messageHelper: MessageHelper, - private val contactsPictureLoader: ContactPictureLoader, - private val preferences: Preferences, - private val listItemListener: MessageListItemActionListener, - private val appearance: MessageListAppearance + context: Context, + theme: Resources.Theme, + private val res: Resources, + private val layoutInflater: LayoutInflater, + private val messageHelper: MessageHelper, + private val contactsPictureLoader: ContactPictureLoader, + private val preferences: Preferences, + private val listItemListener: MessageListItemActionListener, + private val appearance: MessageListAppearance ) : CursorAdapter(context, null, 0) { private val forwardedIcon: Drawable @@ -249,10 +245,10 @@ class MessageListAdapter internal constructor( } private fun formatPreviewText( - preview: TextView, - beforePreviewText: CharSequence, - sigil: String, - messageRead: Boolean + preview: TextView, + beforePreviewText: CharSequence, + sigil: String, + messageRead: Boolean ) { val previewText = preview.text as Spannable @@ -287,10 +283,10 @@ class MessageListAdapter internal constructor( } private fun fetchCounterPartyAddress( - fromMe: Boolean, - toAddrs: Array
, - ccAddrs: Array
, - fromAddrs: Array
+ fromMe: Boolean, + toAddrs: Array
, + ccAddrs: Array
, + fromAddrs: Array
): Address? { if (fromMe) { if (toAddrs.size > 0) { diff --git a/app/ui/src/main/java/com/fsck/k9/fragment/MessageViewHolder.kt b/app/ui/src/main/java/com/fsck/k9/fragment/MessageViewHolder.kt index 242f643c4..d85110f37 100644 --- a/app/ui/src/main/java/com/fsck/k9/fragment/MessageViewHolder.kt +++ b/app/ui/src/main/java/com/fsck/k9/fragment/MessageViewHolder.kt @@ -1,6 +1,5 @@ package com.fsck.k9.fragment - import android.annotation.SuppressLint import android.view.View import android.widget.CheckBox @@ -11,8 +10,8 @@ import com.fsck.k9.ui.R @SuppressLint("ResourceType") class MessageViewHolder( - view: View, - private val itemActionListener: MessageListItemActionListener + view: View, + private val itemActionListener: MessageListItemActionListener ) : View.OnClickListener { var position = -1 diff --git a/app/ui/src/main/java/com/fsck/k9/fragment/SortTypeToastProvider.kt b/app/ui/src/main/java/com/fsck/k9/fragment/SortTypeToastProvider.kt index c27831823..998c9ed62 100644 --- a/app/ui/src/main/java/com/fsck/k9/fragment/SortTypeToastProvider.kt +++ b/app/ui/src/main/java/com/fsck/k9/fragment/SortTypeToastProvider.kt @@ -1,7 +1,13 @@ package com.fsck.k9.fragment import com.fsck.k9.Account.SortType -import com.fsck.k9.Account.SortType.* +import com.fsck.k9.Account.SortType.SORT_ARRIVAL +import com.fsck.k9.Account.SortType.SORT_ATTACHMENT +import com.fsck.k9.Account.SortType.SORT_DATE +import com.fsck.k9.Account.SortType.SORT_FLAGGED +import com.fsck.k9.Account.SortType.SORT_SENDER +import com.fsck.k9.Account.SortType.SORT_SUBJECT +import com.fsck.k9.Account.SortType.SORT_UNREAD import com.fsck.k9.ui.R class SortTypeToastProvider { diff --git a/app/ui/src/main/java/com/fsck/k9/ui/FragmentExtras.kt b/app/ui/src/main/java/com/fsck/k9/ui/FragmentExtras.kt index 14563f4f2..d2382c3d5 100644 --- a/app/ui/src/main/java/com/fsck/k9/ui/FragmentExtras.kt +++ b/app/ui/src/main/java/com/fsck/k9/ui/FragmentExtras.kt @@ -1,9 +1,9 @@ package com.fsck.k9.ui +import androidx.core.os.bundleOf import androidx.fragment.app.Fragment import androidx.fragment.app.FragmentActivity import androidx.fragment.app.FragmentTransaction -import androidx.core.os.bundleOf inline fun FragmentActivity.fragmentTransaction(crossinline block: FragmentTransaction.() -> Unit) { with(supportFragmentManager.beginTransaction()) { @@ -13,8 +13,8 @@ inline fun FragmentActivity.fragmentTransaction(crossinline block: FragmentTrans } inline fun FragmentActivity.fragmentTransactionWithBackStack( - name: String? = null, - crossinline block: FragmentTransaction.() -> Unit + name: String? = null, + crossinline block: FragmentTransaction.() -> Unit ) { fragmentTransaction { block() diff --git a/app/ui/src/main/java/com/fsck/k9/ui/K9Drawer.kt b/app/ui/src/main/java/com/fsck/k9/ui/K9Drawer.kt index a71ffd0b2..fc404781e 100644 --- a/app/ui/src/main/java/com/fsck/k9/ui/K9Drawer.kt +++ b/app/ui/src/main/java/com/fsck/k9/ui/K9Drawer.kt @@ -1,6 +1,5 @@ package com.fsck.k9.ui - import android.graphics.Color import android.graphics.PorterDuff import android.net.Uri @@ -10,7 +9,6 @@ import androidx.drawerlayout.widget.DrawerLayout import androidx.lifecycle.Observer import androidx.lifecycle.ViewModelProviders import com.fsck.k9.Account -import com.fsck.k9.DI import com.fsck.k9.K9 import com.fsck.k9.Preferences import com.fsck.k9.activity.MessageList @@ -33,11 +31,10 @@ import com.mikepenz.materialdrawer.DrawerBuilder import com.mikepenz.materialdrawer.model.DividerDrawerItem import com.mikepenz.materialdrawer.model.PrimaryDrawerItem import com.mikepenz.materialdrawer.model.ProfileDrawerItem -import org.koin.core.KoinComponent -import org.koin.core.inject import java.util.ArrayList import java.util.HashSet - +import org.koin.core.KoinComponent +import org.koin.core.inject class K9Drawer(private val parent: MessageList, savedInstanceState: Bundle?) : KoinComponent { private val folderNameFormatter: FolderNameFormatter by inject() @@ -57,7 +54,6 @@ class K9Drawer(private val parent: MessageList, savedInstanceState: Bundle?) : K setUserFolders(folders) } - val layout: DrawerLayout get() = drawer.drawerLayout @@ -297,7 +293,6 @@ class K9Drawer(private val parent: MessageList, savedInstanceState: Bundle?) : K drawer.drawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED) } - companion object { // Bit shift for identifiers of user folders items, to leave space for other items private const val DRAWER_FOLDER_SHIFT: Int = 2 diff --git a/app/ui/src/main/java/com/fsck/k9/ui/ThemeManager.kt b/app/ui/src/main/java/com/fsck/k9/ui/ThemeManager.kt index 43f76bcf4..5b3c67cb0 100644 --- a/app/ui/src/main/java/com/fsck/k9/ui/ThemeManager.kt +++ b/app/ui/src/main/java/com/fsck/k9/ui/ThemeManager.kt @@ -43,7 +43,6 @@ class ThemeManager(private val context: Context) { @get:StyleRes val translucentDialogThemeResourceId: Int = R.style.Theme_K9_Dialog_Translucent_DayNight - fun init() { updateAppTheme() } @@ -89,7 +88,7 @@ class ThemeManager(private val context: Context) { return when (context.resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK) { Configuration.UI_MODE_NIGHT_NO -> Theme.LIGHT Configuration.UI_MODE_NIGHT_YES -> Theme.DARK - else -> Theme.LIGHT + else -> Theme.LIGHT } } } diff --git a/app/ui/src/main/java/com/fsck/k9/ui/endtoend/AutocryptKeyTransferActivity.kt b/app/ui/src/main/java/com/fsck/k9/ui/endtoend/AutocryptKeyTransferActivity.kt index e9f724d95..d53c96545 100644 --- a/app/ui/src/main/java/com/fsck/k9/ui/endtoend/AutocryptKeyTransferActivity.kt +++ b/app/ui/src/main/java/com/fsck/k9/ui/endtoend/AutocryptKeyTransferActivity.kt @@ -1,6 +1,5 @@ package com.fsck.k9.ui.endtoend - import android.app.PendingIntent import android.content.Context import android.content.Intent @@ -20,7 +19,6 @@ import org.koin.android.ext.android.inject import org.koin.core.parameter.parametersOf import timber.log.Timber - class AutocryptKeyTransferActivity : K9Activity() { private val presenter: AutocryptKeyTransferPresenter by inject { parametersOf(this, this) } @@ -40,7 +38,7 @@ class AutocryptKeyTransferActivity : K9Activity() { override fun onOptionsItemSelected(item: MenuItem?): Boolean { if (item?.itemId == android.R.id.home) { - presenter.onClickHome(); + presenter.onClickHome() return true } else { return super.onOptionsItemSelected(item) diff --git a/app/ui/src/main/java/com/fsck/k9/ui/endtoend/AutocryptKeyTransferPresenter.kt b/app/ui/src/main/java/com/fsck/k9/ui/endtoend/AutocryptKeyTransferPresenter.kt index abbe8a7c7..e0341841e 100644 --- a/app/ui/src/main/java/com/fsck/k9/ui/endtoend/AutocryptKeyTransferPresenter.kt +++ b/app/ui/src/main/java/com/fsck/k9/ui/endtoend/AutocryptKeyTransferPresenter.kt @@ -1,6 +1,5 @@ package com.fsck.k9.ui.endtoend - import android.app.PendingIntent import androidx.lifecycle.LifecycleOwner import androidx.lifecycle.Observer @@ -14,13 +13,12 @@ import org.openintents.openpgp.OpenPgpApiManager.OpenPgpApiManagerCallback import org.openintents.openpgp.OpenPgpApiManager.OpenPgpProviderError import timber.log.Timber - class AutocryptKeyTransferPresenter internal constructor( - lifecycleOwner: LifecycleOwner, - private val openPgpApiManager: OpenPgpApiManager, - private val preferences: Preferences, - private val viewModel: AutocryptKeyTransferViewModel, - private val view: AutocryptKeyTransferActivity + lifecycleOwner: LifecycleOwner, + private val openPgpApiManager: OpenPgpApiManager, + private val preferences: Preferences, + private val viewModel: AutocryptKeyTransferViewModel, + private val view: AutocryptKeyTransferActivity ) { private lateinit var account: Account diff --git a/app/ui/src/main/java/com/fsck/k9/ui/endtoend/AutocryptKeyTransferViewModel.kt b/app/ui/src/main/java/com/fsck/k9/ui/endtoend/AutocryptKeyTransferViewModel.kt index 4616358bb..056514baf 100644 --- a/app/ui/src/main/java/com/fsck/k9/ui/endtoend/AutocryptKeyTransferViewModel.kt +++ b/app/ui/src/main/java/com/fsck/k9/ui/endtoend/AutocryptKeyTransferViewModel.kt @@ -3,5 +3,6 @@ package com.fsck.k9.ui.endtoend import androidx.lifecycle.ViewModel internal class AutocryptKeyTransferViewModel( - val autocryptSetupMessageLiveEvent: AutocryptSetupMessageLiveEvent, - val autocryptSetupTransferLiveEvent: AutocryptSetupTransferLiveEvent) : ViewModel() + val autocryptSetupMessageLiveEvent: AutocryptSetupMessageLiveEvent, + val autocryptSetupTransferLiveEvent: AutocryptSetupTransferLiveEvent +) : ViewModel() diff --git a/app/ui/src/main/java/com/fsck/k9/ui/endtoend/AutocryptSetupMessageLiveEvent.kt b/app/ui/src/main/java/com/fsck/k9/ui/endtoend/AutocryptSetupMessageLiveEvent.kt index 16e7f9a80..ffe9738e3 100644 --- a/app/ui/src/main/java/com/fsck/k9/ui/endtoend/AutocryptSetupMessageLiveEvent.kt +++ b/app/ui/src/main/java/com/fsck/k9/ui/endtoend/AutocryptSetupMessageLiveEvent.kt @@ -7,13 +7,13 @@ import com.fsck.k9.autocrypt.AutocryptTransferMessageCreator import com.fsck.k9.helper.SingleLiveEvent import com.fsck.k9.mail.Address import com.fsck.k9.mail.Message +import java.io.ByteArrayOutputStream +import java.io.InputStream import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.launch import kotlinx.coroutines.withContext import org.openintents.openpgp.util.OpenPgpApi -import java.io.ByteArrayOutputStream -import java.io.InputStream class AutocryptSetupMessageLiveEvent(val messageCreator: AutocryptTransferMessageCreator) : SingleLiveEvent() { fun loadAutocryptSetupMessageAsync(openPgpApi: OpenPgpApi, account: Account) { diff --git a/app/ui/src/main/java/com/fsck/k9/ui/endtoend/AutocryptSetupTransferLiveEvent.kt b/app/ui/src/main/java/com/fsck/k9/ui/endtoend/AutocryptSetupTransferLiveEvent.kt index 1119bdb7d..d1f93a87e 100644 --- a/app/ui/src/main/java/com/fsck/k9/ui/endtoend/AutocryptSetupTransferLiveEvent.kt +++ b/app/ui/src/main/java/com/fsck/k9/ui/endtoend/AutocryptSetupTransferLiveEvent.kt @@ -11,7 +11,7 @@ import kotlinx.coroutines.delay import kotlinx.coroutines.launch class AutocryptSetupTransferLiveEvent( - private val messagingController: MessagingController + private val messagingController: MessagingController ) : SingleLiveEvent() { fun sendMessageAsync(account: Account, setupMsg: AutocryptSetupMessage) { diff --git a/app/ui/src/main/java/com/fsck/k9/ui/folders/FolderNameFormatter.kt b/app/ui/src/main/java/com/fsck/k9/ui/folders/FolderNameFormatter.kt index ab3e03a22..24af30718 100644 --- a/app/ui/src/main/java/com/fsck/k9/ui/folders/FolderNameFormatter.kt +++ b/app/ui/src/main/java/com/fsck/k9/ui/folders/FolderNameFormatter.kt @@ -1,9 +1,9 @@ package com.fsck.k9.ui.folders import android.content.res.Resources -import com.fsck.k9.ui.R import com.fsck.k9.mailstore.Folder import com.fsck.k9.mailstore.FolderType +import com.fsck.k9.ui.R class FolderNameFormatter(private val resources: Resources) { fun displayName(folder: Folder): String = when (folder.type) { diff --git a/app/ui/src/main/java/com/fsck/k9/ui/folders/FoldersLiveData.kt b/app/ui/src/main/java/com/fsck/k9/ui/folders/FoldersLiveData.kt index 6cae51fbf..89b5b47dc 100644 --- a/app/ui/src/main/java/com/fsck/k9/ui/folders/FoldersLiveData.kt +++ b/app/ui/src/main/java/com/fsck/k9/ui/folders/FoldersLiveData.kt @@ -12,16 +12,16 @@ import kotlinx.coroutines.launch import kotlinx.coroutines.withContext class FoldersLiveData( - private val folderRepository: FolderRepository, - private val messagingController: MessagingController, - val accountUuid: String + private val folderRepository: FolderRepository, + private val messagingController: MessagingController, + val accountUuid: String ) : LiveData>() { private val listener = object : SimpleMessagingListener() { override fun folderStatusChanged( - account: Account?, - folderServerId: String?, - unreadMessageCount: Int + account: Account?, + folderServerId: String?, + unreadMessageCount: Int ) { if (account?.uuid == accountUuid) { loadFoldersAsync() diff --git a/app/ui/src/main/java/com/fsck/k9/ui/folders/FoldersLiveDataFactory.kt b/app/ui/src/main/java/com/fsck/k9/ui/folders/FoldersLiveDataFactory.kt index d916ab603..34054d483 100644 --- a/app/ui/src/main/java/com/fsck/k9/ui/folders/FoldersLiveDataFactory.kt +++ b/app/ui/src/main/java/com/fsck/k9/ui/folders/FoldersLiveDataFactory.kt @@ -5,8 +5,8 @@ import com.fsck.k9.controller.MessagingController import com.fsck.k9.mailstore.FolderRepositoryManager class FoldersLiveDataFactory( - private val folderRepositoryManager: FolderRepositoryManager, - private val messagingController: MessagingController + private val folderRepositoryManager: FolderRepositoryManager, + private val messagingController: MessagingController ) { fun create(account: Account): FoldersLiveData { val folderRepository = folderRepositoryManager.getFolderRepository(account) diff --git a/app/ui/src/main/java/com/fsck/k9/ui/helper/HtmlToSpanned.kt b/app/ui/src/main/java/com/fsck/k9/ui/helper/HtmlToSpanned.kt index 6e92b146f..3bea5b97b 100644 --- a/app/ui/src/main/java/com/fsck/k9/ui/helper/HtmlToSpanned.kt +++ b/app/ui/src/main/java/com/fsck/k9/ui/helper/HtmlToSpanned.kt @@ -43,4 +43,3 @@ private class ListTagHandler : TagHandler { } } } - diff --git a/app/ui/src/main/java/com/fsck/k9/ui/helper/MaterialColors.kt b/app/ui/src/main/java/com/fsck/k9/ui/helper/MaterialColors.kt index d369d1027..9c0e2d078 100644 --- a/app/ui/src/main/java/com/fsck/k9/ui/helper/MaterialColors.kt +++ b/app/ui/src/main/java/com/fsck/k9/ui/helper/MaterialColors.kt @@ -5,7 +5,7 @@ object MaterialColors { /* * Heavily modified version of https://gist.github.com/kalehv/bae765c756e94455ed88 */ - const val RED_50 = 0xFFFFEBEE.toInt() + const val RED_50 = 0xFFFFEBEE.toInt() const val RED_100 = 0xFFFFCDD2.toInt() const val RED_200 = 0xFFEF9A9A.toInt() const val RED_300 = 0xFFE57373.toInt() @@ -16,7 +16,7 @@ object MaterialColors { const val RED_800 = 0xFFC62828.toInt() const val RED_900 = 0xFFB71C1C.toInt() - const val DEEP_PURPLE_50 = 0xFFEDE7F6.toInt() + const val DEEP_PURPLE_50 = 0xFFEDE7F6.toInt() const val DEEP_PURPLE_100 = 0xFFD1C4E9.toInt() const val DEEP_PURPLE_200 = 0xFFB39DDB.toInt() const val DEEP_PURPLE_300 = 0xFF9575CD.toInt() @@ -27,7 +27,7 @@ object MaterialColors { const val DEEP_PURPLE_800 = 0xFF4527A0.toInt() const val DEEP_PURPLE_900 = 0xFF311B92.toInt() - const val LIGHT_BLUE_50 = 0xFFE1F5FE.toInt() + const val LIGHT_BLUE_50 = 0xFFE1F5FE.toInt() const val LIGHT_BLUE_100 = 0xFFB3E5FC.toInt() const val LIGHT_BLUE_200 = 0xFF81D4FA.toInt() const val LIGHT_BLUE_300 = 0xFF4FC3F7.toInt() @@ -38,7 +38,7 @@ object MaterialColors { const val LIGHT_BLUE_800 = 0xFF0277BD.toInt() const val LIGHT_BLUE_900 = 0xFF01579B.toInt() - const val GREEN_50 = 0xFFE8F5E9.toInt() + const val GREEN_50 = 0xFFE8F5E9.toInt() const val GREEN_100 = 0xFFC8E6C9.toInt() const val GREEN_200 = 0xFFA5D6A7.toInt() const val GREEN_300 = 0xFF81C784.toInt() @@ -49,7 +49,7 @@ object MaterialColors { const val GREEN_800 = 0xFF2E7D32.toInt() const val GREEN_900 = 0xFF1B5E20.toInt() - const val YELLOW_50 = 0xFFFFFDE7.toInt() + const val YELLOW_50 = 0xFFFFFDE7.toInt() const val YELLOW_100 = 0xFFFFF9C4.toInt() const val YELLOW_200 = 0xFFFFF59D.toInt() const val YELLOW_300 = 0xFFFFF176.toInt() @@ -60,7 +60,7 @@ object MaterialColors { const val YELLOW_800 = 0xFFF9A825.toInt() const val YELLOW_900 = 0xFFF57F17.toInt() - const val DEEP_ORANGE_50 = 0xFFFBE9E7.toInt() + const val DEEP_ORANGE_50 = 0xFFFBE9E7.toInt() const val DEEP_ORANGE_100 = 0xFFFFCCBC.toInt() const val DEEP_ORANGE_200 = 0xFFFFAB91.toInt() const val DEEP_ORANGE_300 = 0xFFFF8A65.toInt() @@ -71,7 +71,7 @@ object MaterialColors { const val DEEP_ORANGE_800 = 0xFFD84315.toInt() const val DEEP_ORANGE_900 = 0xFFBF360C.toInt() - const val BLUE_GREY_50 = 0xFFECEFF1.toInt() + const val BLUE_GREY_50 = 0xFFECEFF1.toInt() const val BLUE_GREY_100 = 0xFFCFD8DC.toInt() const val BLUE_GREY_200 = 0xFFB0BEC5.toInt() const val BLUE_GREY_300 = 0xFF90A4AE.toInt() @@ -82,7 +82,7 @@ object MaterialColors { const val BLUE_GREY_800 = 0xFF37474F.toInt() const val BLUE_GREY_900 = 0xFF263238.toInt() - const val PINK_50 = 0xFFFCE4EC.toInt() + const val PINK_50 = 0xFFFCE4EC.toInt() const val PINK_100 = 0xFFF8BBD0.toInt() const val PINK_200 = 0xFFF48FB1.toInt() const val PINK_300 = 0xFFF06292.toInt() @@ -93,7 +93,7 @@ object MaterialColors { const val PINK_800 = 0xFFAD1457.toInt() const val PINK_900 = 0xFF880E4F.toInt() - const val INDIGO_50 = 0xFFE8EAF6.toInt() + const val INDIGO_50 = 0xFFE8EAF6.toInt() const val INDIGO_100 = 0xFFC5CAE9.toInt() const val INDIGO_200 = 0xFF9FA8DA.toInt() const val INDIGO_300 = 0xFF7986CB.toInt() @@ -104,7 +104,7 @@ object MaterialColors { const val INDIGO_800 = 0xFF283593.toInt() const val INDIGO_900 = 0xFF1A237E.toInt() - const val CYAN_50 = 0xFFE0F7FA.toInt() + const val CYAN_50 = 0xFFE0F7FA.toInt() const val CYAN_100 = 0xFFB2EBF2.toInt() const val CYAN_200 = 0xFF80DEEA.toInt() const val CYAN_300 = 0xFF4DD0E1.toInt() @@ -115,7 +115,7 @@ object MaterialColors { const val CYAN_800 = 0xFF00838F.toInt() const val CYAN_900 = 0xFF006064.toInt() - const val LIGHT_GREEN_50 = 0xFFF1F8E9.toInt() + const val LIGHT_GREEN_50 = 0xFFF1F8E9.toInt() const val LIGHT_GREEN_100 = 0xFFDCEDC8.toInt() const val LIGHT_GREEN_200 = 0xFFC5E1A5.toInt() const val LIGHT_GREEN_300 = 0xFFAED581.toInt() @@ -126,7 +126,7 @@ object MaterialColors { const val LIGHT_GREEN_800 = 0xFF558B2F.toInt() const val LIGHT_GREEN_900 = 0xFF33691E.toInt() - const val AMBER_50 = 0xFFFFF8E1.toInt() + const val AMBER_50 = 0xFFFFF8E1.toInt() const val AMBER_100 = 0xFFFFECB3.toInt() const val AMBER_200 = 0xFFFFE082.toInt() const val AMBER_300 = 0xFFFFD54F.toInt() @@ -137,7 +137,7 @@ object MaterialColors { const val AMBER_800 = 0xFFFF8F00.toInt() const val AMBER_900 = 0xFFFF6F00.toInt() - const val BROWN_50 = 0xFFEFEBE9.toInt() + const val BROWN_50 = 0xFFEFEBE9.toInt() const val BROWN_100 = 0xFFD7CCC8.toInt() const val BROWN_200 = 0xFFBCAAA4.toInt() const val BROWN_300 = 0xFFA1887F.toInt() @@ -148,7 +148,7 @@ object MaterialColors { const val BROWN_800 = 0xFF4E342E.toInt() const val BROWN_900 = 0xFF3E2723.toInt() - const val PURPLE_50 = 0xFFF3E5F5.toInt() + const val PURPLE_50 = 0xFFF3E5F5.toInt() const val PURPLE_100 = 0xFFE1BEE7.toInt() const val PURPLE_200 = 0xFFCE93D8.toInt() const val PURPLE_300 = 0xFFBA68C8.toInt() @@ -159,7 +159,7 @@ object MaterialColors { const val PURPLE_800 = 0xFF6A1B9A.toInt() const val PURPLE_900 = 0xFF4A148C.toInt() - const val BLUE_50 = 0xFFE3F2FD.toInt() + const val BLUE_50 = 0xFFE3F2FD.toInt() const val BLUE_100 = 0xFFBBDEFB.toInt() const val BLUE_200 = 0xFF90CAF9.toInt() const val BLUE_300 = 0xFF64B5F6.toInt() @@ -170,7 +170,7 @@ object MaterialColors { const val BLUE_800 = 0xFF1565C0.toInt() const val BLUE_900 = 0xFF0D47A1.toInt() - const val TEAL_50 = 0xFFE0F2F1.toInt() + const val TEAL_50 = 0xFFE0F2F1.toInt() const val TEAL_100 = 0xFFB2DFDB.toInt() const val TEAL_200 = 0xFF80CBC4.toInt() const val TEAL_300 = 0xFF4DB6AC.toInt() @@ -181,7 +181,7 @@ object MaterialColors { const val TEAL_800 = 0xFF00695C.toInt() const val TEAL_900 = 0xFF004D40.toInt() - const val LIME_50 = 0xFFF9FBE7.toInt() + const val LIME_50 = 0xFFF9FBE7.toInt() const val LIME_100 = 0xFFF0F4C3.toInt() const val LIME_200 = 0xFFE6EE9C.toInt() const val LIME_300 = 0xFFDCE775.toInt() @@ -192,7 +192,7 @@ object MaterialColors { const val LIME_800 = 0xFF9E9D24.toInt() const val LIME_900 = 0xFF827717.toInt() - const val ORANGE_50 = 0xFFFFF3E0.toInt() + const val ORANGE_50 = 0xFFFFF3E0.toInt() const val ORANGE_100 = 0xFFFFE0B2.toInt() const val ORANGE_200 = 0xFFFFCC80.toInt() const val ORANGE_300 = 0xFFFFB74D.toInt() @@ -203,7 +203,7 @@ object MaterialColors { const val ORANGE_800 = 0xFFEF6C00.toInt() const val ORANGE_900 = 0xFFE65100.toInt() - const val GREY_50 = 0xFFFAFAFA.toInt() + const val GREY_50 = 0xFFFAFAFA.toInt() const val GREY_100 = 0xFFF5F5F5.toInt() const val GREY_200 = 0xFFEEEEEE.toInt() const val GREY_300 = 0xFFE0E0E0.toInt() diff --git a/app/ui/src/main/java/com/fsck/k9/ui/messagelist/MessageListAppearance.kt b/app/ui/src/main/java/com/fsck/k9/ui/messagelist/MessageListAppearance.kt index 91d78a858..d7ee9cc38 100644 --- a/app/ui/src/main/java/com/fsck/k9/ui/messagelist/MessageListAppearance.kt +++ b/app/ui/src/main/java/com/fsck/k9/ui/messagelist/MessageListAppearance.kt @@ -3,12 +3,12 @@ package com.fsck.k9.ui.messagelist import com.fsck.k9.FontSizes data class MessageListAppearance( - val fontSizes: FontSizes, - val previewLines: Int, - val stars: Boolean, - val senderAboveSubject: Boolean, - val showContactPicture: Boolean, - val showingThreadedList: Boolean, - val backGroundAsReadIndicator: Boolean, - val showAccountChip: Boolean + val fontSizes: FontSizes, + val previewLines: Int, + val stars: Boolean, + val senderAboveSubject: Boolean, + val showContactPicture: Boolean, + val showingThreadedList: Boolean, + val backGroundAsReadIndicator: Boolean, + val showAccountChip: Boolean ) diff --git a/app/ui/src/main/java/com/fsck/k9/ui/messagelist/MessageListViewModel.kt b/app/ui/src/main/java/com/fsck/k9/ui/messagelist/MessageListViewModel.kt index a6cbeab4a..8afc4d7b7 100644 --- a/app/ui/src/main/java/com/fsck/k9/ui/messagelist/MessageListViewModel.kt +++ b/app/ui/src/main/java/com/fsck/k9/ui/messagelist/MessageListViewModel.kt @@ -8,7 +8,6 @@ import com.fsck.k9.ui.folders.FoldersLiveDataFactory class MessageListViewModel(private val foldersLiveDataFactory: FoldersLiveDataFactory) : ViewModel() { private var foldersLiveData: FoldersLiveData? = null - fun getFolders(account: Account): FoldersLiveData { val liveData = foldersLiveData if (liveData != null && liveData.accountUuid == account.uuid) { diff --git a/app/ui/src/main/java/com/fsck/k9/ui/messagelist/MessageListViewModelFactory.kt b/app/ui/src/main/java/com/fsck/k9/ui/messagelist/MessageListViewModelFactory.kt index 34d45d833..6f29878ba 100644 --- a/app/ui/src/main/java/com/fsck/k9/ui/messagelist/MessageListViewModelFactory.kt +++ b/app/ui/src/main/java/com/fsck/k9/ui/messagelist/MessageListViewModelFactory.kt @@ -9,7 +9,6 @@ import org.koin.core.inject class MessageListViewModelFactory : ViewModelProvider.Factory, KoinComponent { private val foldersLiveDataFactory: FoldersLiveDataFactory by inject() - override fun create(modelClass: Class): T { return MessageListViewModel(foldersLiveDataFactory) as T } diff --git a/app/ui/src/main/java/com/fsck/k9/ui/onboarding/OnboardingActivity.kt b/app/ui/src/main/java/com/fsck/k9/ui/onboarding/OnboardingActivity.kt index acb426fd7..e72816194 100644 --- a/app/ui/src/main/java/com/fsck/k9/ui/onboarding/OnboardingActivity.kt +++ b/app/ui/src/main/java/com/fsck/k9/ui/onboarding/OnboardingActivity.kt @@ -13,7 +13,6 @@ import com.fsck.k9.ui.R class OnboardingActivity : K9Activity() { private lateinit var navController: NavController - override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setLayout(R.layout.activity_onboarding) @@ -32,7 +31,6 @@ class OnboardingActivity : K9Activity() { return navController.navigateUp() || super.onSupportNavigateUp() } - companion object { @JvmStatic fun launch(activity: Activity) { val intent = Intent(activity, OnboardingActivity::class.java).apply { diff --git a/app/ui/src/main/java/com/fsck/k9/ui/onboarding/WelcomeFragment.kt b/app/ui/src/main/java/com/fsck/k9/ui/onboarding/WelcomeFragment.kt index b50b0e16e..edc72eb5e 100644 --- a/app/ui/src/main/java/com/fsck/k9/ui/onboarding/WelcomeFragment.kt +++ b/app/ui/src/main/java/com/fsck/k9/ui/onboarding/WelcomeFragment.kt @@ -20,7 +20,6 @@ class WelcomeFragment : Fragment() { private val htmlToSpanned: HtmlToSpanned by inject() private val importResultViewModel: SettingsImportResultViewModel by sharedViewModel() - override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { return inflater.inflate(R.layout.fragment_welcome_message, container, false) } diff --git a/app/ui/src/main/java/com/fsck/k9/ui/permissions/PermissionRationaleDialogFragment.kt b/app/ui/src/main/java/com/fsck/k9/ui/permissions/PermissionRationaleDialogFragment.kt index 32742edf6..b4e867259 100644 --- a/app/ui/src/main/java/com/fsck/k9/ui/permissions/PermissionRationaleDialogFragment.kt +++ b/app/ui/src/main/java/com/fsck/k9/ui/permissions/PermissionRationaleDialogFragment.kt @@ -3,8 +3,8 @@ package com.fsck.k9.ui.permissions import android.app.AlertDialog import android.app.Dialog import android.os.Bundle -import androidx.fragment.app.DialogFragment import androidx.core.os.bundleOf +import androidx.fragment.app.DialogFragment import com.fsck.k9.activity.K9Activity import com.fsck.k9.activity.K9Activity.Permission import com.fsck.k9.ui.R @@ -34,7 +34,6 @@ class PermissionRationaleDialogFragment : DialogFragment() { }.create() } - companion object { private const val ARG_PERMISSION = "permission" diff --git a/app/ui/src/main/java/com/fsck/k9/ui/settings/AboutActivity.kt b/app/ui/src/main/java/com/fsck/k9/ui/settings/AboutActivity.kt index 7f0200468..598760c24 100644 --- a/app/ui/src/main/java/com/fsck/k9/ui/settings/AboutActivity.kt +++ b/app/ui/src/main/java/com/fsck/k9/ui/settings/AboutActivity.kt @@ -12,10 +12,10 @@ import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView import com.fsck.k9.ui.R import de.cketti.library.changelog.ChangeLog +import java.util.Calendar import kotlinx.android.synthetic.main.about_library.view.* import kotlinx.android.synthetic.main.fragment_about.* import timber.log.Timber -import java.util.Calendar private data class Library(val name: String, val URL: String, val license: String) @@ -95,12 +95,12 @@ class AboutFragment : Fragment() { } } -private class LibrariesAdapter(private val dataset: Array) - : RecyclerView.Adapter() { +private class LibrariesAdapter(private val dataset: Array) : + RecyclerView.Adapter() { class ViewHolder(val view: View) : RecyclerView.ViewHolder(view) - override fun onCreateViewHolder(parent: ViewGroup, viewType: Int) : ViewHolder { + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { val view = LayoutInflater.from(parent.context).inflate(R.layout.about_library, parent, false) return ViewHolder(view) } diff --git a/app/ui/src/main/java/com/fsck/k9/ui/settings/KoinModule.kt b/app/ui/src/main/java/com/fsck/k9/ui/settings/KoinModule.kt index 40855a11f..1096335f0 100644 --- a/app/ui/src/main/java/com/fsck/k9/ui/settings/KoinModule.kt +++ b/app/ui/src/main/java/com/fsck/k9/ui/settings/KoinModule.kt @@ -9,10 +9,10 @@ import com.fsck.k9.ui.settings.general.GeneralSettingsDataStore import com.fsck.k9.ui.settings.import.AccountActivator import com.fsck.k9.ui.settings.import.SettingsImportResultViewModel import com.fsck.k9.ui.settings.import.SettingsImportViewModel +import java.util.concurrent.Executors import org.koin.androidx.viewmodel.dsl.viewModel import org.koin.core.qualifier.named import org.koin.dsl.module -import java.util.concurrent.Executors val settingsUiModule = module { single { AccountsLiveData(get()) } diff --git a/app/ui/src/main/java/com/fsck/k9/ui/settings/PreferenceExtras.kt b/app/ui/src/main/java/com/fsck/k9/ui/settings/PreferenceExtras.kt index 14b738855..87d6d7272 100644 --- a/app/ui/src/main/java/com/fsck/k9/ui/settings/PreferenceExtras.kt +++ b/app/ui/src/main/java/com/fsck/k9/ui/settings/PreferenceExtras.kt @@ -1,10 +1,9 @@ package com.fsck.k9.ui.settings -import androidx.preference.MultiSelectListPreference import androidx.preference.ListPreference +import androidx.preference.MultiSelectListPreference import androidx.preference.Preference - inline fun Preference.onClick(crossinline action: () -> Unit) = setOnPreferenceClickListener { action() true diff --git a/app/ui/src/main/java/com/fsck/k9/ui/settings/SettingsActionItem.kt b/app/ui/src/main/java/com/fsck/k9/ui/settings/SettingsActionItem.kt index 209a2690f..8a70d7d11 100644 --- a/app/ui/src/main/java/com/fsck/k9/ui/settings/SettingsActionItem.kt +++ b/app/ui/src/main/java/com/fsck/k9/ui/settings/SettingsActionItem.kt @@ -1,11 +1,11 @@ package com.fsck.k9.ui.settings +import android.util.TypedValue +import androidx.annotation.IdRes import com.fsck.k9.ui.R import com.xwray.groupie.kotlinandroidextensions.Item import com.xwray.groupie.kotlinandroidextensions.ViewHolder import kotlinx.android.synthetic.main.text_icon_list_item.* -import android.util.TypedValue -import androidx.annotation.IdRes internal class SettingsActionItem(val text: String, @IdRes val navigationAction: Int, val icon: Int) : Item() { diff --git a/app/ui/src/main/java/com/fsck/k9/ui/settings/SettingsActivity.kt b/app/ui/src/main/java/com/fsck/k9/ui/settings/SettingsActivity.kt index fda49d8b7..75208232e 100644 --- a/app/ui/src/main/java/com/fsck/k9/ui/settings/SettingsActivity.kt +++ b/app/ui/src/main/java/com/fsck/k9/ui/settings/SettingsActivity.kt @@ -13,7 +13,6 @@ import com.fsck.k9.ui.R class SettingsActivity : K9Activity() { private lateinit var navController: NavController - override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setLayout(R.layout.activity_settings) @@ -38,7 +37,6 @@ class SettingsActivity : K9Activity() { return true } - companion object { @JvmStatic fun launch(activity: Activity) { val intent = Intent(activity, SettingsActivity::class.java) diff --git a/app/ui/src/main/java/com/fsck/k9/ui/settings/SettingsListFragment.kt b/app/ui/src/main/java/com/fsck/k9/ui/settings/SettingsListFragment.kt index 4ae2bd2b5..042d79ea4 100644 --- a/app/ui/src/main/java/com/fsck/k9/ui/settings/SettingsListFragment.kt +++ b/app/ui/src/main/java/com/fsck/k9/ui/settings/SettingsListFragment.kt @@ -23,7 +23,6 @@ class SettingsListFragment : Fragment() { private lateinit var settingsAdapter: GroupAdapter - override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { return inflater.inflate(R.layout.fragment_settings_list, container, false) } diff --git a/app/ui/src/main/java/com/fsck/k9/ui/settings/account/AccountSelectionSpinner.kt b/app/ui/src/main/java/com/fsck/k9/ui/settings/account/AccountSelectionSpinner.kt index b6e6f97f1..b89a4ecfb 100644 --- a/app/ui/src/main/java/com/fsck/k9/ui/settings/account/AccountSelectionSpinner.kt +++ b/app/ui/src/main/java/com/fsck/k9/ui/settings/account/AccountSelectionSpinner.kt @@ -8,10 +8,8 @@ import android.view.View import android.view.ViewGroup import android.widget.ArrayAdapter import android.widget.Spinner - import com.fsck.k9.Account import com.fsck.k9.ui.R - import kotlinx.android.synthetic.main.account_list_item.view.* class AccountSelectionSpinner : Spinner { @@ -27,7 +25,6 @@ class AccountSelectionSpinner : Spinner { private val cachedBackground: Drawable private var selectedAccount: Account? = null - constructor(context: Context) : super(context) constructor(context: Context, attrs: AttributeSet) : super(context, attrs) @@ -54,11 +51,9 @@ class AccountSelectionSpinner : Spinner { background = if (showAccountSwitcher) cachedBackground else null } - internal class AccountsAdapter(context: Context) : ArrayAdapter(context, 0) { var title: CharSequence = "" - override fun getView(position: Int, convertView: View?, parent: ViewGroup): View { val account = getItem(position) ?: error("No item at position $position") diff --git a/app/ui/src/main/java/com/fsck/k9/ui/settings/account/AccountSettingsActivity.kt b/app/ui/src/main/java/com/fsck/k9/ui/settings/account/AccountSettingsActivity.kt index f598a06d6..d5b3bcab9 100644 --- a/app/ui/src/main/java/com/fsck/k9/ui/settings/account/AccountSettingsActivity.kt +++ b/app/ui/src/main/java/com/fsck/k9/ui/settings/account/AccountSettingsActivity.kt @@ -3,12 +3,12 @@ package com.fsck.k9.ui.settings.account import android.content.Context import android.content.Intent import android.os.Bundle -import androidx.preference.PreferenceFragmentCompat -import androidx.preference.PreferenceFragmentCompat.OnPreferenceStartScreenCallback -import androidx.preference.PreferenceScreen import android.view.MenuItem import android.view.View import android.widget.AdapterView +import androidx.preference.PreferenceFragmentCompat +import androidx.preference.PreferenceFragmentCompat.OnPreferenceStartScreenCallback +import androidx.preference.PreferenceScreen import com.fsck.k9.activity.K9Activity import com.fsck.k9.ui.R import com.fsck.k9.ui.fragmentTransaction @@ -104,7 +104,8 @@ class AccountSettingsActivity : K9Activity(), OnPreferenceStartScreenCallback { } override fun onPreferenceStartScreen( - caller: PreferenceFragmentCompat, preferenceScreen: PreferenceScreen + caller: PreferenceFragmentCompat, + preferenceScreen: PreferenceScreen ): Boolean { fragmentTransactionWithBackStack { replace(R.id.accountSettingsContainer, AccountSettingsFragment.create(accountUuid, preferenceScreen.key)) @@ -118,7 +119,6 @@ class AccountSettingsActivity : K9Activity(), OnPreferenceStartScreenCallback { accountSpinner.setTitle(title) } - companion object { private const val ARG_ACCOUNT_UUID = "accountUuid" private const val ARG_START_SCREEN_KEY = "startScreen" diff --git a/app/ui/src/main/java/com/fsck/k9/ui/settings/account/AccountSettingsDataStore.kt b/app/ui/src/main/java/com/fsck/k9/ui/settings/account/AccountSettingsDataStore.kt index 9353b2ab4..dcca4f2ae 100644 --- a/app/ui/src/main/java/com/fsck/k9/ui/settings/account/AccountSettingsDataStore.kt +++ b/app/ui/src/main/java/com/fsck/k9/ui/settings/account/AccountSettingsDataStore.kt @@ -8,10 +8,10 @@ import com.fsck.k9.job.K9JobManager import java.util.concurrent.ExecutorService class AccountSettingsDataStore( - private val preferences: Preferences, - private val executorService: ExecutorService, - private val account: Account, - private val jobManager: K9JobManager + private val preferences: Preferences, + private val executorService: ExecutorService, + private val account: Account, + private val jobManager: K9JobManager ) : PreferenceDataStore() { override fun getBoolean(key: String, defValue: Boolean): Boolean { @@ -226,8 +226,8 @@ class AccountSettingsDataStore( } private fun saveSpecialFolderSelection( - preferenceValue: String, - specialFolderSetter: (String?, SpecialFolderSelection) -> Unit + preferenceValue: String, + specialFolderSetter: (String?, SpecialFolderSelection) -> Unit ) { val specialFolder = extractFolderName(preferenceValue) @@ -241,7 +241,7 @@ class AccountSettingsDataStore( } private fun loadSpecialFolder(specialFolder: String?, specialFolderSelection: SpecialFolderSelection): String { - val prefix = when (specialFolderSelection) { + val prefix = when (specialFolderSelection) { SpecialFolderSelection.AUTOMATIC -> FolderListPreference.AUTOMATIC_PREFIX SpecialFolderSelection.MANUAL -> FolderListPreference.MANUAL_PREFIX } diff --git a/app/ui/src/main/java/com/fsck/k9/ui/settings/account/AccountSettingsDataStoreFactory.kt b/app/ui/src/main/java/com/fsck/k9/ui/settings/account/AccountSettingsDataStoreFactory.kt index b1bac69ee..852adc7af 100644 --- a/app/ui/src/main/java/com/fsck/k9/ui/settings/account/AccountSettingsDataStoreFactory.kt +++ b/app/ui/src/main/java/com/fsck/k9/ui/settings/account/AccountSettingsDataStoreFactory.kt @@ -6,9 +6,9 @@ import com.fsck.k9.job.K9JobManager import java.util.concurrent.ExecutorService class AccountSettingsDataStoreFactory( - private val preferences: Preferences, - private val jobManager: K9JobManager, - private val executorService: ExecutorService + private val preferences: Preferences, + private val jobManager: K9JobManager, + private val executorService: ExecutorService ) { fun create(account: Account): AccountSettingsDataStore { return AccountSettingsDataStore(preferences, executorService, account, jobManager) diff --git a/app/ui/src/main/java/com/fsck/k9/ui/settings/account/AccountSettingsFragment.kt b/app/ui/src/main/java/com/fsck/k9/ui/settings/account/AccountSettingsFragment.kt index 39c693f1e..ca4486da6 100644 --- a/app/ui/src/main/java/com/fsck/k9/ui/settings/account/AccountSettingsFragment.kt +++ b/app/ui/src/main/java/com/fsck/k9/ui/settings/account/AccountSettingsFragment.kt @@ -52,7 +52,6 @@ class AccountSettingsFragment : PreferenceFragmentCompat(), ConfirmationDialogFr } private var title: CharSequence? = null - override fun onCreatePreferencesFix(savedInstanceState: Bundle?, rootKey: String?) { val account = getAccount() dataStore = dataStoreFactory.create(account) @@ -353,7 +352,6 @@ class AccountSettingsFragment : PreferenceFragmentCompat(), ConfirmationDialogFr dataStore.saveSettingsInBackground() } - companion object { internal const val PREFERENCE_OPENPGP = "openpgp" private const val ARG_ACCOUNT_UUID = "accountUuid" diff --git a/app/ui/src/main/java/com/fsck/k9/ui/settings/account/AccountSettingsViewModel.kt b/app/ui/src/main/java/com/fsck/k9/ui/settings/account/AccountSettingsViewModel.kt index 82b361b15..78c971cf1 100644 --- a/app/ui/src/main/java/com/fsck/k9/ui/settings/account/AccountSettingsViewModel.kt +++ b/app/ui/src/main/java/com/fsck/k9/ui/settings/account/AccountSettingsViewModel.kt @@ -14,8 +14,8 @@ import kotlinx.coroutines.launch import kotlinx.coroutines.withContext class AccountSettingsViewModel( - private val preferences: Preferences, - private val folderRepositoryManager: FolderRepositoryManager + private val preferences: Preferences, + private val folderRepositoryManager: FolderRepositoryManager ) : ViewModel() { public val accounts = AccountsLiveData(preferences) private val accountLiveData = MutableLiveData() diff --git a/app/ui/src/main/java/com/fsck/k9/ui/settings/account/AutocryptPreferEncryptDialogFragment.kt b/app/ui/src/main/java/com/fsck/k9/ui/settings/account/AutocryptPreferEncryptDialogFragment.kt index 090c3e670..38976b7a0 100644 --- a/app/ui/src/main/java/com/fsck/k9/ui/settings/account/AutocryptPreferEncryptDialogFragment.kt +++ b/app/ui/src/main/java/com/fsck/k9/ui/settings/account/AutocryptPreferEncryptDialogFragment.kt @@ -3,15 +3,14 @@ package com.fsck.k9.ui.settings.account import android.annotation.SuppressLint import android.app.Dialog import android.os.Bundle -import androidx.fragment.app.DialogFragment -import androidx.appcompat.app.AlertDialog -import androidx.preference.DialogPreference import android.text.method.LinkMovementMethod import android.view.LayoutInflater import android.view.View import android.widget.CheckBox import android.widget.TextView -import androidx.preference.Preference +import androidx.appcompat.app.AlertDialog +import androidx.fragment.app.DialogFragment +import androidx.preference.DialogPreference import com.fsck.k9.ui.R class AutocryptPreferEncryptDialogFragment : DialogFragment() { @@ -22,7 +21,6 @@ class AutocryptPreferEncryptDialogFragment : DialogFragment() { fragment.findPreference(preferenceKey)!! } - override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { @SuppressLint("InflateParams") val view = LayoutInflater.from(context).inflate(R.layout.dialog_autocrypt_prefer_encrypt, null) @@ -40,7 +38,7 @@ class AutocryptPreferEncryptDialogFragment : DialogFragment() { return AlertDialog.Builder(requireContext()) // TODO add autocrypt logo? - //.setIcon(R.drawable.autocrypt) + // .setIcon(R.drawable.autocrypt) .setView(view) .setPositiveButton(R.string.done_action, null) .create() @@ -50,7 +48,6 @@ class AutocryptPreferEncryptDialogFragment : DialogFragment() { this.movementMethod = LinkMovementMethod.getInstance() } - companion object { private const val ARG_KEY = "key" } diff --git a/app/ui/src/main/java/com/fsck/k9/ui/settings/account/AutocryptPreferEncryptPreference.kt b/app/ui/src/main/java/com/fsck/k9/ui/settings/account/AutocryptPreferEncryptPreference.kt index 5bf846013..e549dcd1f 100644 --- a/app/ui/src/main/java/com/fsck/k9/ui/settings/account/AutocryptPreferEncryptPreference.kt +++ b/app/ui/src/main/java/com/fsck/k9/ui/settings/account/AutocryptPreferEncryptPreference.kt @@ -2,10 +2,10 @@ package com.fsck.k9.ui.settings.account import android.annotation.SuppressLint import android.content.Context +import android.util.AttributeSet import androidx.core.content.res.TypedArrayUtils import androidx.preference.PreferenceViewHolder import androidx.preference.TwoStatePreference -import android.util.AttributeSet import com.fsck.k9.ui.R import com.takisoft.preferencex.PreferenceFragmentCompat @@ -13,11 +13,11 @@ import com.takisoft.preferencex.PreferenceFragmentCompat class AutocryptPreferEncryptPreference @JvmOverloads constructor( - context: Context, - attrs: AttributeSet? = null, - defStyleAttr: Int = TypedArrayUtils.getAttr(context, androidx.preference.R.attr.preferenceStyle, - android.R.attr.preferenceStyle), - defStyleRes: Int = 0 + context: Context, + attrs: AttributeSet? = null, + defStyleAttr: Int = TypedArrayUtils.getAttr(context, androidx.preference.R.attr.preferenceStyle, + android.R.attr.preferenceStyle), + defStyleRes: Int = 0 ) : TwoStatePreference(context, attrs, defStyleAttr, defStyleRes) { init { @@ -45,7 +45,6 @@ constructor( } } - companion object { init { PreferenceFragmentCompat.registerPreferenceFragment( diff --git a/app/ui/src/main/java/com/fsck/k9/ui/settings/account/FolderListPreference.kt b/app/ui/src/main/java/com/fsck/k9/ui/settings/account/FolderListPreference.kt index e52a57a53..de56c08e1 100644 --- a/app/ui/src/main/java/com/fsck/k9/ui/settings/account/FolderListPreference.kt +++ b/app/ui/src/main/java/com/fsck/k9/ui/settings/account/FolderListPreference.kt @@ -3,11 +3,11 @@ package com.fsck.k9.ui.settings.account import android.annotation.SuppressLint import android.content.Context import android.graphics.Typeface -import androidx.core.content.res.TypedArrayUtils -import androidx.preference.ListPreference import android.text.SpannableString import android.text.style.StyleSpan import android.util.AttributeSet +import androidx.core.content.res.TypedArrayUtils +import androidx.preference.ListPreference import com.fsck.k9.mailstore.Folder import com.fsck.k9.ui.R import com.fsck.k9.ui.folders.FolderNameFormatter @@ -21,11 +21,11 @@ import org.koin.core.inject class FolderListPreference @JvmOverloads constructor( - context: Context, - attrs: AttributeSet? = null, - defStyleAttr: Int = TypedArrayUtils.getAttr(context, androidx.preference.R.attr.dialogPreferenceStyle, - android.R.attr.dialogPreferenceStyle), - defStyleRes: Int = 0 + context: Context, + attrs: AttributeSet? = null, + defStyleAttr: Int = TypedArrayUtils.getAttr(context, androidx.preference.R.attr.dialogPreferenceStyle, + android.R.attr.dialogPreferenceStyle), + defStyleRes: Int = 0 ) : ListPreference(context, attrs, defStyleAttr, defStyleRes), KoinComponent { private val folderNameFormatter: FolderNameFormatter by inject() private val noFolderSelectedName = context.getString(R.string.account_settings_no_folder_selected).italicize() @@ -37,7 +37,6 @@ constructor( isEnabled = false } - fun setFolders(folders: List) { entries = (listOf(noFolderSelectedName) + getFolderDisplayNames(folders)).toTypedArray() entryValues = (listOf(NO_FOLDER_SELECTED_VALUE) + getFolderValues(folders)).toTypedArray() diff --git a/app/ui/src/main/java/com/fsck/k9/ui/settings/account/NotificationsPreference.kt b/app/ui/src/main/java/com/fsck/k9/ui/settings/account/NotificationsPreference.kt index 327e69ac0..eef08c071 100644 --- a/app/ui/src/main/java/com/fsck/k9/ui/settings/account/NotificationsPreference.kt +++ b/app/ui/src/main/java/com/fsck/k9/ui/settings/account/NotificationsPreference.kt @@ -4,22 +4,22 @@ import android.annotation.SuppressLint import android.content.Context import android.content.Intent import android.provider.Settings -import androidx.fragment.app.DialogFragment +import android.util.AttributeSet import androidx.core.content.ContextCompat.startActivity import androidx.core.content.res.TypedArrayUtils +import androidx.fragment.app.DialogFragment import androidx.preference.Preference -import android.util.AttributeSet import com.takisoft.preferencex.PreferenceFragmentCompat @SuppressLint("RestrictedApi") class NotificationsPreference @JvmOverloads constructor( - context: Context, - attrs: AttributeSet? = null, - defStyleAttr: Int = TypedArrayUtils.getAttr(context, androidx.preference.R.attr.preferenceStyle, - android.R.attr.preferenceStyle), - defStyleRes: Int = 0 + context: Context, + attrs: AttributeSet? = null, + defStyleAttr: Int = TypedArrayUtils.getAttr(context, androidx.preference.R.attr.preferenceStyle, + android.R.attr.preferenceStyle), + defStyleRes: Int = 0 ) : Preference(context, attrs, defStyleAttr, defStyleRes) { override fun onClick() { diff --git a/app/ui/src/main/java/com/fsck/k9/ui/settings/export/SettingsExportFragment.kt b/app/ui/src/main/java/com/fsck/k9/ui/settings/export/SettingsExportFragment.kt index 18c6fca99..adb27cd1b 100644 --- a/app/ui/src/main/java/com/fsck/k9/ui/settings/export/SettingsExportFragment.kt +++ b/app/ui/src/main/java/com/fsck/k9/ui/settings/export/SettingsExportFragment.kt @@ -15,13 +15,11 @@ import com.mikepenz.fastadapter.commons.adapters.FastItemAdapter import kotlinx.android.synthetic.main.fragment_settings_export.* import org.koin.androidx.viewmodel.ext.android.viewModel - class SettingsExportFragment : Fragment() { private val viewModel: SettingsExportViewModel by viewModel() private lateinit var settingsExportAdapter: FastItemAdapter - override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { return inflater.inflate(R.layout.fragment_settings_export, container, false) } @@ -91,7 +89,7 @@ class SettingsExportFragment : Fragment() { setSettingsList(model.settingsList, model.isSettingsListEnabled) } - //TODO: Update list instead of replacing it completely + // TODO: Update list instead of replacing it completely private fun setSettingsList(items: List, enable: Boolean) { val checkBoxItems = items.map { item -> val checkBoxItem = when (item) { @@ -151,7 +149,6 @@ class SettingsExportFragment : Fragment() { } } - companion object { private const val RESULT_PICK_DOCUMENT = Activity.RESULT_FIRST_USER } diff --git a/app/ui/src/main/java/com/fsck/k9/ui/settings/export/SettingsExportListItems.kt b/app/ui/src/main/java/com/fsck/k9/ui/settings/export/SettingsExportListItems.kt index 7f1a2766f..2363ddf22 100644 --- a/app/ui/src/main/java/com/fsck/k9/ui/settings/export/SettingsExportListItems.kt +++ b/app/ui/src/main/java/com/fsck/k9/ui/settings/export/SettingsExportListItems.kt @@ -3,23 +3,19 @@ package com.fsck.k9.ui.settings.export import com.fsck.k9.ui.R import kotlinx.android.synthetic.main.settings_export_account_list_item.* - private const val GENERAL_SETTINGS_ID = 0L private const val ACCOUNT_ITEMS_ID_OFFSET = 1L - class GeneralSettingsItem : CheckBoxItem(GENERAL_SETTINGS_ID) { override fun getType(): Int = R.id.settings_export_list_general_item override fun getLayoutRes(): Int = R.layout.settings_export_general_list_item } - class AccountItem(account: SettingsListItem.Account) : CheckBoxItem(account.accountNumber + ACCOUNT_ITEMS_ID_OFFSET) { private val displayName = account.displayName private val email = account.email - override fun getType(): Int = R.id.settings_export_list_account_item override fun getLayoutRes(): Int = R.layout.settings_export_account_list_item diff --git a/app/ui/src/main/java/com/fsck/k9/ui/settings/export/SettingsExportUiModel.kt b/app/ui/src/main/java/com/fsck/k9/ui/settings/export/SettingsExportUiModel.kt index 9856300ee..80295f17f 100644 --- a/app/ui/src/main/java/com/fsck/k9/ui/settings/export/SettingsExportUiModel.kt +++ b/app/ui/src/main/java/com/fsck/k9/ui/settings/export/SettingsExportUiModel.kt @@ -1,8 +1,5 @@ package com.fsck.k9.ui.settings.export -import com.fsck.k9.Account as K9Account - - class SettingsExportUiModel { var settingsList: List = emptyList() var isSettingsListEnabled = true @@ -11,7 +8,6 @@ class SettingsExportUiModel { var isProgressVisible = false var statusText = StatusText.HIDDEN - fun enableExportButton() { exportButton = ButtonState.ENABLED isShareButtonVisible = false @@ -78,9 +74,9 @@ sealed class SettingsListItem { object GeneralSettings : SettingsListItem() data class Account( - val accountNumber: Int, - val displayName: String, - val email: String + val accountNumber: Int, + val displayName: String, + val email: String ) : SettingsListItem() } diff --git a/app/ui/src/main/java/com/fsck/k9/ui/settings/export/SettingsExportViewModel.kt b/app/ui/src/main/java/com/fsck/k9/ui/settings/export/SettingsExportViewModel.kt index 734efac19..f77340e05 100644 --- a/app/ui/src/main/java/com/fsck/k9/ui/settings/export/SettingsExportViewModel.kt +++ b/app/ui/src/main/java/com/fsck/k9/ui/settings/export/SettingsExportViewModel.kt @@ -45,7 +45,6 @@ class SettingsExportViewModel(val context: Context, val preferences: Preferences .toSet() } - fun getActionEvents(): LiveData = actionLiveData fun getUiModel(): LiveData { @@ -80,7 +79,6 @@ class SettingsExportViewModel(val context: Context, val preferences: Preferences return uiModelLiveData } - fun initializeFromSavedState(savedInstanceState: Bundle) { savedSelection = SavedListItemSelection( includeGeneralSettings = savedInstanceState.getBoolean(STATE_INCLUDE_GENERAL_SETTINGS), @@ -186,7 +184,6 @@ class SettingsExportViewModel(val context: Context, val preferences: Preferences actionLiveData.value = action } - companion object { private const val MIN_PROGRESS_DURATION = 1000L private const val SETTINGS_MIME_TYPE = "application/octet-stream" @@ -208,6 +205,6 @@ sealed class Action { } private data class SavedListItemSelection( - val includeGeneralSettings: Boolean, - val selectedAccountUuids: Set + val includeGeneralSettings: Boolean, + val selectedAccountUuids: Set ) diff --git a/app/ui/src/main/java/com/fsck/k9/ui/settings/general/GeneralSettingsActivity.kt b/app/ui/src/main/java/com/fsck/k9/ui/settings/general/GeneralSettingsActivity.kt index 03f7d8b3a..e0d9f2376 100644 --- a/app/ui/src/main/java/com/fsck/k9/ui/settings/general/GeneralSettingsActivity.kt +++ b/app/ui/src/main/java/com/fsck/k9/ui/settings/general/GeneralSettingsActivity.kt @@ -4,11 +4,11 @@ import android.content.Context import android.content.Intent import android.os.Bundle import android.os.Handler +import android.view.Menu +import android.view.MenuItem import androidx.preference.PreferenceFragmentCompat import androidx.preference.PreferenceFragmentCompat.OnPreferenceStartScreenCallback import androidx.preference.PreferenceScreen -import android.view.Menu -import android.view.MenuItem import com.bytehamster.lib.preferencesearch.SearchPreferenceActionView import com.bytehamster.lib.preferencesearch.SearchPreferenceResult import com.bytehamster.lib.preferencesearch.SearchPreferenceResultListener @@ -131,7 +131,8 @@ class GeneralSettingsActivity : K9Activity(), OnPreferenceStartScreenCallback, S } override fun onPreferenceStartScreen( - caller: PreferenceFragmentCompat, preferenceScreen: PreferenceScreen + caller: PreferenceFragmentCompat, + preferenceScreen: PreferenceScreen ): Boolean { fragmentTransactionWithBackStack { replace(R.id.generalSettingsContainer, GeneralSettingsFragment.create(preferenceScreen.key)) @@ -140,7 +141,6 @@ class GeneralSettingsActivity : K9Activity(), OnPreferenceStartScreenCallback, S return true } - companion object { private const val KEY_SEARCH_QUERY = "search_query" private const val KEY_SEARCH_ENABLED = "search_enabled" diff --git a/app/ui/src/main/java/com/fsck/k9/ui/settings/general/GeneralSettingsDataStore.kt b/app/ui/src/main/java/com/fsck/k9/ui/settings/general/GeneralSettingsDataStore.kt index 896540c7b..1c76c098e 100644 --- a/app/ui/src/main/java/com/fsck/k9/ui/settings/general/GeneralSettingsDataStore.kt +++ b/app/ui/src/main/java/com/fsck/k9/ui/settings/general/GeneralSettingsDataStore.kt @@ -11,10 +11,10 @@ import com.fsck.k9.ui.ThemeManager import java.util.concurrent.ExecutorService class GeneralSettingsDataStore( - private val preferences: Preferences, - private val jobManager: K9JobManager, - private val executorService: ExecutorService, - private val themeManager: ThemeManager + private val preferences: Preferences, + private val jobManager: K9JobManager, + private val executorService: ExecutorService, + private val themeManager: ThemeManager ) : PreferenceDataStore() { var activity: FragmentActivity? = null diff --git a/app/ui/src/main/java/com/fsck/k9/ui/settings/general/GeneralSettingsFragment.kt b/app/ui/src/main/java/com/fsck/k9/ui/settings/general/GeneralSettingsFragment.kt index ea78d1e31..c52780c3f 100644 --- a/app/ui/src/main/java/com/fsck/k9/ui/settings/general/GeneralSettingsFragment.kt +++ b/app/ui/src/main/java/com/fsck/k9/ui/settings/general/GeneralSettingsFragment.kt @@ -11,7 +11,6 @@ import org.koin.android.ext.android.inject class GeneralSettingsFragment : PreferenceFragmentCompat() { private val dataStore: GeneralSettingsDataStore by inject() - override fun onCreatePreferencesFix(savedInstanceState: Bundle?, rootKey: String?) { preferenceManager.preferenceDataStore = dataStore @@ -35,7 +34,6 @@ class GeneralSettingsFragment : PreferenceFragmentCompat() { } } - companion object { private const val PREFERENCE_THEME = "theme" diff --git a/app/ui/src/main/java/com/fsck/k9/ui/settings/general/LanguagePreference.kt b/app/ui/src/main/java/com/fsck/k9/ui/settings/general/LanguagePreference.kt index 3d784aaaf..38f926b59 100644 --- a/app/ui/src/main/java/com/fsck/k9/ui/settings/general/LanguagePreference.kt +++ b/app/ui/src/main/java/com/fsck/k9/ui/settings/general/LanguagePreference.kt @@ -1,25 +1,23 @@ package com.fsck.k9.ui.settings.general - import android.annotation.SuppressLint import android.content.Context +import android.util.AttributeSet import androidx.core.content.res.TypedArrayUtils import androidx.preference.ListPreference -import android.util.AttributeSet import com.fsck.k9.ui.R - class LanguagePreference @JvmOverloads @SuppressLint("RestrictedApi") constructor( - context: Context, - attrs: AttributeSet? = null, - defStyleAttr: Int = TypedArrayUtils.getAttr(context, - androidx.preference.R.attr.dialogPreferenceStyle, - android.R.attr.dialogPreferenceStyle), - defStyleRes: Int = 0 -) : ListPreference(context, attrs, defStyleAttr, defStyleRes ) { + context: Context, + attrs: AttributeSet? = null, + defStyleAttr: Int = TypedArrayUtils.getAttr(context, + androidx.preference.R.attr.dialogPreferenceStyle, + android.R.attr.dialogPreferenceStyle), + defStyleRes: Int = 0 +) : ListPreference(context, attrs, defStyleAttr, defStyleRes) { init { val supportedLanguages = context.resources.getStringArray(R.array.supported_languages).toSet() diff --git a/app/ui/src/main/java/com/fsck/k9/ui/settings/import/AccountActivator.kt b/app/ui/src/main/java/com/fsck/k9/ui/settings/import/AccountActivator.kt index 3faf2da40..e5c3d0675 100644 --- a/app/ui/src/main/java/com/fsck/k9/ui/settings/import/AccountActivator.kt +++ b/app/ui/src/main/java/com/fsck/k9/ui/settings/import/AccountActivator.kt @@ -11,10 +11,10 @@ import com.fsck.k9.controller.MessagingController * Activate account after server password(s) have been provided on settings import. */ class AccountActivator( - private val context: Context, - private val preferences: Preferences, - private val messagingController: MessagingController, - private val backendManager: BackendManager + private val context: Context, + private val preferences: Preferences, + private val messagingController: MessagingController, + private val backendManager: BackendManager ) { fun enableAccount(accountUuid: String, incomingServerPassword: String?, outgoingServerPassword: String?) { val account = preferences.getAccount(accountUuid) @@ -29,9 +29,9 @@ class AccountActivator( } private fun setAccountPasswords( - account: Account, - incomingServerPassword: String?, - outgoingServerPassword: String? + account: Account, + incomingServerPassword: String?, + outgoingServerPassword: String? ) { if (incomingServerPassword != null) { val incomingServerSettings = backendManager.decodeStoreUri(account.storeUri) diff --git a/app/ui/src/main/java/com/fsck/k9/ui/settings/import/PasswordPromptDialogFragment.kt b/app/ui/src/main/java/com/fsck/k9/ui/settings/import/PasswordPromptDialogFragment.kt index af846e52a..ef23d04fb 100644 --- a/app/ui/src/main/java/com/fsck/k9/ui/settings/import/PasswordPromptDialogFragment.kt +++ b/app/ui/src/main/java/com/fsck/k9/ui/settings/import/PasswordPromptDialogFragment.kt @@ -52,11 +52,11 @@ class PasswordPromptDialogFragment : DialogFragment() { @SuppressLint("InflateParams") private fun createView( - accountName: String, - inputIncomingServerPassword: Boolean, - incomingServerName: String?, - inputOutgoingServerPassword: Boolean, - outgoingServerName: String? + accountName: String, + inputIncomingServerPassword: Boolean, + incomingServerName: String?, + inputOutgoingServerPassword: Boolean, + outgoingServerName: String? ): View { val layoutInflater = LayoutInflater.from(requireContext()) val view = layoutInflater.inflate(R.layout.password_prompt_dialog, null) @@ -106,7 +106,6 @@ class PasswordPromptDialogFragment : DialogFragment() { targetFragment!!.onActivityResult(targetRequestCode, Activity.RESULT_OK, resultIntent) } - companion object { private const val ARG_ACCOUNT_UUID = "accountUuid" private const val ARG_ACCOUNT_NAME = "accountName" @@ -116,14 +115,14 @@ class PasswordPromptDialogFragment : DialogFragment() { private const val ARG_OUTGOING_SERVER_NAME = "outgoingServerName" fun create( - accountUuid: String, - accountName: String, - inputIncomingServerPassword: Boolean, - incomingServerName: String?, - inputOutgoingServerPassword: Boolean, - outgoingServerName: String?, - targetFragment: Fragment, - requestCode: Int + accountUuid: String, + accountName: String, + inputIncomingServerPassword: Boolean, + incomingServerName: String?, + inputOutgoingServerPassword: Boolean, + outgoingServerName: String?, + targetFragment: Fragment, + requestCode: Int ) = PasswordPromptDialogFragment().apply { arguments = bundleOf( ARG_ACCOUNT_UUID to accountUuid, diff --git a/app/ui/src/main/java/com/fsck/k9/ui/settings/import/PasswordPromptResult.kt b/app/ui/src/main/java/com/fsck/k9/ui/settings/import/PasswordPromptResult.kt index 685faf6ec..185dd1d3c 100644 --- a/app/ui/src/main/java/com/fsck/k9/ui/settings/import/PasswordPromptResult.kt +++ b/app/ui/src/main/java/com/fsck/k9/ui/settings/import/PasswordPromptResult.kt @@ -3,9 +3,9 @@ package com.fsck.k9.ui.settings.import import android.content.Intent data class PasswordPromptResult( - val accountUuid: String, - val incomingServerPassword: String?, - val outgoingServerPassword: String? + val accountUuid: String, + val incomingServerPassword: String?, + val outgoingServerPassword: String? ) { fun asIntent() = Intent().apply { putExtra(EXTRA_ACCOUNT_UUID, accountUuid) @@ -13,7 +13,6 @@ data class PasswordPromptResult( putExtra(EXTRA_OUTGOING_SERVER_PASSWORD, outgoingServerPassword) } - companion object { private const val EXTRA_ACCOUNT_UUID = "accountUuid" private const val EXTRA_INCOMING_SERVER_PASSWORD = "incomingServerPassword" diff --git a/app/ui/src/main/java/com/fsck/k9/ui/settings/import/SettingsImportFragment.kt b/app/ui/src/main/java/com/fsck/k9/ui/settings/import/SettingsImportFragment.kt index a20447ce2..ea42be6ca 100644 --- a/app/ui/src/main/java/com/fsck/k9/ui/settings/import/SettingsImportFragment.kt +++ b/app/ui/src/main/java/com/fsck/k9/ui/settings/import/SettingsImportFragment.kt @@ -25,7 +25,6 @@ class SettingsImportFragment : Fragment() { private lateinit var settingsImportAdapter: FastItemAdapter - override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { return inflater.inflate(R.layout.fragment_settings_import, container, false) } @@ -112,7 +111,7 @@ class SettingsImportFragment : Fragment() { setSettingsList(model.settingsList, model.isSettingsListEnabled) } - //TODO: Update list instead of replacing it completely + // TODO: Update list instead of replacing it completely private fun setSettingsList(items: List, enable: Boolean) { val importListItems = items.map { item -> val checkBoxItem = when (item) { @@ -196,7 +195,6 @@ class SettingsImportFragment : Fragment() { } } - companion object { private const val REQUEST_PICK_DOCUMENT = Activity.RESULT_FIRST_USER private const val REQUEST_PASSWORD_PROMPT = Activity.RESULT_FIRST_USER + 1 diff --git a/app/ui/src/main/java/com/fsck/k9/ui/settings/import/SettingsImportListItems.kt b/app/ui/src/main/java/com/fsck/k9/ui/settings/import/SettingsImportListItems.kt index 46c8c370f..889e64e30 100644 --- a/app/ui/src/main/java/com/fsck/k9/ui/settings/import/SettingsImportListItems.kt +++ b/app/ui/src/main/java/com/fsck/k9/ui/settings/import/SettingsImportListItems.kt @@ -15,8 +15,8 @@ import kotlinx.android.synthetic.main.settings_import_account_list_item.* private const val GENERAL_SETTINGS_ID = 0L private const val ACCOUNT_ITEMS_ID_OFFSET = 1L -abstract class ImportListItem(private val id: Long, private val importStatus: ImportStatus) - : AbstractItem() { +abstract class ImportListItem(private val id: Long, private val importStatus: ImportStatus) : + AbstractItem() { override fun getIdentifier(): Long = id @@ -70,10 +70,10 @@ class ImportListItemClickEvent(val action: (position: Int) -> Unit) : ClickEvent } override fun onClick( - view: View, - position: Int, - fastAdapter: FastAdapter, - item: ImportListItem + view: View, + position: Int, + fastAdapter: FastAdapter, + item: ImportListItem ) { action(position) } @@ -86,8 +86,8 @@ class GeneralSettingsItem(importStatus: ImportStatus) : ImportListItem(GENERAL_S override fun getLayoutRes(): Int = R.layout.settings_import_general_list_item } -class AccountItem(account: SettingsListItem.Account) - : ImportListItem(account.accountIndex + ACCOUNT_ITEMS_ID_OFFSET, account.importStatus) { +class AccountItem(account: SettingsListItem.Account) : + ImportListItem(account.accountIndex + ACCOUNT_ITEMS_ID_OFFSET, account.importStatus) { private val displayName = account.displayName diff --git a/app/ui/src/main/java/com/fsck/k9/ui/settings/import/SettingsImportUiModel.kt b/app/ui/src/main/java/com/fsck/k9/ui/settings/import/SettingsImportUiModel.kt index f860fa8f7..0c9905502 100644 --- a/app/ui/src/main/java/com/fsck/k9/ui/settings/import/SettingsImportUiModel.kt +++ b/app/ui/src/main/java/com/fsck/k9/ui/settings/import/SettingsImportUiModel.kt @@ -22,8 +22,7 @@ class SettingsImportUiModel { get() = isSettingsListVisible val wasAccountImportSuccessful - get() = hasImportStarted && settingsList.any { it !is GeneralSettings && it.importStatus.isSuccess} - + get() = hasImportStarted && settingsList.any { it !is GeneralSettings && it.importStatus.isSuccess } fun enablePickDocumentButton() { isPickDocumentButtonEnabled = true diff --git a/app/ui/src/main/java/com/fsck/k9/ui/settings/import/SettingsImportViewModel.kt b/app/ui/src/main/java/com/fsck/k9/ui/settings/import/SettingsImportViewModel.kt index e55a9194f..a011a4cbe 100644 --- a/app/ui/src/main/java/com/fsck/k9/ui/settings/import/SettingsImportViewModel.kt +++ b/app/ui/src/main/java/com/fsck/k9/ui/settings/import/SettingsImportViewModel.kt @@ -25,8 +25,8 @@ private typealias AccountUuid = String private typealias AccountNumber = Int class SettingsImportViewModel( - private val context: Context, - private val accountActivator: AccountActivator + private val context: Context, + private val accountActivator: AccountActivator ) : CoroutineScopeViewModel() { private val uiModelLiveData = MutableLiveData() private val actionLiveData = SingleLiveEvent() @@ -53,7 +53,6 @@ class SettingsImportViewModel( .toSet() } - fun getActionEvents(): LiveData = actionLiveData fun getUiModel(): LiveData { @@ -64,7 +63,6 @@ class SettingsImportViewModel( return uiModelLiveData } - fun initializeFromSavedState(savedInstanceState: Bundle) { contentUri = savedInstanceState.getParcelable(STATE_CONTENT_URI) @@ -267,7 +265,6 @@ class SettingsImportViewModel( delay(MIN_PROGRESS_DURATION - elapsed) } - updateUiModel { setGeneralSettingsImportStatus(importResults, importGeneralSettings) setAccountsImportStatus(importResults) @@ -285,8 +282,8 @@ class SettingsImportViewModel( } private fun SettingsImportUiModel.setGeneralSettingsImportStatus( - importResults: ImportResults, - importGeneralSettings: Boolean + importResults: ImportResults, + importGeneralSettings: Boolean ) { val importStatus = when { importResults.globalSettings -> ImportStatus.IMPORT_SUCCESS @@ -390,7 +387,6 @@ class SettingsImportViewModel( .toCollection(ArrayList(uiModel.settingsList.size - 1)) } - companion object { private const val MIN_PROGRESS_DURATION = 500L @@ -415,31 +411,31 @@ sealed class Action { class Close(val importSuccess: Boolean) : Action() object PickDocument : Action() class PasswordPrompt( - val accountUuid: String, - val accountName: String, - val inputIncomingServerPassword: Boolean, - val incomingServerName: String?, - val inputOutgoingServerPassword: Boolean, - val outgoingServerName: String? + val accountUuid: String, + val accountName: String, + val inputIncomingServerPassword: Boolean, + val incomingServerName: String?, + val inputOutgoingServerPassword: Boolean, + val outgoingServerName: String? ) : Action() } private class AccountState( - val incomingServerName: String?, - val outgoingServerName: String?, - val incomingServerPasswordNeeded: Boolean, - val outgoingServerPasswordNeeded: Boolean + val incomingServerName: String?, + val outgoingServerName: String?, + val incomingServerPasswordNeeded: Boolean, + val outgoingServerPasswordNeeded: Boolean ) @Parcelize private class SavedAccountState( - val accountIndex: Int, - val displayName: String, - val accountUuid: String, - val selected: Boolean, - val importStatus: ImportStatus, - val incomingServerName: String?, - val outgoingServerName: String?, - val incomingServerPasswordNeeded: Boolean, - val outgoingServerPasswordNeeded: Boolean + val accountIndex: Int, + val displayName: String, + val accountUuid: String, + val selected: Boolean, + val importStatus: ImportStatus, + val incomingServerName: String?, + val outgoingServerName: String?, + val incomingServerPasswordNeeded: Boolean, + val outgoingServerPasswordNeeded: Boolean ) : Parcelable diff --git a/app/ui/src/main/java/com/fsck/k9/view/WebViewConfig.kt b/app/ui/src/main/java/com/fsck/k9/view/WebViewConfig.kt index 3398b075b..a5a9253fe 100644 --- a/app/ui/src/main/java/com/fsck/k9/view/WebViewConfig.kt +++ b/app/ui/src/main/java/com/fsck/k9/view/WebViewConfig.kt @@ -1,7 +1,7 @@ package com.fsck.k9.view data class WebViewConfig( - val useDarkMode: Boolean, - val autoFitWidth: Boolean, - val textZoom: Int + val useDarkMode: Boolean, + val autoFitWidth: Boolean, + val textZoom: Int ) diff --git a/app/ui/src/test/java/com/fsck/k9/ViewTestExtensions.kt b/app/ui/src/test/java/com/fsck/k9/ViewTestExtensions.kt index c933413e6..0f1a3b976 100644 --- a/app/ui/src/test/java/com/fsck/k9/ViewTestExtensions.kt +++ b/app/ui/src/test/java/com/fsck/k9/ViewTestExtensions.kt @@ -2,6 +2,5 @@ package com.fsck.k9 import android.widget.TextView - val TextView.textString: String get() = text.toString() diff --git a/app/ui/src/test/java/com/fsck/k9/contacts/ContactLetterExtractorTest.kt b/app/ui/src/test/java/com/fsck/k9/contacts/ContactLetterExtractorTest.kt index cd195a0a2..cc793c47f 100644 --- a/app/ui/src/test/java/com/fsck/k9/contacts/ContactLetterExtractorTest.kt +++ b/app/ui/src/test/java/com/fsck/k9/contacts/ContactLetterExtractorTest.kt @@ -5,7 +5,6 @@ import com.fsck.k9.mail.Address import org.junit.Assert.assertEquals import org.junit.Test - class ContactLetterExtractorTest : RobolectricTest() { val letterExtractor = ContactLetterExtractor() diff --git a/app/ui/src/test/java/com/fsck/k9/fragment/MessageListAdapterTest.kt b/app/ui/src/test/java/com/fsck/k9/fragment/MessageListAdapterTest.kt index 005e67144..abce9e5d0 100644 --- a/app/ui/src/test/java/com/fsck/k9/fragment/MessageListAdapterTest.kt +++ b/app/ui/src/test/java/com/fsck/k9/fragment/MessageListAdapterTest.kt @@ -43,7 +43,6 @@ import org.junit.Test import org.mockito.AdditionalMatchers.aryEq import org.robolectric.RuntimeEnvironment - private const val SOME_ACCOUNT_UUID = "6b84207b-25de-4dab-97c3-953bbf03fec6" private const val DISPLAY_NAME = "Display Name" private const val FIRST_LINE_DEFAULT_FONT_SIZE = 18f @@ -63,7 +62,6 @@ class MessageListAdapterTest : RobolectricTest() { val contactsPictureLoader: ContactPictureLoader = mock() val listItemListener: MessageListItemActionListener = mock() - @Test fun withShowAccountChip_shouldShowAccountChip() { val adapter = createAdapter(showAccountChip = true) @@ -421,17 +419,16 @@ class MessageListAdapterTest : RobolectricTest() { assertEquals(22f, view.secondLineView.textSize) } - fun configureMessageHelperMockToMe(address: String) { val addresses = Address.parse(address) whenever(messageHelper.toMe(eq(testAccount), aryEq(addresses))).thenReturn(true) } fun createFontSizes( - subject: Int = FONT_DEFAULT, - sender: Int = FONT_DEFAULT, - preview: Int = FONT_DEFAULT, - date: Int = FONT_DEFAULT + subject: Int = FONT_DEFAULT, + sender: Int = FONT_DEFAULT, + preview: Int = FONT_DEFAULT, + date: Int = FONT_DEFAULT ): FontSizes { return FontSizes().apply { messageListSubject = subject @@ -442,14 +439,14 @@ class MessageListAdapterTest : RobolectricTest() { } fun createAdapter( - fontSizes: FontSizes = createFontSizes(), - previewLines: Int = 0, - stars: Boolean = true, - senderAboveSubject: Boolean = false, - showContactPicture: Boolean = true, - showingThreadedList: Boolean = true, - backGroundAsReadIndicator: Boolean = false, - showAccountChip: Boolean = false + fontSizes: FontSizes = createFontSizes(), + previewLines: Int = 0, + stars: Boolean = true, + senderAboveSubject: Boolean = false, + showContactPicture: Boolean = true, + showingThreadedList: Boolean = true, + backGroundAsReadIndicator: Boolean = false, + showAccountChip: Boolean = false ): MessageListAdapter { val appearance = MessageListAppearance( fontSizes, @@ -476,26 +473,26 @@ class MessageListAdapterTest : RobolectricTest() { } fun createCursor( - id: Long = 0L, - uid: String = "irrelevant", - internalDate: Long = 0L, - subject: String = "irrelevant", - date: Long = 0L, - sender: String = "irrelevant@domain.example", - to: String = "irrelevant@domain.example", - cc: String = "irrelevant@domain.example", - read: Int = 0, - flagged: Int = 0, - answered: Int = 0, - forwarded: Int = 0, - attachmentCount: Int = 0, - folderId: String = "irrelevant", - previewType: String = "text", - preview: String = "irrelevant", - threadRoot: Long = 0L, - accountUuid: String = SOME_ACCOUNT_UUID, - folderServerId: String = "irrelevant", - threadCount: Int = 0 + id: Long = 0L, + uid: String = "irrelevant", + internalDate: Long = 0L, + subject: String = "irrelevant", + date: Long = 0L, + sender: String = "irrelevant@domain.example", + to: String = "irrelevant@domain.example", + cc: String = "irrelevant@domain.example", + read: Int = 0, + flagged: Int = 0, + answered: Int = 0, + forwarded: Int = 0, + attachmentCount: Int = 0, + folderId: String = "irrelevant", + previewType: String = "text", + preview: String = "irrelevant", + threadRoot: Long = 0L, + accountUuid: String = SOME_ACCOUNT_UUID, + folderServerId: String = "irrelevant", + threadCount: Int = 0 ): Cursor { val mapping = mapOf( MessageColumns.ID to id, @@ -531,7 +528,7 @@ class MessageListAdapterTest : RobolectricTest() { return view } - fun secondLine(senderOrSubject: String, preview: String)= "$senderOrSubject $preview" + fun secondLine(senderOrSubject: String, preview: String) = "$senderOrSubject $preview" val View.accountChipView: View get() = findViewById(R.id.account_color_chip) val View.starView: CheckBox get() = findViewById(R.id.star) diff --git a/app/ui/src/test/java/com/fsck/k9/message/PgpMessageBuilderTest.kt b/app/ui/src/test/java/com/fsck/k9/message/PgpMessageBuilderTest.kt index ee68b52ac..ecc793954 100644 --- a/app/ui/src/test/java/com/fsck/k9/message/PgpMessageBuilderTest.kt +++ b/app/ui/src/test/java/com/fsck/k9/message/PgpMessageBuilderTest.kt @@ -1,6 +1,5 @@ package com.fsck.k9.message - import android.app.Activity import android.app.PendingIntent import android.content.Intent @@ -19,35 +18,48 @@ import com.fsck.k9.mail.Address import com.fsck.k9.mail.BodyPart import com.fsck.k9.mail.BoundaryGenerator import com.fsck.k9.mail.MessagingException -import com.fsck.k9.mail.internet.* +import com.fsck.k9.mail.internet.BinaryTempFileBody +import com.fsck.k9.mail.internet.MessageIdGenerator +import com.fsck.k9.mail.internet.MimeMessage +import com.fsck.k9.mail.internet.MimeMultipart +import com.fsck.k9.mail.internet.MimeUtility +import com.fsck.k9.mail.internet.TextBody import com.fsck.k9.message.MessageBuilder.Callback import com.fsck.k9.message.quote.InsertableHtmlContent import com.fsck.k9.view.RecipientSelectView import com.nhaarman.mockito_kotlin.anyOrNull +import java.io.ByteArrayOutputStream +import java.io.IOException +import java.io.OutputStream +import java.util.Date import org.apache.commons.io.Charsets import org.apache.commons.io.IOUtils import org.apache.james.mime4j.util.MimeUtil import org.junit.Assert -import org.junit.Assert.* +import org.junit.Assert.assertEquals +import org.junit.Assert.assertNotNull +import org.junit.Assert.assertTrue import org.junit.Before import org.junit.Test import org.koin.core.inject import org.mockito.ArgumentCaptor -import org.mockito.Mockito.* +import org.mockito.ArgumentMatchers.any +import org.mockito.ArgumentMatchers.anyInt +import org.mockito.ArgumentMatchers.eq +import org.mockito.ArgumentMatchers.same +import org.mockito.Mockito.`when` +import org.mockito.Mockito.mock +import org.mockito.Mockito.spy +import org.mockito.Mockito.verify +import org.mockito.Mockito.verifyNoMoreInteractions import org.openintents.openpgp.OpenPgpApiManager.OpenPgpProviderState import org.openintents.openpgp.OpenPgpError import org.openintents.openpgp.util.OpenPgpApi import org.openintents.openpgp.util.OpenPgpApi.OpenPgpDataSource import org.robolectric.RuntimeEnvironment -import java.io.ByteArrayOutputStream -import java.io.IOException -import java.io.OutputStream -import java.util.* - class PgpMessageBuilderTest : K9RobolectricTest() { - private val defaultCryptoStatus = ComposeCryptoStatus( OpenPgpProviderState.OK, TEST_KEY_ID, @@ -603,20 +615,17 @@ class PgpMessageBuilderTest : K9RobolectricTest() { val cryptoStatus = defaultCryptoStatus.copy(recipientAddresses = listOf("test@example.org")) pgpMessageBuilder.setCryptoStatus(cryptoStatus) - val returnIntent = Intent() returnIntent.putExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_ERROR) returnIntent.putExtra(OpenPgpApi.RESULT_ERROR, OpenPgpError(OpenPgpError.OPPORTUNISTIC_MISSING_KEYS, "Missing keys")) - `when`(openPgpApi.executeApi(any(Intent::class.java), any(OpenPgpDataSource::class.java), any(OutputStream::class.java))) .thenReturn(returnIntent) val mockCallback = mock(Callback::class.java) pgpMessageBuilder.buildAsync(mockCallback) - val captor = ArgumentCaptor.forClass(MimeMessage::class.java) verify(mockCallback).onMessageBuildSuccess(captor.capture(), eq(false)) verifyNoMoreInteractions(mockCallback) @@ -635,12 +644,10 @@ class PgpMessageBuilderTest : K9RobolectricTest() { returnIntentSigned.putExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_SUCCESS) // no OpenPgpApi.EXTRA_DETACHED_SIGNATURE! - `when`(openPgpApi.executeApi(any(), any(), any())).thenReturn(returnIntentSigned) val mockCallback = mock(Callback::class.java) pgpMessageBuilder.buildAsync(mockCallback) - verify(mockCallback).onMessageBuildException(any()) verifyNoMoreInteractions(mockCallback) } @@ -651,9 +658,11 @@ class PgpMessageBuilderTest : K9RobolectricTest() { private val AUTOCRYPT_KEY_MATERIAL = byteArrayOf(1, 2, 3) private val SENDER_EMAIL = "test@example.org" - private fun createDefaultPgpMessageBuilder(openPgpApi: OpenPgpApi, - autocryptOpenPgpApiInteractor: AutocryptOpenPgpApiInteractor, - resourceProvider: CoreResourceProvider): PgpMessageBuilder { + private fun createDefaultPgpMessageBuilder( + openPgpApi: OpenPgpApi, + autocryptOpenPgpApiInteractor: AutocryptOpenPgpApiInteractor, + resourceProvider: CoreResourceProvider + ): PgpMessageBuilder { val builder = PgpMessageBuilder( MessageIdGenerator.getInstance(), BoundaryGenerator.getInstance(), AutocryptOperations.getInstance(), autocryptOpenPgpApiInteractor, resourceProvider) @@ -704,7 +713,6 @@ class PgpMessageBuilderTest : K9RobolectricTest() { } catch (e: MessagingException) { Assert.fail() } - } private fun assertContentOfBodyPartEquals(reason: String, signatureBodyPart: BodyPart, expected: String) { @@ -718,7 +726,6 @@ class PgpMessageBuilderTest : K9RobolectricTest() { } catch (e: MessagingException) { Assert.fail() } - } private fun assertIntentEqualsActionAndExtras(expected: Intent, actual: Intent) { diff --git a/backend/api/src/main/java/com/fsck/k9/backend/api/Backend.kt b/backend/api/src/main/java/com/fsck/k9/backend/api/Backend.kt index 2aa50955a..80c81eba2 100644 --- a/backend/api/src/main/java/com/fsck/k9/backend/api/Backend.kt +++ b/backend/api/src/main/java/com/fsck/k9/backend/api/Backend.kt @@ -1,6 +1,5 @@ package com.fsck.k9.backend.api - import com.fsck.k9.mail.BodyFactory import com.fsck.k9.mail.FetchProfile import com.fsck.k9.mail.Flag @@ -11,7 +10,6 @@ import com.fsck.k9.mail.Part import com.fsck.k9.mail.PushReceiver import com.fsck.k9.mail.Pusher - interface Backend { val supportsSeenFlag: Boolean val supportsExpunge: Boolean @@ -52,24 +50,24 @@ interface Backend { @Throws(MessagingException::class) fun moveMessages( - sourceFolderServerId: String, - targetFolderServerId: String, - messageServerIds: List + sourceFolderServerId: String, + targetFolderServerId: String, + messageServerIds: List ): Map? @Throws(MessagingException::class) fun copyMessages( - sourceFolderServerId: String, - targetFolderServerId: String, - messageServerIds: List + sourceFolderServerId: String, + targetFolderServerId: String, + messageServerIds: List ): Map? @Throws(MessagingException::class) fun search( - folderServerId: String, - query: String?, - requiredFlags: Set?, - forbiddenFlags: Set? + folderServerId: String, + query: String?, + requiredFlags: Set?, + forbiddenFlags: Set? ): List @Throws(MessagingException::class) diff --git a/backend/api/src/main/java/com/fsck/k9/backend/api/BackendFolder.kt b/backend/api/src/main/java/com/fsck/k9/backend/api/BackendFolder.kt index cb1e05b36..8cffc4e15 100644 --- a/backend/api/src/main/java/com/fsck/k9/backend/api/BackendFolder.kt +++ b/backend/api/src/main/java/com/fsck/k9/backend/api/BackendFolder.kt @@ -4,7 +4,7 @@ import com.fsck.k9.mail.Flag import com.fsck.k9.mail.Message import java.util.Date -//FIXME: add documentation +// FIXME: add documentation interface BackendFolder { val name: String val visibleLimit: Int diff --git a/backend/api/src/main/java/com/fsck/k9/backend/api/SyncConfig.kt b/backend/api/src/main/java/com/fsck/k9/backend/api/SyncConfig.kt index 9d95d8c48..6e3f6f86e 100644 --- a/backend/api/src/main/java/com/fsck/k9/backend/api/SyncConfig.kt +++ b/backend/api/src/main/java/com/fsck/k9/backend/api/SyncConfig.kt @@ -4,12 +4,12 @@ import com.fsck.k9.mail.Flag import java.util.Date data class SyncConfig( - val expungePolicy: ExpungePolicy, - val earliestPollDate: Date?, - val syncRemoteDeletions: Boolean, - val maximumAutoDownloadMessageSize: Int, - val defaultVisibleLimit: Int, - val syncFlags: Set + val expungePolicy: ExpungePolicy, + val earliestPollDate: Date?, + val syncRemoteDeletions: Boolean, + val maximumAutoDownloadMessageSize: Int, + val defaultVisibleLimit: Int, + val syncFlags: Set ) { enum class ExpungePolicy { IMMEDIATELY, diff --git a/backend/imap/src/main/java/com/fsck/k9/backend/imap/CommandDeleteAll.kt b/backend/imap/src/main/java/com/fsck/k9/backend/imap/CommandDeleteAll.kt index 335b95d63..1b6f3482e 100644 --- a/backend/imap/src/main/java/com/fsck/k9/backend/imap/CommandDeleteAll.kt +++ b/backend/imap/src/main/java/com/fsck/k9/backend/imap/CommandDeleteAll.kt @@ -1,12 +1,10 @@ package com.fsck.k9.backend.imap - import com.fsck.k9.mail.Flag import com.fsck.k9.mail.Folder import com.fsck.k9.mail.MessagingException import com.fsck.k9.mail.store.imap.ImapStore - internal class CommandDeleteAll(private val imapStore: ImapStore) { @Throws(MessagingException::class) diff --git a/backend/imap/src/main/java/com/fsck/k9/backend/imap/CommandFetchMessage.kt b/backend/imap/src/main/java/com/fsck/k9/backend/imap/CommandFetchMessage.kt index c96ec867d..c62990d94 100644 --- a/backend/imap/src/main/java/com/fsck/k9/backend/imap/CommandFetchMessage.kt +++ b/backend/imap/src/main/java/com/fsck/k9/backend/imap/CommandFetchMessage.kt @@ -1,6 +1,5 @@ package com.fsck.k9.backend.imap - import com.fsck.k9.mail.BodyFactory import com.fsck.k9.mail.FetchProfile import com.fsck.k9.mail.Folder @@ -10,7 +9,6 @@ import com.fsck.k9.mail.store.imap.ImapFolder import com.fsck.k9.mail.store.imap.ImapMessage import com.fsck.k9.mail.store.imap.ImapStore - internal class CommandFetchMessage(private val imapStore: ImapStore) { fun fetchMessage(folderServerId: String, messageServerId: String, fetchProfile: FetchProfile): Message { @@ -20,7 +18,7 @@ internal class CommandFetchMessage(private val imapStore: ImapStore) { val message = folder.getMessage(messageServerId) - //fun fact: ImapFolder.fetch can't handle getting STRUCTURE at same time as headers + // fun fact: ImapFolder.fetch can't handle getting STRUCTURE at same time as headers if (fetchProfile.contains(FetchProfile.Item.STRUCTURE) && fetchProfile.contains(FetchProfile.Item.ENVELOPE)) { val headerFetchProfile = fetchProfile.without(FetchProfile.Item.STRUCTURE) diff --git a/backend/imap/src/main/java/com/fsck/k9/backend/imap/CommandFindByMessageId.kt b/backend/imap/src/main/java/com/fsck/k9/backend/imap/CommandFindByMessageId.kt index bfa56efb5..7ae311bd6 100644 --- a/backend/imap/src/main/java/com/fsck/k9/backend/imap/CommandFindByMessageId.kt +++ b/backend/imap/src/main/java/com/fsck/k9/backend/imap/CommandFindByMessageId.kt @@ -1,10 +1,8 @@ package com.fsck.k9.backend.imap - import com.fsck.k9.mail.Folder import com.fsck.k9.mail.store.imap.ImapStore - internal class CommandFindByMessageId(private val imapStore: ImapStore) { fun findByMessageId(folderServerId: String, messageId: String): String? { diff --git a/backend/imap/src/main/java/com/fsck/k9/backend/imap/CommandRefreshFolderList.kt b/backend/imap/src/main/java/com/fsck/k9/backend/imap/CommandRefreshFolderList.kt index c7ce563f9..32eec7275 100644 --- a/backend/imap/src/main/java/com/fsck/k9/backend/imap/CommandRefreshFolderList.kt +++ b/backend/imap/src/main/java/com/fsck/k9/backend/imap/CommandRefreshFolderList.kt @@ -1,14 +1,12 @@ package com.fsck.k9.backend.imap - import com.fsck.k9.backend.api.BackendStorage import com.fsck.k9.backend.api.FolderInfo import com.fsck.k9.mail.store.imap.ImapStore - internal class CommandRefreshFolderList( - private val backendStorage: BackendStorage, - private val imapStore: ImapStore + private val backendStorage: BackendStorage, + private val imapStore: ImapStore ) { fun refreshFolderList() { val foldersOnServer = imapStore.personalNamespaces diff --git a/backend/imap/src/main/java/com/fsck/k9/backend/imap/CommandSearch.kt b/backend/imap/src/main/java/com/fsck/k9/backend/imap/CommandSearch.kt index fd1e3f7b0..b3619cf55 100644 --- a/backend/imap/src/main/java/com/fsck/k9/backend/imap/CommandSearch.kt +++ b/backend/imap/src/main/java/com/fsck/k9/backend/imap/CommandSearch.kt @@ -1,17 +1,15 @@ package com.fsck.k9.backend.imap - import com.fsck.k9.mail.Flag import com.fsck.k9.mail.store.imap.ImapStore - internal class CommandSearch(private val imapStore: ImapStore) { fun search( - folderServerId: String, - query: String?, - requiredFlags: Set?, - forbiddenFlags: Set? + folderServerId: String, + query: String?, + requiredFlags: Set?, + forbiddenFlags: Set? ): List { val folder = imapStore.getFolder(folderServerId) try { diff --git a/backend/imap/src/main/java/com/fsck/k9/backend/imap/CommandUploadMessage.kt b/backend/imap/src/main/java/com/fsck/k9/backend/imap/CommandUploadMessage.kt index 2bf987eee..80f2270ae 100644 --- a/backend/imap/src/main/java/com/fsck/k9/backend/imap/CommandUploadMessage.kt +++ b/backend/imap/src/main/java/com/fsck/k9/backend/imap/CommandUploadMessage.kt @@ -1,11 +1,9 @@ package com.fsck.k9.backend.imap - import com.fsck.k9.mail.Folder import com.fsck.k9.mail.Message import com.fsck.k9.mail.store.imap.ImapStore - internal class CommandUploadMessage(private val imapStore: ImapStore) { fun uploadMessage(folderServerId: String, message: Message): String? { diff --git a/backend/pop3/src/main/java/com/fsck/k9/backend/pop3/CommandDeleteAll.kt b/backend/pop3/src/main/java/com/fsck/k9/backend/pop3/CommandDeleteAll.kt index 35a98f40e..ca9a80bd2 100644 --- a/backend/pop3/src/main/java/com/fsck/k9/backend/pop3/CommandDeleteAll.kt +++ b/backend/pop3/src/main/java/com/fsck/k9/backend/pop3/CommandDeleteAll.kt @@ -1,12 +1,10 @@ package com.fsck.k9.backend.pop3 - import com.fsck.k9.mail.Flag import com.fsck.k9.mail.Folder import com.fsck.k9.mail.MessagingException import com.fsck.k9.mail.store.pop3.Pop3Store - internal class CommandDeleteAll(private val pop3Store: Pop3Store) { @Throws(MessagingException::class) diff --git a/backend/pop3/src/main/java/com/fsck/k9/backend/pop3/CommandFetchMessage.kt b/backend/pop3/src/main/java/com/fsck/k9/backend/pop3/CommandFetchMessage.kt index dbd6a6457..055a04a49 100644 --- a/backend/pop3/src/main/java/com/fsck/k9/backend/pop3/CommandFetchMessage.kt +++ b/backend/pop3/src/main/java/com/fsck/k9/backend/pop3/CommandFetchMessage.kt @@ -1,11 +1,9 @@ package com.fsck.k9.backend.pop3 - import com.fsck.k9.mail.FetchProfile import com.fsck.k9.mail.Message import com.fsck.k9.mail.store.pop3.Pop3Store - internal class CommandFetchMessage(private val pop3Store: Pop3Store) { fun fetchMessage(folderServerId: String, messageServerId: String, fetchProfile: FetchProfile): Message { diff --git a/backend/pop3/src/main/java/com/fsck/k9/backend/pop3/CommandRefreshFolderList.kt b/backend/pop3/src/main/java/com/fsck/k9/backend/pop3/CommandRefreshFolderList.kt index 1df7e5f7a..83dd6a25c 100644 --- a/backend/pop3/src/main/java/com/fsck/k9/backend/pop3/CommandRefreshFolderList.kt +++ b/backend/pop3/src/main/java/com/fsck/k9/backend/pop3/CommandRefreshFolderList.kt @@ -1,12 +1,10 @@ package com.fsck.k9.backend.pop3 - import com.fsck.k9.backend.api.BackendStorage import com.fsck.k9.backend.api.FolderInfo import com.fsck.k9.mail.Folder.FolderType import com.fsck.k9.mail.store.pop3.Pop3Folder - internal class CommandRefreshFolderList(private val backendStorage: BackendStorage) { fun refreshFolderList() { val folderServerIds = backendStorage.getFolderServerIds() diff --git a/backend/pop3/src/main/java/com/fsck/k9/backend/pop3/Pop3Backend.kt b/backend/pop3/src/main/java/com/fsck/k9/backend/pop3/Pop3Backend.kt index da9a61bd3..b246a73b1 100644 --- a/backend/pop3/src/main/java/com/fsck/k9/backend/pop3/Pop3Backend.kt +++ b/backend/pop3/src/main/java/com/fsck/k9/backend/pop3/Pop3Backend.kt @@ -16,10 +16,10 @@ import com.fsck.k9.mail.store.pop3.Pop3Store import com.fsck.k9.mail.transport.smtp.SmtpTransport class Pop3Backend( - accountName: String, - backendStorage: BackendStorage, - private val pop3Store: Pop3Store, - private val smtpTransport: SmtpTransport + accountName: String, + backendStorage: BackendStorage, + private val pop3Store: Pop3Store, + private val smtpTransport: SmtpTransport ) : Backend { private val pop3Sync: Pop3Sync = Pop3Sync(accountName, backendStorage, pop3Store) private val commandRefreshFolderList = CommandRefreshFolderList(backendStorage) @@ -74,26 +74,26 @@ class Pop3Backend( } override fun moveMessages( - sourceFolderServerId: String, - targetFolderServerId: String, - messageServerIds: List + sourceFolderServerId: String, + targetFolderServerId: String, + messageServerIds: List ): Map? { throw UnsupportedOperationException("not supported") } override fun copyMessages( - sourceFolderServerId: String, - targetFolderServerId: String, - messageServerIds: List + sourceFolderServerId: String, + targetFolderServerId: String, + messageServerIds: List ): Map? { throw UnsupportedOperationException("not supported") } override fun search( - folderServerId: String, - query: String?, - requiredFlags: Set?, - forbiddenFlags: Set? + folderServerId: String, + query: String?, + requiredFlags: Set?, + forbiddenFlags: Set? ): List { throw UnsupportedOperationException("not supported") } diff --git a/backend/webdav/src/main/java/com/fsck/k9/backend/webdav/CommandDeleteAll.kt b/backend/webdav/src/main/java/com/fsck/k9/backend/webdav/CommandDeleteAll.kt index db25db87a..fb247d843 100644 --- a/backend/webdav/src/main/java/com/fsck/k9/backend/webdav/CommandDeleteAll.kt +++ b/backend/webdav/src/main/java/com/fsck/k9/backend/webdav/CommandDeleteAll.kt @@ -1,12 +1,10 @@ package com.fsck.k9.backend.webdav - import com.fsck.k9.mail.Flag import com.fsck.k9.mail.Folder import com.fsck.k9.mail.MessagingException import com.fsck.k9.mail.store.webdav.WebDavStore - internal class CommandDeleteAll(private val webDavStore: WebDavStore) { @Throws(MessagingException::class) diff --git a/backend/webdav/src/main/java/com/fsck/k9/backend/webdav/CommandFetchMessage.kt b/backend/webdav/src/main/java/com/fsck/k9/backend/webdav/CommandFetchMessage.kt index cd8d0d68f..476102681 100644 --- a/backend/webdav/src/main/java/com/fsck/k9/backend/webdav/CommandFetchMessage.kt +++ b/backend/webdav/src/main/java/com/fsck/k9/backend/webdav/CommandFetchMessage.kt @@ -1,11 +1,9 @@ package com.fsck.k9.backend.webdav - import com.fsck.k9.mail.FetchProfile import com.fsck.k9.mail.Message import com.fsck.k9.mail.store.webdav.WebDavStore - internal class CommandFetchMessage(private val webDavStore: WebDavStore) { fun fetchMessage(folderServerId: String, messageServerId: String, fetchProfile: FetchProfile): Message { diff --git a/backend/webdav/src/main/java/com/fsck/k9/backend/webdav/CommandRefreshFolderList.kt b/backend/webdav/src/main/java/com/fsck/k9/backend/webdav/CommandRefreshFolderList.kt index f1cd5ac33..09bcaa2fe 100644 --- a/backend/webdav/src/main/java/com/fsck/k9/backend/webdav/CommandRefreshFolderList.kt +++ b/backend/webdav/src/main/java/com/fsck/k9/backend/webdav/CommandRefreshFolderList.kt @@ -1,14 +1,12 @@ package com.fsck.k9.backend.webdav - import com.fsck.k9.backend.api.BackendStorage import com.fsck.k9.backend.api.FolderInfo import com.fsck.k9.mail.store.webdav.WebDavStore - internal class CommandRefreshFolderList( - private val backendStorage: BackendStorage, - private val webDavStore: WebDavStore + private val backendStorage: BackendStorage, + private val webDavStore: WebDavStore ) { fun refreshFolderList() { val foldersOnServer = webDavStore.personalNamespaces diff --git a/backend/webdav/src/main/java/com/fsck/k9/backend/webdav/CommandUploadMessage.kt b/backend/webdav/src/main/java/com/fsck/k9/backend/webdav/CommandUploadMessage.kt index 03e63ebe4..0721570c0 100644 --- a/backend/webdav/src/main/java/com/fsck/k9/backend/webdav/CommandUploadMessage.kt +++ b/backend/webdav/src/main/java/com/fsck/k9/backend/webdav/CommandUploadMessage.kt @@ -1,11 +1,9 @@ package com.fsck.k9.backend.webdav - import com.fsck.k9.mail.Folder import com.fsck.k9.mail.Message import com.fsck.k9.mail.store.webdav.WebDavStore - internal class CommandUploadMessage(private val webDavStore: WebDavStore) { fun uploadMessage(folderServerId: String, message: Message): String? { diff --git a/backend/webdav/src/main/java/com/fsck/k9/backend/webdav/WebDavBackend.kt b/backend/webdav/src/main/java/com/fsck/k9/backend/webdav/WebDavBackend.kt index fc2dc8ad3..d2660485a 100644 --- a/backend/webdav/src/main/java/com/fsck/k9/backend/webdav/WebDavBackend.kt +++ b/backend/webdav/src/main/java/com/fsck/k9/backend/webdav/WebDavBackend.kt @@ -17,10 +17,10 @@ import com.fsck.k9.mail.store.webdav.WebDavStore import com.fsck.k9.mail.transport.WebDavTransport class WebDavBackend( - accountName: String, - backendStorage: BackendStorage, - private val webDavStore: WebDavStore, - private val webDavTransport: WebDavTransport + accountName: String, + backendStorage: BackendStorage, + private val webDavStore: WebDavStore, + private val webDavTransport: WebDavTransport ) : Backend { private val webDavSync: WebDavSync = WebDavSync(accountName, backendStorage, webDavStore) private val commandGetFolders = CommandRefreshFolderList(backendStorage, webDavStore) @@ -79,26 +79,26 @@ class WebDavBackend( } override fun moveMessages( - sourceFolderServerId: String, - targetFolderServerId: String, - messageServerIds: List + sourceFolderServerId: String, + targetFolderServerId: String, + messageServerIds: List ): Map? { return commandMoveOrCopyMessages.moveMessages(sourceFolderServerId, targetFolderServerId, messageServerIds) } override fun copyMessages( - sourceFolderServerId: String, - targetFolderServerId: String, - messageServerIds: List + sourceFolderServerId: String, + targetFolderServerId: String, + messageServerIds: List ): Map? { return commandMoveOrCopyMessages.copyMessages(sourceFolderServerId, targetFolderServerId, messageServerIds) } override fun search( - folderServerId: String, - query: String?, - requiredFlags: Set?, - forbiddenFlags: Set? + folderServerId: String, + query: String?, + requiredFlags: Set?, + forbiddenFlags: Set? ): List { throw UnsupportedOperationException("not supported") } diff --git a/mail/common/src/main/java/com/fsck/k9/mail/AuthenticationFailedException.kt b/mail/common/src/main/java/com/fsck/k9/mail/AuthenticationFailedException.kt index cda6de2cd..aeab48441 100644 --- a/mail/common/src/main/java/com/fsck/k9/mail/AuthenticationFailedException.kt +++ b/mail/common/src/main/java/com/fsck/k9/mail/AuthenticationFailedException.kt @@ -1,9 +1,9 @@ package com.fsck.k9.mail class AuthenticationFailedException @JvmOverloads constructor( - message: String, - throwable: Throwable? = null, - val messageFromServer: String? = null + message: String, + throwable: Throwable? = null, + val messageFromServer: String? = null ) : MessagingException(message, throwable) { val isMessageFromServerAvailable = messageFromServer != null } diff --git a/mail/common/src/main/java/com/fsck/k9/mail/filter/Hex.kt b/mail/common/src/main/java/com/fsck/k9/mail/filter/Hex.kt index e02aef95c..fb973a555 100644 --- a/mail/common/src/main/java/com/fsck/k9/mail/filter/Hex.kt +++ b/mail/common/src/main/java/com/fsck/k9/mail/filter/Hex.kt @@ -43,7 +43,7 @@ object Hex { var j = 0 while (i < l) { out[j++] = LOWER_CASE[data[i].toInt() shr 4 and 0x0F] - out[j++] = LOWER_CASE[data[i].toInt() and 0x0F] + out[j++] = LOWER_CASE[data[i].toInt() and 0x0F] i++ } @@ -53,6 +53,6 @@ object Hex { fun StringBuilder.appendHex(value: Byte, lowerCase: Boolean = true) { val digits = if (lowerCase) LOWER_CASE else UPPER_CASE append(digits[value.toInt() shr 4 and 0x0F]) - append(digits[value.toInt() and 0x0F]) + append(digits[value.toInt() and 0x0F]) } } diff --git a/mail/common/src/main/java/com/fsck/k9/mail/helper/Utf8.kt b/mail/common/src/main/java/com/fsck/k9/mail/helper/Utf8.kt index 2c48f70f6..9a79beb6d 100644 --- a/mail/common/src/main/java/com/fsck/k9/mail/helper/Utf8.kt +++ b/mail/common/src/main/java/com/fsck/k9/mail/helper/Utf8.kt @@ -37,14 +37,14 @@ inline fun String.encodeUtf8(beginIndex: Int = 0, endIndex: Int = length, crossi i++ } else if (c < 0x800) { // Emit a 11-bit character with 2 bytes. - writeByte((c shr 6 or 0xc0).toByte()) // 110xxxxx - writeByte((c and 0x3f or 0x80).toByte()) // 10xxxxxx + writeByte((c shr 6 or 0xc0).toByte()) // 110xxxxx + writeByte((c and 0x3f or 0x80).toByte()) // 10xxxxxx i++ } else if (c < 0xd800 || c > 0xdfff) { // Emit a 16-bit character with 3 bytes. - writeByte((c shr 12 or 0xe0).toByte()) // 1110xxxx - writeByte((c shr 6 and 0x3f or 0x80).toByte()) // 10xxxxxx - writeByte((c and 0x3f or 0x80).toByte()) // 10xxxxxx + writeByte((c shr 12 or 0xe0).toByte()) // 1110xxxx + writeByte((c shr 6 and 0x3f or 0x80).toByte()) // 10xxxxxx + writeByte((c and 0x3f or 0x80).toByte()) // 10xxxxxx i++ } else { // c is a surrogate. Make sure it is a high surrogate and that its successor is a low surrogate. @@ -62,10 +62,10 @@ inline fun String.encodeUtf8(beginIndex: Int = 0, endIndex: Int = length, crossi val codePoint = 0x010000 + (c and 0xd800.inv() shl 10 or (low and 0xdc00.inv())) // Emit a 21-bit character with 4 bytes. - writeByte((codePoint shr 18 or 0xf0).toByte()) // 11110xxx + writeByte((codePoint shr 18 or 0xf0).toByte()) // 11110xxx writeByte((codePoint shr 12 and 0x3f or 0x80).toByte()) // 10xxxxxx - writeByte((codePoint shr 6 and 0x3f or 0x80).toByte()) // 10xxyyyy - writeByte((codePoint and 0x3f or 0x80).toByte()) // 10yyyyyy + writeByte((codePoint shr 6 and 0x3f or 0x80).toByte()) // 10xxyyyy + writeByte((codePoint and 0x3f or 0x80).toByte()) // 10yyyyyy i += 2 } } @@ -88,28 +88,28 @@ fun Int.utf8Size(): Int { /** * Encodes this code point using UTF-8. */ -inline fun Int.encodeUtf8(crossinline writeByte: (Byte) -> Unit) { +inline fun Int.encodeUtf8(crossinline writeByte: (Byte) -> Unit) { val codePoint = this if (codePoint < 0x80) { // Emit a 7-bit character with 1 byte. writeByte(codePoint.toByte()) // 0xxxxxxx } else if (codePoint < 0x800) { // Emit a 11-bit character with 2 bytes. - writeByte((codePoint shr 6 or 0xc0).toByte()) // 110xxxxx - writeByte((codePoint and 0x3f or 0x80).toByte()) // 10xxxxxx + writeByte((codePoint shr 6 or 0xc0).toByte()) // 110xxxxx + writeByte((codePoint and 0x3f or 0x80).toByte()) // 10xxxxxx } else if (codePoint < 0xd800 || codePoint in 0xe000..0x10000) { // Emit a 16-bit character with 3 bytes. - writeByte((codePoint shr 12 or 0xe0).toByte()) // 1110xxxx - writeByte((codePoint shr 6 and 0x3f or 0x80).toByte()) // 10xxxxxx - writeByte((codePoint and 0x3f or 0x80).toByte()) // 10xxxxxx + writeByte((codePoint shr 12 or 0xe0).toByte()) // 1110xxxx + writeByte((codePoint shr 6 and 0x3f or 0x80).toByte()) // 10xxxxxx + writeByte((codePoint and 0x3f or 0x80).toByte()) // 10xxxxxx } else if (codePoint in 0xd800..0xdfff) { // codePoint is a surrogate. Emit a replacement character writeByte('?'.toByte()) } else { // Emit a 21-bit character with 4 bytes. - writeByte((codePoint shr 18 or 0xf0).toByte()) // 11110xxx + writeByte((codePoint shr 18 or 0xf0).toByte()) // 11110xxx writeByte((codePoint shr 12 and 0x3f or 0x80).toByte()) // 10xxxxxx - writeByte((codePoint shr 6 and 0x3f or 0x80).toByte()) // 10xxyyyy - writeByte((codePoint and 0x3f or 0x80).toByte()) // 10yyyyyy + writeByte((codePoint shr 6 and 0x3f or 0x80).toByte()) // 10xxyyyy + writeByte((codePoint and 0x3f or 0x80).toByte()) // 10yyyyyy } } diff --git a/mail/common/src/main/java/com/fsck/k9/mail/internet/MimeExtensions.kt b/mail/common/src/main/java/com/fsck/k9/mail/internet/MimeExtensions.kt index 8b1e6c502..efeaef8be 100644 --- a/mail/common/src/main/java/com/fsck/k9/mail/internet/MimeExtensions.kt +++ b/mail/common/src/main/java/com/fsck/k9/mail/internet/MimeExtensions.kt @@ -1,6 +1,5 @@ package com.fsck.k9.mail.internet - // RFC 5322, section 2.1.1 internal const val RECOMMENDED_MAX_LINE_LENGTH = 78 @@ -13,7 +12,6 @@ internal const val HTAB = '\t' // RFC 5234: SP = %x20 internal const val SPACE = ' ' - // RFC 5234: CRLF = %d13.10 internal const val CRLF = "\r\n" @@ -25,7 +23,6 @@ internal const val EQUALS_SIGN = '=' internal const val ASTERISK = '*' internal const val SINGLE_QUOTE = '\'' - internal fun Char.isTSpecial() = this in TSPECIALS // RFC 2045: token := 1* diff --git a/mail/common/src/main/java/com/fsck/k9/mail/internet/MimeParameterDecoder.kt b/mail/common/src/main/java/com/fsck/k9/mail/internet/MimeParameterDecoder.kt index 31552eb14..ad104a0e0 100644 --- a/mail/common/src/main/java/com/fsck/k9/mail/internet/MimeParameterDecoder.kt +++ b/mail/common/src/main/java/com/fsck/k9/mail/internet/MimeParameterDecoder.kt @@ -1,9 +1,9 @@ package com.fsck.k9.mail.internet -import okio.Buffer import java.nio.charset.Charset import java.nio.charset.IllegalCharsetNameException import java.util.Locale +import okio.Buffer private typealias Parameters = Map private typealias BasicParameters = Map @@ -182,11 +182,11 @@ object MimeParameterDecoder { } private fun readExtendedParameterValue( - parser: MimeHeaderParser, - parameterName: String, - newParameterName: String, - section: Int?, - parameterText: String + parser: MimeHeaderParser, + parameterName: String, + newParameterName: String, + section: Int?, + parameterText: String ): ParameterSection? { return try { val charsetName = parser.readUntil(SINGLE_QUOTE) @@ -278,7 +278,7 @@ object MimeParameterDecoder { private data class ParameterValue(val value: String, val wasToken: Boolean) private data class BasicParameterResults( - val parameters: BasicParameters, - val ignoredParameters: IgnoredParameters, - val parserErrorIndex: Int? + val parameters: BasicParameters, + val ignoredParameters: IgnoredParameters, + val parserErrorIndex: Int? ) diff --git a/mail/common/src/main/java/com/fsck/k9/mail/internet/MimeParameterEncoder.kt b/mail/common/src/main/java/com/fsck/k9/mail/internet/MimeParameterEncoder.kt index d045f58b5..ce9b98595 100644 --- a/mail/common/src/main/java/com/fsck/k9/mail/internet/MimeParameterEncoder.kt +++ b/mail/common/src/main/java/com/fsck/k9/mail/internet/MimeParameterEncoder.kt @@ -13,7 +13,6 @@ object MimeParameterEncoder { private const val ENCODED_VALUE_PREFIX = "UTF-8''" - /** * Create header field value with parameters encoded if necessary. */ diff --git a/mail/common/src/main/java/com/fsck/k9/mail/internet/MimeValue.kt b/mail/common/src/main/java/com/fsck/k9/mail/internet/MimeValue.kt index 22b0d9367..df8c2cea6 100644 --- a/mail/common/src/main/java/com/fsck/k9/mail/internet/MimeValue.kt +++ b/mail/common/src/main/java/com/fsck/k9/mail/internet/MimeValue.kt @@ -1,8 +1,8 @@ package com.fsck.k9.mail.internet data class MimeValue( - val value: String, - val parameters: Map = emptyMap(), - val ignoredParameters: List> = emptyList(), - val parserErrorIndex: Int? = null + val value: String, + val parameters: Map = emptyMap(), + val ignoredParameters: List> = emptyList(), + val parserErrorIndex: Int? = null ) diff --git a/mail/common/src/main/java/com/fsck/k9/mail/internet/ParameterSection.kt b/mail/common/src/main/java/com/fsck/k9/mail/internet/ParameterSection.kt index e504cd5bb..c7b9b12da 100644 --- a/mail/common/src/main/java/com/fsck/k9/mail/internet/ParameterSection.kt +++ b/mail/common/src/main/java/com/fsck/k9/mail/internet/ParameterSection.kt @@ -3,30 +3,30 @@ package com.fsck.k9.mail.internet import okio.Buffer internal sealed class ParameterSection( - val name: String, - val originalName: String, - val section: Int? + val name: String, + val originalName: String, + val section: Int? ) internal open class ExtendedValueParameterSection( - name: String, - originalName: String, - section: Int?, - val data: Buffer + name: String, + originalName: String, + section: Int?, + val data: Buffer ) : ParameterSection(name, originalName, section) internal class InitialExtendedValueParameterSection( - name: String, - originalName: String, - section: Int?, - val charsetName: String, - val language: String?, - data: Buffer + name: String, + originalName: String, + section: Int?, + val charsetName: String, + val language: String?, + data: Buffer ) : ExtendedValueParameterSection(name, originalName, section, data) internal class RegularValueParameterSection( - name: String, - originalName: String = name, - section: Int? = null, - val text: String + name: String, + originalName: String = name, + section: Int? = null, + val text: String ) : ParameterSection(name, originalName, section) diff --git a/mail/common/src/test/java/com/fsck/k9/mail/MessageTest.kt b/mail/common/src/test/java/com/fsck/k9/mail/MessageTest.kt index 0512ad3c4..1e9eeb6e1 100644 --- a/mail/common/src/test/java/com/fsck/k9/mail/MessageTest.kt +++ b/mail/common/src/test/java/com/fsck/k9/mail/MessageTest.kt @@ -1,6 +1,5 @@ package com.fsck.k9.mail - import com.fsck.k9.mail.internet.BinaryTempFileBody import com.fsck.k9.mail.internet.BinaryTempFileMessageBody import com.fsck.k9.mail.internet.CharsetSupport @@ -11,16 +10,15 @@ import com.fsck.k9.mail.internet.MimeMessageHelper import com.fsck.k9.mail.internet.MimeMultipart import com.fsck.k9.mail.internet.TextBody import com.google.common.truth.Truth.assertThat +import java.io.ByteArrayOutputStream +import java.util.Date +import java.util.TimeZone import okio.Buffer import org.apache.james.mime4j.util.MimeUtil import org.junit.Before import org.junit.Test import org.junit.runner.RunWith import org.robolectric.RuntimeEnvironment -import java.io.ByteArrayOutputStream -import java.util.Date -import java.util.TimeZone - @RunWith(K9LibRobolectricTestRunner::class) class MessageTest { @@ -263,7 +261,6 @@ class MessageTest { """.trimIndent().crlf()) } - private fun sampleMessage(): MimeMessage { val message = MimeMessage().apply { setFrom(Address("from@example.com")) diff --git a/mail/common/src/test/java/com/fsck/k9/mail/internet/AddressHeaderBuilderTest.kt b/mail/common/src/test/java/com/fsck/k9/mail/internet/AddressHeaderBuilderTest.kt index a31311d7e..5aa000079 100644 --- a/mail/common/src/test/java/com/fsck/k9/mail/internet/AddressHeaderBuilderTest.kt +++ b/mail/common/src/test/java/com/fsck/k9/mail/internet/AddressHeaderBuilderTest.kt @@ -4,11 +4,9 @@ import com.fsck.k9.mail.Address import com.fsck.k9.mail.K9LibRobolectricTestRunner import com.fsck.k9.mail.crlf import org.junit.Assert.assertEquals -import org.junit.Assert.assertNull import org.junit.Test import org.junit.runner.RunWith - @RunWith(K9LibRobolectricTestRunner::class) class AddressHeaderBuilderTest { diff --git a/mail/common/src/test/java/com/fsck/k9/mail/internet/MimeParameterDecoderTest.kt b/mail/common/src/test/java/com/fsck/k9/mail/internet/MimeParameterDecoderTest.kt index 929670831..a28e0a74a 100644 --- a/mail/common/src/test/java/com/fsck/k9/mail/internet/MimeParameterDecoderTest.kt +++ b/mail/common/src/test/java/com/fsck/k9/mail/internet/MimeParameterDecoderTest.kt @@ -4,7 +4,6 @@ import org.junit.Assert.assertEquals import org.junit.Assert.assertTrue import org.junit.Test - class MimeParameterDecoderTest { @Test fun rfc2045_example1() { @@ -344,7 +343,6 @@ class MimeParameterDecoderTest { assertTrue(mimeValue.ignoredParameters.isEmpty()) } - private fun assertParametersEquals(mimeValue: MimeValue, vararg expected: Pair) { assertEquals(expected.toSet(), mimeValue.parameters.toPairSet()) } diff --git a/mail/common/src/test/java/com/fsck/k9/mail/internet/MimeParameterEncoderTest.kt b/mail/common/src/test/java/com/fsck/k9/mail/internet/MimeParameterEncoderTest.kt index 18d0f1057..031cdf8a5 100644 --- a/mail/common/src/test/java/com/fsck/k9/mail/internet/MimeParameterEncoderTest.kt +++ b/mail/common/src/test/java/com/fsck/k9/mail/internet/MimeParameterEncoderTest.kt @@ -4,7 +4,6 @@ import com.fsck.k9.mail.crlf import com.google.common.truth.Truth.assertThat import org.junit.Test - class MimeParameterEncoderTest { @Test fun valueWithoutParameters() {