mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-13 00:05:08 +01:00
Better RTL support in manga details and library
This commit is contained in:
parent
024b075330
commit
9586b564ed
@ -54,6 +54,7 @@ import eu.kanade.tachiyomi.ui.manga.MangaDetailsController
|
||||
import eu.kanade.tachiyomi.ui.migration.manga.design.PreMigrationController
|
||||
import eu.kanade.tachiyomi.ui.reader.ReaderActivity
|
||||
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.launchUI
|
||||
import eu.kanade.tachiyomi.util.system.toast
|
||||
@ -169,7 +170,7 @@ class LibraryController(
|
||||
text_view_m.translationY = view.height *
|
||||
(index.toFloat() / (adapter.headerItems.size + 1))
|
||||
- text_view_m.height / 2 + 16.dpToPx
|
||||
text_view_m.translationX = 45f.dpToPx
|
||||
text_view_m.translationX = 45f.dpToPxEnd
|
||||
text_view_m.alpha = 1f
|
||||
text_view_m.text = headerItem.category.name
|
||||
}
|
||||
@ -189,7 +190,7 @@ class LibraryController(
|
||||
}
|
||||
RecyclerView.SCROLL_STATE_IDLE -> {
|
||||
scrollAnim = fast_scroller.animate().setStartDelay(1000).setDuration(250)
|
||||
.translationX(25f.dpToPx)
|
||||
.translationX(25f.dpToPxEnd)
|
||||
scrollAnim?.start()
|
||||
}
|
||||
}
|
||||
@ -199,7 +200,8 @@ class LibraryController(
|
||||
private fun hideScroller(duration: Long = 1000) {
|
||||
if (alwaysShowScroller) return
|
||||
scrollAnim =
|
||||
fast_scroller.animate().setStartDelay(duration).setDuration(250).translationX(25f.dpToPx)
|
||||
fast_scroller.animate().setStartDelay(duration).setDuration(250)
|
||||
.translationX(25f.dpToPxEnd)
|
||||
scrollAnim?.start()
|
||||
}
|
||||
|
||||
@ -219,7 +221,7 @@ class LibraryController(
|
||||
super.onViewCreated(view)
|
||||
view.applyWindowInsetsForRootController(activity!!.bottom_nav)
|
||||
if (!::presenter.isInitialized) presenter = LibraryPresenter(this)
|
||||
if (!alwaysShowScroller) fast_scroller.translationX = 25f.dpToPx
|
||||
if (!alwaysShowScroller) fast_scroller.translationX = 25f.dpToPxEnd
|
||||
setFastScrollBackground()
|
||||
|
||||
adapter = LibraryCategoryAdapter(this)
|
||||
|
@ -93,6 +93,7 @@ import eu.kanade.tachiyomi.ui.webview.WebViewActivity
|
||||
import eu.kanade.tachiyomi.util.storage.getUriCompat
|
||||
import eu.kanade.tachiyomi.util.system.ThemeUtil
|
||||
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.launchUI
|
||||
import eu.kanade.tachiyomi.util.system.pxToDp
|
||||
@ -293,7 +294,7 @@ class MangaDetailsController : BaseController,
|
||||
showScroll = show
|
||||
scrollAnim?.cancel()
|
||||
scrollAnim = fast_scroller.animate().setDuration(100).translationX(
|
||||
if (show) 0f else 25f.dpToPx)
|
||||
if (show) 0f else 25f.dpToPxEnd)
|
||||
scrollAnim?.start()
|
||||
}
|
||||
if (fPosition > 0 && !showScroll) {
|
||||
@ -312,7 +313,7 @@ class MangaDetailsController : BaseController,
|
||||
}
|
||||
|
||||
private fun setFastScroller() {
|
||||
fast_scroller.translationX = if (showScroll || isTablet) 0f else 25f.dpToPx
|
||||
fast_scroller.translationX = if (showScroll || isTablet) 0f else 25f.dpToPxEnd
|
||||
fast_scroller.setupWithRecyclerView(recycler, { position ->
|
||||
val letter = adapter?.getSectionText(position)
|
||||
when {
|
||||
|
@ -20,6 +20,7 @@ import eu.kanade.tachiyomi.source.LocalSource
|
||||
import eu.kanade.tachiyomi.source.model.SManga
|
||||
import eu.kanade.tachiyomi.ui.base.holder.BaseFlexibleViewHolder
|
||||
import eu.kanade.tachiyomi.util.system.getResourceColor
|
||||
import eu.kanade.tachiyomi.util.system.isLTR
|
||||
import eu.kanade.tachiyomi.util.view.gone
|
||||
import eu.kanade.tachiyomi.util.view.invisible
|
||||
import eu.kanade.tachiyomi.util.view.resetStrokeColor
|
||||
@ -56,6 +57,8 @@ class MangaHeaderHolder(
|
||||
true
|
||||
false
|
||||
}
|
||||
if (!itemView.resources.isLTR)
|
||||
more_bg_gradient.rotation = 180f
|
||||
less_button.setOnClickListener { collapseDesc() }
|
||||
manga_genres_tags.setOnTagClickListener {
|
||||
adapter.delegate.tagClicked(it)
|
||||
|
@ -9,14 +9,13 @@ import android.content.Intent
|
||||
import android.content.IntentFilter
|
||||
import android.content.pm.PackageManager
|
||||
import android.content.res.Resources
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.net.ConnectivityManager
|
||||
import android.net.Uri
|
||||
import android.os.PowerManager
|
||||
import android.view.View
|
||||
import android.widget.Toast
|
||||
import androidx.annotation.AttrRes
|
||||
import androidx.annotation.ColorRes
|
||||
import androidx.annotation.DrawableRes
|
||||
import androidx.annotation.StringRes
|
||||
import androidx.browser.customtabs.CustomTabsIntent
|
||||
import androidx.core.app.NotificationCompat
|
||||
@ -101,15 +100,6 @@ fun Context.contextCompatColor(@ColorRes resource: Int): Int {
|
||||
return ContextCompat.getColor(this, resource)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the color from ContextCompat
|
||||
*
|
||||
* @param resource the color.
|
||||
*/
|
||||
fun Context.contextCompatDrawable(@DrawableRes resource: Int): Drawable? {
|
||||
return ContextCompat.getDrawable(this, resource)
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts to dp.
|
||||
*/
|
||||
@ -125,6 +115,14 @@ val Int.dpToPx: Int
|
||||
val Float.dpToPx: Float
|
||||
get() = (this * Resources.getSystem().displayMetrics.density)
|
||||
|
||||
/** Converts to px and takes into account LTR/RTL layout */
|
||||
val Float.dpToPxEnd: Float
|
||||
get() = (this * Resources.getSystem().displayMetrics.density *
|
||||
if (Resources.getSystem().isLTR) 1 else -1)
|
||||
|
||||
val Resources.isLTR
|
||||
get() = configuration.layoutDirection == View.LAYOUT_DIRECTION_LTR
|
||||
|
||||
/**
|
||||
* Property to get the notification manager from the context.
|
||||
*/
|
||||
|
@ -1,8 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item
|
||||
android:left="0dp"
|
||||
android:right="4dp"
|
||||
android:start="0dp"
|
||||
android:end="4dp"
|
||||
android:bottom="4dp"
|
||||
android:top="4dp">
|
||||
<shape android:shape="rectangle">
|
||||
@ -14,7 +14,7 @@
|
||||
</shape>
|
||||
</item>
|
||||
<item
|
||||
android:left="10dp"
|
||||
android:start="10dp"
|
||||
android:bottom="4dp"
|
||||
android:top="4dp">
|
||||
<shape android:shape="rectangle">
|
||||
|
@ -117,7 +117,7 @@
|
||||
|
||||
<com.google.android.material.textview.MaterialTextView
|
||||
style="@style/TextAppearance.MaterialComponents.Headline6"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="12dp"
|
||||
android:paddingStart="16dp"
|
||||
@ -128,7 +128,7 @@
|
||||
android:id="@+id/sort_method_group"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:orientation="horizontal"
|
||||
android:paddingStart="12dp"
|
||||
android:paddingEnd="12dp">
|
||||
|
||||
|
@ -49,9 +49,9 @@
|
||||
android:id="@+id/top_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="100dp"
|
||||
android:layout_marginTop="0dp"
|
||||
app:layout_constraintBottom_toTopOf="@id/cover_card"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.0"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
@ -116,11 +116,13 @@
|
||||
<TextView
|
||||
android:id="@+id/manga_status"
|
||||
style="@style/TextAppearance.Regular.Body1.Secondary"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="4dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:text="@string/unknown_status"
|
||||
android:textIsSelectable="false"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="@id/title"
|
||||
app:layout_constraintTop_toBottomOf="@+id/manga_author" />
|
||||
|
||||
@ -268,7 +270,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:text="@string/more"
|
||||
android:textAlignment="textEnd"
|
||||
android:textAlignment="viewEnd"
|
||||
app:layout_constraintBottom_toBottomOf="@id/more_guide"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:rippleColor="@null" />
|
||||
|
Loading…
Reference in New Issue
Block a user