Refactor show history and updates buttons
This commit is contained in:
parent
34c16015e5
commit
57dde4c922
@ -379,9 +379,9 @@ object PreferenceKeys {
|
||||
|
||||
const val bottomBarLabels = "pref_show_bottom_bar_labels"
|
||||
|
||||
const val hideUpdatesButton = "pref_hide_updates_button"
|
||||
const val showNavUpdates = "pref_show_updates_button"
|
||||
|
||||
const val hideHistoryButton = "pref_hide_history_button"
|
||||
const val showNavHistory = "pref_show_history_button"
|
||||
|
||||
const val pageLayout = "page_layout"
|
||||
|
||||
|
@ -494,9 +494,9 @@ class PreferencesHelper(val context: Context) {
|
||||
|
||||
fun bottomBarLabels() = flowPrefs.getBoolean(Keys.bottomBarLabels, true)
|
||||
|
||||
fun hideUpdatesButton() = flowPrefs.getBoolean(Keys.hideUpdatesButton, false)
|
||||
fun showNavUpdates() = flowPrefs.getBoolean(Keys.showNavUpdates, true)
|
||||
|
||||
fun hideHistoryButton() = flowPrefs.getBoolean(Keys.hideHistoryButton, false)
|
||||
fun showNavHistory() = flowPrefs.getBoolean(Keys.showNavHistory, true)
|
||||
|
||||
fun pageLayout() = flowPrefs.getInt(Keys.pageLayout, PagerConfig.PageLayout.AUTOMATIC)
|
||||
|
||||
|
@ -223,7 +223,7 @@ class MigrationListController(bundle: Bundle? = null) :
|
||||
} else {
|
||||
source.getChapterList(localManga.toMangaInfo())
|
||||
}.map { it.toSChapter() }
|
||||
} catch (e: java.lang.Exception) {
|
||||
} catch (e: Exception) {
|
||||
Timber.e(e)
|
||||
emptyList()
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.os.Looper
|
||||
import android.view.Gravity
|
||||
import android.view.Menu
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.Toast
|
||||
@ -525,10 +526,9 @@ class MainActivity : BaseViewBindingActivity<MainActivityBinding>() {
|
||||
if (visible) {
|
||||
if (collapse) {
|
||||
bottomNavAnimator?.expand()
|
||||
val navUpdates = it.menu.findItem(R.id.nav_updates)
|
||||
navUpdates.isVisible = !preferences.hideUpdatesButton().get()
|
||||
val navHistory = it.menu.findItem(R.id.nav_history)
|
||||
navHistory.isVisible = !preferences.hideHistoryButton().get()
|
||||
// SY -->
|
||||
updateNavMenu(it.menu)
|
||||
// SY <--
|
||||
}
|
||||
|
||||
bottomViewNavigationBehavior?.slideUp(it)
|
||||
@ -545,9 +545,19 @@ class MainActivity : BaseViewBindingActivity<MainActivityBinding>() {
|
||||
private fun showSideNav(visible: Boolean) {
|
||||
binding.sideNav?.let {
|
||||
it.isVisible = visible
|
||||
// SY -->
|
||||
updateNavMenu(it.menu)
|
||||
// SY <--
|
||||
}
|
||||
}
|
||||
|
||||
// SY -->
|
||||
private fun updateNavMenu(menu: Menu) {
|
||||
menu.findItem(R.id.nav_updates).isVisible = preferences.showNavUpdates().get()
|
||||
menu.findItem(R.id.nav_history).isVisible = preferences.showNavHistory().get()
|
||||
}
|
||||
// SY <--
|
||||
|
||||
/**
|
||||
* Used to manually offset a view within the activity's child views that might be cut off due to
|
||||
* the collapsing AppBarLayout.
|
||||
|
@ -76,7 +76,7 @@ class MoreController :
|
||||
}
|
||||
|
||||
preferenceCategory {
|
||||
if (preferences.hideUpdatesButton().get()) {
|
||||
if (!preferences.showNavUpdates().get()) {
|
||||
preference {
|
||||
titleRes = R.string.label_recent_updates
|
||||
iconRes = R.drawable.ic_updates_outline_24dp
|
||||
@ -86,7 +86,7 @@ class MoreController :
|
||||
}
|
||||
}
|
||||
}
|
||||
if (preferences.hideHistoryButton().get()) {
|
||||
if (!preferences.showNavHistory().get()) {
|
||||
preference {
|
||||
titleRes = R.string.label_recent_manga
|
||||
iconRes = R.drawable.ic_history_24dp
|
||||
|
@ -451,7 +451,7 @@ class ReaderPresenter(
|
||||
val shouldTrack = !incognitoMode || hasTrackers
|
||||
if (
|
||||
(selectedChapter.pages?.lastIndex == page.index && shouldTrack) ||
|
||||
(hasExtraPage && selectedChapter.pages?.lastIndex?.minus(1) == page.index && shouldTrack)
|
||||
(hasExtraPage && selectedChapter.pages?.lastIndex?.minus(1) == page.index && shouldTrack)
|
||||
) {
|
||||
selectedChapter.chapter.read = true
|
||||
// SY -->
|
||||
|
@ -61,12 +61,12 @@ class SettingsGeneralController : SettingsController() {
|
||||
}
|
||||
}
|
||||
switchPreference {
|
||||
key = Keys.hideUpdatesButton
|
||||
key = Keys.showNavUpdates
|
||||
titleRes = R.string.pref_hide_updates_button
|
||||
defaultValue = false
|
||||
}
|
||||
switchPreference {
|
||||
key = Keys.hideHistoryButton
|
||||
key = Keys.showNavHistory
|
||||
titleRes = R.string.pref_hide_history_button
|
||||
defaultValue = false
|
||||
}
|
||||
|
@ -136,10 +136,10 @@ fun syncChaptersWithSource(
|
||||
if (manga.isEhBasedManga()) {
|
||||
val finalAdded = toAdd.subtract(readded)
|
||||
if (finalAdded.isNotEmpty()) {
|
||||
val max = dbChapters.maxByOrNull { it.last_page_read }
|
||||
if (max != null && max.last_page_read > 0) {
|
||||
for (chapter in finalAdded) {
|
||||
chapter.last_page_read = max.last_page_read
|
||||
val max = dbChapters.maxOfOrNull { it.last_page_read }
|
||||
if (max != null && max > 0) {
|
||||
finalAdded.forEach { chapter ->
|
||||
chapter.last_page_read = max
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -110,7 +110,7 @@ class EHentaiUpdateHelper(context: Context) {
|
||||
.fold(accepted.chapters) { curChapters, chapter ->
|
||||
val existing = curChapters.find { it.url == chapter.url }
|
||||
|
||||
val newLastPageRead = chainsAsChapters.maxByOrNull { it.last_page_read }?.last_page_read
|
||||
val newLastPageRead = chainsAsChapters.maxOfOrNull { it.last_page_read }
|
||||
|
||||
if (existing != null) {
|
||||
existing.read = existing.read || chapter.read
|
||||
|
@ -118,14 +118,14 @@ class MangaHandler(
|
||||
|
||||
suspend fun getTrackingInfo(track: Track): Pair<Track, MangaDexSearchMetadata?> {
|
||||
return withIOContext {
|
||||
val metadata = async {
|
||||
/*val metadata = async {
|
||||
val mangaUrl = MdUtil.buildMangaUrl(MdUtil.getMangaId(track.tracking_url))
|
||||
val manga = MangaInfo(mangaUrl, track.title)
|
||||
val response = client.newCall(mangaRequest(manga)).await()
|
||||
val metadata = MangaDexSearchMetadata()
|
||||
apiMangaParser.parseIntoMetadata(metadata, response, emptyList())
|
||||
metadata
|
||||
}
|
||||
}*/
|
||||
val remoteTrack = async {
|
||||
followsHandler.fetchTrackingInfo(track.tracking_url)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user