Option to disable reading progress indicators
This commit is contained in:
@@ -104,10 +104,13 @@ class AppSettings(context: Context) {
|
||||
val isReaderModeDetectionEnabled: Boolean
|
||||
get() = prefs.getBoolean(KEY_READER_MODE_DETECT, true)
|
||||
|
||||
var historyGrouping: Boolean
|
||||
var isHistoryGroupingEnabled: Boolean
|
||||
get() = prefs.getBoolean(KEY_HISTORY_GROUPING, true)
|
||||
set(value) = prefs.edit { putBoolean(KEY_HISTORY_GROUPING, value) }
|
||||
|
||||
val isReadingIndicatorsEnabled: Boolean
|
||||
get() = prefs.getBoolean(KEY_READING_INDICATORS, true)
|
||||
|
||||
val isHistoryExcludeNsfw: Boolean
|
||||
get() = prefs.getBoolean(KEY_HISTORY_EXCLUDE_NSFW, false)
|
||||
|
||||
@@ -303,6 +306,7 @@ class AppSettings(context: Context) {
|
||||
const val KEY_BACKUP = "backup"
|
||||
const val KEY_RESTORE = "restore"
|
||||
const val KEY_HISTORY_GROUPING = "history_grouping"
|
||||
const val KEY_READING_INDICATORS = "reading_indicators"
|
||||
const val KEY_REVERSE_CHAPTERS = "reverse_chapters"
|
||||
const val KEY_HISTORY_EXCLUDE_NSFW = "history_exclude_nsfw"
|
||||
const val KEY_PAGES_NUMBERS = "pages_numbers"
|
||||
|
||||
@@ -12,6 +12,7 @@ import org.koitharu.kotatsu.core.prefs.AppSettings
|
||||
import org.koitharu.kotatsu.favourites.domain.FavouritesRepository
|
||||
import org.koitharu.kotatsu.favourites.ui.list.FavouritesListFragment.Companion.NO_ID
|
||||
import org.koitharu.kotatsu.history.domain.HistoryRepository
|
||||
import org.koitharu.kotatsu.history.domain.PROGRESS_NONE
|
||||
import org.koitharu.kotatsu.list.domain.ListExtraProvider
|
||||
import org.koitharu.kotatsu.list.ui.MangaListViewModel
|
||||
import org.koitharu.kotatsu.list.ui.model.EmptyState
|
||||
@@ -27,7 +28,7 @@ class FavouritesListViewModel(
|
||||
private val repository: FavouritesRepository,
|
||||
private val trackingRepository: TrackingRepository,
|
||||
private val historyRepository: HistoryRepository,
|
||||
settings: AppSettings,
|
||||
private val settings: AppSettings,
|
||||
) : MangaListViewModel(settings), ListExtraProvider {
|
||||
|
||||
var sortOrder: LiveData<SortOrder?> = if (categoryId == NO_ID) {
|
||||
@@ -96,6 +97,10 @@ class FavouritesListViewModel(
|
||||
}
|
||||
|
||||
override suspend fun getProgress(mangaId: Long): Float {
|
||||
return historyRepository.getProgress(mangaId)
|
||||
return if (settings.isReadingIndicatorsEnabled) {
|
||||
historyRepository.getProgress(mangaId)
|
||||
} else {
|
||||
PROGRESS_NONE
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -17,6 +17,7 @@ import org.koitharu.kotatsu.core.prefs.observeAsFlow
|
||||
import org.koitharu.kotatsu.core.ui.DateTimeAgo
|
||||
import org.koitharu.kotatsu.history.domain.HistoryRepository
|
||||
import org.koitharu.kotatsu.history.domain.MangaWithHistory
|
||||
import org.koitharu.kotatsu.history.domain.PROGRESS_NONE
|
||||
import org.koitharu.kotatsu.list.ui.MangaListViewModel
|
||||
import org.koitharu.kotatsu.list.ui.model.*
|
||||
import org.koitharu.kotatsu.tracker.domain.TrackingRepository
|
||||
@@ -37,7 +38,7 @@ class HistoryListViewModel(
|
||||
val isGroupingEnabled = MutableLiveData<Boolean>()
|
||||
val onItemsRemoved = SingleLiveEvent<ReversibleHandle>()
|
||||
|
||||
private val historyGrouping = settings.observeAsFlow(AppSettings.KEY_HISTORY_GROUPING) { historyGrouping }
|
||||
private val historyGrouping = settings.observeAsFlow(AppSettings.KEY_HISTORY_GROUPING) { isHistoryGroupingEnabled }
|
||||
.onEach { isGroupingEnabled.postValue(it) }
|
||||
|
||||
override val content = combine(
|
||||
@@ -89,7 +90,7 @@ class HistoryListViewModel(
|
||||
}
|
||||
|
||||
fun setGrouping(isGroupingEnabled: Boolean) {
|
||||
settings.historyGrouping = isGroupingEnabled
|
||||
settings.isHistoryGroupingEnabled = isGroupingEnabled
|
||||
}
|
||||
|
||||
private suspend fun mapList(
|
||||
@@ -98,6 +99,7 @@ class HistoryListViewModel(
|
||||
mode: ListMode
|
||||
): List<ListModel> {
|
||||
val result = ArrayList<ListModel>(if (grouped) (list.size * 1.4).toInt() else list.size + 1)
|
||||
val showPercent = settings.isReadingIndicatorsEnabled
|
||||
var prevDate: DateTimeAgo? = null
|
||||
if (!grouped) {
|
||||
result += ListHeader(null, R.string.history, null)
|
||||
@@ -111,10 +113,11 @@ class HistoryListViewModel(
|
||||
prevDate = date
|
||||
}
|
||||
val counter = trackingRepository.getNewChaptersCount(manga.id)
|
||||
val percent = if (showPercent) history.percent else PROGRESS_NONE
|
||||
result += when (mode) {
|
||||
ListMode.LIST -> manga.toListModel(counter, history.percent)
|
||||
ListMode.DETAILED_LIST -> manga.toListDetailedModel(counter, history.percent)
|
||||
ListMode.GRID -> manga.toGridModel(counter, history.percent)
|
||||
ListMode.LIST -> manga.toListModel(counter, percent)
|
||||
ListMode.DETAILED_LIST -> manga.toListDetailedModel(counter, percent)
|
||||
ListMode.GRID -> manga.toGridModel(counter, percent)
|
||||
}
|
||||
}
|
||||
return result
|
||||
|
||||
Reference in New Issue
Block a user