Skip to content

Commit

Permalink
Merge pull request #2427 from PaulWoitaschek/renovate/ktlint
Browse files Browse the repository at this point in the history
Update Ktlint
  • Loading branch information
PaulWoitaschek committed Sep 22, 2024
2 parents ffa16f8 + 9820cca commit 402ed3a
Show file tree
Hide file tree
Showing 38 changed files with 72 additions and 110 deletions.
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ ktlint_standard_filename = disabled
ktlint_standard_function-naming = disabled
ktlint_standard_backing-property-naming = disabled
ktlint_code_style = intellij_idea
ktlint_standard_function-expression-body = disabled
ktlint_function_signature_rule_force_multiline_when_parameter_count_greater_or_equal_than = 2
ktlint_class_signature_rule_force_multiline_when_parameter_count_greater_or_equal_than = 2
ktlint_compose_parameter-naming = disabled
ij_java_class_count_to_use_import_on_demand = 999
ij_kotlin_allow_trailing_comma = true
ij_kotlin_allow_trailing_comma_on_call_site = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ import voice.playback.notification.MainActivityIntentProvider
import javax.inject.Inject

class MainActivityIntentProviderImpl
@Inject constructor(
private val context: Context,
) : MainActivityIntentProvider {
@Inject constructor(private val context: Context) : MainActivityIntentProvider {

override fun toCurrentBook(): PendingIntent {
val intent = MainActivity.goToBookIntent(context)
Expand Down
6 changes: 4 additions & 2 deletions app/src/main/kotlin/voice/app/uitools/CropTransformation.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ import coil.size.Size
import coil.transform.Transformation
import voice.app.features.imagepicker.CropOverlay

class CropTransformation(cropOverlay: CropOverlay, private val cropSource: ImageView) :
Transformation {
class CropTransformation(
cropOverlay: CropOverlay,
private val cropSource: ImageView,
) : Transformation {

private val rect = cropOverlay.selectedRect

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ import javax.inject.Inject

@BookOverviewScope
class BottomSheetViewModel
@Inject constructor(
private val viewModels: Set<@JvmSuppressWildcards BottomSheetItemViewModel>,
) {
@Inject constructor(private val viewModels: Set<@JvmSuppressWildcards BottomSheetItemViewModel>) {

private val scope = MainScope()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ import androidx.compose.material.icons.outlined.Title
import androidx.compose.ui.graphics.vector.ImageVector
import voice.strings.R as StringsR

internal data class EditBookBottomSheetState(
val items: List<BottomSheetItem>,
)
internal data class EditBookBottomSheetState(val items: List<BottomSheetItem>)

enum class BottomSheetItem(
@StringRes val titleRes: Int,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ import javax.inject.Inject
)
class EditBookCategoryViewModel
@Inject
constructor(
private val repo: BookRepository,
) : BottomSheetItemViewModel {
constructor(private val repo: BookRepository) : BottomSheetItemViewModel {

override suspend fun items(bookId: BookId): List<BottomSheetItem> {
val book = repo.get(bookId) ?: return emptyList()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ import javax.inject.Inject
)
class EditBookTitleViewModel
@Inject
constructor(
private val repo: BookRepository,
) : BottomSheetItemViewModel {
constructor(private val repo: BookRepository) : BottomSheetItemViewModel {

private val scope = MainScope()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ import javax.inject.Inject
@ContributesMultibinding(BookOverviewScope::class, boundType = BottomSheetItemViewModel::class)
class FileCoverViewModel
@Inject
constructor(
private val navigator: Navigator,
) : BottomSheetItemViewModel {
constructor(private val navigator: Navigator) : BottomSheetItemViewModel {

private var bookId: BookId? = null

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ import javax.inject.Inject
@ContributesMultibinding(BookOverviewScope::class)
class InternetCoverViewModel
@Inject
constructor(
private val navigator: Navigator,
) : BottomSheetItemViewModel {
constructor(private val navigator: Navigator) : BottomSheetItemViewModel {

override suspend fun items(bookId: BookId): List<BottomSheetItem> {
return listOf(BottomSheetItem.InternetCover)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ import voice.data.putBookId
private const val NI_BOOK_ID = "ni#bookId"

@Suppress("unused")
class BookmarkController(args: Bundle) :
ComposeController(args) {
class BookmarkController(args: Bundle) : ComposeController(args) {

constructor(bookId: BookId) : this(
Bundle().apply {
Expand Down
4 changes: 1 addition & 3 deletions common/src/main/kotlin/voice/common/grid/GridCount.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ import android.content.Context
import javax.inject.Inject

class GridCount
@Inject constructor(
private val context: Context,
) {
@Inject constructor(private val context: Context) {

fun useGridAsDefault(): Boolean {
val displayMetrics = context.resources.displayMetrics
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ sealed interface NavigationCommand {
val replace: Boolean,
) : NavigationCommand

data class Execute(
val action: (NavController<Destination.Compose>) -> Unit,
) : NavigationCommand
data class Execute(val action: (NavController<Destination.Compose>) -> Unit) : NavigationCommand
}

sealed interface Destination {
Expand All @@ -26,11 +24,16 @@ sealed interface Destination {
@Parcelize
data class CoverFromInternet(val bookId: BookId) : Compose
data class Website(val url: String) : Destination
data class EditCover(val bookId: BookId, val cover: Uri) : Destination
data class EditCover(
val bookId: BookId,
val cover: Uri,
) : Destination

data class Activity(val intent: Intent) : Destination

sealed interface Compose : Destination, Parcelable
sealed interface Compose :
Destination,
Parcelable

@Parcelize
object Migration : Compose
Expand All @@ -45,7 +48,10 @@ sealed interface Destination {
object FolderPicker : Compose

@Parcelize
data class SelectFolderType(val uri: Uri, val mode: Mode) : Compose {
data class SelectFolderType(
val uri: Uri,
val mode: Mode,
) : Compose {

enum class Mode {
Default,
Expand Down
4 changes: 1 addition & 3 deletions cover/src/main/kotlin/voice/cover/api/CoverApi.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ import voice.logging.core.Logger
import javax.inject.Inject

class CoverApi
@Inject constructor(
private val api: InternalCoverApi,
) {
@Inject constructor(private val api: InternalCoverApi) {

internal suspend fun token(query: String): String? {
Logger.d("query token")
Expand Down
4 changes: 1 addition & 3 deletions data/src/main/kotlin/voice/data/BookComparator.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ package voice.data

import voice.common.comparator.NaturalOrderComparator

enum class BookComparator(
private val comparatorFunction: Comparator<Book>,
) : Comparator<Book> by comparatorFunction {
enum class BookComparator(private val comparatorFunction: Comparator<Book>) : Comparator<Book> by comparatorFunction {

ByLastPlayed(
compareByDescending {
Expand Down
4 changes: 1 addition & 3 deletions data/src/main/kotlin/voice/data/repo/BookContentRepo.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ import javax.inject.Singleton

@Singleton
class BookContentRepo
@Inject constructor(
private val dao: BookContentDao,
) {
@Inject constructor(private val dao: BookContentDao) {

private val cacheMutex = Mutex()
private var cacheFilled = false
Expand Down
4 changes: 1 addition & 3 deletions data/src/main/kotlin/voice/data/repo/ChapterRepo.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ import javax.inject.Singleton

@Singleton
class ChapterRepo
@Inject constructor(
private val dao: ChapterDao,
) {
@Inject constructor(private val dao: ChapterDao) {

private val cache = mutableMapOf<ChapterId, Chapter?>()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,5 +71,9 @@ class Migration32to34
}
}

private data class Holder(val path: String, val title: String, val time: Long)
private data class Holder(
val path: String,
val title: String,
val time: Long,
)
}
5 changes: 4 additions & 1 deletion data/src/test/kotlin/voice/data/ChapterTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -128,5 +128,8 @@ class ChapterTest {
positions.shouldContainInOrder(expected)
}

data class MarkPosition(val start: Long, val end: Long)
data class MarkPosition(
val start: Long,
val end: Long,
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,15 @@ class DataBaseMigratorTest {
val dbName = "testDb"
val db = helper.createDatabase(dbName, 44)

data class BookSetting(val id: String, val currentFile: String, val positionInChapter: Int)
data class Chapter(val file: String, val bookId: String)
data class BookSetting(
val id: String,
val currentFile: String,
val positionInChapter: Int,
)
data class Chapter(
val file: String,
val bookId: String,
)

fun insertBookSettings(settings: BookSetting) {
db.execSQL(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ import androidx.core.net.toFile
import androidx.core.net.toUri
import java.io.File

data class FileBasedDocumentFile(
private val file: File,
) : CachedDocumentFile {
data class FileBasedDocumentFile(private val file: File) : CachedDocumentFile {

override val children: List<CachedDocumentFile> get() = file.listFiles()?.map { FileBasedDocumentFile(it) } ?: emptyList()
override val name: String? get() = file.name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ import javax.inject.Inject

@ContributesBinding(AppScope::class)
class RealCachedDocumentFileFactory
@Inject constructor(
private val context: Context,
) : CachedDocumentFileFactory {
@Inject constructor(private val context: Context) : CachedDocumentFileFactory {
override fun create(uri: Uri): CachedDocumentFile {
return RealCachedDocumentFile(context = context, uri = uri, preFilledContent = null)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ package voice.folderPicker.folderPicker
import android.net.Uri
import voice.data.folders.FolderType

data class FolderPickerViewState(
val items: List<Item>,
) {
data class FolderPickerViewState(val items: List<Item>) {

data class Item(
val name: String,
Expand Down
6 changes: 3 additions & 3 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ dagger = "2.52"
kotlin = "2.0.20"
media3 = "1.3.1"
agp = "8.6.1"
ktlint-core = "1.2.1"
ktlint-gradlePlugin = "0.9.0"
ktlint-core = "1.3.1"
ktlint-gradlePlugin = "0.10.0"
retrofit = "2.11.0"

[libraries]
Expand Down Expand Up @@ -113,7 +113,7 @@ compose-navigation = "dev.olshevski.navigation:reimagined:1.5.0"

ktlint-core = { module = "com.pinterest.ktlint:ktlint-cli", version.ref = "ktlint-core" }
ktlint-gradlePlugin = { module = "io.github.usefulness:ktlint-gradle-plugin", version.ref = "ktlint-gradlePlugin" }
ktlint-compose = "io.nlopez.compose.rules:ktlint:0.4.1"
ktlint-compose = "io.nlopez.compose.rules:ktlint:0.4.12"

[bundles]
compose = [
Expand Down
4 changes: 1 addition & 3 deletions playback/src/main/kotlin/voice/playback/misc/VolumeGain.kt
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,7 @@ class VolumeGainSetter

@Singleton
class VolumeGain
@Inject constructor(
private val volumeGainSetter: VolumeGainSetter,
) {
@Inject constructor(private val volumeGainSetter: VolumeGainSetter) {

var gain: Decibel by Delegates.observable(Decibel(0F)) { _, _, _ -> updateLoudnessEnhancer() }
var audioSessionId: Int? by Delegates.observable(null) { _, _, _ -> updateLoudnessEnhancer() }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ import voice.playback.session.toMediaIdOrNull
import javax.inject.Inject

class DurationInconsistenciesUpdater
@Inject constructor(
private val chapterRepo: ChapterRepo,
) : Player.Listener {
@Inject constructor(private val chapterRepo: ChapterRepo) : Player.Listener {

private lateinit var player: Player

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ import androidx.media3.exoplayer.video.VideoRendererEventListener
import javax.inject.Inject

class OnlyAudioRenderersFactory
@Inject constructor(
context: Context,
) : DefaultRenderersFactory(context) {
@Inject constructor(context: Context) : DefaultRenderersFactory(context) {

override fun buildVideoRenderers(
context: Context,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ import androidx.media3.common.Player
import javax.inject.Inject

class PlayStateDelegatingListener
@Inject constructor(
private val playStateManager: PlayStateManager,
) : Player.Listener {
@Inject constructor(private val playStateManager: PlayStateManager) : Player.Listener {

private lateinit var player: Player

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ import java.io.File
import javax.inject.Inject

class ImageFileProvider
@Inject constructor(
private val application: Application,
) {
@Inject constructor(private val application: Application) {

internal fun uri(file: File): Uri {
return FileProvider
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ import javax.inject.Inject
import voice.strings.R as StringsR

class SleepTimerCommandUpdater
@Inject constructor(
private val context: Context,
) {
@Inject constructor(private val context: Context) {

fun update(
session: MediaSession,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@ data class BookPlayViewState(
}

internal sealed interface BookPlayDialogViewState {
data class SpeedDialog(
val speed: Float,
) : BookPlayDialogViewState {
data class SpeedDialog(val speed: Float) : BookPlayDialogViewState {

val maxSpeed: Float get() = if (speed < 2F) 2F else 3.5F
}
Expand All @@ -47,7 +45,5 @@ internal sealed interface BookPlayDialogViewState {
) : BookPlayDialogViewState

@JvmInline
value class SleepTimer(
val viewState: SleepTimerViewState,
) : BookPlayDialogViewState
value class SleepTimer(val viewState: SleepTimerViewState) : BookPlayDialogViewState
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ fun interface IsIgnoringBatteryOptimizations {

@ContributesBinding(AppScope::class)
class IsIgnoringBatteryOptimizationsImpl
@Inject constructor(
private val context: Application,
) : IsIgnoringBatteryOptimizations {
@Inject constructor(private val context: Application) : IsIgnoringBatteryOptimizations {
override fun invoke(): Boolean {
val powerManager = context.getSystemService<PowerManager>()
?: return true
Expand Down
Loading

0 comments on commit 402ed3a

Please sign in to comment.