mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-19 04:29:19 +01:00
Hide tracking when no tracker is logged in and change filter logic (#4310)
* Hide tracking when not logged in * Change string name and value
This commit is contained in:
parent
4044427d93
commit
1a5858e99b
@ -118,6 +118,7 @@ class LibraryPresenter(
|
|||||||
val filterUnread = preferences.filterUnread().get()
|
val filterUnread = preferences.filterUnread().get()
|
||||||
val filterCompleted = preferences.filterCompleted().get()
|
val filterCompleted = preferences.filterCompleted().get()
|
||||||
val tracking = preferences.filterTracking().get()
|
val tracking = preferences.filterTracking().get()
|
||||||
|
val isNotLogged = !trackManager.hasLoggedServices()
|
||||||
|
|
||||||
val filterFnUnread: (LibraryItem) -> Boolean = unread@{ item ->
|
val filterFnUnread: (LibraryItem) -> Boolean = unread@{ item ->
|
||||||
if (filterUnread == State.IGNORE.value) return@unread true
|
if (filterUnread == State.IGNORE.value) return@unread true
|
||||||
@ -148,7 +149,7 @@ class LibraryPresenter(
|
|||||||
}
|
}
|
||||||
|
|
||||||
val filterFnTracking: (LibraryItem) -> Boolean = tracking@{ item ->
|
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
|
val isTracking = trackMap[item.manga.id ?: -1] ?: false
|
||||||
|
|
||||||
@ -310,9 +311,12 @@ class LibraryPresenter(
|
|||||||
*/
|
*/
|
||||||
private fun getTracksObservable(): Observable<Map<Long, Boolean>> {
|
private fun getTracksObservable(): Observable<Map<Long, Boolean>> {
|
||||||
return db.getTracks().asRxObservable().map { tracks ->
|
return db.getTracks().asRxObservable().map { tracks ->
|
||||||
tracks.associate { track ->
|
tracks.groupBy { it.manga_id }
|
||||||
val isLogged = tracks.any { trackManager.getService(it.sync_id)?.isLogged ?: false }
|
.mapValues { tracksForMangaId ->
|
||||||
Pair(track.manga_id, isLogged)
|
// Check if any of the trackers is logged in for the current manga id
|
||||||
|
tracksForMangaId.value.any {
|
||||||
|
trackManager.getService(it.sync_id)?.isLogged ?: false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}.observeOn(Schedulers.io())
|
}.observeOn(Schedulers.io())
|
||||||
}
|
}
|
||||||
|
@ -7,10 +7,12 @@ import com.bluelinelabs.conductor.Router
|
|||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferenceValues.DisplayMode
|
import eu.kanade.tachiyomi.data.preference.PreferenceValues.DisplayMode
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||||
|
import eu.kanade.tachiyomi.data.track.TrackManager
|
||||||
import eu.kanade.tachiyomi.widget.ExtendedNavigationView
|
import eu.kanade.tachiyomi.widget.ExtendedNavigationView
|
||||||
import eu.kanade.tachiyomi.widget.ExtendedNavigationView.Item.TriStateGroup.State
|
import eu.kanade.tachiyomi.widget.ExtendedNavigationView.Item.TriStateGroup.State
|
||||||
import eu.kanade.tachiyomi.widget.TabbedBottomSheetDialog
|
import eu.kanade.tachiyomi.widget.TabbedBottomSheetDialog
|
||||||
import uy.kohesive.injekt.injectLazy
|
import uy.kohesive.injekt.injectLazy
|
||||||
|
import uy.kohesive.injekt.injectValue
|
||||||
|
|
||||||
class LibrarySettingsSheet(
|
class LibrarySettingsSheet(
|
||||||
router: Router,
|
router: Router,
|
||||||
@ -52,6 +54,8 @@ class LibrarySettingsSheet(
|
|||||||
|
|
||||||
private val filterGroup = FilterGroup()
|
private val filterGroup = FilterGroup()
|
||||||
|
|
||||||
|
private val trackManager: TrackManager by injectValue()
|
||||||
|
|
||||||
init {
|
init {
|
||||||
setGroups(listOf(filterGroup))
|
setGroups(listOf(filterGroup))
|
||||||
}
|
}
|
||||||
@ -68,7 +72,7 @@ class LibrarySettingsSheet(
|
|||||||
private val downloaded = Item.TriStateGroup(R.string.action_filter_downloaded, this)
|
private val downloaded = Item.TriStateGroup(R.string.action_filter_downloaded, this)
|
||||||
private val unread = Item.TriStateGroup(R.string.action_filter_unread, this)
|
private val unread = Item.TriStateGroup(R.string.action_filter_unread, this)
|
||||||
private val completed = Item.TriStateGroup(R.string.completed, 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)
|
||||||
|
|
||||||
override val header = null
|
override val header = null
|
||||||
override val items = listOf(downloaded, unread, completed, tracking)
|
override val items = listOf(downloaded, unread, completed, tracking)
|
||||||
@ -83,7 +87,14 @@ class LibrarySettingsSheet(
|
|||||||
}
|
}
|
||||||
unread.state = preferences.filterUnread().get()
|
unread.state = preferences.filterUnread().get()
|
||||||
completed.state = preferences.filterCompleted().get()
|
completed.state = preferences.filterCompleted().get()
|
||||||
|
|
||||||
|
if (!trackManager.hasLoggedServices()) {
|
||||||
|
tracking.state = State.IGNORE.value
|
||||||
|
tracking.isVisible = false
|
||||||
|
} else {
|
||||||
tracking.state = preferences.filterTracking().get()
|
tracking.state = preferences.filterTracking().get()
|
||||||
|
tracking.isVisible = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onItemClicked(item: Item) {
|
override fun onItemClicked(item: Item) {
|
||||||
|
@ -8,6 +8,7 @@ import androidx.annotation.AttrRes
|
|||||||
import androidx.annotation.CallSuper
|
import androidx.annotation.CallSuper
|
||||||
import androidx.appcompat.content.res.AppCompatResources
|
import androidx.appcompat.content.res.AppCompatResources
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
|
import androidx.core.view.isVisible
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.util.system.getResourceColor
|
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).
|
* 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.
|
* Returns the drawable associated to every possible each state.
|
||||||
@ -258,6 +259,7 @@ open class ExtendedNavigationView @JvmOverloads constructor(
|
|||||||
|
|
||||||
// Mimics checkbox/radio button
|
// Mimics checkbox/radio button
|
||||||
holder.text.alpha = if (item.enabled) 1f else 0.4f
|
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">Filter</string>
|
||||||
<string name="action_filter_downloaded">Downloaded</string>
|
<string name="action_filter_downloaded">Downloaded</string>
|
||||||
<string name="action_filter_bookmarked">Bookmarked</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_unread">Unread</string>
|
||||||
<string name="action_filter_empty">Remove filter</string>
|
<string name="action_filter_empty">Remove filter</string>
|
||||||
<string name="action_sort_alpha">Alphabetically</string>
|
<string name="action_sort_alpha">Alphabetically</string>
|
||||||
|
Loading…
Reference in New Issue
Block a user