Address spotless lint errors (#1138)

* Add spotless (with ktlint)

* Run spotlessApply

* screaming case screaming case screaming case

* Update PagerViewerAdapter.kt

* Update ReaderTransitionView.kt
This commit is contained in:
AntsyLich
2024-08-19 18:11:39 +06:00
committed by GitHub
parent 5ae8095ef1
commit d6252ab770
230 changed files with 580 additions and 467 deletions

View File

@@ -97,7 +97,7 @@ class SecureActivityDelegateImpl : SecureActivityDelegate, DefaultLifecycleObser
val incognitoModeFlow = preferences.incognitoMode().changes()
combine(secureScreenFlow, incognitoModeFlow) { secureScreen, incognitoMode ->
secureScreen == SecurityPreferences.SecureScreenMode.ALWAYS ||
secureScreen == SecurityPreferences.SecureScreenMode.INCOGNITO && incognitoMode
(secureScreen == SecurityPreferences.SecureScreenMode.INCOGNITO && incognitoMode)
}
.onEach(activity.window::setSecureScreen)
.launchIn(activity.lifecycleScope)

View File

@@ -41,7 +41,7 @@ class ExtensionsScreenModel(
private val getExtensions: GetExtensionsByType = Injekt.get(),
) : StateScreenModel<ExtensionsScreenModel.State>(State()) {
private var _currentDownloads = MutableStateFlow<Map<String, InstallStep>>(hashMapOf())
private val currentDownloads = MutableStateFlow<Map<String, InstallStep>>(hashMapOf())
init {
val context = Injekt.get<Application>()
@@ -62,14 +62,20 @@ class ExtensionsScreenModel(
it.name.contains(input, ignoreCase = true) ||
it.baseUrl.contains(input, ignoreCase = true) ||
it.id == input.toLongOrNull()
} || extension.name.contains(input, ignoreCase = true)
} ||
extension.name.contains(input, ignoreCase = true)
}
is Extension.Installed -> {
extension.sources.any {
it.name.contains(input, ignoreCase = true) ||
it.id == input.toLongOrNull() ||
if (it is HttpSource) { it.baseUrl.contains(input, ignoreCase = true) } else false
} || extension.name.contains(input, ignoreCase = true)
if (it is HttpSource) {
it.baseUrl.contains(input, ignoreCase = true)
} else {
false
}
} ||
extension.name.contains(input, ignoreCase = true)
}
is Extension.Untrusted -> extension.name.contains(input, ignoreCase = true)
}
@@ -80,7 +86,7 @@ class ExtensionsScreenModel(
screenModelScope.launchIO {
combine(
state.map { it.searchQuery }.distinctUntilChanged().debounce(SEARCH_DEBOUNCE_MILLIS),
_currentDownloads,
currentDownloads,
getExtensions.subscribe(),
) { query, downloads, (_updates, _installed, _available, _untrusted) ->
val searchQuery = query ?: ""
@@ -166,11 +172,11 @@ class ExtensionsScreenModel(
}
private fun addDownloadState(extension: Extension, installStep: InstallStep) {
_currentDownloads.update { it + Pair(extension.pkgName, installStep) }
currentDownloads.update { it + Pair(extension.pkgName, installStep) }
}
private fun removeDownloadState(extension: Extension) {
_currentDownloads.update { it - extension.pkgName }
currentDownloads.update { it - extension.pkgName }
}
private suspend fun Flow<InstallStep>.collectToInstallUpdate(extension: Extension) =

View File

@@ -66,8 +66,8 @@ object HomeScreen : Screen() {
private val openTabEvent = Channel<Tab>()
private val showBottomNavEvent = Channel<Boolean>()
private const val TabFadeDuration = 200
private const val TabNavigatorKey = "HomeTabs"
private const val TAB_FADE_DURATION = 200
private const val TAB_NAVIGATOR_KEY = "HomeTabs"
private val tabs = listOf(
LibraryTab,
@@ -82,7 +82,7 @@ object HomeScreen : Screen() {
val navigator = LocalNavigator.currentOrThrow
TabNavigator(
tab = LibraryTab,
key = TabNavigatorKey,
key = TAB_NAVIGATOR_KEY,
) { tabNavigator ->
// Provide usable navigator to content screen
CompositionLocalProvider(LocalNavigator provides navigator) {
@@ -124,8 +124,11 @@ object HomeScreen : Screen() {
AnimatedContent(
targetState = tabNavigator.current,
transitionSpec = {
materialFadeThroughIn(initialScale = 1f, durationMillis = TabFadeDuration) togetherWith
materialFadeThroughOut(durationMillis = TabFadeDuration)
materialFadeThroughIn(
initialScale = 1f,
durationMillis = TAB_FADE_DURATION,
) togetherWith
materialFadeThroughOut(durationMillis = TAB_FADE_DURATION)
},
label = "tabContent",
) {

View File

@@ -258,7 +258,7 @@ class LibraryScreenModel(
private fun LibraryMap.applySort(
// Map<MangaId, List<Track>>
trackMap: Map<Long, List<Track>>,
loggedInTrackerIds: Set<Long>
loggedInTrackerIds: Set<Long>,
): LibraryMap {
val sortAlphabetically: (LibraryItem, LibraryItem) -> Int = { i1, i2 ->
i1.libraryManga.manga.title.lowercase().compareToWithCollator(i2.libraryManga.manga.title.lowercase())

View File

@@ -32,7 +32,7 @@ class LibrarySettingsScreenModel(
.stateIn(
scope = screenModelScope,
started = SharingStarted.WhileSubscribed(5.seconds.inWholeMilliseconds),
initialValue = trackerManager.loggedInTrackers()
initialValue = trackerManager.loggedInTrackers(),
)
fun toggleFilter(preference: (LibraryPreferences) -> Preference<TriState>) {

View File

@@ -87,8 +87,8 @@ private class MoreScreenModel(
var downloadedOnly by preferences.downloadedOnly().asState(screenModelScope)
var incognitoMode by preferences.incognitoMode().asState(screenModelScope)
private var _state: MutableStateFlow<DownloadQueueState> = MutableStateFlow(DownloadQueueState.Stopped)
val downloadQueueState: StateFlow<DownloadQueueState> = _state.asStateFlow()
private var _downloadQueueState: MutableStateFlow<DownloadQueueState> = MutableStateFlow(DownloadQueueState.Stopped)
val downloadQueueState: StateFlow<DownloadQueueState> = _downloadQueueState.asStateFlow()
init {
// Handle running/paused status change and queue progress updating
@@ -99,7 +99,7 @@ private class MoreScreenModel(
) { isRunning, downloadQueue -> Pair(isRunning, downloadQueue.size) }
.collectLatest { (isDownloading, downloadQueueSize) ->
val pendingDownloadExists = downloadQueueSize != 0
_state.value = when {
_downloadQueueState.value = when {
!pendingDownloadExists -> DownloadQueueState.Stopped
!isDownloading -> DownloadQueueState.Paused(downloadQueueSize)
else -> DownloadQueueState.Downloading(downloadQueueSize)

View File

@@ -165,13 +165,19 @@ class ReaderViewModel @JvmOverloads constructor(
(
manga.downloadedFilterRaw == Manga.CHAPTER_SHOW_DOWNLOADED &&
!downloadManager.isChapterDownloaded(
it.name, it.scanlator, manga.title, manga.source,
it.name,
it.scanlator,
manga.title,
manga.source,
)
) ||
(
manga.downloadedFilterRaw == Manga.CHAPTER_SHOW_NOT_DOWNLOADED &&
downloadManager.isChapterDownloaded(
it.name, it.scanlator, manga.title, manga.source,
it.name,
it.scanlator,
manga.title,
manga.source,
)
) ||
(manga.bookmarkedFilterRaw == Manga.CHAPTER_SHOW_BOOKMARKED && !it.bookmark) ||

View File

@@ -142,7 +142,7 @@ class ReaderPreferences(
enum class FlashColor {
BLACK,
WHITE,
WHITE_BLACK
WHITE_BLACK,
}
enum class TappingInvertMode(

View File

@@ -404,7 +404,9 @@ open class ReaderPageImageView @JvmOverloads constructor(
)
enum class ZoomStartPosition {
LEFT, CENTER, RIGHT
LEFT,
CENTER,
RIGHT,
}
}

View File

@@ -32,15 +32,16 @@ class ReaderTransitionView @JvmOverloads constructor(context: Context, attrs: At
Data(
transition = transition,
currChapterDownloaded = transition.from.pageLoader?.isLocal == true,
goingToChapterDownloaded = manga.isLocal() || transition.to?.chapter?.let { goingToChapter ->
downloadManager.isChapterDownloaded(
chapterName = goingToChapter.name,
chapterScanlator = goingToChapter.scanlator,
mangaTitle = manga.title,
sourceId = manga.source,
skipCache = true,
)
} ?: false,
goingToChapterDownloaded = manga.isLocal() ||
transition.to?.chapter?.let { goingToChapter ->
downloadManager.isChapterDownloaded(
chapterName = goingToChapter.name,
chapterScanlator = goingToChapter.scanlator,
mangaTitle = manga.title,
sourceId = manga.source,
skipCache = true,
)
} ?: false,
)
} else {
null

View File

@@ -92,7 +92,9 @@ class PagerViewerAdapter(private val viewer: PagerViewer) : ViewPagerAdapter() {
// Add next chapter transition and pages.
nextTransition = ChapterTransition.Next(chapters.currChapter, chapters.nextChapter)
.also {
if (nextHasMissingChapters || forceTransition ||
if (
nextHasMissingChapters ||
forceTransition ||
chapters.nextChapter?.state !is ReaderChapter.State.Loaded
) {
newItems.add(it)

View File

@@ -82,7 +82,7 @@ class WebtoonConfig(
readerPreferences.webtoonDisableZoomOut()
.register(
{ zoomOutDisabled = it },
{ zoomPropertyChangedListener?.invoke(it) }
{ zoomPropertyChangedListener?.invoke(it) },
)
readerPreferences.webtoonDoubleTapZoomEnabled()

View File

@@ -182,7 +182,11 @@ class WebtoonRecyclerView @JvmOverloads constructor(
setScaleRate(currentScale)
layoutParams.height = if (currentScale < 1) { (originalHeight / currentScale).toInt() } else { originalHeight }
layoutParams.height = if (currentScale < 1) {
(originalHeight / currentScale).toInt()
} else {
originalHeight
}
halfHeight = layoutParams.height / 2
if (currentScale != DEFAULT_RATE) {

View File

@@ -79,7 +79,7 @@ class WebtoonViewer(val activity: ReaderActivity, val isContinuous: Boolean = tr
.threshold
init {
recycler.setItemViewCacheSize(RecyclerViewCacheSize)
recycler.setItemViewCacheSize(RECYCLER_VIEW_CACHE_SIZE)
recycler.isVisible = false // Don't let the recycler layout yet
recycler.layoutParams = ViewGroup.LayoutParams(MATCH_PARENT, MATCH_PARENT)
recycler.isFocusable = false
@@ -362,4 +362,4 @@ class WebtoonViewer(val activity: ReaderActivity, val isContinuous: Boolean = tr
}
// Double the cache size to reduce rebinds/recycles incurred by the extra layout space on scroll direction changes
private const val RecyclerViewCacheSize = 4
private const val RECYCLER_VIEW_CACHE_SIZE = 4