mirror of
https://github.com/Suwayomi/TachideskJUI.git
synced 2025-12-22 04:22:32 +01:00
Automatic Lint
This commit is contained in:
@@ -30,7 +30,9 @@ class UpdateCheckWorker(private val context: Context, workerParams: WorkerParame
|
|||||||
.let {
|
.let {
|
||||||
if (it.updatePreferences.enabled().get()) {
|
if (it.updatePreferences.enabled().get()) {
|
||||||
it.updateChecker.await(false)
|
it.updateChecker.await(false)
|
||||||
} else null
|
} else {
|
||||||
|
null
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (update is Update.UpdateFound) {
|
if (update is Update.UpdateFound) {
|
||||||
|
|||||||
@@ -21,5 +21,7 @@ fun String.chop(count: Int, replacement: String = "…"): String {
|
|||||||
fun String.addSuffix(char: Char): String {
|
fun String.addSuffix(char: Char): String {
|
||||||
return if (endsWith(char)) {
|
return if (endsWith(char)) {
|
||||||
this
|
this
|
||||||
} else this + char
|
} else {
|
||||||
|
this + char
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -65,5 +65,7 @@ fun <T> Preference<T>.getAsFlow(action: (suspend (T) -> Unit)? = null): Flow<T>
|
|||||||
.onStart { emit(get()) }
|
.onStart { emit(get()) }
|
||||||
return if (action != null) {
|
return if (action != null) {
|
||||||
flow.onEach(action = action)
|
flow.onEach(action = action)
|
||||||
} else flow
|
} else {
|
||||||
|
flow
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -173,7 +173,9 @@ suspend fun main() {
|
|||||||
}
|
}
|
||||||
else -> false
|
else -> false
|
||||||
}
|
}
|
||||||
} else false
|
} else {
|
||||||
|
false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
) {
|
) {
|
||||||
AppTheme {
|
AppTheme {
|
||||||
|
|||||||
@@ -23,7 +23,9 @@ class GetCategories @Inject constructor(private val categoryRepository: Category
|
|||||||
.map { categories ->
|
.map { categories ->
|
||||||
if (dropDefault) {
|
if (dropDefault) {
|
||||||
categories.filterNot { it.name.equals("default", true) }
|
categories.filterNot { it.name.equals("default", true) }
|
||||||
} else categories
|
} else {
|
||||||
|
categories
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|||||||
@@ -13,5 +13,5 @@ enum class DownloadState(val state: Int) {
|
|||||||
Queued(0),
|
Queued(0),
|
||||||
Downloading(1),
|
Downloading(1),
|
||||||
Finished(2),
|
Finished(2),
|
||||||
Error(3),
|
Error(3)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,5 +18,5 @@ enum class ImageScale(@Transient val res: StringResource) {
|
|||||||
FitWidth(MR.strings.scale_fit_width),
|
FitWidth(MR.strings.scale_fit_width),
|
||||||
FitHeight(MR.strings.scale_fit_height),
|
FitHeight(MR.strings.scale_fit_height),
|
||||||
OriginalSize(MR.strings.scale_original),
|
OriginalSize(MR.strings.scale_original),
|
||||||
SmartFit(MR.strings.scale_smart),
|
SmartFit(MR.strings.scale_smart)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,5 +16,5 @@ enum class NavigationMode(@Transient val res: StringResource) {
|
|||||||
LNavigation(MR.strings.nav_l_shaped),
|
LNavigation(MR.strings.nav_l_shaped),
|
||||||
KindlishNavigation(MR.strings.nav_kindle_ish),
|
KindlishNavigation(MR.strings.nav_kindle_ish),
|
||||||
EdgeNavigation(MR.strings.nav_edge),
|
EdgeNavigation(MR.strings.nav_edge),
|
||||||
RightAndLeftNavigation(MR.strings.nav_left_right),
|
RightAndLeftNavigation(MR.strings.nav_left_right)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,7 +52,9 @@ class ReaderModePreferences(private val mode: String, private val preferenceStor
|
|||||||
} else {
|
} else {
|
||||||
700
|
700
|
||||||
}
|
}
|
||||||
} else 0
|
} else {
|
||||||
|
0
|
||||||
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,8 @@ data class SourceFilterChange(val position: Int, val state: String) {
|
|||||||
position,
|
position,
|
||||||
if (state is SortFilter.Selection) {
|
if (state is SortFilter.Selection) {
|
||||||
Json.encodeToString(state)
|
Json.encodeToString(state)
|
||||||
} else state.toString()
|
} else {
|
||||||
|
state.toString()
|
||||||
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,8 @@ data class SourcePreferenceChange(val position: Int, val value: String) {
|
|||||||
if (value is List<*>) {
|
if (value is List<*>) {
|
||||||
@Suppress("UNCHECKED_CAST")
|
@Suppress("UNCHECKED_CAST")
|
||||||
Json.encodeToString(value as List<String>)
|
Json.encodeToString(value as List<String>)
|
||||||
} else value.toString()
|
} else {
|
||||||
|
value.toString()
|
||||||
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,5 +12,5 @@ import kotlinx.serialization.Serializable
|
|||||||
enum class ThemeMode {
|
enum class ThemeMode {
|
||||||
System,
|
System,
|
||||||
Light,
|
Light,
|
||||||
Dark,
|
Dark
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -89,8 +89,12 @@ class ServerService @Inject constructor(
|
|||||||
if (file.toString().contains("java") || file.toString().contains("jdk")) {
|
if (file.toString().contains("java") || file.toString().contains("jdk")) {
|
||||||
if (file.name.equals("bin", true)) {
|
if (file.name.equals("bin", true)) {
|
||||||
file
|
file
|
||||||
} else file.resolve("bin")
|
} else {
|
||||||
} else null
|
file.resolve("bin")
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
null
|
||||||
|
}
|
||||||
}
|
}
|
||||||
.mapNotNull { getJavaFromPath(it) }
|
.mapNotNull { getJavaFromPath(it) }
|
||||||
.firstOrNull()
|
.firstOrNull()
|
||||||
|
|||||||
@@ -24,7 +24,9 @@ sealed class ServerHostPreference<T : Any> {
|
|||||||
val preference = preference().get().takeIf(::validate)
|
val preference = preference().get().takeIf(::validate)
|
||||||
return if (preference != null) {
|
return if (preference != null) {
|
||||||
propertyPrefix + preference.toString()
|
propertyPrefix + preference.toString()
|
||||||
} else null
|
} else {
|
||||||
|
null
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract val preferenceStore: PreferenceStore
|
protected abstract val preferenceStore: PreferenceStore
|
||||||
|
|||||||
@@ -42,7 +42,9 @@ class DownloadsScreenViewModel @Inject constructor(
|
|||||||
) : ViewModel(contextWrapper) {
|
) : ViewModel(contextWrapper) {
|
||||||
private val uiScope = if (standalone) {
|
private val uiScope = if (standalone) {
|
||||||
MainScope()
|
MainScope()
|
||||||
} else null
|
} else {
|
||||||
|
null
|
||||||
|
}
|
||||||
|
|
||||||
override val scope: CoroutineScope
|
override val scope: CoroutineScope
|
||||||
get() = uiScope ?: super.scope
|
get() = uiScope ?: super.scope
|
||||||
|
|||||||
@@ -173,7 +173,9 @@ fun DownloadsItem(
|
|||||||
)
|
)
|
||||||
val progress = if (item.chapter.pageCount != null && item.chapter.pageCount != -1) {
|
val progress = if (item.chapter.pageCount != null && item.chapter.pageCount != -1) {
|
||||||
" - " + "${(item.chapter.pageCount!! * item.progress).toInt()}/${item.chapter.pageCount}"
|
" - " + "${(item.chapter.pageCount!! * item.progress).toInt()}/${item.chapter.pageCount}"
|
||||||
} else ""
|
} else {
|
||||||
|
""
|
||||||
|
}
|
||||||
MangaListItemSubtitle(
|
MangaListItemSubtitle(
|
||||||
text = item.chapter.name + progress
|
text = item.chapter.name + progress
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -143,7 +143,9 @@ class ExtensionsScreenViewModel @Inject constructor(
|
|||||||
.let {
|
.let {
|
||||||
if (it.isNotEmpty()) {
|
if (it.isNotEmpty()) {
|
||||||
listOf(ExtensionUI.Header(MR.strings.installed.toPlatformString())) + it
|
listOf(ExtensionUI.Header(MR.strings.installed.toPlatformString())) + it
|
||||||
} else it
|
} else {
|
||||||
|
it
|
||||||
|
}
|
||||||
}.plus(
|
}.plus(
|
||||||
filterNot(Extension::installed)
|
filterNot(Extension::installed)
|
||||||
.groupBy(Extension::lang)
|
.groupBy(Extension::lang)
|
||||||
|
|||||||
@@ -47,7 +47,9 @@ fun DownloadsExtraInfo() {
|
|||||||
} else {
|
} else {
|
||||||
remainingDownloads
|
remainingDownloads
|
||||||
}
|
}
|
||||||
} else null
|
} else {
|
||||||
|
null
|
||||||
|
}
|
||||||
}
|
}
|
||||||
WebsocketService.Status.STOPPED -> null
|
WebsocketService.Status.STOPPED -> null
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -213,7 +213,9 @@ private fun getActionItems(
|
|||||||
icon = Icons.Rounded.Label,
|
icon = Icons.Rounded.Label,
|
||||||
doAction = setCategories
|
doAction = setCategories
|
||||||
)
|
)
|
||||||
} else null,
|
} else {
|
||||||
|
null
|
||||||
|
},
|
||||||
ActionItem(
|
ActionItem(
|
||||||
name = stringResource(if (inLibrary) MR.strings.action_remove_favorite else MR.strings.action_favorite),
|
name = stringResource(if (inLibrary) MR.strings.action_remove_favorite else MR.strings.action_favorite),
|
||||||
icon = if (inLibrary) {
|
icon = if (inLibrary) {
|
||||||
|
|||||||
@@ -277,7 +277,9 @@ private fun ReaderProgressSlider(
|
|||||||
modifier = modifier.let {
|
modifier = modifier.let {
|
||||||
if (isRtL) {
|
if (isRtL) {
|
||||||
it then Modifier.rotate(180F)
|
it then Modifier.rotate(180F)
|
||||||
} else it
|
} else {
|
||||||
|
it
|
||||||
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -113,7 +113,9 @@ class TachideskPageLoader(
|
|||||||
.getOrElse {
|
.getOrElse {
|
||||||
ReaderPage.ImageDecodeState.FailedToDecode(it)
|
ReaderPage.ImageDecodeState.FailedToDecode(it)
|
||||||
}
|
}
|
||||||
} else ReaderPage.ImageDecodeState.UnknownDecoder
|
} else {
|
||||||
|
ReaderPage.ImageDecodeState.UnknownDecoder
|
||||||
|
}
|
||||||
} ?: ReaderPage.ImageDecodeState.FailedToGetSnapShot
|
} ?: ReaderPage.ImageDecodeState.FailedToGetSnapShot
|
||||||
}
|
}
|
||||||
page.status.value = ReaderPage.Status.READY
|
page.status.value = ReaderPage.Status.READY
|
||||||
@@ -156,7 +158,9 @@ class TachideskPageLoader(
|
|||||||
channel.send(it)
|
channel.send(it)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else null
|
} else {
|
||||||
|
null
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -114,7 +114,9 @@ fun ContinuousReader(
|
|||||||
Direction.Up, Direction.Down -> Modifier.width(maxSize.dp)
|
Direction.Up, Direction.Down -> Modifier.width(maxSize.dp)
|
||||||
Direction.Left, Direction.Right -> Modifier.height(maxSize.dp)
|
Direction.Left, Direction.Right -> Modifier.height(maxSize.dp)
|
||||||
}
|
}
|
||||||
} else Modifier
|
} else {
|
||||||
|
Modifier
|
||||||
|
}
|
||||||
val contentPadding = when (direction) {
|
val contentPadding = when (direction) {
|
||||||
Direction.Right -> PaddingValues(end = padding.dp)
|
Direction.Right -> PaddingValues(end = padding.dp)
|
||||||
Direction.Left -> PaddingValues(start = padding.dp)
|
Direction.Left -> PaddingValues(start = padding.dp)
|
||||||
|
|||||||
@@ -547,7 +547,9 @@ private fun getActionItems(
|
|||||||
doAction = onToggleFiltersClick,
|
doAction = onToggleFiltersClick,
|
||||||
enabled = !isLatest
|
enabled = !isLatest
|
||||||
)
|
)
|
||||||
} else null,
|
} else {
|
||||||
|
null
|
||||||
|
},
|
||||||
if (showLatestButton) {
|
if (showLatestButton) {
|
||||||
ActionItem(
|
ActionItem(
|
||||||
name = stringResource(
|
name = stringResource(
|
||||||
@@ -564,7 +566,9 @@ private fun getActionItems(
|
|||||||
},
|
},
|
||||||
doAction = onClickMode
|
doAction = onClickMode
|
||||||
)
|
)
|
||||||
} else null,
|
} else {
|
||||||
|
null
|
||||||
|
},
|
||||||
ActionItem(
|
ActionItem(
|
||||||
name = stringResource(MR.strings.display_mode),
|
name = stringResource(MR.strings.display_mode),
|
||||||
icon = Icons.Rounded.ViewModule,
|
icon = Icons.Rounded.ViewModule,
|
||||||
@@ -576,6 +580,8 @@ private fun getActionItems(
|
|||||||
icon = Icons.Rounded.Settings,
|
icon = Icons.Rounded.Settings,
|
||||||
doAction = onSourceSettingsClick
|
doAction = onSourceSettingsClick
|
||||||
)
|
)
|
||||||
} else null
|
} else {
|
||||||
|
null
|
||||||
|
}
|
||||||
).toImmutableList()
|
).toImmutableList()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -301,7 +301,9 @@ fun SortView(sortHolder: StableHolder<SourceFiltersView.Sort>, startExpanded: Bo
|
|||||||
index,
|
index,
|
||||||
if (state?.index == index) {
|
if (state?.index == index) {
|
||||||
state?.ascending?.not() ?: false
|
state?.ascending?.not() ?: false
|
||||||
} else false
|
} else {
|
||||||
|
false
|
||||||
|
}
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -319,7 +321,9 @@ fun TextView(textHolder: StableHolder<SourceFiltersView.Text>) {
|
|||||||
mutableStateOf(
|
mutableStateOf(
|
||||||
if (state == placeholderText) {
|
if (state == placeholderText) {
|
||||||
""
|
""
|
||||||
} else state
|
} else {
|
||||||
|
state
|
||||||
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
val interactionSource = remember { MutableInteractionSource() }
|
val interactionSource = remember { MutableInteractionSource() }
|
||||||
|
|||||||
@@ -198,11 +198,15 @@ private fun Modifier.drawScrollbar(
|
|||||||
val totalSize = estimatedItemSize * layoutInfo.totalItemsCount
|
val totalSize = estimatedItemSize * layoutInfo.totalItemsCount
|
||||||
val canvasSize = if (orientation == Orientation.Horizontal) size.width else size.height
|
val canvasSize = if (orientation == Orientation.Horizontal) size.width else size.height
|
||||||
val thumbSize = viewportSize / totalSize * canvasSize
|
val thumbSize = viewportSize / totalSize * canvasSize
|
||||||
val startOffset = if (items.isEmpty()) 0f else items
|
val startOffset = if (items.isEmpty()) {
|
||||||
|
0f
|
||||||
|
} else {
|
||||||
|
items
|
||||||
.first()
|
.first()
|
||||||
.run {
|
.run {
|
||||||
(estimatedItemSize * index - offset) / totalSize * canvasSize
|
(estimatedItemSize * index - offset) / totalSize * canvasSize
|
||||||
}
|
}
|
||||||
|
}
|
||||||
val drawScrollbar = onDrawScrollbar(
|
val drawScrollbar = onDrawScrollbar(
|
||||||
orientation = orientation,
|
orientation = orientation,
|
||||||
reverseDirection = reverseDirection,
|
reverseDirection = reverseDirection,
|
||||||
@@ -245,11 +249,15 @@ private fun Modifier.drawScrollbar(
|
|||||||
val totalSize = estimatedItemSize * layoutInfo.totalItemsCount
|
val totalSize = estimatedItemSize * layoutInfo.totalItemsCount
|
||||||
val canvasSize = if (orientation == Orientation.Horizontal) size.width else size.height
|
val canvasSize = if (orientation == Orientation.Horizontal) size.width else size.height
|
||||||
val thumbSize = viewportSize / totalSize * canvasSize
|
val thumbSize = viewportSize / totalSize * canvasSize
|
||||||
val startOffset = if (items.isEmpty()) 0f else items
|
val startOffset = if (items.isEmpty()) {
|
||||||
|
0f
|
||||||
|
} else {
|
||||||
|
items
|
||||||
.first()
|
.first()
|
||||||
.run {
|
.run {
|
||||||
(estimatedItemSize * index - if (orientation == Orientation.Vertical) offset.y else offset.x) / totalSize * canvasSize
|
(estimatedItemSize * index - if (orientation == Orientation.Vertical) offset.y else offset.x) / totalSize * canvasSize
|
||||||
}
|
}
|
||||||
|
}
|
||||||
val drawScrollbar = onDrawScrollbar(
|
val drawScrollbar = onDrawScrollbar(
|
||||||
orientation = orientation,
|
orientation = orientation,
|
||||||
reverseDirection = reverseDirection,
|
reverseDirection = reverseDirection,
|
||||||
@@ -332,7 +340,9 @@ private fun Modifier.drawScrollbar(
|
|||||||
val isLtr = LocalLayoutDirection.current == LayoutDirection.Ltr
|
val isLtr = LocalLayoutDirection.current == LayoutDirection.Ltr
|
||||||
val reverseDirection = if (orientation == Orientation.Horizontal) {
|
val reverseDirection = if (orientation == Orientation.Horizontal) {
|
||||||
if (isLtr) reverseScrolling else !reverseScrolling
|
if (isLtr) reverseScrolling else !reverseScrolling
|
||||||
} else reverseScrolling
|
} else {
|
||||||
|
reverseScrolling
|
||||||
|
}
|
||||||
val atEnd = if (orientation == Orientation.Vertical) isLtr else true
|
val atEnd = if (orientation == Orientation.Vertical) isLtr else true
|
||||||
|
|
||||||
// Calculate thickness here to workaround https://issuetracker.google.com/issues/206972664
|
// Calculate thickness here to workaround https://issuetracker.google.com/issues/206972664
|
||||||
|
|||||||
@@ -30,7 +30,11 @@ fun Modifier.keyboardHandler(
|
|||||||
} else if (it.key == Key.Tab) {
|
} else if (it.key == Key.Tab) {
|
||||||
action(focusManager)
|
action(focusManager)
|
||||||
true
|
true
|
||||||
} else false
|
} else {
|
||||||
} else false
|
false
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ private val log = logging()
|
|||||||
private enum class ImageLoaderImageState {
|
private enum class ImageLoaderImageState {
|
||||||
Loading,
|
Loading,
|
||||||
Success,
|
Success,
|
||||||
Failure,
|
Failure
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
|
|||||||
Reference in New Issue
Block a user