mirror of
https://github.com/aniyomiorg/aniyomi.git
synced 2024-11-28 17:19:00 +03:00
update anime stuff according to pr17
This commit is contained in:
parent
af584a403f
commit
4e9c0b740e
26 changed files with 182 additions and 96 deletions
|
@ -21,12 +21,14 @@ import eu.kanade.tachiyomi.data.download.DownloadService
|
|||
import eu.kanade.tachiyomi.data.notification.Notifications
|
||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||
import eu.kanade.tachiyomi.data.track.TrackManager
|
||||
import eu.kanade.tachiyomi.data.track.UnattendedTrackService
|
||||
import eu.kanade.tachiyomi.source.AnimeSourceManager
|
||||
import eu.kanade.tachiyomi.source.model.SAnime
|
||||
import eu.kanade.tachiyomi.source.model.toSAnime
|
||||
import eu.kanade.tachiyomi.source.model.toSEpisode
|
||||
import eu.kanade.tachiyomi.util.episode.NoEpisodesException
|
||||
import eu.kanade.tachiyomi.util.episode.syncEpisodesWithSource
|
||||
import eu.kanade.tachiyomi.util.episode.syncEpisodesWithTrackServiceTwoWay
|
||||
import eu.kanade.tachiyomi.util.prepUpdateCover
|
||||
import eu.kanade.tachiyomi.util.shouldDownloadNewEpisodes
|
||||
import eu.kanade.tachiyomi.util.storage.getUriCompat
|
||||
|
@ -413,8 +415,12 @@ class AnimelibUpdateService(
|
|||
val service = trackManager.getService(track.sync_id)
|
||||
if (service != null && service in loggedServices) {
|
||||
try {
|
||||
val updatedTrack = service.refreshAnime(track)
|
||||
val updatedTrack = service.refresh(track)
|
||||
db.insertTrack(updatedTrack).executeAsBlocking()
|
||||
|
||||
if (service is UnattendedTrackService) {
|
||||
syncEpisodesWithTrackServiceTwoWay(db, db.getEpisodes(anime).executeAsBlocking(), track, service)
|
||||
}
|
||||
} catch (e: Throwable) {
|
||||
// Ignore errors and continue
|
||||
Timber.e(e)
|
||||
|
|
|
@ -52,15 +52,15 @@ abstract class TrackService(val id: Int) {
|
|||
|
||||
abstract suspend fun add(track: Track): Track
|
||||
|
||||
abstract suspend fun addAnime(track: AnimeTrack): AnimeTrack
|
||||
abstract suspend fun add(track: AnimeTrack): AnimeTrack
|
||||
|
||||
abstract suspend fun update(track: Track): Track
|
||||
|
||||
abstract suspend fun updateAnime(track: AnimeTrack): AnimeTrack
|
||||
abstract suspend fun update(track: AnimeTrack): AnimeTrack
|
||||
|
||||
abstract suspend fun bind(track: Track): Track
|
||||
|
||||
abstract suspend fun bindAnime(track: AnimeTrack): AnimeTrack
|
||||
abstract suspend fun bind(track: AnimeTrack): AnimeTrack
|
||||
|
||||
abstract suspend fun search(query: String): List<TrackSearch>
|
||||
|
||||
|
@ -68,7 +68,7 @@ abstract class TrackService(val id: Int) {
|
|||
|
||||
abstract suspend fun refresh(track: Track): Track
|
||||
|
||||
abstract suspend fun refreshAnime(track: AnimeTrack): AnimeTrack
|
||||
abstract suspend fun refresh(track: AnimeTrack): AnimeTrack
|
||||
|
||||
abstract suspend fun login(username: String, password: String)
|
||||
|
||||
|
|
|
@ -155,7 +155,7 @@ class Anilist(private val context: Context, id: Int) : TrackService(id) {
|
|||
return api.addLibManga(track)
|
||||
}
|
||||
|
||||
override suspend fun addAnime(track: AnimeTrack): AnimeTrack {
|
||||
override suspend fun add(track: AnimeTrack): AnimeTrack {
|
||||
return api.addLibAnime(track)
|
||||
}
|
||||
|
||||
|
@ -170,7 +170,7 @@ class Anilist(private val context: Context, id: Int) : TrackService(id) {
|
|||
return api.updateLibManga(track)
|
||||
}
|
||||
|
||||
override suspend fun updateAnime(track: AnimeTrack): AnimeTrack {
|
||||
override suspend fun update(track: AnimeTrack): AnimeTrack {
|
||||
// If user was using API v1 fetch library_id
|
||||
if (track.library_id == null || track.library_id!! == 0L) {
|
||||
val libManga = api.findLibAnime(track, getUsername().toInt())
|
||||
|
@ -195,17 +195,17 @@ class Anilist(private val context: Context, id: Int) : TrackService(id) {
|
|||
}
|
||||
}
|
||||
|
||||
override suspend fun bindAnime(track: AnimeTrack): AnimeTrack {
|
||||
override suspend fun bind(track: AnimeTrack): AnimeTrack {
|
||||
val remoteTrack = api.findLibAnime(track, getUsername().toInt())
|
||||
return if (remoteTrack != null) {
|
||||
track.copyPersonalFrom(remoteTrack)
|
||||
track.library_id = remoteTrack.library_id
|
||||
updateAnime(track)
|
||||
update(track)
|
||||
} else {
|
||||
// Set default fields if it's not found in the list
|
||||
track.status = READING
|
||||
track.score = 0F
|
||||
addAnime(track)
|
||||
add(track)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -224,7 +224,7 @@ class Anilist(private val context: Context, id: Int) : TrackService(id) {
|
|||
return track
|
||||
}
|
||||
|
||||
override suspend fun refreshAnime(track: AnimeTrack): AnimeTrack {
|
||||
override suspend fun refresh(track: AnimeTrack): AnimeTrack {
|
||||
val remoteTrack = api.getLibAnime(track, getUsername().toInt())
|
||||
track.copyPersonalFrom(remoteTrack)
|
||||
track.total_episodes = remoteTrack.total_episodes
|
||||
|
|
|
@ -41,7 +41,7 @@ class Bangumi(private val context: Context, id: Int) : TrackService(id) {
|
|||
return api.addLibManga(track)
|
||||
}
|
||||
|
||||
override suspend fun addAnime(track: AnimeTrack): AnimeTrack {
|
||||
override suspend fun add(track: AnimeTrack): AnimeTrack {
|
||||
return api.addLibAnime(track)
|
||||
}
|
||||
|
||||
|
@ -49,7 +49,7 @@ class Bangumi(private val context: Context, id: Int) : TrackService(id) {
|
|||
return api.updateLibManga(track)
|
||||
}
|
||||
|
||||
override suspend fun updateAnime(track: AnimeTrack): AnimeTrack {
|
||||
override suspend fun update(track: AnimeTrack): AnimeTrack {
|
||||
return api.updateLibAnime(track)
|
||||
}
|
||||
|
||||
|
@ -73,7 +73,7 @@ class Bangumi(private val context: Context, id: Int) : TrackService(id) {
|
|||
}
|
||||
}
|
||||
|
||||
override suspend fun bindAnime(track: AnimeTrack): AnimeTrack {
|
||||
override suspend fun bind(track: AnimeTrack): AnimeTrack {
|
||||
val statusTrack = api.statusLibAnime(track)
|
||||
val remoteTrack = api.findLibAnime(track)
|
||||
return if (remoteTrack != null && statusTrack != null) {
|
||||
|
@ -83,13 +83,13 @@ class Bangumi(private val context: Context, id: Int) : TrackService(id) {
|
|||
track.score = statusTrack.score
|
||||
track.last_episode_seen = statusTrack.last_episode_seen
|
||||
track.total_episodes = remoteTrack.total_episodes
|
||||
refreshAnime(track)
|
||||
refresh(track)
|
||||
} else {
|
||||
// Set default fields if it's not found in the list
|
||||
track.status = READING
|
||||
track.score = 0F
|
||||
addAnime(track)
|
||||
updateAnime(track)
|
||||
add(track)
|
||||
update(track)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -110,7 +110,7 @@ class Bangumi(private val context: Context, id: Int) : TrackService(id) {
|
|||
return track
|
||||
}
|
||||
|
||||
override suspend fun refreshAnime(track: AnimeTrack): AnimeTrack {
|
||||
override suspend fun refresh(track: AnimeTrack): AnimeTrack {
|
||||
val remoteStatusTrack = api.statusLibAnime(track)
|
||||
track.copyPersonalFrom(remoteStatusTrack!!)
|
||||
api.findLibAnime(track)?.let { remoteTrack ->
|
||||
|
|
|
@ -78,7 +78,7 @@ class Kitsu(private val context: Context, id: Int) : TrackService(id) {
|
|||
return api.addLibManga(track, getUserId())
|
||||
}
|
||||
|
||||
override suspend fun addAnime(track: AnimeTrack): AnimeTrack {
|
||||
override suspend fun add(track: AnimeTrack): AnimeTrack {
|
||||
return api.addLibAnime(track, getUserId())
|
||||
}
|
||||
|
||||
|
@ -86,7 +86,7 @@ class Kitsu(private val context: Context, id: Int) : TrackService(id) {
|
|||
return api.updateLibManga(track)
|
||||
}
|
||||
|
||||
override suspend fun updateAnime(track: AnimeTrack): AnimeTrack {
|
||||
override suspend fun update(track: AnimeTrack): AnimeTrack {
|
||||
return api.updateLibAnime(track)
|
||||
}
|
||||
|
||||
|
@ -103,16 +103,16 @@ class Kitsu(private val context: Context, id: Int) : TrackService(id) {
|
|||
}
|
||||
}
|
||||
|
||||
override suspend fun bindAnime(track: AnimeTrack): AnimeTrack {
|
||||
override suspend fun bind(track: AnimeTrack): AnimeTrack {
|
||||
val remoteTrack = api.findLibAnime(track, getUserId())
|
||||
return if (remoteTrack != null) {
|
||||
track.copyPersonalFrom(remoteTrack)
|
||||
track.media_id = remoteTrack.media_id
|
||||
updateAnime(track)
|
||||
update(track)
|
||||
} else {
|
||||
track.status = READING
|
||||
track.score = 0F
|
||||
addAnime(track)
|
||||
add(track)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -131,7 +131,7 @@ class Kitsu(private val context: Context, id: Int) : TrackService(id) {
|
|||
return track
|
||||
}
|
||||
|
||||
override suspend fun refreshAnime(track: AnimeTrack): AnimeTrack {
|
||||
override suspend fun refresh(track: AnimeTrack): AnimeTrack {
|
||||
val remoteTrack = api.getLibAnime(track)
|
||||
track.copyPersonalFrom(remoteTrack)
|
||||
track.total_episodes = remoteTrack.total_episodes
|
||||
|
|
|
@ -62,19 +62,19 @@ class Komga(private val context: Context, id: Int) : TrackService(id), Unattende
|
|||
|
||||
override suspend fun add(track: Track): Track = throw Exception("Not used")
|
||||
|
||||
override suspend fun addAnime(track: AnimeTrack): AnimeTrack = throw Exception("Not used")
|
||||
override suspend fun add(track: AnimeTrack): AnimeTrack = throw Exception("Not used")
|
||||
|
||||
override suspend fun update(track: Track): Track {
|
||||
return api.updateProgress(track)
|
||||
}
|
||||
|
||||
override suspend fun updateAnime(track: AnimeTrack): AnimeTrack = throw Exception("Not used")
|
||||
override suspend fun update(track: AnimeTrack): AnimeTrack = throw Exception("Not used")
|
||||
|
||||
override suspend fun bind(track: Track): Track {
|
||||
return track
|
||||
}
|
||||
|
||||
override suspend fun bindAnime(track: AnimeTrack): AnimeTrack = throw Exception("Not used")
|
||||
override suspend fun bind(track: AnimeTrack): AnimeTrack = throw Exception("Not used")
|
||||
|
||||
override suspend fun search(query: String): List<TrackSearch> = throw Exception("Not used")
|
||||
|
||||
|
@ -87,7 +87,7 @@ class Komga(private val context: Context, id: Int) : TrackService(id), Unattende
|
|||
return track
|
||||
}
|
||||
|
||||
override suspend fun refreshAnime(track: AnimeTrack): AnimeTrack {
|
||||
override suspend fun refresh(track: AnimeTrack): AnimeTrack {
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
|
||||
|
|
|
@ -78,7 +78,7 @@ class MyAnimeList(private val context: Context, id: Int) : TrackService(id) {
|
|||
return api.updateItem(track)
|
||||
}
|
||||
|
||||
override suspend fun addAnime(track: AnimeTrack): AnimeTrack {
|
||||
override suspend fun add(track: AnimeTrack): AnimeTrack {
|
||||
track.status = READING
|
||||
track.score = 0F
|
||||
return api.updateItem(track)
|
||||
|
@ -88,7 +88,7 @@ class MyAnimeList(private val context: Context, id: Int) : TrackService(id) {
|
|||
return api.updateItem(track)
|
||||
}
|
||||
|
||||
override suspend fun updateAnime(track: AnimeTrack): AnimeTrack {
|
||||
override suspend fun update(track: AnimeTrack): AnimeTrack {
|
||||
return api.updateItem(track)
|
||||
}
|
||||
|
||||
|
@ -103,14 +103,14 @@ class MyAnimeList(private val context: Context, id: Int) : TrackService(id) {
|
|||
}
|
||||
}
|
||||
|
||||
override suspend fun bindAnime(track: AnimeTrack): AnimeTrack {
|
||||
override suspend fun bind(track: AnimeTrack): AnimeTrack {
|
||||
val remoteTrack = api.findListItem(track)
|
||||
return if (remoteTrack != null) {
|
||||
track.copyPersonalFrom(remoteTrack)
|
||||
track.media_id = remoteTrack.media_id
|
||||
updateAnime(track)
|
||||
update(track)
|
||||
} else {
|
||||
addAnime(track)
|
||||
add(track)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -150,8 +150,8 @@ class MyAnimeList(private val context: Context, id: Int) : TrackService(id) {
|
|||
return api.findListItem(track) ?: add(track)
|
||||
}
|
||||
|
||||
override suspend fun refreshAnime(track: AnimeTrack): AnimeTrack {
|
||||
return api.findListItem(track) ?: addAnime(track)
|
||||
override suspend fun refresh(track: AnimeTrack): AnimeTrack {
|
||||
return api.findListItem(track) ?: add(track)
|
||||
}
|
||||
|
||||
override suspend fun login(username: String, password: String) = login(password)
|
||||
|
|
|
@ -50,7 +50,7 @@ class Shikimori(private val context: Context, id: Int) : TrackService(id) {
|
|||
return api.addLibManga(track, getUsername())
|
||||
}
|
||||
|
||||
override suspend fun addAnime(track: AnimeTrack): AnimeTrack {
|
||||
override suspend fun add(track: AnimeTrack): AnimeTrack {
|
||||
return api.addLibAnime(track, getUsername())
|
||||
}
|
||||
|
||||
|
@ -58,7 +58,7 @@ class Shikimori(private val context: Context, id: Int) : TrackService(id) {
|
|||
return api.updateLibManga(track, getUsername())
|
||||
}
|
||||
|
||||
override suspend fun updateAnime(track: AnimeTrack): AnimeTrack {
|
||||
override suspend fun update(track: AnimeTrack): AnimeTrack {
|
||||
return api.updateLibAnime(track, getUsername())
|
||||
}
|
||||
|
||||
|
@ -76,17 +76,17 @@ class Shikimori(private val context: Context, id: Int) : TrackService(id) {
|
|||
}
|
||||
}
|
||||
|
||||
override suspend fun bindAnime(track: AnimeTrack): AnimeTrack {
|
||||
override suspend fun bind(track: AnimeTrack): AnimeTrack {
|
||||
val remoteTrack = api.findLibAnime(track, getUsername())
|
||||
return if (remoteTrack != null) {
|
||||
track.copyPersonalFrom(remoteTrack)
|
||||
track.library_id = remoteTrack.library_id
|
||||
updateAnime(track)
|
||||
update(track)
|
||||
} else {
|
||||
// Set default fields if it's not found in the list
|
||||
track.status = READING
|
||||
track.score = 0F
|
||||
addAnime(track)
|
||||
add(track)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -106,7 +106,7 @@ class Shikimori(private val context: Context, id: Int) : TrackService(id) {
|
|||
return track
|
||||
}
|
||||
|
||||
override suspend fun refreshAnime(track: AnimeTrack): AnimeTrack {
|
||||
override suspend fun refresh(track: AnimeTrack): AnimeTrack {
|
||||
api.findLibAnime(track, getUsername())?.let { remoteTrack ->
|
||||
track.copyPersonalFrom(remoteTrack)
|
||||
track.total_episodes = remoteTrack.total_episodes
|
||||
|
|
|
@ -36,6 +36,8 @@ import eu.kanade.tachiyomi.data.database.models.Episode
|
|||
import eu.kanade.tachiyomi.data.download.DownloadService
|
||||
import eu.kanade.tachiyomi.data.download.model.AnimeDownload
|
||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||
import eu.kanade.tachiyomi.data.track.TrackService
|
||||
import eu.kanade.tachiyomi.data.track.UnattendedTrackService
|
||||
import eu.kanade.tachiyomi.data.track.model.AnimeTrackSearch
|
||||
import eu.kanade.tachiyomi.databinding.AnimeControllerBinding
|
||||
import eu.kanade.tachiyomi.source.AnimeSource
|
||||
|
@ -71,6 +73,7 @@ import eu.kanade.tachiyomi.ui.watcher.WatcherActivity
|
|||
import eu.kanade.tachiyomi.ui.webview.WebViewActivity
|
||||
import eu.kanade.tachiyomi.util.episode.NoEpisodesException
|
||||
import eu.kanade.tachiyomi.util.hasCustomCover
|
||||
import eu.kanade.tachiyomi.util.lang.launchIO
|
||||
import eu.kanade.tachiyomi.util.lang.launchUI
|
||||
import eu.kanade.tachiyomi.util.system.getResourceColor
|
||||
import eu.kanade.tachiyomi.util.system.toast
|
||||
|
@ -504,6 +507,24 @@ class AnimeController :
|
|||
.showDialog(router)
|
||||
}
|
||||
}
|
||||
|
||||
if (source != null && preferences.autoAddTrack()) {
|
||||
presenter.trackList
|
||||
.map { it.service }
|
||||
.filterIsInstance<UnattendedTrackService>()
|
||||
.filter { it.accept(source!!) }
|
||||
.forEach { service ->
|
||||
launchIO {
|
||||
try {
|
||||
service.match(anime)?.let { track ->
|
||||
presenter.registerTracking(track, service as TrackService)
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
Timber.w(e, "Could not match manga: ${anime.title} with service $service")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -17,6 +17,7 @@ import eu.kanade.tachiyomi.data.download.model.AnimeDownload
|
|||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||
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.AnimeSource
|
||||
import eu.kanade.tachiyomi.source.LocalAnimeSource
|
||||
import eu.kanade.tachiyomi.source.model.toEpisodeInfo
|
||||
|
@ -27,6 +28,7 @@ import eu.kanade.tachiyomi.ui.anime.track.TrackItem
|
|||
import eu.kanade.tachiyomi.ui.base.presenter.BasePresenter
|
||||
import eu.kanade.tachiyomi.util.episode.EpisodeSettingsHelper
|
||||
import eu.kanade.tachiyomi.util.episode.syncEpisodesWithSource
|
||||
import eu.kanade.tachiyomi.util.episode.syncEpisodesWithTrackServiceTwoWay
|
||||
import eu.kanade.tachiyomi.util.isLocal
|
||||
import eu.kanade.tachiyomi.util.lang.launchIO
|
||||
import eu.kanade.tachiyomi.util.lang.withUIContext
|
||||
|
@ -752,8 +754,12 @@ class AnimePresenter(
|
|||
.filter { it.track != null }
|
||||
.map {
|
||||
async {
|
||||
val track = it.service.refreshAnime(it.track!!)
|
||||
val track = it.service.refresh(it.track!!)
|
||||
db.insertTrack(track).executeAsBlocking()
|
||||
|
||||
if (it.service is UnattendedTrackService) {
|
||||
syncEpisodesWithTrackServiceTwoWay(db, episodes, track, it.service)
|
||||
}
|
||||
}
|
||||
}
|
||||
.awaitAll()
|
||||
|
@ -783,7 +789,7 @@ class AnimePresenter(
|
|||
item.anime_id = anime.id!!
|
||||
launchIO {
|
||||
try {
|
||||
service.bindAnime(item)
|
||||
service.bind(item)
|
||||
db.insertTrack(item).executeAsBlocking()
|
||||
} catch (e: Throwable) {
|
||||
withUIContext { view?.applicationContext?.toast(e.message) }
|
||||
|
@ -801,7 +807,7 @@ class AnimePresenter(
|
|||
private fun updateRemote(track: AnimeTrack, service: TrackService) {
|
||||
launchIO {
|
||||
try {
|
||||
service.updateAnime(track)
|
||||
service.update(track)
|
||||
db.insertTrack(track).executeAsBlocking()
|
||||
withUIContext { view?.onTrackingRefreshDone() }
|
||||
} catch (e: Throwable) {
|
||||
|
|
|
@ -3,6 +3,7 @@ package eu.kanade.tachiyomi.ui.anime.track
|
|||
import android.annotation.SuppressLint
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import eu.kanade.tachiyomi.R.string
|
||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||
import eu.kanade.tachiyomi.databinding.TrackItemBinding
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
|
@ -49,6 +50,12 @@ class TrackHolder(private val binding: TrackItemBinding, adapter: TrackAdapter)
|
|||
if (track.total_episodes > 0) track.total_episodes else "-"
|
||||
binding.trackStatus.text = item.service.getStatus(track.status)
|
||||
binding.trackScore.text = if (track.score == 0f) "-" else item.service.displayScore(track)
|
||||
if (item.service.getScoreList().isEmpty()) {
|
||||
with(binding.trackScore) {
|
||||
text = context.getString(string.score_unsupported)
|
||||
isEnabled = false
|
||||
}
|
||||
}
|
||||
|
||||
if (item.service.supportsReadingDates) {
|
||||
binding.trackStartDate.text =
|
||||
|
|
|
@ -5,16 +5,25 @@ import android.view.LayoutInflater
|
|||
import android.view.View
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import com.google.android.material.bottomsheet.BottomSheetBehavior
|
||||
import eu.kanade.tachiyomi.R.string
|
||||
import eu.kanade.tachiyomi.data.database.models.Anime
|
||||
import eu.kanade.tachiyomi.data.track.UnattendedTrackService
|
||||
import eu.kanade.tachiyomi.databinding.TrackControllerBinding
|
||||
import eu.kanade.tachiyomi.source.AnimeSourceManager
|
||||
import eu.kanade.tachiyomi.ui.anime.AnimeController
|
||||
import eu.kanade.tachiyomi.ui.base.controller.openInBrowser
|
||||
import eu.kanade.tachiyomi.util.lang.launchIO
|
||||
import eu.kanade.tachiyomi.util.lang.withUIContext
|
||||
import eu.kanade.tachiyomi.util.system.copyToClipboard
|
||||
import eu.kanade.tachiyomi.util.system.toast
|
||||
import eu.kanade.tachiyomi.widget.sheet.BaseBottomSheetDialog
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
|
||||
class TrackSheet(
|
||||
val controller: AnimeController,
|
||||
val anime: Anime
|
||||
val anime: Anime,
|
||||
private val sourceManager: AnimeSourceManager = Injekt.get()
|
||||
) : BaseBottomSheetDialog(controller.activity!!),
|
||||
TrackAdapter.OnClickListener,
|
||||
SetTrackStatusDialog.Listener,
|
||||
|
@ -41,15 +50,10 @@ class TrackSheet(
|
|||
adapter.items = controller.presenter.trackList
|
||||
}
|
||||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
sheetBehavior.skipCollapsed = true
|
||||
}
|
||||
|
||||
override fun show() {
|
||||
super.show()
|
||||
controller.presenter.refreshTrackers()
|
||||
sheetBehavior.state = BottomSheetBehavior.STATE_EXPANDED
|
||||
sheetBehavior.state = BottomSheetBehavior.STATE_COLLAPSED
|
||||
}
|
||||
|
||||
fun onNextTrackers(trackers: List<TrackItem>) {
|
||||
|
@ -69,7 +73,31 @@ class TrackSheet(
|
|||
|
||||
override fun onSetClick(position: Int) {
|
||||
val item = adapter.getItem(position) ?: return
|
||||
TrackSearchDialog(controller, item.service).showDialog(controller.router, TAG_SEARCH_CONTROLLER)
|
||||
|
||||
if (item.service is UnattendedTrackService) {
|
||||
if (item.track != null) {
|
||||
controller.presenter.unregisterTracking(item.service)
|
||||
return
|
||||
}
|
||||
|
||||
if (!item.service.accept(sourceManager.getOrStub(anime.source))) {
|
||||
controller.presenter.view?.applicationContext?.toast(string.source_unsupported)
|
||||
return
|
||||
}
|
||||
|
||||
launchIO {
|
||||
try {
|
||||
item.service.match(anime)?.let { track ->
|
||||
controller.presenter.registerTracking(track, item.service)
|
||||
}
|
||||
?: withUIContext { controller.presenter.view?.applicationContext?.toast(string.error_no_match) }
|
||||
} catch (e: Exception) {
|
||||
withUIContext { controller.presenter.view?.applicationContext?.toast(string.error_no_match) }
|
||||
}
|
||||
}
|
||||
} else {
|
||||
TrackSearchDialog(controller, item.service).showDialog(controller.router, TAG_SEARCH_CONTROLLER)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onTitleLongClick(position: Int) {
|
||||
|
@ -94,7 +122,7 @@ class TrackSheet(
|
|||
|
||||
override fun onScoreClick(position: Int) {
|
||||
val item = adapter.getItem(position) ?: return
|
||||
if (item.track == null) return
|
||||
if (item.track == null || item.service.getScoreList().isEmpty()) return
|
||||
|
||||
SetTrackScoreDialog(controller, this, item).showDialog(controller.router)
|
||||
}
|
||||
|
|
|
@ -9,6 +9,9 @@ import eu.kanade.tachiyomi.data.database.models.AnimeCategory
|
|||
import eu.kanade.tachiyomi.data.database.models.Category
|
||||
import eu.kanade.tachiyomi.data.database.models.toAnimeInfo
|
||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||
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.AnimeCatalogueSource
|
||||
import eu.kanade.tachiyomi.source.AnimeSourceManager
|
||||
import eu.kanade.tachiyomi.source.model.Filter
|
||||
|
@ -30,6 +33,7 @@ import eu.kanade.tachiyomi.ui.browse.animesource.filter.TextSectionItem
|
|||
import eu.kanade.tachiyomi.ui.browse.animesource.filter.TriStateItem
|
||||
import eu.kanade.tachiyomi.ui.browse.animesource.filter.TriStateSectionItem
|
||||
import eu.kanade.tachiyomi.util.episode.EpisodeSettingsHelper
|
||||
import eu.kanade.tachiyomi.util.episode.syncEpisodesWithTrackServiceTwoWay
|
||||
import eu.kanade.tachiyomi.util.lang.launchIO
|
||||
import eu.kanade.tachiyomi.util.lang.withUIContext
|
||||
import eu.kanade.tachiyomi.util.removeCovers
|
||||
|
@ -102,6 +106,8 @@ open class BrowseAnimeSourcePresenter(
|
|||
*/
|
||||
private var pageSubscription: Subscription? = null
|
||||
|
||||
private val loggedServices by lazy { Injekt.get<TrackManager>().services.filter { it.isLogged } }
|
||||
|
||||
init {
|
||||
query = searchQuery ?: ""
|
||||
}
|
||||
|
@ -260,11 +266,36 @@ open class BrowseAnimeSourcePresenter(
|
|||
anime.removeCovers(coverCache)
|
||||
} else {
|
||||
EpisodeSettingsHelper.applySettingDefaults(anime)
|
||||
|
||||
if (prefs.autoAddTrack()) {
|
||||
autoAddTrack(anime)
|
||||
}
|
||||
}
|
||||
|
||||
db.insertAnime(anime).executeAsBlocking()
|
||||
}
|
||||
|
||||
private fun autoAddTrack(anime: Anime) {
|
||||
loggedServices
|
||||
.filterIsInstance<UnattendedTrackService>()
|
||||
.filter { it.accept(source) }
|
||||
.forEach { service ->
|
||||
launchIO {
|
||||
try {
|
||||
service.match(anime)?.let { track ->
|
||||
track.anime_id = anime.id!!
|
||||
(service as TrackService).bind(track)
|
||||
db.insertTrack(track).executeAsBlocking()
|
||||
|
||||
syncEpisodesWithTrackServiceTwoWay(db, db.getEpisodes(anime).executeAsBlocking(), track, service as TrackService)
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
Timber.w(e, "Could not match anime: ${anime.title} with service $service")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the filter states for the current source.
|
||||
*
|
||||
|
|
|
@ -33,7 +33,7 @@ fun syncEpisodesWithTrackServiceTwoWay(db: AnimeDatabaseHelper, episodes: List<E
|
|||
|
||||
launchIO {
|
||||
try {
|
||||
service.updateAnime(remoteTrack)
|
||||
service.update(remoteTrack)
|
||||
db.insertTrack(remoteTrack).executeAsBlocking()
|
||||
} catch (e: Throwable) {
|
||||
Timber.w(e)
|
||||
|
|
|
@ -8,21 +8,13 @@
|
|||
android:fillType="evenOdd"
|
||||
android:pathData="M14.5,7L86.5,7A7,7 0,0 1,93.5 14L93.5,95A7,7 0,0 1,86.5 102L14.5,102A7,7 0,0 1,7.5 95L7.5,14A7,7 0,0 1,14.5 7z" />
|
||||
<path
|
||||
android:fillColor="#2E84BF"
|
||||
android:fillColor="#CE84BF"
|
||||
android:fillType="evenOdd"
|
||||
<<<<<<< HEAD
|
||||
android:fillColor="#CE84BF"/>
|
||||
=======
|
||||
android:pathData="M14.5,7L86.5,7A7,7 0,0 1,93.5 14L93.5,95A7,7 0,0 1,86.5 102L14.5,102A7,7 0,0 1,7.5 95L7.5,14A7,7 0,0 1,14.5 7z" />
|
||||
>>>>>>> pr17
|
||||
<path
|
||||
android:fillColor="#69A3CB"
|
||||
android:fillColor="#C9A3CB"
|
||||
android:fillType="evenOdd"
|
||||
<<<<<<< HEAD
|
||||
android:fillColor="#C9A3CB"/>
|
||||
=======
|
||||
android:pathData="M7.5,12.01C7.5,9.24 9.74,7 12.5,7L17.5,7L17.5,102L12.5,102C9.74,102 7.5,99.77 7.5,96.99L7.5,12.01Z" />
|
||||
>>>>>>> pr17
|
||||
<path
|
||||
android:fillColor="#000"
|
||||
android:fillType="evenOdd"
|
||||
|
@ -36,11 +28,7 @@
|
|||
android:fillType="evenOdd"
|
||||
android:pathData="M54,54.5m-19.94,0a19.94,19.94 0,1 1,39.87 0a19.94,19.94 0,1 1,-39.87 0" />
|
||||
<path
|
||||
<<<<<<< HEAD
|
||||
android:pathData="M47,41v28l22,-14z"
|
||||
=======
|
||||
android:fillColor="#000"
|
||||
>>>>>>> pr17
|
||||
android:fillType="evenOdd"
|
||||
android:pathData="M52.04,46.3L47.42,46.3C46.14,46.3 44.93,46.23 44.2,46.14L44.2,49.76C45,49.65 46.16,49.6 47.42,49.6L60.58,49.6C61.86,49.6 63.02,49.65 63.82,49.76L63.82,46.14C63.09,46.23 61.86,46.3 60.58,46.3L55.69,46.3L55.69,45.07C55.69,44.43 55.73,43.95 55.82,43.45L51.9,43.45C51.99,44 52.04,44.43 52.04,45.07L52.04,46.3ZM46.78,60.68C45.46,60.68 44.29,60.63 43.45,60.52L43.45,64.14C44.34,64.03 45.46,63.98 46.78,63.98L61.29,63.98C62.57,63.98 63.71,64.03 64.57,64.14L64.57,60.52C63.73,60.63 62.57,60.68 61.29,60.68L58.24,60.68C59.33,58.06 59.99,56.23 60.7,53.91C61.34,51.81 61.34,51.81 61.56,51.13L57.58,50.06C57.51,50.93 57.37,51.52 56.89,53.41C56.19,56.14 55.32,58.74 54.5,60.68L46.78,60.68ZM46.48,51.36C47.55,54.02 48.28,56.53 49.03,60.15L52.66,58.9C51.65,54.98 50.92,52.66 49.94,50.11L46.48,51.36Z" />
|
||||
android:pathData="M47,41v28l22,-14z" />
|
||||
</vector>
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:background="@drawable/selectable_item_background"
|
||||
android:paddingStart="16dp"
|
||||
android:paddingTop="4dp"
|
||||
android:paddingEnd="12dp"
|
||||
|
@ -28,7 +28,7 @@
|
|||
android:id="@+id/btn_episodes_filter"
|
||||
android:layout_width="28dp"
|
||||
android:layout_height="28dp"
|
||||
android:background="?selectableItemBackgroundBorderless"
|
||||
android:background="@drawable/ripple_regular"
|
||||
android:contentDescription="@string/action_filter"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:clipToPadding="false"
|
||||
android:paddingTop="4dp"
|
||||
android:paddingBottom="@dimen/action_toolbar_list_padding"
|
||||
tools:listitem="@layout/history_item" />
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@
|
|||
android:id="@+id/remove"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?selectableItemBackgroundBorderless"
|
||||
android:background="@drawable/ripple_regular"
|
||||
android:contentDescription="@string/action_remove"
|
||||
android:padding="8dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
|
@ -69,7 +69,7 @@
|
|||
android:id="@+id/resume"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?selectableItemBackgroundBorderless"
|
||||
android:background="@drawable/ripple_regular"
|
||||
android:contentDescription="@string/action_resume"
|
||||
android:padding="8dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
|
|
|
@ -142,7 +142,8 @@
|
|||
app:icon="@drawable/ic_favorite_border_24dp"
|
||||
app:layout_constraintEnd_toStartOf="@+id/btn_tracking"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/anime_info" />
|
||||
app:layout_constraintTop_toBottomOf="@+id/anime_info"
|
||||
app:rippleColor="?attr/rippleColor" />
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/btn_tracking"
|
||||
|
@ -155,6 +156,7 @@
|
|||
app:layout_constraintEnd_toStartOf="@+id/btn_webview"
|
||||
app:layout_constraintStart_toEndOf="@+id/btn_favorite"
|
||||
app:layout_constraintTop_toBottomOf="@+id/anime_info"
|
||||
app:rippleColor="?attr/rippleColor"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
|
@ -169,6 +171,7 @@
|
|||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@+id/btn_tracking"
|
||||
app:layout_constraintTop_toBottomOf="@+id/anime_info"
|
||||
app:rippleColor="?attr/rippleColor"
|
||||
tools:visibility="visible" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
|
|
@ -42,8 +42,8 @@
|
|||
android:layout_height="0dp"
|
||||
android:layout_gravity="top"
|
||||
android:layout_weight="1"
|
||||
android:paddingBottom="8dp"
|
||||
android:clipChildren="false"
|
||||
android:clipToPadding="false" />
|
||||
android:clipToPadding="false"
|
||||
android:paddingBottom="8dp" />
|
||||
|
||||
</LinearLayout>
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/material_component_lists_single_line_with_avatar_height"
|
||||
android:layout_height="56dp"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:background="@drawable/list_item_selector_background"
|
||||
android:paddingStart="8dp"
|
||||
|
@ -11,8 +11,8 @@
|
|||
|
||||
<ImageView
|
||||
android:id="@+id/thumbnail"
|
||||
android:layout_width="@dimen/material_component_lists_single_line_with_avatar_height"
|
||||
android:layout_height="@dimen/material_component_lists_single_line_with_avatar_height"
|
||||
android:layout_width="56dp"
|
||||
android:layout_height="56dp"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:padding="8dp"
|
||||
android:scaleType="centerCrop"
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:clipToPadding="false"
|
||||
android:paddingTop="4dp"
|
||||
android:paddingBottom="@dimen/action_toolbar_list_padding"
|
||||
tools:listitem="@layout/anime_updates_item" />
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/material_component_lists_two_line_height"
|
||||
android:layout_height="56dp"
|
||||
android:background="@drawable/list_item_selector_background"
|
||||
android:paddingEnd="4dp">
|
||||
|
||||
|
@ -55,8 +55,8 @@
|
|||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingStart="4dp"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent" />
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="42dp"
|
||||
android:layout_height="42dp"
|
||||
android:padding="8dp"
|
||||
android:background="?selectableItemBackgroundBorderless">
|
||||
android:background="@drawable/ripple_regular"
|
||||
android:padding="8dp">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/download_icon"
|
||||
|
@ -22,7 +22,6 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:padding="1dp"
|
||||
android:visibility="gone"
|
||||
android:progress="100"
|
||||
app:indicatorColor="?android:attr/textColorHint"
|
||||
app:indicatorInset="0dp"
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
android:id="@+id/title_wrapper"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/selectableItemBackground">
|
||||
android:background="@drawable/selectable_item_background">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/title"
|
||||
|
@ -46,7 +46,7 @@
|
|||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:contentDescription="@string/label_more"
|
||||
android:padding="@dimen/material_component_text_fields_padding_above_and_below_label"
|
||||
android:padding="16dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
|
@ -59,9 +59,9 @@
|
|||
android:id="@+id/no_results_found"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingStart="@dimen/material_component_text_fields_padding_above_and_below_label"
|
||||
android:paddingEnd="@dimen/material_component_text_fields_padding_above_and_below_label"
|
||||
android:paddingBottom="@dimen/material_component_text_fields_padding_above_and_below_label"
|
||||
android:paddingStart="16dp"
|
||||
android:paddingEnd="16dp"
|
||||
android:paddingBottom="16dp"
|
||||
android:text="@string/no_results_found"
|
||||
android:visibility="gone" />
|
||||
|
||||
|
|
|
@ -56,13 +56,8 @@
|
|||
android:id="@+id/remove"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
<<<<<<< HEAD
|
||||
android:background="?selectableItemBackgroundBorderless"
|
||||
android:contentDescription="@string/action_remove"
|
||||
=======
|
||||
android:background="@drawable/ripple_regular"
|
||||
android:contentDescription="@string/action_resume"
|
||||
>>>>>>> pr17
|
||||
android:contentDescription="@string/action_remove"
|
||||
android:padding="8dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@+id/resume"
|
||||
|
|
Loading…
Reference in a new issue