Fix library column setting jumping in
This commit is contained in:
parent
1b2c12385f
commit
f6f5b6aeab
@ -35,7 +35,7 @@ import eu.kanade.tachiyomi.data.preference.PreferenceValues
|
|||||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||||
import eu.kanade.tachiyomi.network.NetworkHelper
|
import eu.kanade.tachiyomi.network.NetworkHelper
|
||||||
import eu.kanade.tachiyomi.ui.base.delegate.SecureActivityDelegate
|
import eu.kanade.tachiyomi.ui.base.delegate.SecureActivityDelegate
|
||||||
import eu.kanade.tachiyomi.util.preference.asImmediateFlow
|
import eu.kanade.tachiyomi.util.preference.asHotFlow
|
||||||
import eu.kanade.tachiyomi.util.system.AuthenticatorUtil
|
import eu.kanade.tachiyomi.util.system.AuthenticatorUtil
|
||||||
import eu.kanade.tachiyomi.util.system.WebViewUtil
|
import eu.kanade.tachiyomi.util.system.WebViewUtil
|
||||||
import eu.kanade.tachiyomi.util.system.animatorDurationScale
|
import eu.kanade.tachiyomi.util.system.animatorDurationScale
|
||||||
@ -114,7 +114,7 @@ class App : Application(), DefaultLifecycleObserver, ImageLoaderFactory {
|
|||||||
.launchIn(ProcessLifecycleOwner.get().lifecycleScope)
|
.launchIn(ProcessLifecycleOwner.get().lifecycleScope)
|
||||||
|
|
||||||
preferences.themeMode()
|
preferences.themeMode()
|
||||||
.asImmediateFlow {
|
.asHotFlow {
|
||||||
AppCompatDelegate.setDefaultNightMode(
|
AppCompatDelegate.setDefaultNightMode(
|
||||||
when (it) {
|
when (it) {
|
||||||
PreferenceValues.ThemeMode.light -> AppCompatDelegate.MODE_NIGHT_NO
|
PreferenceValues.ThemeMode.light -> AppCompatDelegate.MODE_NIGHT_NO
|
||||||
|
@ -45,7 +45,7 @@ import eu.kanade.tachiyomi.ui.more.MoreController
|
|||||||
import eu.kanade.tachiyomi.ui.webview.WebViewActivity
|
import eu.kanade.tachiyomi.ui.webview.WebViewActivity
|
||||||
import eu.kanade.tachiyomi.util.lang.launchIO
|
import eu.kanade.tachiyomi.util.lang.launchIO
|
||||||
import eu.kanade.tachiyomi.util.lang.withUIContext
|
import eu.kanade.tachiyomi.util.lang.withUIContext
|
||||||
import eu.kanade.tachiyomi.util.preference.asImmediateFlow
|
import eu.kanade.tachiyomi.util.preference.asHotFlow
|
||||||
import eu.kanade.tachiyomi.util.system.connectivityManager
|
import eu.kanade.tachiyomi.util.system.connectivityManager
|
||||||
import eu.kanade.tachiyomi.util.system.logcat
|
import eu.kanade.tachiyomi.util.system.logcat
|
||||||
import eu.kanade.tachiyomi.util.system.openInBrowser
|
import eu.kanade.tachiyomi.util.system.openInBrowser
|
||||||
@ -218,7 +218,7 @@ open class BrowseSourceController(bundle: Bundle) :
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
(binding.catalogueView.inflate(R.layout.source_recycler_autofit) as AutofitRecyclerView).apply {
|
(binding.catalogueView.inflate(R.layout.source_recycler_autofit) as AutofitRecyclerView).apply {
|
||||||
numColumnsJob = getColumnsPreferenceForCurrentOrientation().asImmediateFlow { spanCount = it }
|
numColumnsJob = getColumnsPreferenceForCurrentOrientation().asHotFlow { spanCount = it }
|
||||||
.drop(1)
|
.drop(1)
|
||||||
// Set again the adapter to recalculate the covers height
|
// Set again the adapter to recalculate the covers height
|
||||||
.onEach { adapter = this@BrowseSourceController.adapter }
|
.onEach { adapter = this@BrowseSourceController.adapter }
|
||||||
|
@ -32,6 +32,7 @@ import eu.kanade.tachiyomi.ui.main.MainActivity
|
|||||||
import eu.kanade.tachiyomi.ui.manga.MangaController
|
import eu.kanade.tachiyomi.ui.manga.MangaController
|
||||||
import eu.kanade.tachiyomi.util.lang.launchIO
|
import eu.kanade.tachiyomi.util.lang.launchIO
|
||||||
import eu.kanade.tachiyomi.util.lang.launchUI
|
import eu.kanade.tachiyomi.util.lang.launchUI
|
||||||
|
import eu.kanade.tachiyomi.util.preference.asHotFlow
|
||||||
import eu.kanade.tachiyomi.util.system.getResourceColor
|
import eu.kanade.tachiyomi.util.system.getResourceColor
|
||||||
import eu.kanade.tachiyomi.util.system.openInBrowser
|
import eu.kanade.tachiyomi.util.system.openInBrowser
|
||||||
import eu.kanade.tachiyomi.util.system.toast
|
import eu.kanade.tachiyomi.util.system.toast
|
||||||
@ -71,14 +72,8 @@ class LibraryController(
|
|||||||
*/
|
*/
|
||||||
private var actionMode: ActionModeWithToolbar? = null
|
private var actionMode: ActionModeWithToolbar? = null
|
||||||
|
|
||||||
/**
|
private var mangaMap: LibraryMap = emptyMap()
|
||||||
* Relay to notify the library's viewpager for updates.
|
|
||||||
*/
|
|
||||||
val libraryMangaRelay: BehaviorRelay<LibraryMangaEvent> = BehaviorRelay.create()
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Adapter of the view pager.
|
|
||||||
*/
|
|
||||||
private var adapter: LibraryAdapter? = null
|
private var adapter: LibraryAdapter? = null
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -121,11 +116,9 @@ class LibraryController(
|
|||||||
currentCategory?.name
|
currentCategory?.name
|
||||||
}
|
}
|
||||||
|
|
||||||
if (preferences.categoryNumberOfItems().get() && libraryMangaRelay.hasValue()) {
|
if (preferences.categoryNumberOfItems().get()) {
|
||||||
libraryMangaRelay.value.mangas.let { mangaMap ->
|
if (!showCategoryTabs || adapter?.categories?.size == 1) {
|
||||||
if (!showCategoryTabs || adapter?.categories?.size == 1) {
|
title += " (${mangaMap[currentCategory?.id]?.size ?: 0})"
|
||||||
title += " (${mangaMap[currentCategory?.id]?.size ?: 0})"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -149,8 +142,7 @@ class LibraryController(
|
|||||||
)
|
)
|
||||||
|
|
||||||
getColumnsPreferenceForCurrentOrientation()
|
getColumnsPreferenceForCurrentOrientation()
|
||||||
.asFlow()
|
.asHotFlow { presenter.columns = it }
|
||||||
.onEach { presenter.columns = it }
|
|
||||||
.launchIn(viewScope)
|
.launchIn(viewScope)
|
||||||
|
|
||||||
binding.libraryPager.adapter = adapter
|
binding.libraryPager.adapter = adapter
|
||||||
@ -299,7 +291,7 @@ class LibraryController(
|
|||||||
presenter.loadedMangaFlow.value = presenter.loadedManga
|
presenter.loadedMangaFlow.value = presenter.loadedManga
|
||||||
|
|
||||||
// Send the manga map to child fragments after the adapter is updated.
|
// Send the manga map to child fragments after the adapter is updated.
|
||||||
libraryMangaRelay.call(LibraryMangaEvent(mangaMap))
|
this.mangaMap = mangaMap
|
||||||
|
|
||||||
// Finally update the title
|
// Finally update the title
|
||||||
updateTitle()
|
updateTitle()
|
||||||
@ -322,9 +314,6 @@ class LibraryController(
|
|||||||
updateTitle()
|
updateTitle()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Called when the sorting mode is changed.
|
|
||||||
*/
|
|
||||||
private fun onSortChanged() {
|
private fun onSortChanged() {
|
||||||
presenter.requestSortUpdate()
|
presenter.requestSortUpdate()
|
||||||
}
|
}
|
||||||
@ -343,9 +332,6 @@ class LibraryController(
|
|||||||
adapter.recycle = true
|
adapter.recycle = true
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates the action mode if it's not created already.
|
|
||||||
*/
|
|
||||||
fun createActionModeIfNeeded() {
|
fun createActionModeIfNeeded() {
|
||||||
val activity = activity
|
val activity = activity
|
||||||
if (actionMode == null && activity is MainActivity) {
|
if (actionMode == null && activity is MainActivity) {
|
||||||
@ -354,9 +340,6 @@ class LibraryController(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Destroys the action mode.
|
|
||||||
*/
|
|
||||||
private fun destroyActionModeIfNeeded() {
|
private fun destroyActionModeIfNeeded() {
|
||||||
actionMode?.finish()
|
actionMode?.finish()
|
||||||
}
|
}
|
||||||
|
@ -1,3 +0,0 @@
|
|||||||
package eu.kanade.tachiyomi.ui.library
|
|
||||||
|
|
||||||
class LibraryMangaEvent(val mangas: LibraryMap)
|
|
@ -44,9 +44,6 @@ import eu.kanade.tachiyomi.util.lang.launchIO
|
|||||||
import eu.kanade.tachiyomi.util.removeCovers
|
import eu.kanade.tachiyomi.util.removeCovers
|
||||||
import eu.kanade.tachiyomi.widget.ExtendedNavigationView.Item.TriStateGroup.State
|
import eu.kanade.tachiyomi.widget.ExtendedNavigationView.Item.TriStateGroup.State
|
||||||
import kotlinx.coroutines.flow.MutableStateFlow
|
import kotlinx.coroutines.flow.MutableStateFlow
|
||||||
import kotlinx.coroutines.flow.drop
|
|
||||||
import kotlinx.coroutines.flow.launchIn
|
|
||||||
import kotlinx.coroutines.flow.onEach
|
|
||||||
import kotlinx.coroutines.runBlocking
|
import kotlinx.coroutines.runBlocking
|
||||||
import rx.Observable
|
import rx.Observable
|
||||||
import rx.Subscription
|
import rx.Subscription
|
||||||
@ -126,20 +123,10 @@ class LibraryPresenter(
|
|||||||
*/
|
*/
|
||||||
private val sortTriggerRelay = BehaviorRelay.create(Unit)
|
private val sortTriggerRelay = BehaviorRelay.create(Unit)
|
||||||
|
|
||||||
/**
|
|
||||||
* Library subscription.
|
|
||||||
*/
|
|
||||||
private var librarySubscription: Subscription? = null
|
private var librarySubscription: Subscription? = null
|
||||||
|
|
||||||
override fun onCreate(savedState: Bundle?) {
|
override fun onCreate(savedState: Bundle?) {
|
||||||
super.onCreate(savedState)
|
super.onCreate(savedState)
|
||||||
preferences.libraryDisplayMode()
|
|
||||||
.asFlow()
|
|
||||||
.drop(1)
|
|
||||||
.onEach {
|
|
||||||
currentDisplayMode = it
|
|
||||||
}
|
|
||||||
.launchIn(presenterScope)
|
|
||||||
|
|
||||||
subscribeLibrary()
|
subscribeLibrary()
|
||||||
}
|
}
|
||||||
|
@ -62,7 +62,7 @@ import eu.kanade.tachiyomi.ui.recent.updates.UpdatesController
|
|||||||
import eu.kanade.tachiyomi.ui.setting.SettingsMainController
|
import eu.kanade.tachiyomi.ui.setting.SettingsMainController
|
||||||
import eu.kanade.tachiyomi.util.lang.launchIO
|
import eu.kanade.tachiyomi.util.lang.launchIO
|
||||||
import eu.kanade.tachiyomi.util.lang.launchUI
|
import eu.kanade.tachiyomi.util.lang.launchUI
|
||||||
import eu.kanade.tachiyomi.util.preference.asImmediateFlow
|
import eu.kanade.tachiyomi.util.preference.asHotFlow
|
||||||
import eu.kanade.tachiyomi.util.system.dpToPx
|
import eu.kanade.tachiyomi.util.system.dpToPx
|
||||||
import eu.kanade.tachiyomi.util.system.getThemeColor
|
import eu.kanade.tachiyomi.util.system.getThemeColor
|
||||||
import eu.kanade.tachiyomi.util.system.isTablet
|
import eu.kanade.tachiyomi.util.system.isTablet
|
||||||
@ -145,7 +145,7 @@ class MainActivity : BaseActivity() {
|
|||||||
|
|
||||||
if (binding.sideNav != null) {
|
if (binding.sideNav != null) {
|
||||||
preferences.sideNavIconAlignment()
|
preferences.sideNavIconAlignment()
|
||||||
.asImmediateFlow {
|
.asHotFlow {
|
||||||
binding.sideNav?.menuGravity = when (it) {
|
binding.sideNav?.menuGravity = when (it) {
|
||||||
1 -> Gravity.CENTER
|
1 -> Gravity.CENTER
|
||||||
2 -> Gravity.BOTTOM
|
2 -> Gravity.BOTTOM
|
||||||
@ -255,11 +255,11 @@ class MainActivity : BaseActivity() {
|
|||||||
.launchIn(lifecycleScope)
|
.launchIn(lifecycleScope)
|
||||||
|
|
||||||
preferences.extensionUpdatesCount()
|
preferences.extensionUpdatesCount()
|
||||||
.asImmediateFlow { setExtensionsBadge() }
|
.asHotFlow { setExtensionsBadge() }
|
||||||
.launchIn(lifecycleScope)
|
.launchIn(lifecycleScope)
|
||||||
|
|
||||||
preferences.downloadedOnly()
|
preferences.downloadedOnly()
|
||||||
.asImmediateFlow { binding.downloadedOnly.isVisible = it }
|
.asHotFlow { binding.downloadedOnly.isVisible = it }
|
||||||
.launchIn(lifecycleScope)
|
.launchIn(lifecycleScope)
|
||||||
|
|
||||||
binding.incognitoMode.isVisible = preferences.incognitoMode().get()
|
binding.incognitoMode.isVisible = preferences.incognitoMode().get()
|
||||||
|
@ -45,7 +45,7 @@ import eu.kanade.tachiyomi.util.lang.launchIO
|
|||||||
import eu.kanade.tachiyomi.util.lang.launchUI
|
import eu.kanade.tachiyomi.util.lang.launchUI
|
||||||
import eu.kanade.tachiyomi.util.lang.toRelativeString
|
import eu.kanade.tachiyomi.util.lang.toRelativeString
|
||||||
import eu.kanade.tachiyomi.util.lang.withUIContext
|
import eu.kanade.tachiyomi.util.lang.withUIContext
|
||||||
import eu.kanade.tachiyomi.util.preference.asImmediateFlow
|
import eu.kanade.tachiyomi.util.preference.asHotFlow
|
||||||
import eu.kanade.tachiyomi.util.removeCovers
|
import eu.kanade.tachiyomi.util.removeCovers
|
||||||
import eu.kanade.tachiyomi.util.shouldDownloadNewChapters
|
import eu.kanade.tachiyomi.util.shouldDownloadNewChapters
|
||||||
import eu.kanade.tachiyomi.util.system.logcat
|
import eu.kanade.tachiyomi.util.system.logcat
|
||||||
@ -207,13 +207,13 @@ class MangaPresenter(
|
|||||||
}
|
}
|
||||||
|
|
||||||
preferences.incognitoMode()
|
preferences.incognitoMode()
|
||||||
.asImmediateFlow { incognito ->
|
.asHotFlow { incognito ->
|
||||||
incognitoMode = incognito
|
incognitoMode = incognito
|
||||||
}
|
}
|
||||||
.launchIn(presenterScope)
|
.launchIn(presenterScope)
|
||||||
|
|
||||||
preferences.downloadedOnly()
|
preferences.downloadedOnly()
|
||||||
.asImmediateFlow { downloadedOnly ->
|
.asHotFlow { downloadedOnly ->
|
||||||
downloadedOnlyMode = downloadedOnly
|
downloadedOnlyMode = downloadedOnly
|
||||||
}
|
}
|
||||||
.launchIn(presenterScope)
|
.launchIn(presenterScope)
|
||||||
|
@ -10,7 +10,7 @@ import eu.kanade.tachiyomi.R
|
|||||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||||
import eu.kanade.tachiyomi.databinding.ReaderGeneralSettingsBinding
|
import eu.kanade.tachiyomi.databinding.ReaderGeneralSettingsBinding
|
||||||
import eu.kanade.tachiyomi.ui.reader.ReaderActivity
|
import eu.kanade.tachiyomi.ui.reader.ReaderActivity
|
||||||
import eu.kanade.tachiyomi.util.preference.asImmediateFlow
|
import eu.kanade.tachiyomi.util.preference.asHotFlow
|
||||||
import eu.kanade.tachiyomi.util.preference.bindToPreference
|
import eu.kanade.tachiyomi.util.preference.bindToPreference
|
||||||
import kotlinx.coroutines.flow.launchIn
|
import kotlinx.coroutines.flow.launchIn
|
||||||
import uy.kohesive.injekt.injectLazy
|
import uy.kohesive.injekt.injectLazy
|
||||||
@ -39,7 +39,7 @@ class ReaderGeneralSettings @JvmOverloads constructor(context: Context, attrs: A
|
|||||||
binding.showPageNumber.bindToPreference(preferences.showPageNumber())
|
binding.showPageNumber.bindToPreference(preferences.showPageNumber())
|
||||||
binding.fullscreen.bindToPreference(preferences.fullscreen())
|
binding.fullscreen.bindToPreference(preferences.fullscreen())
|
||||||
preferences.fullscreen()
|
preferences.fullscreen()
|
||||||
.asImmediateFlow {
|
.asHotFlow {
|
||||||
// If the preference is explicitly disabled, that means the setting was configured since there is a cutout
|
// If the preference is explicitly disabled, that means the setting was configured since there is a cutout
|
||||||
binding.cutoutShort.isVisible = it && ((context as ReaderActivity).hasCutout || !preferences.cutoutShort().get())
|
binding.cutoutShort.isVisible = it && ((context as ReaderActivity).hasCutout || !preferences.cutoutShort().get())
|
||||||
binding.cutoutShort.bindToPreference(preferences.cutoutShort())
|
binding.cutoutShort.bindToPreference(preferences.cutoutShort())
|
||||||
|
@ -12,7 +12,7 @@ import eu.kanade.tachiyomi.databinding.ReaderReadingModeSettingsBinding
|
|||||||
import eu.kanade.tachiyomi.ui.reader.ReaderActivity
|
import eu.kanade.tachiyomi.ui.reader.ReaderActivity
|
||||||
import eu.kanade.tachiyomi.ui.reader.viewer.pager.PagerViewer
|
import eu.kanade.tachiyomi.ui.reader.viewer.pager.PagerViewer
|
||||||
import eu.kanade.tachiyomi.ui.reader.viewer.webtoon.WebtoonViewer
|
import eu.kanade.tachiyomi.ui.reader.viewer.webtoon.WebtoonViewer
|
||||||
import eu.kanade.tachiyomi.util.preference.asImmediateFlow
|
import eu.kanade.tachiyomi.util.preference.asHotFlow
|
||||||
import eu.kanade.tachiyomi.util.preference.bindToPreference
|
import eu.kanade.tachiyomi.util.preference.bindToPreference
|
||||||
import kotlinx.coroutines.flow.launchIn
|
import kotlinx.coroutines.flow.launchIn
|
||||||
import uy.kohesive.injekt.injectLazy
|
import uy.kohesive.injekt.injectLazy
|
||||||
@ -73,12 +73,12 @@ class ReaderReadingModeSettings @JvmOverloads constructor(context: Context, attr
|
|||||||
|
|
||||||
binding.pagerPrefsGroup.pagerNav.bindToPreference(preferences.navigationModePager())
|
binding.pagerPrefsGroup.pagerNav.bindToPreference(preferences.navigationModePager())
|
||||||
preferences.navigationModePager()
|
preferences.navigationModePager()
|
||||||
.asImmediateFlow { binding.pagerPrefsGroup.tappingInverted.isVisible = it != 5 }
|
.asHotFlow { binding.pagerPrefsGroup.tappingInverted.isVisible = it != 5 }
|
||||||
.launchIn((context as ReaderActivity).lifecycleScope)
|
.launchIn((context as ReaderActivity).lifecycleScope)
|
||||||
// Makes so that landscape zoom gets hidden away when image scale type is not fit screen
|
// Makes so that landscape zoom gets hidden away when image scale type is not fit screen
|
||||||
binding.pagerPrefsGroup.scaleType.bindToPreference(preferences.imageScaleType(), 1)
|
binding.pagerPrefsGroup.scaleType.bindToPreference(preferences.imageScaleType(), 1)
|
||||||
preferences.imageScaleType()
|
preferences.imageScaleType()
|
||||||
.asImmediateFlow { binding.pagerPrefsGroup.landscapeZoom.isVisible = it == 1 }
|
.asHotFlow { binding.pagerPrefsGroup.landscapeZoom.isVisible = it == 1 }
|
||||||
.launchIn((context as ReaderActivity).lifecycleScope)
|
.launchIn((context as ReaderActivity).lifecycleScope)
|
||||||
binding.pagerPrefsGroup.landscapeZoom.bindToPreference(preferences.landscapeZoom())
|
binding.pagerPrefsGroup.landscapeZoom.bindToPreference(preferences.landscapeZoom())
|
||||||
|
|
||||||
@ -89,7 +89,7 @@ class ReaderReadingModeSettings @JvmOverloads constructor(context: Context, attr
|
|||||||
// Makes so that dual page invert gets hidden away when turning of dual page split
|
// Makes so that dual page invert gets hidden away when turning of dual page split
|
||||||
binding.pagerPrefsGroup.dualPageSplit.bindToPreference(preferences.dualPageSplitPaged())
|
binding.pagerPrefsGroup.dualPageSplit.bindToPreference(preferences.dualPageSplitPaged())
|
||||||
preferences.dualPageSplitPaged()
|
preferences.dualPageSplitPaged()
|
||||||
.asImmediateFlow { binding.pagerPrefsGroup.dualPageInvert.isVisible = it }
|
.asHotFlow { binding.pagerPrefsGroup.dualPageInvert.isVisible = it }
|
||||||
.launchIn((context as ReaderActivity).lifecycleScope)
|
.launchIn((context as ReaderActivity).lifecycleScope)
|
||||||
binding.pagerPrefsGroup.dualPageInvert.bindToPreference(preferences.dualPageInvertPaged())
|
binding.pagerPrefsGroup.dualPageInvert.bindToPreference(preferences.dualPageInvertPaged())
|
||||||
}
|
}
|
||||||
@ -105,7 +105,7 @@ class ReaderReadingModeSettings @JvmOverloads constructor(context: Context, attr
|
|||||||
|
|
||||||
binding.webtoonPrefsGroup.webtoonNav.bindToPreference(preferences.navigationModeWebtoon())
|
binding.webtoonPrefsGroup.webtoonNav.bindToPreference(preferences.navigationModeWebtoon())
|
||||||
preferences.navigationModeWebtoon()
|
preferences.navigationModeWebtoon()
|
||||||
.asImmediateFlow { binding.webtoonPrefsGroup.tappingInverted.isVisible = it != 5 }
|
.asHotFlow { binding.webtoonPrefsGroup.tappingInverted.isVisible = it != 5 }
|
||||||
.launchIn((context as ReaderActivity).lifecycleScope)
|
.launchIn((context as ReaderActivity).lifecycleScope)
|
||||||
binding.webtoonPrefsGroup.cropBordersWebtoon.bindToPreference(preferences.cropBordersWebtoon())
|
binding.webtoonPrefsGroup.cropBordersWebtoon.bindToPreference(preferences.cropBordersWebtoon())
|
||||||
binding.webtoonPrefsGroup.webtoonSidePadding.bindToIntPreference(preferences.webtoonSidePadding(), R.array.webtoon_side_padding_values)
|
binding.webtoonPrefsGroup.webtoonSidePadding.bindToIntPreference(preferences.webtoonSidePadding(), R.array.webtoon_side_padding_values)
|
||||||
@ -113,7 +113,7 @@ class ReaderReadingModeSettings @JvmOverloads constructor(context: Context, attr
|
|||||||
// Makes so that dual page invert gets hidden away when turning of dual page split
|
// Makes so that dual page invert gets hidden away when turning of dual page split
|
||||||
binding.webtoonPrefsGroup.dualPageSplit.bindToPreference(preferences.dualPageSplitWebtoon())
|
binding.webtoonPrefsGroup.dualPageSplit.bindToPreference(preferences.dualPageSplitWebtoon())
|
||||||
preferences.dualPageSplitWebtoon()
|
preferences.dualPageSplitWebtoon()
|
||||||
.asImmediateFlow { binding.webtoonPrefsGroup.dualPageInvert.isVisible = it }
|
.asHotFlow { binding.webtoonPrefsGroup.dualPageInvert.isVisible = it }
|
||||||
.launchIn((context as ReaderActivity).lifecycleScope)
|
.launchIn((context as ReaderActivity).lifecycleScope)
|
||||||
binding.webtoonPrefsGroup.dualPageInvert.bindToPreference(preferences.dualPageInvertWebtoon())
|
binding.webtoonPrefsGroup.dualPageInvert.bindToPreference(preferences.dualPageInvertWebtoon())
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@ import eu.kanade.tachiyomi.R
|
|||||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||||
import eu.kanade.tachiyomi.ui.base.controller.BaseController
|
import eu.kanade.tachiyomi.ui.base.controller.BaseController
|
||||||
import eu.kanade.tachiyomi.ui.base.controller.RootController
|
import eu.kanade.tachiyomi.ui.base.controller.RootController
|
||||||
import eu.kanade.tachiyomi.util.preference.asImmediateFlow
|
import eu.kanade.tachiyomi.util.preference.asHotFlow
|
||||||
import eu.kanade.tachiyomi.util.system.getResourceColor
|
import eu.kanade.tachiyomi.util.system.getResourceColor
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.MainScope
|
import kotlinx.coroutines.MainScope
|
||||||
@ -138,7 +138,7 @@ abstract class SettingsController : PreferenceController() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
inline fun <T> Preference.visibleIf(preference: com.fredporciuncula.flow.preferences.Preference<T>, crossinline block: (T) -> Boolean) {
|
inline fun <T> Preference.visibleIf(preference: com.fredporciuncula.flow.preferences.Preference<T>, crossinline block: (T) -> Boolean) {
|
||||||
preference.asImmediateFlow { isVisible = block(it) }
|
preference.asHotFlow { isVisible = block(it) }
|
||||||
.launchIn(viewScope)
|
.launchIn(viewScope)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ fun CompoundButton.bindToPreference(pref: Preference<Boolean>) {
|
|||||||
setOnCheckedChangeListener { _, isChecked -> pref.set(isChecked) }
|
setOnCheckedChangeListener { _, isChecked -> pref.set(isChecked) }
|
||||||
}
|
}
|
||||||
|
|
||||||
fun <T> Preference<T>.asImmediateFlow(block: (T) -> Unit): Flow<T> {
|
fun <T> Preference<T>.asHotFlow(block: (T) -> Unit): Flow<T> {
|
||||||
block(get())
|
block(get())
|
||||||
return asFlow()
|
return asFlow()
|
||||||
.onEach { block(it) }
|
.onEach { block(it) }
|
||||||
|
@ -7,7 +7,7 @@ import androidx.appcompat.widget.SearchView
|
|||||||
import androidx.core.view.inputmethod.EditorInfoCompat
|
import androidx.core.view.inputmethod.EditorInfoCompat
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||||
import eu.kanade.tachiyomi.util.preference.asImmediateFlow
|
import eu.kanade.tachiyomi.util.preference.asHotFlow
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.SupervisorJob
|
import kotlinx.coroutines.SupervisorJob
|
||||||
@ -31,7 +31,7 @@ class TachiyomiSearchView @JvmOverloads constructor(
|
|||||||
override fun onAttachedToWindow() {
|
override fun onAttachedToWindow() {
|
||||||
super.onAttachedToWindow()
|
super.onAttachedToWindow()
|
||||||
scope = CoroutineScope(SupervisorJob() + Dispatchers.Main)
|
scope = CoroutineScope(SupervisorJob() + Dispatchers.Main)
|
||||||
Injekt.get<PreferencesHelper>().incognitoMode().asImmediateFlow {
|
Injekt.get<PreferencesHelper>().incognitoMode().asHotFlow {
|
||||||
imeOptions = if (it) {
|
imeOptions = if (it) {
|
||||||
imeOptions or EditorInfoCompat.IME_FLAG_NO_PERSONALIZED_LEARNING
|
imeOptions or EditorInfoCompat.IME_FLAG_NO_PERSONALIZED_LEARNING
|
||||||
} else {
|
} else {
|
||||||
|
@ -7,7 +7,7 @@ import androidx.core.view.inputmethod.EditorInfoCompat
|
|||||||
import com.google.android.material.textfield.TextInputEditText
|
import com.google.android.material.textfield.TextInputEditText
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||||
import eu.kanade.tachiyomi.util.preference.asImmediateFlow
|
import eu.kanade.tachiyomi.util.preference.asHotFlow
|
||||||
import eu.kanade.tachiyomi.widget.TachiyomiTextInputEditText.Companion.setIncognito
|
import eu.kanade.tachiyomi.widget.TachiyomiTextInputEditText.Companion.setIncognito
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
@ -49,7 +49,7 @@ class TachiyomiTextInputEditText @JvmOverloads constructor(
|
|||||||
* if [PreferencesHelper.incognitoMode] is true. Some IMEs may not respect this flag.
|
* if [PreferencesHelper.incognitoMode] is true. Some IMEs may not respect this flag.
|
||||||
*/
|
*/
|
||||||
fun EditText.setIncognito(viewScope: CoroutineScope) {
|
fun EditText.setIncognito(viewScope: CoroutineScope) {
|
||||||
Injekt.get<PreferencesHelper>().incognitoMode().asImmediateFlow {
|
Injekt.get<PreferencesHelper>().incognitoMode().asHotFlow {
|
||||||
imeOptions = if (it) {
|
imeOptions = if (it) {
|
||||||
imeOptions or EditorInfoCompat.IME_FLAG_NO_PERSONALIZED_LEARNING
|
imeOptions or EditorInfoCompat.IME_FLAG_NO_PERSONALIZED_LEARNING
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user