diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/core/ui/widgets/SlidingBottomNavigationView.kt b/app/src/main/kotlin/org/koitharu/kotatsu/core/ui/widgets/SlidingBottomNavigationView.kt index 3a95fa398..57e8fdcfa 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/core/ui/widgets/SlidingBottomNavigationView.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/core/ui/widgets/SlidingBottomNavigationView.kt @@ -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 diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/main/ui/MainActivity.kt b/app/src/main/kotlin/org/koitharu/kotatsu/main/ui/MainActivity.kt index 6e26e4a37..94e937de9 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/main/ui/MainActivity.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/main/ui/MainActivity.kt @@ -144,6 +144,9 @@ class MainActivity : BaseActivity(), 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(), 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(), 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(), AppBarOwner, BottomNav if (isOpened) R.string.search_hint else R.string.search_manga, ) bottomNav?.showOrHide(!isOpened) + closeSearchCallback.isEnabled = isOpened } private fun requestNotificationsPermission() { diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/main/ui/MainViewModel.kt b/app/src/main/kotlin/org/koitharu/kotatsu/main/ui/MainViewModel.kt index ce5e9748a..985992c44 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/main/ui/MainViewModel.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/main/ui/MainViewModel.kt @@ -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(