SY linting
This commit is contained in:
@@ -32,7 +32,9 @@ abstract class SourcePagingSource(
|
||||
// SY -->
|
||||
val metadata = if (mangasPage is MetadataMangasPage) {
|
||||
mangasPage.mangasMetadata
|
||||
} else emptyList()
|
||||
} else {
|
||||
emptyList()
|
||||
}
|
||||
// SY <--
|
||||
|
||||
return LoadResult.Page(
|
||||
|
||||
@@ -181,7 +181,9 @@ class SyncChaptersWithSource(
|
||||
updatedToAdd = updatedToAdd.map {
|
||||
if (it !in reAdded) {
|
||||
it.copy(lastPageRead = max)
|
||||
} else it
|
||||
} else {
|
||||
it
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,9 @@ class GetFlatMetadataById(
|
||||
val titles = mangaMetadataRepository.getTitlesById(id)
|
||||
|
||||
FlatMetadata(meta, tags, titles)
|
||||
} else null
|
||||
} else {
|
||||
null
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
logcat(LogPriority.ERROR, e)
|
||||
null
|
||||
@@ -34,7 +36,9 @@ class GetFlatMetadataById(
|
||||
) { meta, tags, titles ->
|
||||
if (meta != null) {
|
||||
FlatMetadata(meta, tags, titles)
|
||||
} else null
|
||||
} else {
|
||||
null
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,9 @@ class GetSortTag(private val preferences: PreferencesHelper) {
|
||||
val index = it.indexOf('|')
|
||||
if (index != -1) {
|
||||
(it.substring(0, index).toIntOrNull() ?: return@mapNotNull null) to it.substring(index + 1)
|
||||
} else null
|
||||
} else {
|
||||
null
|
||||
}
|
||||
}
|
||||
.sortedBy { it.first }.map { it.second }
|
||||
}
|
||||
|
||||
@@ -38,7 +38,9 @@ class UpdateManga(
|
||||
val title = if (remoteManga.title.isNotBlank() && localManga.ogTitle != remoteManga.title) {
|
||||
downloadManager.renameMangaDir(localManga.ogTitle, remoteManga.title, localManga.source)
|
||||
remoteManga.title
|
||||
} else null
|
||||
} else {
|
||||
null
|
||||
}
|
||||
// SY <--
|
||||
|
||||
val coverLastModified =
|
||||
|
||||
@@ -43,7 +43,9 @@ data class Manga(
|
||||
// SY -->
|
||||
private val customMangaInfo = if (favorite) {
|
||||
customMangaManager.getManga(this)
|
||||
} else null
|
||||
} else {
|
||||
null
|
||||
}
|
||||
|
||||
val title: String
|
||||
get() = customMangaInfo?.title ?: ogTitle
|
||||
|
||||
@@ -20,7 +20,9 @@ class RenameSourceCategory(
|
||||
val index = it.indexOf('|')
|
||||
if (index != -1 && it.substring(index + 1) == categoryOld) {
|
||||
it.substring(0, index + 1) + categoryNew
|
||||
} else it
|
||||
} else {
|
||||
it
|
||||
}
|
||||
}
|
||||
.toSet(),
|
||||
)
|
||||
|
||||
@@ -317,7 +317,9 @@ private infix fun String.plusRepo(extension: Extension): String {
|
||||
} else {
|
||||
"$this • "
|
||||
} + context.getString(R.string.repo_source)
|
||||
} else this
|
||||
} else {
|
||||
this
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -181,7 +181,9 @@ fun SourceHeader(
|
||||
Text(
|
||||
text = if (!isCategory) {
|
||||
LocaleHelper.getSourceDisplayName(language, context)
|
||||
} else language,
|
||||
} else {
|
||||
language
|
||||
},
|
||||
modifier = modifier
|
||||
.padding(horizontal = horizontalPadding, vertical = 8.dp),
|
||||
style = MaterialTheme.typography.header,
|
||||
|
||||
+6
-2
@@ -124,7 +124,9 @@ fun BrowseSourceEHentaiListItem(
|
||||
resources.getQuantityString(R.plurals.browse_language_and_pages, pageCount, pageCount, locale.toLanguageTag().uppercase())
|
||||
} else if (pageCount != null) {
|
||||
resources.getQuantityString(R.plurals.num_pages, pageCount, pageCount)
|
||||
} else locale?.toLanguageTag()?.uppercase().orEmpty()
|
||||
} else {
|
||||
locale?.toLanguageTag()?.uppercase().orEmpty()
|
||||
}
|
||||
}
|
||||
}
|
||||
val datePosted by produceState("", metadata) {
|
||||
@@ -237,7 +239,9 @@ fun BrowseSourceEHentaiListItem(
|
||||
Card(
|
||||
colors = if (color != null) {
|
||||
CardDefaults.cardColors(Color(color))
|
||||
} else CardDefaults.cardColors(),
|
||||
} else {
|
||||
CardDefaults.cardColors()
|
||||
},
|
||||
) {
|
||||
Text(
|
||||
text = if (res != null) {
|
||||
|
||||
@@ -132,7 +132,9 @@ fun BrowseSourceRegularToolbar(
|
||||
icon = Icons.Outlined.Settings,
|
||||
onClick = onSettingsClick,
|
||||
)
|
||||
} else null,
|
||||
} else {
|
||||
null
|
||||
},
|
||||
// SY <--
|
||||
),
|
||||
)
|
||||
|
||||
@@ -137,5 +137,5 @@ fun LibraryGridCover(
|
||||
|
||||
enum class PlayButtonPosition(val alignment: Alignment) {
|
||||
Top(Alignment.TopEnd),
|
||||
Bottom(Alignment.BottomEnd)
|
||||
Bottom(Alignment.BottomEnd),
|
||||
}
|
||||
|
||||
@@ -70,7 +70,9 @@ value class SearchMetadataChips(
|
||||
EHentaiSearchMetadata.TAG_TYPE_LIGHT -> 1
|
||||
else -> null
|
||||
}
|
||||
} else null,
|
||||
} else {
|
||||
null
|
||||
},
|
||||
)
|
||||
}
|
||||
.groupBy { it.namespace.orEmpty() },
|
||||
@@ -86,7 +88,9 @@ value class SearchMetadataChips(
|
||||
it.namespace.orEmpty()
|
||||
},
|
||||
)
|
||||
} else null
|
||||
} else {
|
||||
null
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -331,7 +331,9 @@ class Downloader(
|
||||
|
||||
val dataSaver = if (preferences.dataSaverDownloader().get()) {
|
||||
DataSaver(download.source, preferences)
|
||||
} else DataSaver.NoOp
|
||||
} else {
|
||||
DataSaver.NoOp
|
||||
}
|
||||
|
||||
pageListObservable
|
||||
.doOnNext { _ ->
|
||||
|
||||
@@ -142,7 +142,7 @@ class LibraryUpdateService(
|
||||
// SY -->
|
||||
SYNC_FOLLOWS, // MangaDex specific, pull mangadex manga in reading, rereading
|
||||
|
||||
PUSH_FAVORITES // MangaDex specific, push mangadex manga to mangadex
|
||||
PUSH_FAVORITES, // MangaDex specific, push mangadex manga to mangadex
|
||||
// SY <--
|
||||
}
|
||||
|
||||
|
||||
@@ -89,7 +89,7 @@ object PreferenceValues {
|
||||
enum class GroupLibraryMode {
|
||||
GLOBAL,
|
||||
ALL_BUT_UNGROUPED,
|
||||
ALL
|
||||
ALL,
|
||||
}
|
||||
// SY <--
|
||||
}
|
||||
|
||||
@@ -18,7 +18,8 @@ enum class TrackStatus(val int: Int, @StringRes val res: Int) {
|
||||
PAUSED(4, R.string.on_hold),
|
||||
COMPLETED(5, R.string.completed),
|
||||
DROPPED(6, R.string.dropped),
|
||||
OTHER(7, R.string.not_tracked);
|
||||
OTHER(7, R.string.not_tracked),
|
||||
;
|
||||
|
||||
companion object {
|
||||
fun parseTrackerStatus(tracker: Long, statusLong: Long): TrackStatus? {
|
||||
|
||||
@@ -100,7 +100,9 @@ class MdList(private val context: Context, id: Long) : TrackService(id) {
|
||||
if (it.status == FollowStatus.UNFOLLOWED.int) {
|
||||
it.status = if (hasReadChapters) {
|
||||
FollowStatus.READING.int
|
||||
} else FollowStatus.PLAN_TO_READ.int
|
||||
} else {
|
||||
FollowStatus.PLAN_TO_READ.int
|
||||
}
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
@@ -122,8 +122,12 @@ class SourceManager(
|
||||
val matched = factories.find { sourceQName.startsWith(it) }
|
||||
if (matched != null) {
|
||||
DELEGATED_SOURCES[matched]
|
||||
} else DELEGATED_SOURCES[sourceQName]
|
||||
} else null
|
||||
} else {
|
||||
DELEGATED_SOURCES[sourceQName]
|
||||
}
|
||||
} else {
|
||||
null
|
||||
}
|
||||
val newSource = if (this is HttpSource && delegate != null) {
|
||||
xLogD("Delegating source: %s -> %s!", sourceQName, delegate.newSourceClass.qualifiedName)
|
||||
val enhancedSource = EnhancedHttpSource(
|
||||
@@ -139,12 +143,16 @@ class SourceManager(
|
||||
delegate.factory,
|
||||
)
|
||||
enhancedSource
|
||||
} else this
|
||||
} else {
|
||||
this
|
||||
}
|
||||
|
||||
return if (id in BlacklistedSources.BLACKLISTED_EXT_SOURCES) {
|
||||
xLogD("Removing blacklisted source: (id: %s, name: %s, lang: %s)!", id, name, (this as? CatalogueSource)?.lang)
|
||||
null
|
||||
} else newSource
|
||||
} else {
|
||||
newSource
|
||||
}
|
||||
// EXH <--
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,6 @@ interface LoginSource : Source {
|
||||
enum class AuthSupport {
|
||||
NOT_SUPPORTED,
|
||||
SUPPORTED,
|
||||
REQUIRED
|
||||
REQUIRED,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,7 +58,9 @@ interface MetadataSource<M : RaisedSearchMetadata, I> : CatalogueSource {
|
||||
val metadata = if (mangaId != null) {
|
||||
val flatMetadata = getFlatMetadataById.await(mangaId)
|
||||
flatMetadata?.raise(metaClass) ?: newMetaInstance()
|
||||
} else newMetaInstance()
|
||||
} else {
|
||||
newMetaInstance()
|
||||
}
|
||||
|
||||
parseIntoMetadata(metadata, input)
|
||||
if (mangaId != null) {
|
||||
|
||||
@@ -267,7 +267,9 @@ class EHentai(
|
||||
return if (text != null) {
|
||||
val date = MetadataUtil.EX_DATE_FORMAT.parse(text)
|
||||
date?.time
|
||||
} else null
|
||||
} else {
|
||||
null
|
||||
}
|
||||
}
|
||||
|
||||
private fun getRating(element: Element?): Double? {
|
||||
@@ -279,9 +281,15 @@ class EHentai(
|
||||
if (matches[1] == 21) {
|
||||
rate--
|
||||
rate + 0.5
|
||||
} else rate.toDouble()
|
||||
} else null
|
||||
} else null
|
||||
} else {
|
||||
rate.toDouble()
|
||||
}
|
||||
} else {
|
||||
null
|
||||
}
|
||||
} else {
|
||||
null
|
||||
}
|
||||
}
|
||||
|
||||
private fun getUploader(element: Element?): String? {
|
||||
@@ -292,7 +300,9 @@ class EHentai(
|
||||
val pageCount = element?.text()?.trimOrNull()
|
||||
return if (pageCount != null) {
|
||||
PAGE_COUNT_REGEX.find(pageCount)?.value?.toIntOrNull()
|
||||
} else null
|
||||
} else {
|
||||
null
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -333,7 +343,9 @@ class EHentai(
|
||||
),
|
||||
)
|
||||
url = EHentaiSearchMetadata.normalizeUrl(parentLink)
|
||||
} else break
|
||||
} else {
|
||||
break
|
||||
}
|
||||
} else {
|
||||
this@EHentai.xLogD("Parent cache hit: %s!", gid)
|
||||
url = EHentaiSearchMetadata.idAndTokenToUrl(
|
||||
@@ -393,9 +405,11 @@ class EHentai(
|
||||
}
|
||||
}!!
|
||||
.doOnNext { pages ->
|
||||
if (pages.any { it.url == "https://$domain/img/509.gif" }) throw Exception(
|
||||
"Hit page limit",
|
||||
)
|
||||
if (pages.any { it.url == "https://$domain/img/509.gif" }) {
|
||||
throw Exception(
|
||||
"Hit page limit",
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private fun fetchChapterPage(
|
||||
@@ -440,7 +454,9 @@ class EHentai(
|
||||
private fun <T : MangasPage> Observable<T>.checkValid(): Observable<MangasPage> = map {
|
||||
if (exh && it.mangas.isEmpty() && preferences.igneousVal().get().equals("mystery", true)) {
|
||||
throw Exception("Invalid igneous cookie, try re-logging or finding a correct one to input in the login menu")
|
||||
} else it
|
||||
} else {
|
||||
it
|
||||
}
|
||||
}
|
||||
|
||||
override fun fetchLatestUpdates(page: Int): Observable<MangasPage> {
|
||||
@@ -479,7 +495,9 @@ class EHentai(
|
||||
|
||||
val regularPage = if (toplist == ToplistOption.NONE) {
|
||||
page
|
||||
} else null
|
||||
} else {
|
||||
null
|
||||
}
|
||||
|
||||
val request = exGet(uri.toString(), regularPage)
|
||||
|
||||
@@ -517,7 +535,9 @@ class EHentai(
|
||||
return GET(
|
||||
if (page != null) {
|
||||
addParam(url, "page", (page - 1).toString())
|
||||
} else url,
|
||||
} else {
|
||||
url
|
||||
},
|
||||
if (additionalHeaders != null) {
|
||||
val headers = headers.newBuilder()
|
||||
additionalHeaders.toMultimap().forEach { (t, u) ->
|
||||
@@ -526,7 +546,9 @@ class EHentai(
|
||||
}
|
||||
}
|
||||
headers.build()
|
||||
} else headers,
|
||||
} else {
|
||||
headers
|
||||
},
|
||||
).let {
|
||||
if (cacheControl == null) {
|
||||
it
|
||||
@@ -555,7 +577,9 @@ class EHentai(
|
||||
manga.url = EHentaiSearchMetadata.normalizeUrl(newerGallery.attr("href"))
|
||||
client.newCall(mangaDetailsRequest(manga))
|
||||
.asObservableSuccess().map { it.asJsoup() }
|
||||
} else Observable.just(doc)
|
||||
} else {
|
||||
Observable.just(doc)
|
||||
}
|
||||
|
||||
pre.flatMap {
|
||||
@Suppress("DEPRECATION")
|
||||
@@ -591,7 +615,9 @@ class EHentai(
|
||||
url = EHentaiSearchMetadata.normalizeUrl(newerGallery.attr("href")),
|
||||
)
|
||||
client.newCall(mangaDetailsRequest(sManga)).await().asJsoup()
|
||||
} else doc
|
||||
} else {
|
||||
doc
|
||||
}
|
||||
return parseToManga(manga, pre)
|
||||
} else {
|
||||
response.close()
|
||||
@@ -646,7 +672,9 @@ class EHentai(
|
||||
// Parent is older variation of the gallery
|
||||
"parent" -> parent = if (!right.equals("None", true)) {
|
||||
rightElement.child(0).attr("href")
|
||||
} else null
|
||||
} else {
|
||||
null
|
||||
}
|
||||
"visible" -> visible = right.nullIfBlank()
|
||||
"language" -> {
|
||||
language = right.removeSuffix(TR_SUFFIX).trimOrNull()
|
||||
@@ -884,7 +912,8 @@ class EHentai(
|
||||
ALL_TIME("All time", 11),
|
||||
PAST_YEAR("Past year", 12),
|
||||
PAST_MONTH("Past month", 13),
|
||||
YESTERDAY("Yesterday", 15);
|
||||
YESTERDAY("Yesterday", 15),
|
||||
;
|
||||
|
||||
override fun toString(): String {
|
||||
return humanName
|
||||
@@ -1034,12 +1063,16 @@ class EHentai(
|
||||
|
||||
// === URL IMPORT STUFF
|
||||
|
||||
override val matchingHosts: List<String> = if (exh) listOf(
|
||||
"exhentai.org",
|
||||
) else listOf(
|
||||
"g.e-hentai.org",
|
||||
"e-hentai.org",
|
||||
)
|
||||
override val matchingHosts: List<String> = if (exh) {
|
||||
listOf(
|
||||
"exhentai.org",
|
||||
)
|
||||
} else {
|
||||
listOf(
|
||||
"g.e-hentai.org",
|
||||
"e-hentai.org",
|
||||
)
|
||||
}
|
||||
|
||||
override suspend fun mapUrlToMangaUrl(uri: Uri): String? {
|
||||
return when (uri.pathSegments.firstOrNull()) {
|
||||
|
||||
@@ -252,7 +252,9 @@ class MangaDex(delegate: HttpSource, val context: Context) :
|
||||
return if (result) {
|
||||
mdList.saveCredentials(username, password)
|
||||
true
|
||||
} else false
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
override suspend fun logout(): Boolean {
|
||||
|
||||
@@ -117,9 +117,13 @@ class MergedSource : HttpSource() {
|
||||
"$source: ${chapter.scanlator}"
|
||||
},
|
||||
)
|
||||
} else chapter
|
||||
} else {
|
||||
chapter
|
||||
}
|
||||
}
|
||||
} else chapterList
|
||||
} else {
|
||||
chapterList
|
||||
}
|
||||
return if (dedupe) dedupeChapterList(mangaReferences, chapters) else chapters
|
||||
}
|
||||
|
||||
|
||||
@@ -45,7 +45,9 @@ class Pururin(delegate: HttpSource, val context: Context) :
|
||||
val trimmedIdQuery = query.trim().removePrefix("id:")
|
||||
val newQuery = if (trimmedIdQuery.toIntOrNull() ?: -1 >= 0) {
|
||||
"$baseUrl/gallery/$trimmedIdQuery/-"
|
||||
} else query
|
||||
} else {
|
||||
query
|
||||
}
|
||||
|
||||
return urlImportFetchSearchManga(context, newQuery) {
|
||||
super.fetchSearchManga(page, query, filters)
|
||||
|
||||
@@ -40,13 +40,17 @@ class BrowseController : FullComposeController<BrowsePresenter>, RootController
|
||||
titleRes = R.string.browse,
|
||||
// SY -->
|
||||
tabs = (
|
||||
if (presenter.feedTabInFront) listOf(
|
||||
feedTab(router, presenter.feedPresenter),
|
||||
sourcesTab(router, presenter.sourcesPresenter),
|
||||
) else listOf(
|
||||
sourcesTab(router, presenter.sourcesPresenter),
|
||||
feedTab(router, presenter.feedPresenter),
|
||||
)
|
||||
if (presenter.feedTabInFront) {
|
||||
listOf(
|
||||
feedTab(router, presenter.feedPresenter),
|
||||
sourcesTab(router, presenter.sourcesPresenter),
|
||||
)
|
||||
} else {
|
||||
listOf(
|
||||
sourcesTab(router, presenter.sourcesPresenter),
|
||||
feedTab(router, presenter.feedPresenter),
|
||||
)
|
||||
}
|
||||
) + listOf(
|
||||
extensionsTab(router, presenter.extensionsPresenter),
|
||||
migrateSourcesTab(router, presenter.migrationSourcesPresenter),
|
||||
|
||||
@@ -290,7 +290,9 @@ open class FeedPresenter(
|
||||
}
|
||||
},
|
||||
)
|
||||
} else itemUI
|
||||
} else {
|
||||
itemUI
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
+3
-1
@@ -45,7 +45,9 @@ class MigrationBottomSheetDialog(private val activity: Activity, private val lis
|
||||
listener.startMigration(
|
||||
if (binding.useSmartSearch.isChecked && binding.extraSearchParamText.text.isNotBlank()) {
|
||||
binding.extraSearchParamText.toString()
|
||||
} else null,
|
||||
} else {
|
||||
null
|
||||
},
|
||||
)
|
||||
dismiss()
|
||||
}
|
||||
|
||||
+6
-2
@@ -106,7 +106,9 @@ class MigrationListPresenter(
|
||||
if (manga.source == MERGED_SOURCE_ID) {
|
||||
getMergedReferencesById.await(manga.id)
|
||||
.map { sourceManager.getOrStub(it.mangaSourceId) }
|
||||
} else null,
|
||||
} else {
|
||||
null
|
||||
},
|
||||
),
|
||||
parentContext = presenterScope.coroutineContext,
|
||||
getManga = ::getManga,
|
||||
@@ -233,7 +235,9 @@ class MigrationListPresenter(
|
||||
}
|
||||
syncChaptersWithSource.await(chapters, localManga, source)
|
||||
localManga
|
||||
} else null
|
||||
} else {
|
||||
null
|
||||
}
|
||||
} catch (e: CancellationException) {
|
||||
// Ignore cancellations
|
||||
throw e
|
||||
|
||||
@@ -32,7 +32,7 @@ class SourcesController(bundle: Bundle? = null) : FullComposeController<SourcesP
|
||||
|
||||
enum class Mode {
|
||||
CATALOGUE,
|
||||
SMART_SEARCH
|
||||
SMART_SEARCH,
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
@@ -40,7 +40,9 @@ fun sourcesTab(
|
||||
onClick = { router?.pushController(SourceFilterController()) },
|
||||
),
|
||||
)
|
||||
} else emptyList(),
|
||||
} else {
|
||||
emptyList()
|
||||
},
|
||||
// SY <--
|
||||
content = {
|
||||
SourcesScreen(
|
||||
|
||||
@@ -139,7 +139,9 @@ open class SourceFeedPresenter(
|
||||
return listOfNotNull(
|
||||
if (source.supportsLatest) {
|
||||
SourceFeedUI.Latest(null)
|
||||
} else null,
|
||||
} else {
|
||||
null
|
||||
},
|
||||
SourceFeedUI.Browse(null),
|
||||
) + feedSavedSearch
|
||||
.map { SourceFeedUI.SourceSavedSearch(it, savedSearches[it.savedSearch]!!, null) }
|
||||
@@ -244,7 +246,9 @@ open class SourceFeedPresenter(
|
||||
}
|
||||
},
|
||||
)
|
||||
} else itemUI
|
||||
} else {
|
||||
itemUI
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -46,7 +46,9 @@ data class TimeRange(private val startTime: Duration, private val endTime: Durat
|
||||
timeRange.substring(0, index).toDoubleOrNull()?.minutes ?: return null,
|
||||
timeRange.substring(index + 1).toDoubleOrNull()?.minutes ?: return null,
|
||||
)
|
||||
} else return null
|
||||
} else {
|
||||
return null
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -353,8 +353,11 @@ class LibraryPresenter(
|
||||
if (filterLewd == State.IGNORE.value) return@lewd true
|
||||
val isLewd = item.manga.isLewd()
|
||||
|
||||
return@lewd if (filterLewd == State.INCLUDE.value) isLewd
|
||||
else !isLewd
|
||||
return@lewd if (filterLewd == State.INCLUDE.value) {
|
||||
isLewd
|
||||
} else {
|
||||
!isLewd
|
||||
}
|
||||
}
|
||||
// SY <--
|
||||
|
||||
@@ -412,7 +415,9 @@ class LibraryPresenter(
|
||||
getMergedMangaById.await(mergeMangaId)
|
||||
}.sumOf { downloadManager.getDownloadCount(it) }
|
||||
} ?: 0
|
||||
} else /* SY <-- */ downloadManager.getDownloadCount(item.manga.toDomainManga()!!)
|
||||
} else {
|
||||
/* SY <-- */ downloadManager.getDownloadCount(item.manga.toDomainManga()!!)
|
||||
}
|
||||
} else {
|
||||
// Unset download count if not enabled
|
||||
-1
|
||||
@@ -758,8 +763,10 @@ class LibraryPresenter(
|
||||
getChapterByMangaId.await(manga.id).minByOrNull { it.sourceOrder }
|
||||
?.takeUnless { it.read }
|
||||
.let(::listOfNotNull)
|
||||
} else /* SY <-- */ getChapterByMangaId.await(manga.id)
|
||||
.filter { !it.read }
|
||||
} else {
|
||||
/* SY <-- */ getChapterByMangaId.await(manga.id)
|
||||
.filter { !it.read }
|
||||
}
|
||||
|
||||
downloadManager.downloadChapters(manga, chapters.map { it.toDbChapter() })
|
||||
}
|
||||
@@ -852,7 +859,9 @@ class LibraryPresenter(
|
||||
val mergedSource = sources.firstOrNull { mergedManga.source == it.id } as? HttpSource ?: return@merge
|
||||
downloadManager.deleteManga(mergedManga, mergedSource)
|
||||
}
|
||||
} else downloadManager.deleteManga(manga.toDomainManga()!!, source)
|
||||
} else {
|
||||
downloadManager.deleteManga(manga.toDomainManga()!!, source)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -905,7 +914,9 @@ class LibraryPresenter(
|
||||
return produceState(initialValue = default, category, loadedManga, mangaCountVisibility, tabVisibility, groupType, context) {
|
||||
val title = if (tabVisibility.not()) {
|
||||
getCategoryName(context, category, groupType, categoryName)
|
||||
} else defaultTitle
|
||||
} else {
|
||||
defaultTitle
|
||||
}
|
||||
val count = when {
|
||||
category == null || mangaCountVisibility.not() -> null
|
||||
tabVisibility.not() -> loadedManga[category.id]?.size
|
||||
@@ -966,7 +977,9 @@ class LibraryPresenter(
|
||||
val mangaWithMetaIds = getIdsOfFavoriteMangaWithMetadata.await()
|
||||
val tracks = if (loggedServices.isNotEmpty()) {
|
||||
getTracks.await(unfiltered.mapNotNull { it.manga.id }.distinct())
|
||||
} else emptyMap()
|
||||
} else {
|
||||
emptyMap()
|
||||
}
|
||||
val sources = unfiltered
|
||||
.distinctBy { it.manga.source }
|
||||
.mapNotNull { sourceManager.get(it.manga.source) }
|
||||
@@ -1091,7 +1104,9 @@ class LibraryPresenter(
|
||||
val status = trackService.getStatus(it.status.toInt())
|
||||
val name = services[it.syncId]
|
||||
status.contains(constraint, true) || name?.contains(constraint, true) == true
|
||||
} else false
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1150,7 +1165,9 @@ class LibraryPresenter(
|
||||
fun getFirstUnread(manga: Manga): Chapter? {
|
||||
val chapters = if (manga.source == MERGED_SOURCE_ID) {
|
||||
(sourceManager.get(MERGED_SOURCE_ID) as MergedSource).getChaptersAsBlocking(manga.id)
|
||||
} else runBlocking { getChapterByMangaId.await(manga.id) }
|
||||
} else {
|
||||
runBlocking { getChapterByMangaId.await(manga.id) }
|
||||
}
|
||||
return if (manga.isEhBasedManga()) {
|
||||
val chapter = chapters.sortedBy { it.sourceOrder }.getOrNull(0)
|
||||
if (chapter?.read == false) chapter else null
|
||||
|
||||
@@ -231,7 +231,9 @@ class EditMangaDialog : DialogController {
|
||||
private fun ChipGroup.getTextStrings(): List<String> = children.mapNotNull {
|
||||
if (it is Chip && !it.text.toString().contains(context.getString(R.string.add_tag), ignoreCase = true)) {
|
||||
it.text.toString()
|
||||
} else null
|
||||
} else {
|
||||
null
|
||||
}
|
||||
}.toList()
|
||||
|
||||
private companion object {
|
||||
|
||||
@@ -284,7 +284,9 @@ class MangaPresenter(
|
||||
) { (manga, chapters), mergedChapters ->
|
||||
if (manga.source == MERGED_SOURCE_ID) {
|
||||
manga to mergedChapters
|
||||
} else manga to chapters
|
||||
} else {
|
||||
manga to chapters
|
||||
}
|
||||
}
|
||||
.onEach { (manga, chapters) ->
|
||||
if (chapters.isNotEmpty() && manga.isEhBasedManga() && DebugToggles.ENABLE_EXH_ROOT_REDIRECT.enabled) {
|
||||
@@ -333,7 +335,9 @@ class MangaPresenter(
|
||||
references.map { it.mangaSourceId }.distinct()
|
||||
.map { sourceManager.getOrStub(it) },
|
||||
)
|
||||
} else null
|
||||
} else {
|
||||
null
|
||||
}
|
||||
},
|
||||
) { state, mergedData ->
|
||||
state.copy(mergedData = mergedData)
|
||||
@@ -420,7 +424,9 @@ class MangaPresenter(
|
||||
return if (flatMetadata != null) {
|
||||
val metaClass = source.getMainSource<MetadataSource<*, *>>()?.metaClass
|
||||
if (metaClass != null) flatMetadata.raise(metaClass) else null
|
||||
} else null
|
||||
} else {
|
||||
null
|
||||
}
|
||||
}
|
||||
|
||||
fun updateMangaInfo(
|
||||
@@ -765,7 +771,9 @@ class MangaPresenter(
|
||||
mergedManga?.forEach { (manga, source) ->
|
||||
downloadManager.deleteManga(manga, source)
|
||||
}
|
||||
} else /* SY <-- */ downloadManager.deleteManga(state.manga, state.source)
|
||||
} else {
|
||||
/* SY <-- */ downloadManager.deleteManga(state.manga, state.source)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1361,7 +1369,9 @@ class MangaPresenter(
|
||||
}
|
||||
else -> trackItems
|
||||
}
|
||||
} else trackItems
|
||||
} else {
|
||||
trackItems
|
||||
}
|
||||
}
|
||||
// SY <--
|
||||
.collectLatest { trackItems ->
|
||||
|
||||
@@ -61,7 +61,9 @@ class EditMergedMangaHolder(view: View, val adapter: EditMergedMangaAdapter) : F
|
||||
fun updateDownloadChaptersIcon(setTint: Boolean) {
|
||||
val color = if (setTint) {
|
||||
itemView.context.getResourceColor(R.attr.colorAccent)
|
||||
} else itemView.context.getResourceColor(R.attr.colorOnSurface)
|
||||
} else {
|
||||
itemView.context.getResourceColor(R.attr.colorOnSurface)
|
||||
}
|
||||
|
||||
binding.download.drawable.setTint(color)
|
||||
}
|
||||
@@ -69,7 +71,9 @@ class EditMergedMangaHolder(view: View, val adapter: EditMergedMangaAdapter) : F
|
||||
fun updateChapterUpdatesIcon(setTint: Boolean) {
|
||||
val color = if (setTint) {
|
||||
itemView.context.getResourceColor(R.attr.colorAccent)
|
||||
} else itemView.context.getResourceColor(R.attr.colorOnSurface)
|
||||
} else {
|
||||
itemView.context.getResourceColor(R.attr.colorOnSurface)
|
||||
}
|
||||
|
||||
binding.getChapterUpdates.drawable.setTint(color)
|
||||
}
|
||||
|
||||
+3
-1
@@ -99,7 +99,9 @@ class EditMergedSettingsHeaderAdapter(private val controller: EditMergedSettings
|
||||
mergedMangas.indexOfFirst { it.second.isInfoManga }.let {
|
||||
if (it != -1) {
|
||||
binding.mangaInfoSpinner.setSelection(it)
|
||||
} else binding.mangaInfoSpinner.setSelection(0)
|
||||
} else {
|
||||
binding.mangaInfoSpinner.setSelection(0)
|
||||
}
|
||||
}
|
||||
|
||||
binding.mangaInfoSpinner.onItemSelectedListener = object : AdapterView.OnItemSelectedListener {
|
||||
|
||||
@@ -174,7 +174,9 @@ class ReaderPresenter(
|
||||
/* SY --> */ if (manga.source == MERGED_SOURCE_ID) {
|
||||
(sourceManager.get(MERGED_SOURCE_ID) as MergedSource)
|
||||
.getChapters(manga.id!!)
|
||||
} else /* SY <-- */ getChapterByMangaId.await(manga.id!!)
|
||||
} else {
|
||||
/* SY <-- */ getChapterByMangaId.await(manga.id!!)
|
||||
}
|
||||
}
|
||||
|
||||
val selectedChapter = chapters.find { it.id == chapterId }
|
||||
@@ -303,7 +305,9 @@ class ReaderPresenter(
|
||||
val source = sourceManager.get(manga.source)?.getMainSource<MetadataSource<*, *>>()
|
||||
val metadata = if (source != null) {
|
||||
getFlatMetadataById.await(mangaId)?.raise(source.metaClass)
|
||||
} else null
|
||||
} else {
|
||||
null
|
||||
}
|
||||
withUIContext {
|
||||
init(manga.toDbManga(), initialChapterId, metadata)
|
||||
}
|
||||
|
||||
@@ -439,7 +439,11 @@ class PagerPageHolder(
|
||||
|
||||
val centerMargin = if (viewer.config.centerMarginType and PagerConfig.CenterMarginType.DOUBLE_PAGE_CENTER_MARGIN > 0 &&
|
||||
!viewer.config.imageCropBorders
|
||||
) 96 / (max(1, getHeight()) / max(height, height2)) else 0
|
||||
) {
|
||||
96 / (max(1, getHeight()) / max(height, height2))
|
||||
} else {
|
||||
0
|
||||
}
|
||||
|
||||
return ImageUtil.mergeBitmaps(imageBitmap, imageBitmap2, isLTR, centerMargin, viewer.config.pageCanvasColor) {
|
||||
viewer.scope.launchUI {
|
||||
@@ -480,7 +484,11 @@ class PagerPageHolder(
|
||||
|
||||
val sideMargin = if ((viewer.config.centerMarginType and PagerConfig.CenterMarginType.DOUBLE_PAGE_CENTER_MARGIN) > 0 &&
|
||||
viewer.config.doublePages && !viewer.config.imageCropBorders
|
||||
) 48 else 0
|
||||
) {
|
||||
48
|
||||
} else {
|
||||
0
|
||||
}
|
||||
|
||||
return ImageUtil.splitInHalf(imageStream, side, sideMargin)
|
||||
}
|
||||
|
||||
@@ -276,9 +276,13 @@ class PagerViewerAdapter(private val viewer: PagerViewer) : ViewPagerAdapter() {
|
||||
val fullPageBeforeIndex = max(
|
||||
0,
|
||||
(
|
||||
if (index > -1) (
|
||||
items.take(index).indexOfLast { it?.fullPage == true }
|
||||
) else -1
|
||||
if (index > -1) {
|
||||
(
|
||||
items.take(index).indexOfLast { it?.fullPage == true }
|
||||
)
|
||||
} else {
|
||||
-1
|
||||
}
|
||||
),
|
||||
)
|
||||
// Add a shifted page to the first place there isnt a full page
|
||||
|
||||
@@ -554,12 +554,15 @@ class SettingsAdvancedController(
|
||||
withUIContext {
|
||||
val activity = activity ?: return@withUIContext
|
||||
val cleanupString =
|
||||
if (foldersCleared == 0) activity.getString(R.string.no_folders_to_cleanup)
|
||||
else resources!!.getQuantityString(
|
||||
R.plurals.cleanup_done,
|
||||
foldersCleared,
|
||||
foldersCleared,
|
||||
)
|
||||
if (foldersCleared == 0) {
|
||||
activity.getString(R.string.no_folders_to_cleanup)
|
||||
} else {
|
||||
resources!!.getQuantityString(
|
||||
R.plurals.cleanup_done,
|
||||
foldersCleared,
|
||||
foldersCleared,
|
||||
)
|
||||
}
|
||||
activity.toast(cleanupString, Toast.LENGTH_LONG)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -470,7 +470,9 @@ class SettingsEhController : SettingsController() {
|
||||
|
||||
val statsText = if (stats != null) {
|
||||
context.getString(R.string.gallery_updater_stats_text, getRelativeTimeString(getRelativeTimeFromNow(stats.startTime.milliseconds), context), stats.updateCount, stats.possibleUpdates)
|
||||
} else context.getString(R.string.gallery_updater_not_ran_yet)
|
||||
} else {
|
||||
context.getString(R.string.gallery_updater_not_ran_yet)
|
||||
}
|
||||
|
||||
val allMeta = getExhFavoriteMangaWithMetadata.await()
|
||||
.mapNotNull {
|
||||
|
||||
@@ -82,14 +82,18 @@ class SettingsMainController : BasicFullComposeController() {
|
||||
painter = painterResource(R.drawable.eh_ic_ehlogo_red_24dp),
|
||||
onClick = { router.pushController(SettingsEhController()) },
|
||||
)
|
||||
} else null,
|
||||
} else {
|
||||
null
|
||||
},
|
||||
if (remember { MdUtil.getEnabledMangaDexs(preferences).isNotEmpty() }) {
|
||||
SettingsSection(
|
||||
titleRes = R.string.pref_category_mangadex,
|
||||
painter = painterResource(R.drawable.ic_tracker_mangadex_logo_24dp),
|
||||
onClick = { router.pushController(SettingsMangaDexController()) },
|
||||
)
|
||||
} else null,
|
||||
} else {
|
||||
null
|
||||
},
|
||||
// SY <--
|
||||
SettingsSection(
|
||||
titleRes = R.string.pref_category_advanced,
|
||||
|
||||
Reference in New Issue
Block a user