|
@@ -21,6 +21,7 @@ import android.view.animation.Animation
|
|
|
import android.view.animation.AnimationUtils
|
|
|
import android.widget.SeekBar
|
|
|
import androidx.core.view.ViewCompat
|
|
|
+import androidx.core.view.WindowInsetsCompat
|
|
|
import androidx.core.view.isVisible
|
|
|
import androidx.core.view.setPadding
|
|
|
import com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView
|
|
@@ -56,8 +57,6 @@ import eu.kanade.tachiyomi.util.view.showBar
|
|
|
import eu.kanade.tachiyomi.util.view.snack
|
|
|
import eu.kanade.tachiyomi.widget.SimpleAnimationListener
|
|
|
import eu.kanade.tachiyomi.widget.SimpleSeekBarListener
|
|
|
-import java.io.File
|
|
|
-import kotlin.math.abs
|
|
|
import kotlinx.coroutines.FlowPreview
|
|
|
import kotlinx.coroutines.delay
|
|
|
import kotlinx.coroutines.flow.drop
|
|
@@ -67,6 +66,8 @@ import kotlinx.coroutines.flow.sample
|
|
|
import nucleus.factory.RequiresPresenter
|
|
|
import timber.log.Timber
|
|
|
import uy.kohesive.injekt.injectLazy
|
|
|
+import java.io.File
|
|
|
+import kotlin.math.abs
|
|
|
|
|
|
/**
|
|
|
* Activity containing the reader of Tachiyomi. This activity is mostly a container of the
|
|
@@ -290,24 +291,27 @@ class ReaderActivity : BaseRxActivity<ReaderActivityBinding, ReaderPresenter>()
|
|
|
|
|
|
ViewCompat.setOnApplyWindowInsetsListener(binding.readerMenu) { _, insets ->
|
|
|
if (!window.isDefaultBar()) {
|
|
|
+ val systemInsets = insets.getInsets(WindowInsetsCompat.Type.systemBars())
|
|
|
binding.readerMenu.setPadding(
|
|
|
- insets.systemWindowInsetLeft,
|
|
|
- insets.systemWindowInsetTop,
|
|
|
- insets.systemWindowInsetRight,
|
|
|
- insets.systemWindowInsetBottom
|
|
|
+ systemInsets.left,
|
|
|
+ systemInsets.top,
|
|
|
+ systemInsets.right,
|
|
|
+ systemInsets.bottom
|
|
|
)
|
|
|
}
|
|
|
insets
|
|
|
}
|
|
|
|
|
|
// Init listeners on bottom menu
|
|
|
- binding.pageSeekbar.setOnSeekBarChangeListener(object : SimpleSeekBarListener() {
|
|
|
- override fun onProgressChanged(seekBar: SeekBar, value: Int, fromUser: Boolean) {
|
|
|
- if (viewer != null && fromUser) {
|
|
|
- moveToPageIndex(value)
|
|
|
+ binding.pageSeekbar.setOnSeekBarChangeListener(
|
|
|
+ object : SimpleSeekBarListener() {
|
|
|
+ override fun onProgressChanged(seekBar: SeekBar, value: Int, fromUser: Boolean) {
|
|
|
+ if (viewer != null && fromUser) {
|
|
|
+ moveToPageIndex(value)
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- })
|
|
|
+ )
|
|
|
binding.leftChapter.setOnClickListener {
|
|
|
if (viewer != null) {
|
|
|
if (viewer is R2LPagerViewer) {
|
|
@@ -347,12 +351,14 @@ class ReaderActivity : BaseRxActivity<ReaderActivityBinding, ReaderPresenter>()
|
|
|
|
|
|
if (animate) {
|
|
|
val toolbarAnimation = AnimationUtils.loadAnimation(this, R.anim.enter_from_top)
|
|
|
- toolbarAnimation.setAnimationListener(object : SimpleAnimationListener() {
|
|
|
- override fun onAnimationStart(animation: Animation) {
|
|
|
- // Fix status bar being translucent the first time it's opened.
|
|
|
- window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS)
|
|
|
+ toolbarAnimation.setAnimationListener(
|
|
|
+ object : SimpleAnimationListener() {
|
|
|
+ override fun onAnimationStart(animation: Animation) {
|
|
|
+// Fix status bar being translucent the first time it's opened.
|
|
|
+ window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS)
|
|
|
+ }
|
|
|
}
|
|
|
- })
|
|
|
+ )
|
|
|
binding.toolbar.startAnimation(toolbarAnimation)
|
|
|
|
|
|
val bottomAnimation = AnimationUtils.loadAnimation(this, R.anim.enter_from_bottom)
|
|
@@ -371,11 +377,13 @@ class ReaderActivity : BaseRxActivity<ReaderActivityBinding, ReaderPresenter>()
|
|
|
|
|
|
if (animate) {
|
|
|
val toolbarAnimation = AnimationUtils.loadAnimation(this, R.anim.exit_to_top)
|
|
|
- toolbarAnimation.setAnimationListener(object : SimpleAnimationListener() {
|
|
|
- override fun onAnimationEnd(animation: Animation) {
|
|
|
- binding.readerMenu.isVisible = false
|
|
|
+ toolbarAnimation.setAnimationListener(
|
|
|
+ object : SimpleAnimationListener() {
|
|
|
+ override fun onAnimationEnd(animation: Animation) {
|
|
|
+ binding.readerMenu.isVisible = false
|
|
|
+ }
|
|
|
}
|
|
|
- })
|
|
|
+ )
|
|
|
binding.toolbar.startAnimation(toolbarAnimation)
|
|
|
|
|
|
val bottomAnimation = AnimationUtils.loadAnimation(this, R.anim.exit_to_bottom)
|
|
@@ -572,9 +580,13 @@ class ReaderActivity : BaseRxActivity<ReaderActivityBinding, ReaderPresenter>()
|
|
|
* Called from the presenter when a page is ready to be shared. It shows Android's default
|
|
|
* sharing tool.
|
|
|
*/
|
|
|
- fun onShareImageResult(file: File) {
|
|
|
+ fun onShareImageResult(file: File, page: ReaderPage) {
|
|
|
+ val manga = presenter.manga ?: return
|
|
|
+ val chapter = page.chapter.chapter
|
|
|
+
|
|
|
val stream = file.getUriCompat(this)
|
|
|
val intent = Intent(Intent.ACTION_SEND).apply {
|
|
|
+ putExtra(Intent.EXTRA_TEXT, getString(R.string.share_page_info, manga.title, chapter.name, page.number))
|
|
|
putExtra(Intent.EXTRA_STREAM, stream)
|
|
|
flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_GRANT_READ_URI_PERMISSION
|
|
|
type = "image/*"
|