Merge remote-tracking branch 'origin/devel' into devel
This commit is contained in:
@@ -21,13 +21,15 @@ class Migration16To17(context: Context) : Migration(16, 17) {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
val name = source.name
|
val name = source.name
|
||||||
|
var isEnabled = name !in hiddenSources
|
||||||
var sortKey = order.indexOf(name)
|
var sortKey = order.indexOf(name)
|
||||||
if (sortKey == -1) {
|
if (sortKey == -1) {
|
||||||
sortKey = order.size + source.ordinal
|
sortKey = order.size + source.ordinal
|
||||||
|
isEnabled = false
|
||||||
}
|
}
|
||||||
database.execSQL(
|
database.execSQL(
|
||||||
"INSERT INTO `sources` (`source`, `enabled`, `sort_key`) VALUES (?, ?, ?)",
|
"INSERT INTO `sources` (`source`, `enabled`, `sort_key`) VALUES (?, ?, ?)",
|
||||||
arrayOf(name, (name !in hiddenSources).toInt(), sortKey),
|
arrayOf(name, isEnabled.toInt(), sortKey),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ class FavouritesCategoriesViewModel @Inject constructor(
|
|||||||
mangaCount = covers.size,
|
mangaCount = covers.size,
|
||||||
covers = covers.take(3),
|
covers = covers.take(3),
|
||||||
category = category,
|
category = category,
|
||||||
|
isTrackerEnabled = settings.isTrackerEnabled && AppSettings.TRACK_FAVOURITES in settings.trackSources,
|
||||||
)
|
)
|
||||||
}.ifEmpty {
|
}.ifEmpty {
|
||||||
listOf(
|
listOf(
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ class CategoryListModel(
|
|||||||
val mangaCount: Int,
|
val mangaCount: Int,
|
||||||
val covers: List<Cover>,
|
val covers: List<Cover>,
|
||||||
val category: FavouriteCategory,
|
val category: FavouriteCategory,
|
||||||
|
val isTrackerEnabled: Boolean,
|
||||||
) : ListModel {
|
) : ListModel {
|
||||||
|
|
||||||
override fun areItemsTheSame(other: ListModel): Boolean {
|
override fun areItemsTheSame(other: ListModel): Boolean {
|
||||||
@@ -21,6 +22,7 @@ class CategoryListModel(
|
|||||||
other as CategoryListModel
|
other as CategoryListModel
|
||||||
|
|
||||||
if (mangaCount != other.mangaCount) return false
|
if (mangaCount != other.mangaCount) return false
|
||||||
|
if (isTrackerEnabled != other.isTrackerEnabled) return false
|
||||||
if (covers != other.covers) return false
|
if (covers != other.covers) return false
|
||||||
if (category.id != other.category.id) return false
|
if (category.id != other.category.id) return false
|
||||||
if (category.title != other.category.title) return false
|
if (category.title != other.category.title) return false
|
||||||
@@ -33,6 +35,7 @@ class CategoryListModel(
|
|||||||
|
|
||||||
override fun hashCode(): Int {
|
override fun hashCode(): Int {
|
||||||
var result = mangaCount
|
var result = mangaCount
|
||||||
|
result = 31 * result + isTrackerEnabled.hashCode()
|
||||||
result = 31 * result + covers.hashCode()
|
result = 31 * result + covers.hashCode()
|
||||||
result = 31 * result + category.id.hashCode()
|
result = 31 * result + category.id.hashCode()
|
||||||
result = 31 * result + category.title.hashCode()
|
result = 31 * result + category.title.hashCode()
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import kotlinx.coroutines.flow.stateIn
|
|||||||
import kotlinx.coroutines.plus
|
import kotlinx.coroutines.plus
|
||||||
import org.koitharu.kotatsu.core.model.ids
|
import org.koitharu.kotatsu.core.model.ids
|
||||||
import org.koitharu.kotatsu.core.model.parcelable.ParcelableManga
|
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.ui.BaseViewModel
|
||||||
import org.koitharu.kotatsu.core.util.ext.require
|
import org.koitharu.kotatsu.core.util.ext.require
|
||||||
import org.koitharu.kotatsu.favourites.domain.FavouritesRepository
|
import org.koitharu.kotatsu.favourites.domain.FavouritesRepository
|
||||||
@@ -24,6 +25,7 @@ import javax.inject.Inject
|
|||||||
class MangaCategoriesViewModel @Inject constructor(
|
class MangaCategoriesViewModel @Inject constructor(
|
||||||
savedStateHandle: SavedStateHandle,
|
savedStateHandle: SavedStateHandle,
|
||||||
private val favouritesRepository: FavouritesRepository,
|
private val favouritesRepository: FavouritesRepository,
|
||||||
|
settings: AppSettings,
|
||||||
) : BaseViewModel() {
|
) : BaseViewModel() {
|
||||||
|
|
||||||
private val manga = savedStateHandle.require<List<ParcelableManga>>(KEY_MANGA_LIST).map { it.manga }
|
private val manga = savedStateHandle.require<List<ParcelableManga>>(KEY_MANGA_LIST).map { it.manga }
|
||||||
@@ -39,6 +41,7 @@ class MangaCategoriesViewModel @Inject constructor(
|
|||||||
MangaCategoryItem(
|
MangaCategoryItem(
|
||||||
category = it,
|
category = it,
|
||||||
isChecked = it.id in checked,
|
isChecked = it.id in checked,
|
||||||
|
isTrackerEnabled = settings.isTrackerEnabled && AppSettings.TRACK_FAVOURITES in settings.trackSources,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ fun mangaCategoryAD(
|
|||||||
bind { payloads ->
|
bind { payloads ->
|
||||||
binding.checkableImageView.setChecked(item.isChecked, ListModelDiffCallback.PAYLOAD_CHECKED_CHANGED !in payloads)
|
binding.checkableImageView.setChecked(item.isChecked, ListModelDiffCallback.PAYLOAD_CHECKED_CHANGED !in payloads)
|
||||||
binding.textViewTitle.text = item.category.title
|
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
|
binding.imageViewVisible.isVisible = item.category.isVisibleInLibrary
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import org.koitharu.kotatsu.list.ui.model.ListModel
|
|||||||
data class MangaCategoryItem(
|
data class MangaCategoryItem(
|
||||||
val category: FavouriteCategory,
|
val category: FavouriteCategory,
|
||||||
val isChecked: Boolean,
|
val isChecked: Boolean,
|
||||||
|
val isTrackerEnabled: Boolean,
|
||||||
) : ListModel {
|
) : ListModel {
|
||||||
|
|
||||||
override fun areItemsTheSame(other: ListModel): Boolean {
|
override fun areItemsTheSame(other: ListModel): Boolean {
|
||||||
|
|||||||
@@ -19,14 +19,14 @@
|
|||||||
<PreferenceScreen
|
<PreferenceScreen
|
||||||
android:fragment="org.koitharu.kotatsu.settings.SuggestionsSettingsFragment"
|
android:fragment="org.koitharu.kotatsu.settings.SuggestionsSettingsFragment"
|
||||||
android:key="suggestions"
|
android:key="suggestions"
|
||||||
android:title="@string/suggestions" />
|
android:title="@string/suggestions"
|
||||||
|
app:allowDividerAbove="true" />
|
||||||
|
|
||||||
<SwitchPreferenceCompat
|
<SwitchPreferenceCompat
|
||||||
android:defaultValue="true"
|
android:defaultValue="true"
|
||||||
android:key="related_manga"
|
android:key="related_manga"
|
||||||
android:summary="@string/related_manga_summary"
|
android:summary="@string/related_manga_summary"
|
||||||
android:title="@string/related_manga"
|
android:title="@string/related_manga" />
|
||||||
app:allowDividerAbove="true" />
|
|
||||||
|
|
||||||
<PreferenceCategory android:title="@string/tracking">
|
<PreferenceCategory android:title="@string/tracking">
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user