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