Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add spotless code formatter #6630

Merged
merged 10 commits into from
Feb 6, 2023
16 changes: 7 additions & 9 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,21 @@
If the app is not behaving like it should, it's not necessarily a bug. Please consult the following resources before
submitting a new issue.

* [User Manual](https://docs.k9mail.app/)
* [Frequently Asked Questions](https://forum.k9mail.app/c/faq)
* [Support Forum](https://forum.k9mail.app/)
- [User Manual](https://docs.k9mail.app/)
- [Frequently Asked Questions](https://forum.k9mail.app/c/faq)
- [Support Forum](https://forum.k9mail.app/)

### Bug report guidelines

* The issue tracker is solely for bug reports and feature/enhancement requests. If you have a question of any kind,
please use the [support forum](https://forum.k9mail.app/c/support) instead.
* Search the [existing issues](https://github.com/thundernest/k-9/issues?q=) first to make sure your issue hasn't been
reported before.

- The issue tracker is solely for bug reports and feature/enhancement requests. If you have a question of any kind,
please use the [support forum](https://forum.k9mail.app/c/support) instead.
- Search the [existing issues](https://github.com/thundernest/k-9/issues?q=) first to make sure your issue hasn't been
reported before.

## Translations

We're using [Transifex](https://www.transifex.com/k-9/k9mail/) to manage translations.


## Contributing code

We love [pull requests](https://github.com/thundernest/k-9/pulls) from everyone!
Expand Down
16 changes: 8 additions & 8 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
Please ensure that your pull request meets the following requirements - thanks!

* Does not contain merge commits. Rebase instead.
* Contains commits with descriptive titles.
* New code is written in Kotlin whenever possible.
* Follows our existing codestyle (`gradlew ktlintCheck`; will be checked by CI).
* Does not break any unit tests (`gradlew testDebugUnitTest`; will be checked by CI).
* Uses a descriptive title; don't put issue numbers in there.
* Contains a reference to the issue that it fixes (e.g. *Closes #XXX* or *Fixes #XXX*) in the body text.
* For cosmetic changes add one or multiple images, if possible.
- Does not contain merge commits. Rebase instead.
- Contains commits with descriptive titles.
- New code is written in Kotlin whenever possible.
- Follows our existing codestyle (`gradlew spotlessCheck` to check and `gradlew spotlessFormat` to format your source code; will be checked by CI).
- Does not break any unit tests (`gradlew testDebugUnitTest`; will be checked by CI).
- Uses a descriptive title; don't put issue numbers in there.
- Contains a reference to the issue that it fixes (e.g. _Closes #XXX_ or _Fixes #XXX_) in the body text.
- For cosmetic changes add one or multiple images, if possible.

Finally, please replace this template text with a description of the change and additional context if necessary.
2 changes: 1 addition & 1 deletion .github/workflows/android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ jobs:
distribution: 'zulu'
java-version: 17
- uses: gradle/gradle-build-action@v2
- run: ./gradlew assembleDebug ktlintCheck testsOnCi
- run: ./gradlew assembleDebug spotlessCheck testsOnCi
11 changes: 2 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# K-9 Mail

[![Latest release](https://img.shields.io/github/release/thundernest/k-9.svg?style=flat-square)](https://github.com/thundernest/k-9/releases/latest)
[![Latest beta release](https://img.shields.io/github/v/release/thundernest/k-9.svg?include_prereleases&style=flat-square)](https://github.com/thundernest/k-9/releases)

K-9 Mail is an open-source email client for Android.


## Download

K-9 Mail can be downloaded from a couple of sources:
Expand All @@ -15,13 +15,11 @@ K-9 Mail can be downloaded from a couple of sources:

You might also be interested in becoming a [tester](https://forum.k9mail.app/t/how-do-i-become-a-beta-tester/68) to get an early look at new versions.


## Release Notes

Check out the [Release Notes](https://github.com/thundernest/k-9/wiki/ReleaseNotes) to find out what changed
in each version of K-9 Mail.


## Need Help?

If the app is not behaving like it should, you might find these resources helpful:
Expand All @@ -30,26 +28,22 @@ If the app is not behaving like it should, you might find these resources helpfu
- [Frequently Asked Questions](https://forum.k9mail.app/c/faq)
- [Support Forum](https://forum.k9mail.app/)


## Translations

Interested in helping to translate K-9 Mail? Contribute here:

https://www.transifex.com/projects/p/k9mail/


## Contributing

Thank you for contributing! If you're unfamiliar with the code,
start by reading the [developer documentation](docs/DESIGN.md)
Thank you for contributing! If you're unfamiliar with the code, start by reading the [developer documentation](docs/DESIGN.md)

Please fork this repository and contribute back using [pull requests](https://github.com/thundernest/k-9/pulls).

Any contributions, large or small, major features, bug fixes, unit/integration tests are welcomed and appreciated
but will be thoroughly reviewed and discussed.
Please make sure you read the [Code Style Guidelines](https://github.com/thundernest/k-9/wiki/CodeStyle).


## Communication

Aside from discussing changes in [pull requests](https://github.com/thundernest/k-9/pulls) and
Expand All @@ -59,7 +53,6 @@ Aside from discussing changes in [pull requests](https://github.com/thundernest/
- IRC: [#k9mail on Libera Chat](https://web.libera.chat/#k9mail)
- [Developer mailing list](https://groups.google.com/forum/#!forum/k-9-dev)


## License

Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class ProvidersXmlDiscoveryTest : RobolectricTest() {

return OAuthConfigurationProvider(
configurations = mapOf(
listOf("imap.gmail.com", "smtp.gmail.com") to googleConfig,
listOf("imap.gmail.com", "smtp.gmail.com") to googleConfig
),
googleConfiguration = googleConfig
)
Expand Down
14 changes: 8 additions & 6 deletions app/core/src/main/java/com/fsck/k9/Account.kt
Original file line number Diff line number Diff line change
Expand Up @@ -551,12 +551,14 @@ class Account(override val uuid: String) : BaseAccount {

if (age < 28) {
now.add(Calendar.DATE, age * -1)
} else when (age) {
28 -> now.add(Calendar.MONTH, -1)
56 -> now.add(Calendar.MONTH, -2)
84 -> now.add(Calendar.MONTH, -3)
168 -> now.add(Calendar.MONTH, -6)
365 -> now.add(Calendar.YEAR, -1)
} else {
when (age) {
28 -> now.add(Calendar.MONTH, -1)
56 -> now.add(Calendar.MONTH, -2)
84 -> now.add(Calendar.MONTH, -3)
168 -> now.add(Calendar.MONTH, -6)
365 -> now.add(Calendar.YEAR, -1)
}
}

return now.time
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,35 +67,40 @@ class AccountPreferenceSerializer(

val draftsFolderId = storage.getString("$accountUuid.draftsFolderId", null)?.toLongOrNull()
val draftsFolderSelection = getEnumStringPref<SpecialFolderSelection>(
storage, "$accountUuid.draftsFolderSelection",
storage,
"$accountUuid.draftsFolderSelection",
SpecialFolderSelection.AUTOMATIC
)
setDraftsFolderId(draftsFolderId, draftsFolderSelection)

val sentFolderId = storage.getString("$accountUuid.sentFolderId", null)?.toLongOrNull()
val sentFolderSelection = getEnumStringPref<SpecialFolderSelection>(
storage, "$accountUuid.sentFolderSelection",
storage,
"$accountUuid.sentFolderSelection",
SpecialFolderSelection.AUTOMATIC
)
setSentFolderId(sentFolderId, sentFolderSelection)

val trashFolderId = storage.getString("$accountUuid.trashFolderId", null)?.toLongOrNull()
val trashFolderSelection = getEnumStringPref<SpecialFolderSelection>(
storage, "$accountUuid.trashFolderSelection",
storage,
"$accountUuid.trashFolderSelection",
SpecialFolderSelection.AUTOMATIC
)
setTrashFolderId(trashFolderId, trashFolderSelection)

val archiveFolderId = storage.getString("$accountUuid.archiveFolderId", null)?.toLongOrNull()
val archiveFolderSelection = getEnumStringPref<SpecialFolderSelection>(
storage, "$accountUuid.archiveFolderSelection",
storage,
"$accountUuid.archiveFolderSelection",
SpecialFolderSelection.AUTOMATIC
)
setArchiveFolderId(archiveFolderId, archiveFolderSelection)

val spamFolderId = storage.getString("$accountUuid.spamFolderId", null)?.toLongOrNull()
val spamFolderSelection = getEnumStringPref<SpecialFolderSelection>(
storage, "$accountUuid.spamFolderSelection",
storage,
"$accountUuid.spamFolderSelection",
SpecialFolderSelection.AUTOMATIC
)
setSpamFolderId(spamFolderId, spamFolderSelection)
Expand Down Expand Up @@ -524,8 +529,11 @@ class AccountPreferenceSerializer(
java.lang.Enum.valueOf<T>(defaultEnum.declaringJavaClass, stringPref)
} catch (ex: IllegalArgumentException) {
Timber.w(
ex, "Unable to convert preference key [%s] value [%s] to enum of type %s",
key, stringPref, defaultEnum.declaringJavaClass
ex,
"Unable to convert preference key [%s] value [%s] to enum of type %s",
key,
stringPref,
defaultEnum.declaringJavaClass
)

defaultEnum
Expand Down
7 changes: 4 additions & 3 deletions app/core/src/main/java/com/fsck/k9/Core.kt
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,11 @@ object Core : EarlyInit {
if (enabled != alreadyEnabled) {
pm.setComponentEnabledSetting(
ComponentName(context, clazz),
if (enabled)
if (enabled) {
PackageManager.COMPONENT_ENABLED_STATE_ENABLED
else
PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
} else {
PackageManager.COMPONENT_ENABLED_STATE_DISABLED
},
PackageManager.DONT_KILL_APP
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,21 @@ data class AutocryptDraftStateHeader(
fun fromCryptoStatus(cryptoStatus: CryptoStatus): AutocryptDraftStateHeader {
if (cryptoStatus.isSignOnly) {
return AutocryptDraftStateHeader(
false, true, cryptoStatus.isReplyToEncrypted,
cryptoStatus.isUserChoice(), cryptoStatus.isPgpInlineModeEnabled, mapOf()
false,
true,
cryptoStatus.isReplyToEncrypted,
cryptoStatus.isUserChoice(),
cryptoStatus.isPgpInlineModeEnabled,
mapOf()
)
}
return AutocryptDraftStateHeader(
cryptoStatus.isEncryptionEnabled, false, cryptoStatus.isReplyToEncrypted,
cryptoStatus.isUserChoice(), cryptoStatus.isPgpInlineModeEnabled, mapOf()
cryptoStatus.isEncryptionEnabled,
false,
cryptoStatus.isReplyToEncrypted,
cryptoStatus.isUserChoice(),
cryptoStatus.isPgpInlineModeEnabled,
mapOf()
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ data class FolderSettings(
val notifyClass: FolderClass,
val pushClass: FolderClass,
val inTopGroup: Boolean,
val integrate: Boolean,
val integrate: Boolean
)
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class FolderSettingsProvider(val preferences: Preferences, val account: Account)
notifyClass = storage.getString("$prefix.notifyMode", null).toFolderClass(FolderClass.INHERITED),
pushClass = storage.getString("$prefix.pushMode", null).toFolderClass(FolderClass.SECOND_CLASS),
inTopGroup = storage.getBoolean("$prefix.inTopGroup", false),
integrate = storage.getBoolean("$prefix.integrate", false),
integrate = storage.getBoolean("$prefix.integrate", false)
).also {
removeImportedFolderSettings(prefix)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class MessageRepository(private val messageStoreManager: MessageStoreManager) {
"reply-to",
"to",
"cc",
"bcc",
"bcc"
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ class OutboxStateRepository(private val database: LockableDatabase, private val
TABLE_NAME,
COLUMNS,
"$COLUMN_MESSAGE_ID = ?",
arrayOf(messageId.toString()), null, null, null
arrayOf(messageId.toString()),
null,
null,
null
).use { cursor ->
if (!cursor.moveToFirst()) {
throw IllegalStateException("No outbox_state entry for message with id $messageId")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ object UriMatcher {
"mailto:" to genericUriParser,
"matrix:" to genericUriParser,
"rtsp:" to httpUriParser,
"xmpp:" to genericUriParser,
"xmpp:" to genericUriParser
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,9 @@ val coreNotificationModule = module {
}
factory {
NotificationSettingsUpdater(
preferences = get(), notificationChannelManager = get(), notificationConfigurationConverter = get()
preferences = get(),
notificationChannelManager = get(),
notificationConfigurationConverter = get()
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ internal class SingleMessageNotificationDataCreator {
content = data.activeNotifications.first().content,
actions = createSingleNotificationActions(),
wearActions = createSingleNotificationWearActions(data.account),
addLockScreenNotification = false,
),
addLockScreenNotification = false
)
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,10 @@ internal class AndroidPowerManager(private val systemPowerManager: SystemPowerMa

Timber.v(
"AndroidWakeLock for tag %s / id %d: releasing after %d ms, timeout = %d ms",
tag, id, endTime - startTime, timeout
tag,
id,
endTime - startTime,
timeout
)
} else {
Timber.v("AndroidWakeLock for tag %s / id %d, timeout = %d ms: releasing", tag, id, timeout)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ class SettingsExporter(
} catch (e: InvalidSettingValueException) {
Timber.w(
"Global setting \"%s\" has invalid value \"%s\" in preference storage. This shouldn't happen!",
key, valueString
key,
valueString
)
}
} else {
Expand Down Expand Up @@ -271,7 +272,9 @@ class SettingsExporter(
Timber.w(
"Account setting \"%s\" (%s) has invalid value \"%s\" in preference storage. " +
"This shouldn't happen!",
keyPart, account, valueString
keyPart,
account,
valueString
)
}
}
Expand Down Expand Up @@ -375,7 +378,8 @@ class SettingsExporter(
Timber.w(
"Identity setting \"%s\" has invalid value \"%s\" in preference storage. " +
"This shouldn't happen!",
identityKey, valueString
identityKey,
valueString
)
}
}
Expand Down Expand Up @@ -413,7 +417,8 @@ class SettingsExporter(
} catch (e: InvalidSettingValueException) {
Timber.w(
"Folder setting \"%s\" has invalid value \"%s\" in preference storage. This shouldn't happen!",
key, value
key,
value
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ fun LocalSearch.limitToDisplayableFolders(account: Account) {

// 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 = conditions
if (root.mRight != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ internal fun createFolderSettingsProvider(): FolderSettingsProvider {
notifyClass = FolderClass.INHERITED,
pushClass = FolderClass.SECOND_CLASS,
inTopGroup = false,
integrate = false,
integrate = false
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -429,5 +429,5 @@ private data class MessageData(
val isRead: Boolean = false,
val isStarred: Boolean = false,
val isAnswered: Boolean = false,
val isForwarded: Boolean = false,
val isForwarded: Boolean = false
)
Loading