diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryController.kt index 68e2e61124..d7b180e17e 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryController.kt @@ -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) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaDetailsController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaDetailsController.kt index eef9aca26e..cde0e28d9f 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaDetailsController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaDetailsController.kt @@ -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 { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaHeaderHolder.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaHeaderHolder.kt index 4d5a4cd980..2212f7c88a 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaHeaderHolder.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaHeaderHolder.kt @@ -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) diff --git a/app/src/main/java/eu/kanade/tachiyomi/util/system/ContextExtensions.kt b/app/src/main/java/eu/kanade/tachiyomi/util/system/ContextExtensions.kt index 33f6eb8f60..535607110b 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/util/system/ContextExtensions.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/util/system/ContextExtensions.kt @@ -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. */ diff --git a/app/src/main/res/drawable/fast_scroll_background.xml b/app/src/main/res/drawable/fast_scroll_background.xml index 3f5fb0f8f0..c004264c58 100644 --- a/app/src/main/res/drawable/fast_scroll_background.xml +++ b/app/src/main/res/drawable/fast_scroll_background.xml @@ -1,8 +1,8 @@ @@ -14,7 +14,7 @@ diff --git a/app/src/main/res/layout/chapter_sort_bottom_sheet.xml b/app/src/main/res/layout/chapter_sort_bottom_sheet.xml index 87e7f31128..ebccb642c0 100644 --- a/app/src/main/res/layout/chapter_sort_bottom_sheet.xml +++ b/app/src/main/res/layout/chapter_sort_bottom_sheet.xml @@ -117,7 +117,7 @@ diff --git a/app/src/main/res/layout/manga_header_item.xml b/app/src/main/res/layout/manga_header_item.xml index 0798739a50..ab4ae410f4 100644 --- a/app/src/main/res/layout/manga_header_item.xml +++ b/app/src/main/res/layout/manga_header_item.xml @@ -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 @@ @@ -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" />