|
|
|
|
@ -13,6 +13,7 @@ import androidx.appcompat.view.ActionMode
|
|
|
|
|
import androidx.core.app.ActivityCompat
|
|
|
|
|
import androidx.core.content.ContextCompat
|
|
|
|
|
import androidx.core.graphics.Insets
|
|
|
|
|
import androidx.core.view.children
|
|
|
|
|
import androidx.core.view.inputmethod.EditorInfoCompat
|
|
|
|
|
import androidx.core.view.isInvisible
|
|
|
|
|
import androidx.core.view.isVisible
|
|
|
|
|
@ -131,6 +132,7 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), AppBarOwner, BottomNav
|
|
|
|
|
viewModel.onFirstStart.observeEvent(this) {
|
|
|
|
|
WelcomeSheet.show(supportFragmentManager)
|
|
|
|
|
}
|
|
|
|
|
viewModel.isBottomNavPinned.observe(this, ::setNavbarPinned)
|
|
|
|
|
searchSuggestionViewModel.isIncognitoModeEnabled.observe(this, this::onIncognitoModeChanged)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -399,6 +401,22 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), AppBarOwner, BottomNav
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private fun setNavbarPinned(isPinned: Boolean) {
|
|
|
|
|
viewBinding.bottomNav?.isPinned = isPinned
|
|
|
|
|
for (view in viewBinding.appbar.children) {
|
|
|
|
|
val lp = view.layoutParams as? AppBarLayout.LayoutParams ?: continue
|
|
|
|
|
val scrollFlags = if (isPinned) {
|
|
|
|
|
lp.scrollFlags and SCROLL_FLAG_SCROLL.inv()
|
|
|
|
|
} else {
|
|
|
|
|
lp.scrollFlags or SCROLL_FLAG_SCROLL
|
|
|
|
|
}
|
|
|
|
|
if (scrollFlags != lp.scrollFlags) {
|
|
|
|
|
lp.scrollFlags = scrollFlags
|
|
|
|
|
view.layoutParams = lp
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private inner class CloseSearchCallback : OnBackPressedCallback(false) {
|
|
|
|
|
|
|
|
|
|
override fun handleOnBackPressed() {
|
|
|
|
|
|