Hide categories notification indicators if tracking disabled

This commit is contained in:
Koitharu
2023-08-17 17:00:48 +03:00
parent 20a7e5a6a8
commit 91266183c2
6 changed files with 12 additions and 4 deletions

View File

@@ -35,6 +35,7 @@ class FavouritesCategoriesViewModel @Inject constructor(
mangaCount = covers.size,
covers = covers.take(3),
category = category,
isTrackerEnabled = settings.isTrackerEnabled && AppSettings.TRACK_FAVOURITES in settings.trackSources,
)
}.ifEmpty {
listOf(

View File

@@ -8,6 +8,7 @@ class CategoryListModel(
val mangaCount: Int,
val covers: List<Cover>,
val category: FavouriteCategory,
val isTrackerEnabled: Boolean,
) : ListModel {
override fun areItemsTheSame(other: ListModel): Boolean {
@@ -21,6 +22,7 @@ class CategoryListModel(
other as CategoryListModel
if (mangaCount != other.mangaCount) return false
if (isTrackerEnabled != other.isTrackerEnabled) return false
if (covers != other.covers) return false
if (category.id != other.category.id) return false
if (category.title != other.category.title) return false
@@ -33,6 +35,7 @@ class CategoryListModel(
override fun hashCode(): Int {
var result = mangaCount
result = 31 * result + isTrackerEnabled.hashCode()
result = 31 * result + covers.hashCode()
result = 31 * result + category.id.hashCode()
result = 31 * result + category.title.hashCode()

View File

@@ -11,6 +11,7 @@ import kotlinx.coroutines.flow.stateIn
import kotlinx.coroutines.plus
import org.koitharu.kotatsu.core.model.ids
import org.koitharu.kotatsu.core.model.parcelable.ParcelableManga
import org.koitharu.kotatsu.core.prefs.AppSettings
import org.koitharu.kotatsu.core.ui.BaseViewModel
import org.koitharu.kotatsu.core.util.ext.require
import org.koitharu.kotatsu.favourites.domain.FavouritesRepository
@@ -24,6 +25,7 @@ import javax.inject.Inject
class MangaCategoriesViewModel @Inject constructor(
savedStateHandle: SavedStateHandle,
private val favouritesRepository: FavouritesRepository,
settings: AppSettings,
) : BaseViewModel() {
private val manga = savedStateHandle.require<List<ParcelableManga>>(KEY_MANGA_LIST).map { it.manga }
@@ -39,6 +41,7 @@ class MangaCategoriesViewModel @Inject constructor(
MangaCategoryItem(
category = it,
isChecked = it.id in checked,
isTrackerEnabled = settings.isTrackerEnabled && AppSettings.TRACK_FAVOURITES in settings.trackSources,
)
}
}

View File

@@ -22,7 +22,7 @@ fun mangaCategoryAD(
bind { payloads ->
binding.checkableImageView.setChecked(item.isChecked, ListModelDiffCallback.PAYLOAD_CHECKED_CHANGED !in payloads)
binding.textViewTitle.text = item.category.title
binding.imageViewTracker.isVisible = item.category.isTrackingEnabled
binding.imageViewTracker.isVisible = item.category.isTrackingEnabled && item.isTrackerEnabled
binding.imageViewVisible.isVisible = item.category.isVisibleInLibrary
}
}

View File

@@ -7,6 +7,7 @@ import org.koitharu.kotatsu.list.ui.model.ListModel
data class MangaCategoryItem(
val category: FavouriteCategory,
val isChecked: Boolean,
val isTrackerEnabled: Boolean,
) : ListModel {
override fun areItemsTheSame(other: ListModel): Boolean {

View File

@@ -19,14 +19,14 @@
<PreferenceScreen
android:fragment="org.koitharu.kotatsu.settings.SuggestionsSettingsFragment"
android:key="suggestions"
android:title="@string/suggestions" />
android:title="@string/suggestions"
app:allowDividerAbove="true" />
<SwitchPreferenceCompat
android:defaultValue="true"
android:key="related_manga"
android:summary="@string/related_manga_summary"
android:title="@string/related_manga"
app:allowDividerAbove="true" />
android:title="@string/related_manga" />
<PreferenceCategory android:title="@string/tracking">