From ed5a56be60d144c917b7b09bf183c688e6d54b06 Mon Sep 17 00:00:00 2001 From: arkon Date: Sat, 27 May 2023 19:15:11 -0400 Subject: [PATCH] Set reader chapter name to marquee if too long Closes #7159 --- .../java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt index d605b7890..965dbd41c 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt @@ -14,6 +14,7 @@ import android.graphics.Paint import android.net.Uri import android.os.Build import android.os.Bundle +import android.text.TextUtils import android.view.Gravity import android.view.KeyEvent import android.view.Menu @@ -38,6 +39,7 @@ import androidx.core.view.isVisible import androidx.core.view.updateLayoutParams import androidx.lifecycle.lifecycleScope import com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView +import com.google.android.material.internal.ToolbarUtils import com.google.android.material.shape.MaterialShapeDrawable import com.google.android.material.transition.platform.MaterialContainerTransform import dev.chrisbanes.insetter.applyInsetter @@ -695,10 +697,16 @@ class ReaderActivity : BaseActivity() { * method to the current viewer, but also set the subtitle on the toolbar, and * hides or disables the reader prev/next buttons if there's a prev or next chapter */ + @SuppressLint("RestrictedApi") private fun setChapters(viewerChapters: ViewerChapters) { binding.readerContainer.removeView(loadingIndicator) viewModel.state.value.viewer?.setChapters(viewerChapters) + binding.toolbar.subtitle = viewerChapters.currChapter.chapter.name + ToolbarUtils.getSubtitleTextView(binding.toolbar)?.let { + it.ellipsize = TextUtils.TruncateAt.MARQUEE + it.isSelected = true + } // Invalidate menu to show proper chapter bookmark state invalidateOptionsMenu()