Fixed reader activity layout issues

This commit is contained in:
Jay 2020-05-04 15:00:00 -04:00
parent af817fb13c
commit 22eb46ac0b
2 changed files with 32 additions and 27 deletions

View File

@ -312,8 +312,7 @@ class ReaderActivity : BaseRxActivity<ReaderPresenter>(),
// Set toolbar
setSupportActionBar(toolbar)
val primaryColor = ColorUtils.setAlphaComponent(
getResourceColor(R.attr.colorSecondary),
200
getResourceColor(R.attr.colorSecondary), 200
)
appbar.setBackgroundColor(primaryColor)
window.statusBarColor = Color.TRANSPARENT
@ -334,8 +333,8 @@ class ReaderActivity : BaseRxActivity<ReaderPresenter>(),
// Set initial visibility
setMenuVisibility(menuVisible)
chapters_bottom_sheet.sheetBehavior?.isHideable = !menuVisible
if (!menuVisible)
chapters_bottom_sheet.sheetBehavior?.state = BottomSheetBehavior.STATE_HIDDEN
if (!menuVisible) chapters_bottom_sheet.sheetBehavior?.state =
BottomSheetBehavior.STATE_HIDDEN
reader_layout.doOnApplyWindowInsets { v, insets, _ ->
sheetManageNavColor = when {
insets.isBottomTappable() -> {
@ -352,10 +351,14 @@ class ReaderActivity : BaseRxActivity<ReaderPresenter>(),
}
}
appbar.updateLayoutParams<ViewGroup.MarginLayoutParams> {
leftMargin = insets.systemWindowInsetLeft
rightMargin = insets.systemWindowInsetRight
}
toolbar.updateLayoutParams<ViewGroup.MarginLayoutParams> {
topMargin = insets.systemWindowInsetTop
}
v.updateLayoutParams<ViewGroup.MarginLayoutParams> {
chapters_bottom_sheet.updateLayoutParams<ViewGroup.MarginLayoutParams> {
leftMargin = insets.systemWindowInsetLeft
rightMargin = insets.systemWindowInsetRight
}
@ -372,7 +375,7 @@ class ReaderActivity : BaseRxActivity<ReaderPresenter>(),
if (visible) {
snackbar?.dismiss()
systemUi?.show()
toolbar.visibility = View.VISIBLE
appbar.visible()
if (chapters_bottom_sheet.sheetBehavior?.state == BottomSheetBehavior.STATE_EXPANDED) {
chapters_bottom_sheet.sheetBehavior?.isHideable = false
@ -399,14 +402,15 @@ class ReaderActivity : BaseRxActivity<ReaderPresenter>(),
val toolbarAnimation = AnimationUtils.loadAnimation(this, R.anim.exit_to_top)
toolbarAnimation.setAnimationListener(object : SimpleAnimationListener() {
override fun onAnimationEnd(animation: Animation) {
toolbar.visibility = View.GONE
appbar.gone()
}
})
appbar.startAnimation(toolbarAnimation)
BottomSheetBehavior.from(chapters_bottom_sheet).isHideable = true
BottomSheetBehavior.from(chapters_bottom_sheet).state = BottomSheetBehavior.STATE_HIDDEN
BottomSheetBehavior.from(chapters_bottom_sheet).state =
BottomSheetBehavior.STATE_HIDDEN
} else {
toolbar.visibility = View.GONE
appbar.gone()
}
}
menuStickyVisible = false
@ -661,7 +665,7 @@ class ReaderActivity : BaseRxActivity<ReaderPresenter>(),
}
}
if (sheetManageNavColor) window.navigationBarColor = getResourceColor(R.attr.colorSecondary)
toolbar.visibility = View.VISIBLE
appbar.visible()
val toolbarAnimation = AnimationUtils.loadAnimation(this, R.anim.enter_from_top)
toolbarAnimation.setAnimationListener(object : SimpleAnimationListener() {
override fun onAnimationStart(animation: Animation) {

View File

@ -48,6 +48,7 @@
android:background="?attr/colorSecondary"
android:stateListAnimator="@null"
android:theme="?attr/actionBarTheme"
android:visibility="gone"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent">