mirror of
https://github.com/null2264/yokai.git
synced 2025-06-21 10:44:42 +00:00
Fixes to RTL layouts
Fixed the fast scroll making it unable to scroll (why has no one reported this?) Fixed swiping of recycler items being inverted Not RTL but fixed the bookmarks icon when swiping being unreadable in certain themes
This commit is contained in:
parent
b8c7f56d5f
commit
53a6ec50e8
16 changed files with 105 additions and 51 deletions
|
@ -11,6 +11,7 @@ import eu.davidea.fastscroller.FastScroller
|
|||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.util.system.dpToPx
|
||||
import eu.kanade.tachiyomi.util.system.dpToPxEnd
|
||||
import eu.kanade.tachiyomi.util.system.isLTR
|
||||
import eu.kanade.tachiyomi.util.view.marginTop
|
||||
import kotlin.math.abs
|
||||
|
||||
|
@ -39,7 +40,13 @@ class MaterialFastScroll @JvmOverloads constructor(context: Context, attrs: Attr
|
|||
|
||||
when (event.action) {
|
||||
MotionEvent.ACTION_DOWN -> {
|
||||
if (event.x < handle.x - ViewCompat.getPaddingStart(handle)) return false
|
||||
if (
|
||||
if (context.resources.isLTR) {
|
||||
event.x < handle.x - ViewCompat.getPaddingStart(handle)
|
||||
} else {
|
||||
event.x > handle.width + ViewCompat.getPaddingStart(handle)
|
||||
}
|
||||
) return false
|
||||
val y = event.y
|
||||
startY = event.y
|
||||
if (canScroll) {
|
||||
|
|
|
@ -3,10 +3,27 @@ package eu.kanade.tachiyomi.ui.base.holder
|
|||
import android.view.View
|
||||
import eu.davidea.flexibleadapter.FlexibleAdapter
|
||||
import eu.davidea.viewholders.FlexibleViewHolder
|
||||
import eu.kanade.tachiyomi.util.system.isLTR
|
||||
|
||||
abstract class BaseFlexibleViewHolder(
|
||||
view: View,
|
||||
adapter: FlexibleAdapter<*>,
|
||||
stickyHeader: Boolean = false
|
||||
) :
|
||||
FlexibleViewHolder(view, adapter, stickyHeader)
|
||||
FlexibleViewHolder(view, adapter, stickyHeader) {
|
||||
override fun getRearRightView(): View? {
|
||||
return if (contentView.resources.isLTR) getRearEndView() else getRearStartView()
|
||||
}
|
||||
|
||||
override fun getRearLeftView(): View? {
|
||||
return if (contentView.resources.isLTR) getRearStartView() else getRearEndView()
|
||||
}
|
||||
|
||||
open fun getRearStartView(): View? {
|
||||
return null
|
||||
}
|
||||
|
||||
open fun getRearEndView(): View? {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
|
|
@ -109,11 +109,11 @@ class DownloadHolder(private val view: View, val adapter: DownloadAdapter) :
|
|||
return binding.frontView
|
||||
}
|
||||
|
||||
override fun getRearRightView(): View {
|
||||
return binding.rightView
|
||||
override fun getRearStartView(): View {
|
||||
return binding.startView
|
||||
}
|
||||
|
||||
override fun getRearLeftView(): View {
|
||||
return binding.leftView
|
||||
override fun getRearEndView(): View {
|
||||
return binding.endView
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
|||
import eu.kanade.tachiyomi.ui.manga.chapter.BaseChapterAdapter
|
||||
import eu.kanade.tachiyomi.ui.manga.chapter.ChapterItem
|
||||
import eu.kanade.tachiyomi.util.chapter.ChapterUtil
|
||||
import eu.kanade.tachiyomi.util.system.isLTR
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
import java.text.DecimalFormat
|
||||
import java.text.DecimalFormatSymbols
|
||||
|
@ -62,8 +63,16 @@ class MangaDetailsAdapter(
|
|||
override fun onItemSwiped(position: Int, direction: Int) {
|
||||
super.onItemSwiped(position, direction)
|
||||
when (direction) {
|
||||
ItemTouchHelper.RIGHT -> controller.bookmarkChapter(position)
|
||||
ItemTouchHelper.LEFT -> controller.toggleReadChapter(position)
|
||||
ItemTouchHelper.RIGHT -> if (recyclerView.resources.isLTR) {
|
||||
controller.bookmarkChapter(position)
|
||||
} else {
|
||||
controller.toggleReadChapter(position)
|
||||
}
|
||||
ItemTouchHelper.LEFT -> if (recyclerView.resources.isLTR) {
|
||||
controller.toggleReadChapter(position)
|
||||
} else {
|
||||
controller.bookmarkChapter(position)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -104,14 +104,14 @@ class ChapterHolder(
|
|||
val animatorSet = AnimatorSet()
|
||||
val anim1 = slideAnimation(0f, slide)
|
||||
anim1.startDelay = 1000
|
||||
anim1.addListener(StartAnimatorListener { binding.leftView.isVisible = true })
|
||||
anim1.addListener(StartAnimatorListener { binding.startView.isVisible = true })
|
||||
val anim2 = slideAnimation(slide, -slide)
|
||||
anim2.duration = 600
|
||||
anim2.startDelay = 500
|
||||
anim2.addUpdateListener {
|
||||
if (binding.leftView.isVisible && binding.frontView.translationX <= 0) {
|
||||
binding.leftView.isVisible = false
|
||||
binding.rightView.isVisible = true
|
||||
if (binding.startView.isVisible && binding.frontView.translationX <= 0) {
|
||||
binding.startView.isVisible = false
|
||||
binding.endView.isVisible = true
|
||||
}
|
||||
}
|
||||
val anim3 = slideAnimation(-slide, 0f)
|
||||
|
@ -134,12 +134,12 @@ class ChapterHolder(
|
|||
return binding.frontView
|
||||
}
|
||||
|
||||
override fun getRearRightView(): View {
|
||||
return binding.rightView
|
||||
override fun getRearEndView(): View {
|
||||
return binding.endView
|
||||
}
|
||||
|
||||
override fun getRearLeftView(): View {
|
||||
return binding.leftView
|
||||
override fun getRearStartView(): View {
|
||||
return binding.startView
|
||||
}
|
||||
|
||||
private fun resetFrontView() {
|
||||
|
|
|
@ -74,6 +74,7 @@ class RecentMangaAdapter(val delegate: RecentsInterface) :
|
|||
super.onItemSwiped(position, direction)
|
||||
when (direction) {
|
||||
ItemTouchHelper.LEFT -> delegate.markAsRead(position)
|
||||
ItemTouchHelper.RIGHT -> delegate.markAsRead(position)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -182,7 +182,7 @@ class RecentMangaHolder(
|
|||
return binding.frontView
|
||||
}
|
||||
|
||||
override fun getRearRightView(): View {
|
||||
return binding.rightView
|
||||
override fun getRearEndView(): View {
|
||||
return binding.endView
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,6 +48,7 @@ import eu.kanade.tachiyomi.ui.source.browse.ProgressItem
|
|||
import eu.kanade.tachiyomi.util.system.dpToPx
|
||||
import eu.kanade.tachiyomi.util.system.getBottomGestureInsets
|
||||
import eu.kanade.tachiyomi.util.system.getResourceColor
|
||||
import eu.kanade.tachiyomi.util.system.isLTR
|
||||
import eu.kanade.tachiyomi.util.system.spToPx
|
||||
import eu.kanade.tachiyomi.util.system.toInt
|
||||
import eu.kanade.tachiyomi.util.view.activityBinding
|
||||
|
@ -151,7 +152,7 @@ class RecentsController(bundle: Bundle? = null) :
|
|||
)
|
||||
adapter.isSwipeEnabled = true
|
||||
adapter.itemTouchHelperCallback.setSwipeFlags(
|
||||
ItemTouchHelper.LEFT
|
||||
if (view.resources.isLTR) ItemTouchHelper.LEFT else ItemTouchHelper.RIGHT
|
||||
)
|
||||
val attrsArray = intArrayOf(android.R.attr.actionBarSize)
|
||||
val array = view.context.obtainStyledAttributes(attrsArray)
|
||||
|
|
|
@ -56,22 +56,18 @@ class SourceHolder(view: View, val adapter: SourceAdapter) :
|
|||
}
|
||||
}
|
||||
|
||||
if (source.supportsLatest) {
|
||||
binding.sourceLatest.isVisible = true
|
||||
} else {
|
||||
binding.sourceLatest.isVisible = false
|
||||
}
|
||||
binding.sourceLatest.isVisible = source.supportsLatest
|
||||
}
|
||||
|
||||
override fun getFrontView(): View {
|
||||
return binding.card
|
||||
}
|
||||
|
||||
override fun getRearLeftView(): View {
|
||||
return binding.leftView
|
||||
override fun getRearStartView(): View {
|
||||
return binding.startView
|
||||
}
|
||||
|
||||
override fun getRearRightView(): View {
|
||||
return binding.rightView
|
||||
override fun getRearEndView(): View {
|
||||
return binding.endView
|
||||
}
|
||||
}
|
||||
|
|
|
@ -84,7 +84,9 @@
|
|||
<TextView
|
||||
android:id="@+id/title"
|
||||
style="@style/TextAppearance.MaterialComponents.Headline6"
|
||||
android:layout_width="0dp"
|
||||
android:layout_width="wrap_content"
|
||||
app:layout_constraintHorizontal_bias="0.0"
|
||||
app:layout_constrainedWidth="true"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="12dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
|
@ -100,8 +102,10 @@
|
|||
|
||||
<TextView
|
||||
android:id="@+id/manga_author"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="wrap_content"
|
||||
app:layout_constraintHorizontal_bias="0.0"
|
||||
app:layout_constrainedWidth="true"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="2"
|
||||
|
@ -116,7 +120,9 @@
|
|||
<TextView
|
||||
android:id="@+id/manga_status"
|
||||
style="@style/TextAppearance.Regular.Body1.Secondary"
|
||||
android:layout_width="0dp"
|
||||
android:layout_width="wrap_content"
|
||||
app:layout_constraintHorizontal_bias="0.0"
|
||||
app:layout_constrainedWidth="true"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="4dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
|
@ -129,7 +135,9 @@
|
|||
<com.google.android.material.textview.MaterialTextView
|
||||
android:id="@+id/manga_source"
|
||||
style="@style/TextAppearance.Regular.Body1.Secondary"
|
||||
android:layout_width="0dp"
|
||||
android:layout_width="wrap_content"
|
||||
app:layout_constraintHorizontal_bias="0.0"
|
||||
app:layout_constrainedWidth="true"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:ellipsize="end"
|
||||
|
|
|
@ -84,7 +84,9 @@
|
|||
<TextView
|
||||
android:id="@+id/title"
|
||||
style="@style/TextAppearance.MaterialComponents.Headline6"
|
||||
android:layout_width="0dp"
|
||||
android:layout_width="wrap_content"
|
||||
app:layout_constraintHorizontal_bias="0.0"
|
||||
app:layout_constrainedWidth="true"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="12dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
|
@ -100,8 +102,10 @@
|
|||
|
||||
<TextView
|
||||
android:id="@+id/manga_author"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="wrap_content"
|
||||
app:layout_constraintHorizontal_bias="0.0"
|
||||
app:layout_constrainedWidth="true"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="2"
|
||||
|
@ -116,8 +120,10 @@
|
|||
<TextView
|
||||
android:id="@+id/manga_status"
|
||||
style="@style/TextAppearance.Regular.Body1.Secondary"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="wrap_content"
|
||||
app:layout_constraintHorizontal_bias="0.0"
|
||||
app:layout_constrainedWidth="true"
|
||||
android:layout_marginTop="4dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:text="@string/unknown_status"
|
||||
|
@ -129,8 +135,10 @@
|
|||
<com.google.android.material.textview.MaterialTextView
|
||||
android:id="@+id/manga_source"
|
||||
style="@style/TextAppearance.Regular.Body1.Secondary"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="wrap_content"
|
||||
app:layout_constraintHorizontal_bias="0.0"
|
||||
app:layout_constrainedWidth="true"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
android:background="?android:attr/colorBackground">
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/right_view"
|
||||
android:id="@+id/end_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:visibility="gone"
|
||||
|
@ -30,7 +30,7 @@
|
|||
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/left_view"
|
||||
android:id="@+id/start_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:visibility="gone"
|
||||
|
@ -46,7 +46,7 @@
|
|||
android:layout_height="24dp"
|
||||
android:layout_gravity="start|center"
|
||||
android:layout_marginStart="21dp"
|
||||
app:tint="@color/md_white_1000"
|
||||
app:tint="?colorOnAccent"
|
||||
android:src="@drawable/ic_bookmark_24dp" />
|
||||
</FrameLayout>
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/right_view"
|
||||
android:id="@+id/end_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:visibility="gone"
|
||||
|
@ -24,7 +24,7 @@
|
|||
</FrameLayout>
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/left_view"
|
||||
android:id="@+id/start_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:visibility="gone"
|
||||
|
|
|
@ -80,11 +80,12 @@
|
|||
tools:src="@mipmap/ic_launcher" />
|
||||
</com.google.android.material.card.MaterialCardView>
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/title"
|
||||
style="@style/TextAppearance.MaterialComponents.Headline6"
|
||||
android:layout_width="0dp"
|
||||
android:layout_width="wrap_content"
|
||||
app:layout_constraintHorizontal_bias="0.0"
|
||||
app:layout_constrainedWidth="true"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="12dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
|
@ -100,8 +101,10 @@
|
|||
|
||||
<TextView
|
||||
android:id="@+id/manga_author"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="wrap_content"
|
||||
app:layout_constraintHorizontal_bias="0.0"
|
||||
app:layout_constrainedWidth="true"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="2"
|
||||
|
@ -116,8 +119,10 @@
|
|||
<TextView
|
||||
android:id="@+id/manga_status"
|
||||
style="@style/TextAppearance.Regular.Body1.Secondary"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="wrap_content"
|
||||
app:layout_constraintHorizontal_bias="0.0"
|
||||
app:layout_constrainedWidth="true"
|
||||
android:layout_marginTop="4dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:text="@string/unknown_status"
|
||||
|
@ -129,8 +134,10 @@
|
|||
<com.google.android.material.textview.MaterialTextView
|
||||
android:id="@+id/manga_source"
|
||||
style="@style/TextAppearance.Regular.Body1.Secondary"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="wrap_content"
|
||||
app:layout_constraintHorizontal_bias="0.0"
|
||||
app:layout_constrainedWidth="true"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
android:background="?android:attr/colorBackground">
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/right_view"
|
||||
android:id="@+id/end_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/material_green_800"
|
||||
|
@ -75,7 +75,7 @@
|
|||
<com.google.android.material.textview.MaterialTextView
|
||||
android:id="@+id/title"
|
||||
style="@style/TextAppearance.Regular.Body1.SemiBold"
|
||||
android:layout_width="0dp"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="12dp"
|
||||
android:layout_marginTop="2dp"
|
||||
|
@ -93,7 +93,7 @@
|
|||
app:flow_verticalBias="0.0"
|
||||
app:layout_constraintStart_toEndOf="@id/card_layout"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:text="New Chapter" />
|
||||
tools:text="New Chapters" />
|
||||
|
||||
<com.google.android.material.textview.MaterialTextView
|
||||
android:id="@+id/subtitle"
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
android:layout_height="wrap_content">
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/right_view"
|
||||
android:id="@+id/end_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/material_red_500"
|
||||
|
@ -27,7 +27,7 @@
|
|||
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/left_view"
|
||||
android:id="@+id/start_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/material_red_500">
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue