diff --git a/app/build.gradle.kts b/app/build.gradle.kts
index 540b8608f3..35b1459791 100644
--- a/app/build.gradle.kts
+++ b/app/build.gradle.kts
@@ -89,7 +89,7 @@ androidExtensions {
dependencies {
// Modified dependencies
- implementation("com.github.tachiyomiorg:subsampling-scale-image-view:6caf219")
+ implementation("com.github.jays2kings:subsampling-scale-image-view:dfd3e43")
implementation("com.github.inorichi:junrar-android:634c1f5")
// Source models and interfaces from Tachiyomi 1.x
diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferenceKeys.kt b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferenceKeys.kt
index 36c4190220..4f8e9b1457 100644
--- a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferenceKeys.kt
+++ b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferenceKeys.kt
@@ -15,6 +15,8 @@ object PreferenceKeys {
const val enableTransitions = "pref_enable_transitions_key"
+ const val pagerCutoutBehavior = "pager_cutout_behavior"
+
const val doubleTapAnimationSpeed = "pref_double_tap_anim_speed"
const val showPageNumber = "pref_show_page_number_key"
diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt
index fefe4ed258..31864f8d36 100644
--- a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt
+++ b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt
@@ -89,6 +89,8 @@ class PreferencesHelper(val context: Context) {
fun pageTransitions() = flowPrefs.getBoolean(Keys.enableTransitions, true)
+ fun pagerCutoutBehavior() = flowPrefs.getInt(Keys.pagerCutoutBehavior, 1)
+
fun doubleTapAnimSpeed() = flowPrefs.getInt(Keys.doubleTapAnimationSpeed, 500)
fun showPageNumber() = flowPrefs.getBoolean(Keys.showPageNumber, true)
diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/settings/ReaderPagedView.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/settings/ReaderPagedView.kt
index 42988d5650..c67f100d91 100644
--- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/settings/ReaderPagedView.kt
+++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/settings/ReaderPagedView.kt
@@ -1,7 +1,9 @@
package eu.kanade.tachiyomi.ui.reader.settings
+import android.app.Activity
import android.content.Context
import android.util.AttributeSet
+import com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView
import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.ui.reader.ReaderActivity
import eu.kanade.tachiyomi.util.bindToPreference
@@ -13,12 +15,17 @@ class ReaderPagedView @JvmOverloads constructor(context: Context, attrs: Attribu
BaseReaderSettingsView(context, attrs) {
override fun initGeneralPreferences() {
- scale_type.bindToPreference(preferences.imageScaleType(), 1)
+ scale_type.bindToPreference(preferences.imageScaleType(), 1) {
+ val mangaViewer = (context as? ReaderActivity)?.presenter?.getMangaViewer() ?: 0
+ val isWebtoonView = mangaViewer == ReaderActivity.WEBTOON || mangaViewer == ReaderActivity.VERTICAL_PLUS
+ updatePagedGroup(!isWebtoonView)
+ }
zoom_start.bindToPreference(preferences.zoomStart(), 1)
crop_borders.bindToPreference(preferences.cropBorders())
page_transitions.bindToPreference(preferences.pageTransitions())
pager_nav.bindToPreference(preferences.navigationModePager())
pager_invert.bindToPreference(preferences.pagerNavInverted())
+ extend_past_cutout.bindToPreference(preferences.pagerCutoutBehavior())
val mangaViewer = (context as? ReaderActivity)?.presenter?.getMangaViewer() ?: 0
val isWebtoonView = mangaViewer == ReaderActivity.WEBTOON || mangaViewer == ReaderActivity.VERTICAL_PLUS
@@ -43,5 +50,18 @@ class ReaderPagedView @JvmOverloads constructor(context: Context, attrs: Attribu
private fun updatePagedGroup(show: Boolean) {
listOf(scale_type, zoom_start, crop_borders, page_transitions, pager_nav, pager_invert).forEach { it.visibleIf(show) }
listOf(crop_borders_webtoon, webtoon_side_padding, webtoon_enable_zoom_out, webtoon_nav, webtoon_invert).forEach { it.visibleIf(!show) }
+ val isFullFit = when (preferences.imageScaleType().get()) {
+ SubsamplingScaleImageView.SCALE_TYPE_FIT_HEIGHT,
+ SubsamplingScaleImageView.SCALE_TYPE_SMART_FIT,
+ SubsamplingScaleImageView.SCALE_TYPE_CENTER_CROP -> true
+ else -> false
+ }
+ val ogView = (context as? Activity)?.window?.decorView
+ val hasCutout = if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.P) {
+ ogView?.rootWindowInsets?.displayCutout?.safeInsetTop != null || ogView?.rootWindowInsets?.displayCutout?.safeInsetBottom != null
+ } else {
+ false
+ }
+ extend_past_cutout.visibleIf(show && isFullFit && hasCutout)
}
}
diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerConfig.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerConfig.kt
index 6577970b6f..c7c199818e 100644
--- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerConfig.kt
+++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerConfig.kt
@@ -1,5 +1,6 @@
package eu.kanade.tachiyomi.ui.reader.viewer.pager
+import com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
import eu.kanade.tachiyomi.ui.reader.viewer.ViewerConfig
import eu.kanade.tachiyomi.ui.reader.viewer.ViewerNavigation
@@ -34,6 +35,9 @@ class PagerConfig(private val viewer: PagerViewer, preferences: PreferencesHelpe
var readerTheme = 0
private set
+ var cutoutBehavior = 0
+ private set
+
init {
preferences.pageTransitions()
.register({ usePageTransitions = it })
@@ -59,6 +63,9 @@ class PagerConfig(private val viewer: PagerViewer, preferences: PreferencesHelpe
}
.launchIn(scope)
+ preferences.pagerCutoutBehavior()
+ .register({ cutoutBehavior = it }, { imagePropertyChangedListener?.invoke() })
+
preferences.zoomStart()
.register({ zoomTypeFromPreference(it) }, { imagePropertyChangedListener?.invoke() })
@@ -103,6 +110,15 @@ class PagerConfig(private val viewer: PagerViewer, preferences: PreferencesHelpe
}
}
+ fun scaleTypeIsFullFit(): Boolean {
+ return when (imageScaleType) {
+ SubsamplingScaleImageView.SCALE_TYPE_FIT_HEIGHT,
+ SubsamplingScaleImageView.SCALE_TYPE_SMART_FIT,
+ SubsamplingScaleImageView.SCALE_TYPE_CENTER_CROP -> true
+ else -> false
+ }
+ }
+
override fun updateNavigation(navigationMode: Int) {
navigator = when (navigationMode) {
0 -> defaultNavigation()
@@ -118,4 +134,10 @@ class PagerConfig(private val viewer: PagerViewer, preferences: PreferencesHelpe
enum class ZoomType {
Left, Center, Right
}
+
+ companion object {
+ const val CUTOUT_PAD = 0
+ const val CUTOUT_START_EXTENDED = 1
+ const val CUTOUT_IGNORE = 2
+ }
}
diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerPageHolder.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerPageHolder.kt
index a54f4b2a79..4bcff62faf 100644
--- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerPageHolder.kt
+++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerPageHolder.kt
@@ -29,6 +29,8 @@ import eu.kanade.tachiyomi.data.preference.PreferencesHelper
import eu.kanade.tachiyomi.source.model.Page
import eu.kanade.tachiyomi.ui.reader.model.ReaderPage
import eu.kanade.tachiyomi.ui.reader.viewer.ReaderProgressBar
+import eu.kanade.tachiyomi.ui.reader.viewer.pager.PagerConfig.Companion.CUTOUT_IGNORE
+import eu.kanade.tachiyomi.ui.reader.viewer.pager.PagerConfig.Companion.CUTOUT_START_EXTENDED
import eu.kanade.tachiyomi.ui.reader.viewer.pager.PagerConfig.ZoomType
import eu.kanade.tachiyomi.util.system.ImageUtil
import eu.kanade.tachiyomi.util.system.ThemeUtil
@@ -365,7 +367,18 @@ class PagerPageHolder(
setMinimumDpi(90)
setMinimumTileDpi(180)
setCropBorders(config.imageCropBorders)
- if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.Q) {
+ val topInsets =
+ if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.P) {
+ viewer.activity.window.decorView.rootWindowInsets.displayCutout?.safeInsetTop?.toFloat() ?: 0f
+ } else 0f
+ val bottomInsets =
+ if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.P) {
+ viewer.activity.window.decorView.rootWindowInsets.displayCutout?.safeInsetBottom?.toFloat() ?: 0f
+ } else 0f
+ setExtendPastCutout(config.cutoutBehavior == CUTOUT_START_EXTENDED && config.scaleTypeIsFullFit() && topInsets + bottomInsets > 0)
+ if ((config.cutoutBehavior != CUTOUT_IGNORE || !config.scaleTypeIsFullFit()) &&
+ android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.Q
+ ) {
val insets: WindowInsets? = viewer.activity.window.decorView.rootWindowInsets
setExtraSpace(
0f,
@@ -377,10 +390,28 @@ class PagerPageHolder(
setOnImageEventListener(
object : SubsamplingScaleImageView.DefaultOnImageEventListener() {
override fun onReady() {
+ var centerV = 0f
when (config.imageZoomType) {
- ZoomType.Left -> setScaleAndCenter(scale, PointF(0f, 0f))
- ZoomType.Right -> setScaleAndCenter(scale, PointF(sWidth.toFloat(), 0f))
- ZoomType.Center -> setScaleAndCenter(scale, center.also { it?.y = 0f })
+ ZoomType.Left -> {
+ setScaleAndCenter(scale, PointF(0f, 0f))
+ }
+ ZoomType.Right -> {
+ setScaleAndCenter(scale, PointF(sWidth.toFloat(), 0f))
+ centerV = sWidth.toFloat()
+ }
+ ZoomType.Center -> {
+ setScaleAndCenter(scale, center.also { it?.y = 0f })
+ centerV = center?.x ?: 0f
+ }
+ }
+ if (config.cutoutBehavior == CUTOUT_START_EXTENDED &&
+ topInsets + bottomInsets > 0 &&
+ config.scaleTypeIsFullFit()
+ ) {
+ setScaleAndCenter(
+ scale,
+ PointF(centerV, (center?.y?.plus(topInsets)?.minus(bottomInsets) ?: 0f))
+ )
}
onImageDecoded()
}
diff --git a/app/src/main/res/layout/reader_paged_layout.xml b/app/src/main/res/layout/reader_paged_layout.xml
index e0c9f71d23..980a50e6f7 100644
--- a/app/src/main/res/layout/reader_paged_layout.xml
+++ b/app/src/main/res/layout/reader_paged_layout.xml
@@ -40,6 +40,14 @@
app:title="@string/scale_type"
android:entries="@array/image_scale_type" />
+
+
-
@string/both_axes
+
+ - @string/pad_cutout_areas
+ - @string/start_past_cutout
+ - @string/ignore_cutout_areas
+
+
- @string/clean_orphaned_downloads
- @string/clean_read_downloads
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 1816e3c985..f3a1462496 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -378,6 +378,10 @@
Horizontally
Vertically
Both Axes
+ Cutout area behavior
+ Pad cutout areas
+ Start past cutout
+ Ignore cutout areas
About this %1$s