Incognito mode indicator
This commit is contained in:
@@ -65,6 +65,9 @@ class SlidingBottomNavigationView @JvmOverloads constructor(
|
||||
}
|
||||
|
||||
fun show() {
|
||||
if (currentState == STATE_UP) {
|
||||
return
|
||||
}
|
||||
currentAnimator?.cancel()
|
||||
clearAnimation()
|
||||
|
||||
@@ -77,6 +80,9 @@ class SlidingBottomNavigationView @JvmOverloads constructor(
|
||||
}
|
||||
|
||||
fun hide() {
|
||||
if (currentState == STATE_DOWN) {
|
||||
return
|
||||
}
|
||||
currentAnimator?.cancel()
|
||||
clearAnimation()
|
||||
|
||||
@@ -117,6 +123,7 @@ class SlidingBottomNavigationView @JvmOverloads constructor(
|
||||
}
|
||||
|
||||
internal class SavedState : AbsSavedState {
|
||||
|
||||
var currentState = STATE_UP
|
||||
var translationY = 0F
|
||||
|
||||
|
||||
@@ -144,6 +144,9 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), AppBarOwner, BottomNav
|
||||
viewModel.onFirstStart.observeEvent(this) {
|
||||
OnboardDialogFragment.show(supportFragmentManager)
|
||||
}
|
||||
viewModel.isIncognitoMode.observe(this) {
|
||||
adjustSearchUI(isSearchOpened(), false)
|
||||
}
|
||||
searchSuggestionViewModel.isIncognitoModeEnabled.observe(this, this::onIncognitoModeChanged)
|
||||
}
|
||||
|
||||
@@ -312,13 +315,11 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), AppBarOwner, BottomNav
|
||||
|
||||
private fun onSearchOpened() {
|
||||
adjustSearchUI(isOpened = true, animate = true)
|
||||
closeSearchCallback.isEnabled = true
|
||||
}
|
||||
|
||||
private fun onSearchClosed() {
|
||||
viewBinding.searchView.hideKeyboard()
|
||||
adjustSearchUI(isOpened = false, animate = true)
|
||||
closeSearchCallback.isEnabled = false
|
||||
}
|
||||
|
||||
private fun isSearchOpened(): Boolean {
|
||||
@@ -379,7 +380,11 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), AppBarOwner, BottomNav
|
||||
adjustFabVisibility(isSearchOpened = isOpened)
|
||||
supportActionBar?.apply {
|
||||
setHomeAsUpIndicator(
|
||||
if (isOpened) materialR.drawable.abc_ic_ab_back_material else materialR.drawable.abc_ic_search_api_material,
|
||||
when {
|
||||
isOpened -> materialR.drawable.abc_ic_ab_back_material
|
||||
viewModel.isIncognitoMode.value -> R.drawable.ic_incognito
|
||||
else -> materialR.drawable.abc_ic_search_api_material
|
||||
},
|
||||
)
|
||||
setHomeActionContentDescription(
|
||||
if (isOpened) R.string.back else R.string.search,
|
||||
@@ -389,6 +394,7 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), AppBarOwner, BottomNav
|
||||
if (isOpened) R.string.search_hint else R.string.search_manga,
|
||||
)
|
||||
bottomNav?.showOrHide(!isOpened)
|
||||
closeSearchCallback.isEnabled = isOpened
|
||||
}
|
||||
|
||||
private fun requestNotificationsPermission() {
|
||||
|
||||
@@ -13,6 +13,7 @@ import org.koitharu.kotatsu.core.exceptions.EmptyHistoryException
|
||||
import org.koitharu.kotatsu.core.github.AppUpdateRepository
|
||||
import org.koitharu.kotatsu.core.prefs.AppSettings
|
||||
import org.koitharu.kotatsu.core.prefs.NavItem
|
||||
import org.koitharu.kotatsu.core.prefs.observeAsStateFlow
|
||||
import org.koitharu.kotatsu.core.ui.BaseViewModel
|
||||
import org.koitharu.kotatsu.core.util.ext.MutableEventFlow
|
||||
import org.koitharu.kotatsu.core.util.ext.call
|
||||
@@ -43,6 +44,12 @@ class MainViewModel @Inject constructor(
|
||||
initialValue = false,
|
||||
)
|
||||
|
||||
val isIncognitoMode = settings.observeAsStateFlow(
|
||||
scope = viewModelScope + Dispatchers.Default,
|
||||
key = AppSettings.KEY_INCOGNITO_MODE,
|
||||
valueProducer = { isIncognitoModeEnabled },
|
||||
)
|
||||
|
||||
val appUpdate = appUpdateRepository.observeAvailableUpdate()
|
||||
|
||||
val counters = combine(
|
||||
|
||||
Reference in New Issue
Block a user