Put Komga tracker in separate group
This commit is contained in:
parent
a252a8acee
commit
8bfc5f0450
@ -20,9 +20,9 @@ import eu.kanade.tachiyomi.data.library.LibraryUpdateRanker.rankingScheme
|
||||
import eu.kanade.tachiyomi.data.library.LibraryUpdateService.Companion.start
|
||||
import eu.kanade.tachiyomi.data.notification.Notifications
|
||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||
import eu.kanade.tachiyomi.data.track.EnhancedTrackService
|
||||
import eu.kanade.tachiyomi.data.track.TrackManager
|
||||
import eu.kanade.tachiyomi.data.track.TrackService
|
||||
import eu.kanade.tachiyomi.data.track.UnattendedTrackService
|
||||
import eu.kanade.tachiyomi.source.SourceManager
|
||||
import eu.kanade.tachiyomi.source.model.SManga
|
||||
import eu.kanade.tachiyomi.source.model.toSChapter
|
||||
@ -489,7 +489,7 @@ class LibraryUpdateService(
|
||||
val updatedTrack = service.refresh(track)
|
||||
db.insertTrack(updatedTrack).executeAsBlocking()
|
||||
|
||||
if (service is UnattendedTrackService) {
|
||||
if (service is EnhancedTrackService) {
|
||||
syncChaptersWithTrackServiceTwoWay(db, db.getChapters(manga).executeAsBlocking(), track, service)
|
||||
}
|
||||
} catch (e: Throwable) {
|
||||
|
@ -1,18 +1,26 @@
|
||||
package eu.kanade.tachiyomi.data.track
|
||||
|
||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
||||
import eu.kanade.tachiyomi.data.track.komga.Komga
|
||||
import eu.kanade.tachiyomi.data.track.model.TrackSearch
|
||||
import eu.kanade.tachiyomi.source.Source
|
||||
|
||||
/**
|
||||
* An Unattended Track Service will never prompt the user to match a manga with the remote.
|
||||
* It is expected that such Track Sercice can only work with specific sources and unique IDs.
|
||||
* An Enhanced Track Service will never prompt the user to match a manga with the remote.
|
||||
* It is expected that such Track Service can only work with specific sources and unique IDs.
|
||||
*/
|
||||
interface UnattendedTrackService {
|
||||
interface EnhancedTrackService {
|
||||
/**
|
||||
* This TrackService will only work with the sources that are accepted by this filter function.
|
||||
*/
|
||||
fun accept(source: Source): Boolean
|
||||
fun accept(source: Source): Boolean {
|
||||
return source::class.qualifiedName in getAcceptedSources()
|
||||
}
|
||||
|
||||
/**
|
||||
* Fully qualified source classes that this track service is compatible with.
|
||||
*/
|
||||
fun getAcceptedSources(): List<String>
|
||||
|
||||
/**
|
||||
* match is similar to TrackService.search, but only return zero or one match.
|
@ -6,22 +6,20 @@ import androidx.annotation.StringRes
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
||||
import eu.kanade.tachiyomi.data.database.models.Track
|
||||
import eu.kanade.tachiyomi.data.track.EnhancedTrackService
|
||||
import eu.kanade.tachiyomi.data.track.NoLoginTrackService
|
||||
import eu.kanade.tachiyomi.data.track.TrackService
|
||||
import eu.kanade.tachiyomi.data.track.UnattendedTrackService
|
||||
import eu.kanade.tachiyomi.data.track.model.TrackSearch
|
||||
import eu.kanade.tachiyomi.source.Source
|
||||
import okhttp3.Dns
|
||||
import okhttp3.OkHttpClient
|
||||
|
||||
class Komga(private val context: Context, id: Int) : TrackService(id), UnattendedTrackService, NoLoginTrackService {
|
||||
class Komga(private val context: Context, id: Int) : TrackService(id), EnhancedTrackService, NoLoginTrackService {
|
||||
|
||||
companion object {
|
||||
const val UNREAD = 1
|
||||
const val READING = 2
|
||||
const val COMPLETED = 3
|
||||
|
||||
const val ACCEPTED_SOURCE = "eu.kanade.tachiyomi.extension.all.komga.Komga"
|
||||
}
|
||||
|
||||
override val client: OkHttpClient =
|
||||
@ -94,7 +92,7 @@ class Komga(private val context: Context, id: Int) : TrackService(id), Unattende
|
||||
saveCredentials("user", "pass")
|
||||
}
|
||||
|
||||
override fun accept(source: Source): Boolean = source::class.qualifiedName == ACCEPTED_SOURCE
|
||||
override fun getAcceptedSources() = listOf("eu.kanade.tachiyomi.extension.all.komga.Komga")
|
||||
|
||||
override suspend fun match(manga: Manga): TrackSearch? =
|
||||
try {
|
||||
|
@ -9,9 +9,9 @@ import eu.kanade.tachiyomi.data.database.models.Manga
|
||||
import eu.kanade.tachiyomi.data.database.models.MangaCategory
|
||||
import eu.kanade.tachiyomi.data.database.models.toMangaInfo
|
||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||
import eu.kanade.tachiyomi.data.track.EnhancedTrackService
|
||||
import eu.kanade.tachiyomi.data.track.TrackManager
|
||||
import eu.kanade.tachiyomi.data.track.TrackService
|
||||
import eu.kanade.tachiyomi.data.track.UnattendedTrackService
|
||||
import eu.kanade.tachiyomi.source.CatalogueSource
|
||||
import eu.kanade.tachiyomi.source.SourceManager
|
||||
import eu.kanade.tachiyomi.source.model.Filter
|
||||
@ -277,7 +277,7 @@ open class BrowseSourcePresenter(
|
||||
|
||||
private fun autoAddTrack(manga: Manga) {
|
||||
loggedServices
|
||||
.filterIsInstance<UnattendedTrackService>()
|
||||
.filterIsInstance<EnhancedTrackService>()
|
||||
.filter { it.accept(source) }
|
||||
.forEach { service ->
|
||||
launchIO {
|
||||
|
@ -36,8 +36,8 @@ import eu.kanade.tachiyomi.data.database.models.Manga
|
||||
import eu.kanade.tachiyomi.data.download.DownloadService
|
||||
import eu.kanade.tachiyomi.data.download.model.Download
|
||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||
import eu.kanade.tachiyomi.data.track.EnhancedTrackService
|
||||
import eu.kanade.tachiyomi.data.track.TrackService
|
||||
import eu.kanade.tachiyomi.data.track.UnattendedTrackService
|
||||
import eu.kanade.tachiyomi.data.track.model.TrackSearch
|
||||
import eu.kanade.tachiyomi.databinding.MangaControllerBinding
|
||||
import eu.kanade.tachiyomi.source.LocalSource
|
||||
@ -538,7 +538,7 @@ class MangaController :
|
||||
if (source != null && preferences.autoAddTrack()) {
|
||||
presenter.trackList
|
||||
.map { it.service }
|
||||
.filterIsInstance<UnattendedTrackService>()
|
||||
.filterIsInstance<EnhancedTrackService>()
|
||||
.filter { it.accept(source!!) }
|
||||
.forEach { service ->
|
||||
launchIO {
|
||||
|
@ -15,9 +15,9 @@ import eu.kanade.tachiyomi.data.database.models.toMangaInfo
|
||||
import eu.kanade.tachiyomi.data.download.DownloadManager
|
||||
import eu.kanade.tachiyomi.data.download.model.Download
|
||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||
import eu.kanade.tachiyomi.data.track.EnhancedTrackService
|
||||
import eu.kanade.tachiyomi.data.track.TrackManager
|
||||
import eu.kanade.tachiyomi.data.track.TrackService
|
||||
import eu.kanade.tachiyomi.data.track.UnattendedTrackService
|
||||
import eu.kanade.tachiyomi.source.LocalSource
|
||||
import eu.kanade.tachiyomi.source.Source
|
||||
import eu.kanade.tachiyomi.source.model.toSChapter
|
||||
@ -747,7 +747,7 @@ class MangaPresenter(
|
||||
val track = it.service.refresh(it.track!!)
|
||||
db.insertTrack(track).executeAsBlocking()
|
||||
|
||||
if (it.service is UnattendedTrackService) {
|
||||
if (it.service is EnhancedTrackService) {
|
||||
syncChaptersWithTrackServiceTwoWay(db, allChapters, track, it.service)
|
||||
}
|
||||
}
|
||||
@ -783,7 +783,7 @@ class MangaPresenter(
|
||||
service.bind(item, hasReadChapters)
|
||||
db.insertTrack(item).executeAsBlocking()
|
||||
|
||||
if (service is UnattendedTrackService) {
|
||||
if (service is EnhancedTrackService) {
|
||||
syncChaptersWithTrackServiceTwoWay(db, allChapters, item, service)
|
||||
}
|
||||
} catch (e: Throwable) {
|
||||
|
@ -12,7 +12,7 @@ import com.google.android.material.datepicker.DateValidatorPointForward
|
||||
import com.google.android.material.datepicker.MaterialDatePicker
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
||||
import eu.kanade.tachiyomi.data.track.UnattendedTrackService
|
||||
import eu.kanade.tachiyomi.data.track.EnhancedTrackService
|
||||
import eu.kanade.tachiyomi.databinding.TrackControllerBinding
|
||||
import eu.kanade.tachiyomi.source.SourceManager
|
||||
import eu.kanade.tachiyomi.ui.base.controller.openInBrowser
|
||||
@ -80,7 +80,7 @@ class TrackSheet(
|
||||
override fun onSetClick(position: Int) {
|
||||
val item = adapter.getItem(position) ?: return
|
||||
|
||||
if (item.service is UnattendedTrackService) {
|
||||
if (item.service is EnhancedTrackService) {
|
||||
if (item.track != null) {
|
||||
controller.presenter.unregisterTracking(item.service)
|
||||
return
|
||||
|
@ -4,8 +4,10 @@ import android.app.Activity
|
||||
import android.view.Menu
|
||||
import android.view.MenuInflater
|
||||
import android.view.MenuItem
|
||||
import androidx.preference.PreferenceGroup
|
||||
import androidx.preference.PreferenceScreen
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.data.track.EnhancedTrackService
|
||||
import eu.kanade.tachiyomi.data.track.NoLoginTrackService
|
||||
import eu.kanade.tachiyomi.data.track.TrackManager
|
||||
import eu.kanade.tachiyomi.data.track.TrackService
|
||||
@ -13,11 +15,13 @@ import eu.kanade.tachiyomi.data.track.anilist.AnilistApi
|
||||
import eu.kanade.tachiyomi.data.track.bangumi.BangumiApi
|
||||
import eu.kanade.tachiyomi.data.track.myanimelist.MyAnimeListApi
|
||||
import eu.kanade.tachiyomi.data.track.shikimori.ShikimoriApi
|
||||
import eu.kanade.tachiyomi.source.SourceManager
|
||||
import eu.kanade.tachiyomi.ui.setting.track.TrackLoginDialog
|
||||
import eu.kanade.tachiyomi.ui.setting.track.TrackLogoutDialog
|
||||
import eu.kanade.tachiyomi.util.preference.add
|
||||
import eu.kanade.tachiyomi.util.preference.defaultValue
|
||||
import eu.kanade.tachiyomi.util.preference.iconRes
|
||||
import eu.kanade.tachiyomi.util.preference.infoPreference
|
||||
import eu.kanade.tachiyomi.util.preference.initThenAdd
|
||||
import eu.kanade.tachiyomi.util.preference.onClick
|
||||
import eu.kanade.tachiyomi.util.preference.preferenceCategory
|
||||
import eu.kanade.tachiyomi.util.preference.switchPreference
|
||||
@ -33,6 +37,7 @@ class SettingsTrackingController :
|
||||
TrackLogoutDialog.Listener {
|
||||
|
||||
private val trackManager: TrackManager by injectLazy()
|
||||
private val sourceManager: SourceManager by injectLazy()
|
||||
|
||||
override fun setupPreferenceScreen(screen: PreferenceScreen) = screen.apply {
|
||||
titleRes = R.string.pref_category_tracking
|
||||
@ -42,11 +47,7 @@ class SettingsTrackingController :
|
||||
titleRes = R.string.pref_auto_update_manga_sync
|
||||
defaultValue = true
|
||||
}
|
||||
switchPreference {
|
||||
key = Keys.autoAddTrack
|
||||
titleRes = R.string.pref_auto_add_track
|
||||
defaultValue = true
|
||||
}
|
||||
|
||||
preferenceCategory {
|
||||
titleRes = R.string.services
|
||||
|
||||
@ -67,26 +68,37 @@ class SettingsTrackingController :
|
||||
trackPreference(trackManager.bangumi) {
|
||||
activity?.openInBrowser(BangumiApi.authUrl(), trackManager.bangumi.getLogoColor())
|
||||
}
|
||||
|
||||
infoPreference(R.string.tracking_info)
|
||||
}
|
||||
|
||||
preferenceCategory {
|
||||
titleRes = R.string.enhanced_services
|
||||
|
||||
switchPreference {
|
||||
key = Keys.autoAddTrack
|
||||
titleRes = R.string.pref_auto_add_track
|
||||
defaultValue = true
|
||||
}
|
||||
|
||||
trackPreference(trackManager.komga) {
|
||||
trackManager.komga.loginNoop()
|
||||
updatePreference(trackManager.komga.id)
|
||||
}
|
||||
}
|
||||
preferenceCategory {
|
||||
infoPreference(R.string.tracking_info)
|
||||
|
||||
infoPreference(R.string.enhanced_tracking_info)
|
||||
}
|
||||
}
|
||||
|
||||
private inline fun PreferenceScreen.trackPreference(
|
||||
private inline fun PreferenceGroup.trackPreference(
|
||||
service: TrackService,
|
||||
crossinline login: () -> Unit
|
||||
): LoginPreference {
|
||||
return initThenAdd(
|
||||
return add(
|
||||
LoginPreference(context).apply {
|
||||
key = Keys.trackUsername(service.id)
|
||||
titleRes = service.nameRes()
|
||||
},
|
||||
{
|
||||
iconRes = service.getLogo()
|
||||
onClick {
|
||||
if (service.isLogged) {
|
||||
if (service is NoLoginTrackService) {
|
||||
|
@ -34,9 +34,8 @@ inline fun PreferenceGroup.preference(block: (@DSL Preference).() -> Unit): Pref
|
||||
}
|
||||
|
||||
inline fun PreferenceGroup.infoPreference(@StringRes infoRes: Int): Preference {
|
||||
return initThenAdd(
|
||||
Preference(context),
|
||||
{
|
||||
return add(
|
||||
Preference(context).apply {
|
||||
iconRes = R.drawable.ic_info_24dp
|
||||
iconTint = context.getResourceColor(android.R.attr.textColorHint)
|
||||
summaryRes = infoRes
|
||||
|
@ -381,9 +381,11 @@
|
||||
<!-- Tracking section -->
|
||||
<string name="tracking_guide">Tracking guide</string>
|
||||
<string name="pref_auto_update_manga_sync">Update chapter progress after reading</string>
|
||||
<string name="pref_auto_add_track">Track silently when adding manga to library</string>
|
||||
<string name="services">Services</string>
|
||||
<string name="tracking_info">One-way sync to update the chapter progress in tracking services. Set up tracking for individual manga entries from their tracking button.</string>
|
||||
<string name="enhanced_services">Enhanced services</string>
|
||||
<string name="pref_auto_add_track">Automatically track manga when added to library</string>
|
||||
<string name="enhanced_tracking_info">Services that provide enhanced features for specific sources.</string>
|
||||
|
||||
<!-- Browse section -->
|
||||
<string name="pref_enable_automatic_extension_updates">Check for extension updates</string>
|
||||
|
Loading…
Reference in New Issue
Block a user