Hide tracking when no tracker is logged in and change filter logic (#4310)
* Hide tracking when not logged in * Change string name and value (cherry picked from commit 1a5858e99ba98482a6470c7f70b2e4c43323940f) # Conflicts: # app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryPresenter.kt # app/src/main/java/eu/kanade/tachiyomi/ui/library/LibrarySettingsSheet.kt
This commit is contained in:
parent
34f8407983
commit
2b8a0f2215
@ -165,6 +165,7 @@ class LibraryPresenter(
|
||||
val filterUnread = preferences.filterUnread().get()
|
||||
val filterCompleted = preferences.filterCompleted().get()
|
||||
val tracking = preferences.filterTracking().get()
|
||||
val isNotLogged = !trackManager.hasLoggedServices()
|
||||
// SY -->
|
||||
val filterStarted = preferences.filterStarted().get()
|
||||
val filterLewd = preferences.filterLewd().get()
|
||||
@ -199,7 +200,7 @@ class LibraryPresenter(
|
||||
}
|
||||
|
||||
val filterFnTracking: (LibraryItem) -> Boolean = tracking@{ item ->
|
||||
if (tracking == State.IGNORE.value) return@tracking true
|
||||
if (isNotLogged || tracking == State.IGNORE.value) return@tracking true
|
||||
|
||||
val isTracking = trackMap[item.manga.id ?: -1] ?: false
|
||||
|
||||
@ -448,10 +449,13 @@ class LibraryPresenter(
|
||||
*/
|
||||
private fun getTracksObservable(): Observable<Map<Long, Boolean>> {
|
||||
return db.getTracks().asRxObservable().map { tracks ->
|
||||
tracks.associate { track ->
|
||||
val isLogged = tracks.any { trackManager.getService(it.sync_id)?.let { tracker -> tracker.isLogged && ((tracker.id == TrackManager.MDLIST && track.status != FollowStatus.UNFOLLOWED.int) || tracker.id != TrackManager.MDLIST) } ?: false }
|
||||
Pair(track.manga_id, isLogged)
|
||||
}
|
||||
tracks.groupBy { it.manga_id }
|
||||
.mapValues { tracksForMangaId ->
|
||||
// Check if any of the trackers is logged in for the current manga id
|
||||
tracksForMangaId.value.any {
|
||||
trackManager.getService(it.sync_id)?.let { tracker -> tracker.isLogged && ((tracker.id == TrackManager.MDLIST && it.status != FollowStatus.UNFOLLOWED.int) || tracker.id != TrackManager.MDLIST) } ?: false
|
||||
}
|
||||
}
|
||||
}.observeOn(Schedulers.io())
|
||||
}
|
||||
|
||||
|
@ -15,6 +15,7 @@ import eu.kanade.tachiyomi.widget.TabbedBottomSheetDialog
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
import uy.kohesive.injekt.injectValue
|
||||
|
||||
class LibrarySettingsSheet(
|
||||
router: Router,
|
||||
@ -66,6 +67,8 @@ class LibrarySettingsSheet(
|
||||
|
||||
private val filterGroup = FilterGroup()
|
||||
|
||||
private val trackManager: TrackManager by injectValue()
|
||||
|
||||
init {
|
||||
setGroups(listOf(filterGroup))
|
||||
}
|
||||
@ -82,7 +85,7 @@ class LibrarySettingsSheet(
|
||||
private val downloaded = Item.TriStateGroup(R.string.action_filter_downloaded, this)
|
||||
private val unread = Item.TriStateGroup(R.string.action_filter_unread, this)
|
||||
private val completed = Item.TriStateGroup(R.string.completed, this)
|
||||
private val tracking = Item.TriStateGroup(R.string.action_filter_tracking, this)
|
||||
private val tracking = Item.TriStateGroup(R.string.action_filter_tracked, this)
|
||||
|
||||
// SY -->
|
||||
private val started = Item.TriStateGroup(R.string.started, this)
|
||||
@ -92,13 +95,7 @@ class LibrarySettingsSheet(
|
||||
override val header = null
|
||||
|
||||
// SY -->
|
||||
override val items = (
|
||||
if (Injekt.get<TrackManager>().hasLoggedServices()) {
|
||||
listOf(downloaded, unread, completed, tracking, started, lewd)
|
||||
} else {
|
||||
listOf(downloaded, unread, completed, started, lewd)
|
||||
}
|
||||
)
|
||||
override val items = listOf(downloaded, unread, completed, tracking, started, lewd)
|
||||
|
||||
// SY <--
|
||||
override val footer = null
|
||||
@ -112,7 +109,15 @@ class LibrarySettingsSheet(
|
||||
}
|
||||
unread.state = preferences.filterUnread().get()
|
||||
completed.state = preferences.filterCompleted().get()
|
||||
tracking.state = preferences.filterTracking().get()
|
||||
|
||||
if (!trackManager.hasLoggedServices()) {
|
||||
tracking.state = State.IGNORE.value
|
||||
tracking.isVisible = false
|
||||
} else {
|
||||
tracking.state = preferences.filterTracking().get()
|
||||
tracking.isVisible = true
|
||||
}
|
||||
|
||||
// SY -->
|
||||
started.state = preferences.filterStarted().get()
|
||||
lewd.state = preferences.filterLewd().get()
|
||||
|
@ -8,6 +8,7 @@ import androidx.annotation.AttrRes
|
||||
import androidx.annotation.CallSuper
|
||||
import androidx.appcompat.content.res.AppCompatResources
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.util.system.getResourceColor
|
||||
@ -59,7 +60,7 @@ open class ExtendedNavigationView @JvmOverloads constructor(
|
||||
/**
|
||||
* An item with which needs more than two states (selected/deselected).
|
||||
*/
|
||||
abstract class MultiState(val resTitle: Int, var state: Int = 0, var enabled: Boolean = true) : Item() {
|
||||
abstract class MultiState(val resTitle: Int, var state: Int = 0, var enabled: Boolean = true, var isVisible: Boolean = true) : Item() {
|
||||
|
||||
/**
|
||||
* Returns the drawable associated to every possible each state.
|
||||
@ -276,6 +277,7 @@ open class ExtendedNavigationView @JvmOverloads constructor(
|
||||
|
||||
// Mimics checkbox/radio button
|
||||
holder.text.alpha = if (item.enabled) 1f else 0.4f
|
||||
holder.itemView.isVisible = item.isVisible
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -34,7 +34,7 @@
|
||||
<string name="action_filter">Filter</string>
|
||||
<string name="action_filter_downloaded">Downloaded</string>
|
||||
<string name="action_filter_bookmarked">Bookmarked</string>
|
||||
<string name="action_filter_tracking">Tracking</string>
|
||||
<string name="action_filter_tracked">Tracked</string>
|
||||
<string name="action_filter_unread">Unread</string>
|
||||
<string name="action_filter_empty">Remove filter</string>
|
||||
<string name="action_sort_alpha">Alphabetically</string>
|
||||
|
Loading…
x
Reference in New Issue
Block a user