mirror of
https://github.com/mihonapp/mihon.git
synced 2025-11-01 22:58:57 +01:00
LoginSource moved to an interface
This commit is contained in:
@@ -10,6 +10,7 @@ import eu.kanade.tachiyomi.data.source.EN
|
||||
import eu.kanade.tachiyomi.data.source.Source
|
||||
import eu.kanade.tachiyomi.data.source.SourceManager
|
||||
import eu.kanade.tachiyomi.data.source.model.MangasPage
|
||||
import eu.kanade.tachiyomi.data.source.online.LoginSource
|
||||
import eu.kanade.tachiyomi.data.source.online.OnlineSource
|
||||
import eu.kanade.tachiyomi.ui.base.presenter.BasePresenter
|
||||
import eu.kanade.tachiyomi.util.RxPager
|
||||
@@ -299,15 +300,13 @@ class CataloguePresenter : BasePresenter<CatalogueFragment>() {
|
||||
* @return true if the source is valid, false otherwise.
|
||||
*/
|
||||
fun isValidSource(source: Source?): Boolean {
|
||||
if (source == null || source !is OnlineSource) return false
|
||||
if (source == null) return false
|
||||
|
||||
return with(source) {
|
||||
if (!isLoginRequired() || isLogged()) {
|
||||
true
|
||||
} else {
|
||||
prefs.sourceUsername(this) != "" && prefs.sourcePassword(this) != ""
|
||||
}
|
||||
if (source is LoginSource) {
|
||||
return source.isLogged() ||
|
||||
(prefs.sourceUsername(source) != "" && prefs.sourcePassword(source) != "")
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -97,7 +97,6 @@ class PagerReaderFragment : BaseFragment() {
|
||||
}
|
||||
|
||||
with(image_view) {
|
||||
setParallelLoadingEnabled(true)
|
||||
setMaxBitmapDimensions(readerActivity.maxBitmapSize)
|
||||
setDoubleTapZoomStyle(SubsamplingScaleImageView.ZOOM_FOCUS_FIXED)
|
||||
setPanLimit(SubsamplingScaleImageView.PAN_LIMIT_INSIDE)
|
||||
|
||||
@@ -44,7 +44,6 @@ class WebtoonHolder(private val view: View, private val adapter: WebtoonAdapter)
|
||||
|
||||
init {
|
||||
with(view.image_view) {
|
||||
setParallelLoadingEnabled(true)
|
||||
setMaxBitmapDimensions(readerActivity.maxBitmapSize)
|
||||
setDoubleTapZoomStyle(SubsamplingScaleImageView.ZOOM_FOCUS_FIXED)
|
||||
setPanLimit(SubsamplingScaleImageView.PAN_LIMIT_INSIDE)
|
||||
|
||||
@@ -9,6 +9,7 @@ import android.view.View
|
||||
import eu.kanade.tachiyomi.data.preference.getOrDefault
|
||||
import eu.kanade.tachiyomi.data.source.Source
|
||||
import eu.kanade.tachiyomi.data.source.getLanguages
|
||||
import eu.kanade.tachiyomi.data.source.online.LoginSource
|
||||
import eu.kanade.tachiyomi.widget.preference.LoginPreference
|
||||
import eu.kanade.tachiyomi.widget.preference.SourceLoginDialog
|
||||
import rx.Subscription
|
||||
@@ -45,11 +46,9 @@ class SettingsSourcesFragment : SettingsNestedFragment() {
|
||||
val enabledSources = settingsActivity.sourceManager.getOnlineSources()
|
||||
.filter { it.lang.code in languages }
|
||||
|
||||
for (source in enabledSources) {
|
||||
if (source.isLoginRequired()) {
|
||||
val pref = createSource(source)
|
||||
sourcesPref.addPreference(pref)
|
||||
}
|
||||
for (source in enabledSources.filterIsInstance(LoginSource::class.java)) {
|
||||
val pref = createLoginSourceEntry(source)
|
||||
sourcesPref.addPreference(pref)
|
||||
}
|
||||
|
||||
// Hide category if it doesn't have any child
|
||||
@@ -62,7 +61,7 @@ class SettingsSourcesFragment : SettingsNestedFragment() {
|
||||
super.onDestroyView()
|
||||
}
|
||||
|
||||
fun createSource(source: Source): Preference {
|
||||
fun createLoginSourceEntry(source: Source): Preference {
|
||||
return LoginPreference(preferenceManager.context).apply {
|
||||
key = preferences.keys.sourceUsername(source.id)
|
||||
title = source.toString()
|
||||
|
||||
Reference in New Issue
Block a user