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