Implement Mihon's spotless PR (#1257)

* Remove detekt (mihonapp/mihon#1130)

Annoying. More annoying in this project.

(cherry picked from commit 777ae2461e1eb277a3aa0c998ff69e4f100387a1)

* Add spotless (with ktlint) (mihonapp/mihon#1136)

(cherry picked from commit 5ae8095ef1ed2ae9f98486f9148e933c77a28692)

* Address spotless lint errors (mihonapp/mihon#1138)

* Add spotless (with ktlint)

* Run spotlessApply

* screaming case screaming case screaming case

* Update PagerViewerAdapter.kt

* Update ReaderTransitionView.kt

(cherry picked from commit d6252ab7703d52ecf9f43de3ee36fd63e665a31f)

* Generate locales_config.xml in build dir

(cherry picked from commit ac41bffdc97b4cfed923de6b9e8e01cccf3eb6eb)

* Address more spotless lint errors in SY

* some more missed

* more missed

* still missing, not sure while it won't report error when running locally

* one more

* more

* more

* correct comment

---------

Co-authored-by: AntsyLich <59261191+AntsyLich@users.noreply.github.com>
This commit is contained in:
Tran M. Cuong
2024-08-23 08:24:50 +07:00
committed by GitHub
parent 759fd4d4e3
commit 3705880a77
363 changed files with 1223 additions and 3138 deletions
@@ -50,4 +50,3 @@ object MigrateUtils {
}
}
}
@@ -9,21 +9,24 @@ import tachiyomi.core.common.util.system.logcat
class MigrationJobFactory(
private val migrationContext: MigrationContext,
private val scope: CoroutineScope
private val scope: CoroutineScope,
) {
@SuppressWarnings("MaxLineLength")
fun create(migrations: List<Migration>): Deferred<Boolean> = with(scope) {
return migrations.sortedBy { it.version }
.fold(CompletableDeferred(true)) { acc: Deferred<Boolean>, migration: Migration ->
if (!migrationContext.dryrun) {
logcat { "Running migration: { name = ${migration::class.simpleName}, version = ${migration.version} }" }
logcat {
"Running migration: { name = ${migration::class.simpleName}, version = ${migration.version} }"
}
async(start = CoroutineStart.UNDISPATCHED) {
val prev = acc.await()
migration(migrationContext) || prev
}
} else {
logcat { "(Dry-run) Running migration: { name = ${migration::class.simpleName}, version = ${migration.version} }" }
logcat {
"(Dry-run) Running migration: { name = ${migration::class.simpleName}, version = ${migration.version} }"
}
CompletableDeferred(true)
}
}
@@ -12,7 +12,7 @@ interface MigrationStrategy {
class DefaultMigrationStrategy(
private val migrationJobFactory: MigrationJobFactory,
private val migrationCompletedListener: MigrationCompletedListener,
private val scope: CoroutineScope
private val scope: CoroutineScope,
) : MigrationStrategy {
override operator fun invoke(migrations: List<Migration>): Deferred<Boolean> = with(scope) {
@@ -46,7 +46,7 @@ class NoopMigrationStrategy(val state: Boolean) : MigrationStrategy {
class VersionRangeMigrationStrategy(
private val versions: IntRange,
private val strategy: DefaultMigrationStrategy
private val strategy: DefaultMigrationStrategy,
) : MigrationStrategy {
override operator fun invoke(migrations: List<Migration>): Deferred<Boolean> {
@@ -17,7 +17,7 @@ object Migrator {
new: Int,
migrations: List<Migration>,
dryrun: Boolean = false,
onMigrationComplete: () -> Unit
onMigrationComplete: () -> Unit,
) {
val migrationContext = MigrationContext(dryrun)
val migrationJobFactory = MigrationJobFactory(migrationContext, scope)
@@ -134,7 +134,6 @@ class MergedMangaRewriteMigration : Migration {
return@withIOContext true
}
@Serializable
private data class UrlConfig(
@SerialName("s")
@@ -23,7 +23,7 @@ class MoveEncryptionSettingsToAppStateMigration : Migration {
withUIContext {
context.toast(
"Restart the app to load your encrypted library",
Toast.LENGTH_LONG
Toast.LENGTH_LONG,
)
}
}
@@ -32,7 +32,7 @@ import java.time.temporal.WeekFields
import java.util.Locale
private val FontSize = 16.sp
private const val DaysOfWeek = 7
private const val DAYS_OF_WEEK = 7
@Composable
fun Calendar(
@@ -54,7 +54,7 @@ fun Calendar(
modifier = Modifier
.fillMaxWidth()
.padding(vertical = MaterialTheme.padding.small)
.padding(start = MaterialTheme.padding.medium)
.padding(start = MaterialTheme.padding.medium),
)
CalendarGrid(
selectedYearMonth = selectedYearMonth,
@@ -72,8 +72,8 @@ private fun CalendarGrid(
) {
val localeFirstDayOfWeek = WeekFields.of(Locale.getDefault()).firstDayOfWeek.value
val weekDays = remember {
(0 until DaysOfWeek)
.map { DayOfWeek.of((localeFirstDayOfWeek - 1 + it) % DaysOfWeek + 1) }
(0 until DAYS_OF_WEEK)
.map { DayOfWeek.of((localeFirstDayOfWeek - 1 + it) % DAYS_OF_WEEK + 1) }
.toImmutableList()
}
@@ -81,12 +81,12 @@ private fun CalendarGrid(
val daysInMonth = selectedYearMonth.lengthOfMonth()
VerticalGrid(
columns = SimpleGridCells.Fixed(DaysOfWeek),
columns = SimpleGridCells.Fixed(DAYS_OF_WEEK),
modifier = if (isMediumWidthWindow() && !isExpandedWidthWindow()) {
Modifier.widthIn(max = 360.dp)
} else {
Modifier
}
},
) {
weekDays.fastForEach { item ->
Text(
@@ -19,9 +19,10 @@ import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import tachiyomi.presentation.core.components.material.DISABLED_ALPHA
import java.time.LocalDate
private const val MaxEvents = 3
private const val MAX_EVENTS = 3
@Composable
fun CalendarDay(
@@ -39,7 +40,7 @@ fun CalendarDay(
Modifier.border(
border = BorderStroke(
width = 1.dp,
color = MaterialTheme.colorScheme.onBackground
color = MaterialTheme.colorScheme.onBackground,
),
shape = CircleShape,
)
@@ -57,14 +58,14 @@ fun CalendarDay(
textAlign = TextAlign.Center,
fontSize = 16.sp,
color = if (date.isBefore(today)) {
MaterialTheme.colorScheme.onBackground.copy(alpha = 0.38f)
MaterialTheme.colorScheme.onBackground.copy(alpha = DISABLED_ALPHA)
} else {
MaterialTheme.colorScheme.onBackground
},
fontWeight = FontWeight.SemiBold,
)
Row(Modifier.offset(y = 12.dp)) {
val size = events.coerceAtMost(MaxEvents)
val size = events.coerceAtMost(MAX_EVENTS)
for (index in 0 until size) {
CalendarIndicator(
index = index,
@@ -63,20 +63,20 @@ fun CalenderHeader(
}
}
private const val MonthYearChangeAnimationDuration = 200
private const val MONTH_YEAR_CHANGE_ANIMATION_DURATION = 200
private fun AnimatedContentTransitionScope<YearMonth>.getAnimation(): ContentTransform {
val movingForward = targetState > initialState
val enterTransition = slideInVertically(
animationSpec = tween(durationMillis = MonthYearChangeAnimationDuration),
animationSpec = tween(durationMillis = MONTH_YEAR_CHANGE_ANIMATION_DURATION),
) { height -> if (movingForward) height else -height } + fadeIn(
animationSpec = tween(durationMillis = MonthYearChangeAnimationDuration),
animationSpec = tween(durationMillis = MONTH_YEAR_CHANGE_ANIMATION_DURATION),
)
val exitTransition = slideOutVertically(
animationSpec = tween(durationMillis = MonthYearChangeAnimationDuration),
animationSpec = tween(durationMillis = MONTH_YEAR_CHANGE_ANIMATION_DURATION),
) { height -> if (movingForward) -height else height } + fadeOut(
animationSpec = tween(durationMillis = MonthYearChangeAnimationDuration),
animationSpec = tween(durationMillis = MONTH_YEAR_CHANGE_ANIMATION_DURATION),
)
return (enterTransition togetherWith exitTransition)
.using(SizeTransform(clip = false))
@@ -12,8 +12,8 @@ import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
private const val IndicatorScale = 12
private const val IndicatorAlphaMultiplier = 0.3f
private const val INDICATOR_SCALE = 12
private const val INDICATOR_ALPHA_MULTIPLIER = 0.3f
@Composable
fun CalendarIndicator(
@@ -26,7 +26,7 @@ fun CalendarIndicator(
modifier = modifier
.padding(horizontal = 1.dp)
.clip(shape = CircleShape)
.background(color = color.copy(alpha = (index + 1) * IndicatorAlphaMultiplier))
.size(size = size.div(IndicatorScale)),
.background(color = color.copy(alpha = (index + 1) * INDICATOR_ALPHA_MULTIPLIER))
.size(size = size.div(INDICATOR_SCALE)),
)
}