Updates to manga header margins + tablet layout fixes for the controller
This commit is contained in:
parent
09a24bd9f2
commit
1c51a4c499
2 changed files with 30 additions and 33 deletions
|
@ -26,6 +26,7 @@ import android.view.MenuItem
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.view.ViewPropertyAnimator
|
import android.view.ViewPropertyAnimator
|
||||||
|
import android.view.WindowInsets
|
||||||
import android.view.animation.DecelerateInterpolator
|
import android.view.animation.DecelerateInterpolator
|
||||||
import android.view.inputmethod.InputMethodManager
|
import android.view.inputmethod.InputMethodManager
|
||||||
import android.widget.LinearLayout
|
import android.widget.LinearLayout
|
||||||
|
@ -93,11 +94,11 @@ import eu.kanade.tachiyomi.ui.webview.WebViewActivity
|
||||||
import eu.kanade.tachiyomi.util.storage.getUriCompat
|
import eu.kanade.tachiyomi.util.storage.getUriCompat
|
||||||
import eu.kanade.tachiyomi.util.system.ThemeUtil
|
import eu.kanade.tachiyomi.util.system.ThemeUtil
|
||||||
import eu.kanade.tachiyomi.util.system.dpToPx
|
import eu.kanade.tachiyomi.util.system.dpToPx
|
||||||
import eu.kanade.tachiyomi.util.system.dpToPxEnd
|
|
||||||
import eu.kanade.tachiyomi.util.system.getResourceColor
|
import eu.kanade.tachiyomi.util.system.getResourceColor
|
||||||
import eu.kanade.tachiyomi.util.system.launchUI
|
import eu.kanade.tachiyomi.util.system.launchUI
|
||||||
import eu.kanade.tachiyomi.util.system.pxToDp
|
import eu.kanade.tachiyomi.util.system.pxToDp
|
||||||
import eu.kanade.tachiyomi.util.system.toast
|
import eu.kanade.tachiyomi.util.system.toast
|
||||||
|
import eu.kanade.tachiyomi.util.view.doOnApplyWindowInsets
|
||||||
import eu.kanade.tachiyomi.util.view.getText
|
import eu.kanade.tachiyomi.util.view.getText
|
||||||
import eu.kanade.tachiyomi.util.view.scrollViewWith
|
import eu.kanade.tachiyomi.util.view.scrollViewWith
|
||||||
import eu.kanade.tachiyomi.util.view.setOnQueryTextChangeListener
|
import eu.kanade.tachiyomi.util.view.setOnQueryTextChangeListener
|
||||||
|
@ -264,21 +265,17 @@ class MangaDetailsController : BaseController,
|
||||||
swipe_refresh.setDistanceToTriggerSync(70.dpToPx)
|
swipe_refresh.setDistanceToTriggerSync(70.dpToPx)
|
||||||
activity!!.appbar.elevation = 0f
|
activity!!.appbar.elevation = 0f
|
||||||
|
|
||||||
scrollViewWith(recycler, padBottom = true, customPadding = true, afterInsets = { insets ->
|
if (isTablet) {
|
||||||
recycler.updatePaddingRelative(bottom = insets.systemWindowInsetBottom)
|
recycler.doOnApplyWindowInsets { _, insets, _ ->
|
||||||
tabletRecycler?.updatePaddingRelative(bottom = insets.systemWindowInsetBottom)
|
setInsets(insets, appbarHeight, offset)
|
||||||
headerHeight = appbarHeight + insets.systemWindowInsetTop
|
|
||||||
swipe_refresh.setProgressViewOffset(false, (-40).dpToPx, headerHeight + offset)
|
|
||||||
// 1dp extra to line up chapter header and manga header
|
|
||||||
if (isTablet) recycler.updatePaddingRelative(top = headerHeight + 1.dpToPx)
|
|
||||||
getHeader()?.setTopHeight(headerHeight)
|
|
||||||
fast_scroll_layout.updateLayoutParams<ViewGroup.MarginLayoutParams> {
|
|
||||||
topMargin = headerHeight
|
|
||||||
bottomMargin = insets.systemWindowInsetBottom
|
|
||||||
}
|
}
|
||||||
}, liftOnScroll = {
|
} else {
|
||||||
colorToolbar(it)
|
scrollViewWith(recycler, padBottom = true, customPadding = true, afterInsets = { insets ->
|
||||||
})
|
setInsets(insets, appbarHeight, offset)
|
||||||
|
}, liftOnScroll = {
|
||||||
|
colorToolbar(it)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
recycler.addOnScrollListener(object : RecyclerView.OnScrollListener() {
|
recycler.addOnScrollListener(object : RecyclerView.OnScrollListener() {
|
||||||
override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
|
override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
|
||||||
|
@ -288,20 +285,6 @@ class MangaDetailsController : BaseController,
|
||||||
val tY = getHeader()?.backdrop?.translationY ?: 0f
|
val tY = getHeader()?.backdrop?.translationY ?: 0f
|
||||||
getHeader()?.backdrop?.translationY = max(0f, tY + dy * 0.25f)
|
getHeader()?.backdrop?.translationY = max(0f, tY + dy * 0.25f)
|
||||||
if (atTop) getHeader()?.backdrop?.translationY = 0f
|
if (atTop) getHeader()?.backdrop?.translationY = 0f
|
||||||
val fPosition =
|
|
||||||
(recycler.layoutManager as LinearLayoutManager).findFirstCompletelyVisibleItemPosition()
|
|
||||||
val scrollFunc: (Boolean) -> Unit = { show ->
|
|
||||||
showScroll = show
|
|
||||||
scrollAnim?.cancel()
|
|
||||||
scrollAnim = fast_scroller.animate().setDuration(100).translationX(
|
|
||||||
if (show) 0f else 25f.dpToPxEnd)
|
|
||||||
scrollAnim?.start()
|
|
||||||
}
|
|
||||||
if (fPosition > 0 && !showScroll) {
|
|
||||||
scrollFunc(true)
|
|
||||||
} else if (fPosition <= 0 && showScroll) {
|
|
||||||
scrollFunc(false)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -312,8 +295,22 @@ class MangaDetailsController : BaseController,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun setInsets(insets: WindowInsets, appbarHeight: Int, offset: Int) {
|
||||||
|
recycler.updatePaddingRelative(bottom = insets.systemWindowInsetBottom)
|
||||||
|
tabletRecycler?.updatePaddingRelative(bottom = insets.systemWindowInsetBottom)
|
||||||
|
headerHeight = appbarHeight + insets.systemWindowInsetTop
|
||||||
|
swipe_refresh.setProgressViewOffset(false, (-40).dpToPx, headerHeight + offset)
|
||||||
|
// 1dp extra to line up chapter header and manga header
|
||||||
|
if (isTablet) recycler.updatePaddingRelative(top = headerHeight + 1.dpToPx)
|
||||||
|
getHeader()?.setTopHeight(headerHeight)
|
||||||
|
fast_scroll_layout.updateLayoutParams<ViewGroup.MarginLayoutParams> {
|
||||||
|
topMargin = headerHeight
|
||||||
|
bottomMargin = insets.systemWindowInsetBottom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun setFastScroller() {
|
private fun setFastScroller() {
|
||||||
fast_scroller.translationX = if (showScroll || isTablet) 0f else 25f.dpToPxEnd
|
// fast_scroller.translationX = if (showScroll || isTablet) 0f else 25f.dpToPxEnd
|
||||||
fast_scroller.setupWithRecyclerView(recycler, { position ->
|
fast_scroller.setupWithRecyclerView(recycler, { position ->
|
||||||
val letter = adapter?.getSectionText(position)
|
val letter = adapter?.getSectionText(position)
|
||||||
when {
|
when {
|
||||||
|
|
|
@ -223,7 +223,7 @@
|
||||||
style="@style/TextAppearance.Regular.Body1.Secondary"
|
style="@style/TextAppearance.Regular.Body1.Secondary"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="18dp"
|
android:layout_marginStart="16dp"
|
||||||
android:layout_marginTop="4dp"
|
android:layout_marginTop="4dp"
|
||||||
android:layout_marginEnd="18dp"
|
android:layout_marginEnd="18dp"
|
||||||
android:clickable="true"
|
android:clickable="true"
|
||||||
|
@ -314,7 +314,7 @@
|
||||||
style="@style/Theme.Widget.Button.TextButton"
|
style="@style/Theme.Widget.Button.TextButton"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="18dp"
|
android:layout_marginStart="16dp"
|
||||||
android:layout_marginEnd="18dp"
|
android:layout_marginEnd="18dp"
|
||||||
android:text="@string/less"
|
android:text="@string/less"
|
||||||
android:textAlignment="textEnd"
|
android:textAlignment="textEnd"
|
||||||
|
@ -331,7 +331,7 @@
|
||||||
style="@style/Theme.Widget.Button.Primary"
|
style="@style/Theme.Widget.Button.Primary"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="24dp"
|
android:layout_marginStart="16dp"
|
||||||
android:layout_marginTop="12dp"
|
android:layout_marginTop="12dp"
|
||||||
android:layout_marginEnd="24dp"
|
android:layout_marginEnd="24dp"
|
||||||
android:text="@string/start_reading"
|
android:text="@string/start_reading"
|
||||||
|
|
Reference in a new issue