Move isLocal extension functions to LocalSource
This commit is contained in:
parent
3cca460282
commit
7ec5a51eb8
@ -8,7 +8,7 @@ import tachiyomi.domain.source.model.Pin
|
||||
import tachiyomi.domain.source.model.Pins
|
||||
import tachiyomi.domain.source.model.Source
|
||||
import tachiyomi.domain.source.repository.SourceRepository
|
||||
import tachiyomi.source.local.LocalSource
|
||||
import tachiyomi.source.local.isLocal
|
||||
|
||||
class GetEnabledSources(
|
||||
private val repository: SourceRepository,
|
||||
@ -24,7 +24,7 @@ class GetEnabledSources(
|
||||
repository.getSources(),
|
||||
) { pinnedSourceIds, enabledLanguages, disabledSources, lastUsedSource, sources ->
|
||||
sources
|
||||
.filter { it.lang in enabledLanguages || it.id == LocalSource.ID }
|
||||
.filter { it.lang in enabledLanguages || it.isLocal() }
|
||||
.filterNot { it.id.toString() in disabledSources }
|
||||
.sortedWith(compareBy(String.CASE_INSENSITIVE_ORDER) { it.name })
|
||||
.flatMap {
|
||||
|
@ -5,7 +5,7 @@ import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.combine
|
||||
import tachiyomi.domain.source.model.Source
|
||||
import tachiyomi.domain.source.repository.SourceRepository
|
||||
import tachiyomi.source.local.LocalSource
|
||||
import tachiyomi.source.local.isLocal
|
||||
import java.text.Collator
|
||||
import java.util.Collections
|
||||
import java.util.Locale
|
||||
@ -22,7 +22,7 @@ class GetSourcesWithFavoriteCount(
|
||||
repository.getSourcesWithFavoriteCount(),
|
||||
) { direction, mode, list ->
|
||||
list
|
||||
.filterNot { it.first.id == LocalSource.ID }
|
||||
.filterNot { it.first.isLocal() }
|
||||
.sortedWith(sortFn(direction, mode))
|
||||
}
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ import tachiyomi.presentation.core.screens.EmptyScreen
|
||||
import tachiyomi.presentation.core.screens.LoadingScreen
|
||||
import tachiyomi.presentation.core.theme.header
|
||||
import tachiyomi.presentation.core.util.plus
|
||||
import tachiyomi.source.local.LocalSource
|
||||
import tachiyomi.source.local.isLocal
|
||||
|
||||
@Composable
|
||||
fun SourcesScreen(
|
||||
@ -175,7 +175,7 @@ fun SourceOptionsDialog(
|
||||
.fillMaxWidth()
|
||||
.padding(vertical = 16.dp),
|
||||
)
|
||||
if (source.id != LocalSource.ID) {
|
||||
if (source.isLocal()) {
|
||||
Text(
|
||||
text = stringResource(R.string.action_disable),
|
||||
modifier = Modifier
|
||||
|
@ -33,7 +33,7 @@ import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.extension.model.Extension
|
||||
import tachiyomi.core.util.lang.withIOContext
|
||||
import tachiyomi.domain.source.model.Source
|
||||
import tachiyomi.source.local.LocalSource
|
||||
import tachiyomi.source.local.isLocal
|
||||
|
||||
private val defaultModifier = Modifier
|
||||
.height(40.dp)
|
||||
@ -62,7 +62,7 @@ fun SourceIcon(
|
||||
modifier = modifier.then(defaultModifier),
|
||||
)
|
||||
}
|
||||
source.id == LocalSource.ID -> {
|
||||
source.isLocal() -> {
|
||||
Image(
|
||||
painter = painterResource(R.mipmap.ic_local_source),
|
||||
contentDescription = null,
|
||||
|
@ -28,6 +28,7 @@ class AndroidSourceManager(
|
||||
private val extensionManager: ExtensionManager,
|
||||
private val sourceRepository: SourceDataRepository,
|
||||
) : SourceManager {
|
||||
|
||||
private val downloadManager: DownloadManager by injectLazy()
|
||||
|
||||
private val scope = CoroutineScope(Job() + Dispatchers.IO)
|
||||
|
@ -38,9 +38,10 @@ import java.io.File
|
||||
import java.io.FileInputStream
|
||||
import java.io.InputStream
|
||||
import java.nio.charset.StandardCharsets
|
||||
import java.util.concurrent.TimeUnit
|
||||
import java.util.zip.ZipFile
|
||||
import kotlin.time.Duration.Companion.days
|
||||
import com.github.junrar.Archive as JunrarArchive
|
||||
import tachiyomi.domain.source.model.Source as DomainSource
|
||||
|
||||
actual class LocalSource(
|
||||
private val context: Context,
|
||||
@ -348,10 +349,12 @@ actual class LocalSource(
|
||||
const val ID = 0L
|
||||
const val HELP_URL = "https://tachiyomi.org/help/guides/local-manga/"
|
||||
|
||||
private val LATEST_THRESHOLD = TimeUnit.MILLISECONDS.convert(7, TimeUnit.DAYS)
|
||||
private val LATEST_THRESHOLD = 7.days.inWholeMilliseconds
|
||||
}
|
||||
}
|
||||
|
||||
fun Manga.isLocal(): Boolean = source == LocalSource.ID
|
||||
|
||||
fun Source.isLocal(): Boolean = id == LocalSource.ID
|
||||
|
||||
fun DomainSource.isLocal(): Boolean = id == LocalSource.ID
|
||||
|
Loading…
Reference in New Issue
Block a user