From 94cba9324c872b1f0caa3f4d385266f190a9b114 Mon Sep 17 00:00:00 2001 From: arkon Date: Sun, 8 Oct 2023 16:23:57 -0400 Subject: [PATCH] Remove beta webtoon viewer split page This had a bunch of issues around split pages not showing up properly so things end up appearing to be missing while reading. It'd be more worthwhile redoing the reader viewers than trying to get this to work properly. It'd be better to just enable the split pages on download instead. Closes #8433 --- .../settings/screen/SettingsReaderScreen.kt | 7 ---- .../reader/settings/ReadingModePage.kt | 8 ---- .../java/eu/kanade/tachiyomi/Migrations.kt | 8 ---- .../data/backup/BackupFileValidator.kt | 5 ++- .../tachiyomi/data/backup/BackupRestoreJob.kt | 7 ++-- .../tachiyomi/ui/reader/ReaderViewModel.kt | 5 +-- .../tachiyomi/ui/reader/model/StencilPage.kt | 16 ------- .../ui/reader/setting/ReaderPreferences.kt | 4 -- .../reader/viewer/webtoon/WebtoonAdapter.kt | 23 ---------- .../ui/reader/viewer/webtoon/WebtoonConfig.kt | 14 ------- .../viewer/webtoon/WebtoonPageHolder.kt | 34 --------------- .../ui/reader/viewer/webtoon/WebtoonViewer.kt | 23 ---------- .../tachiyomi/core/util/system/ImageUtil.kt | 42 ------------------- i18n/src/main/res/values/strings.xml | 1 - 14 files changed, 9 insertions(+), 188 deletions(-) delete mode 100644 app/src/main/java/eu/kanade/tachiyomi/ui/reader/model/StencilPage.kt diff --git a/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsReaderScreen.kt b/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsReaderScreen.kt index bb73b89ec7..ef35ea38b6 100644 --- a/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsReaderScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsReaderScreen.kt @@ -13,7 +13,6 @@ import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.ui.reader.setting.OrientationType import eu.kanade.tachiyomi.ui.reader.setting.ReaderPreferences import eu.kanade.tachiyomi.ui.reader.setting.ReadingModeType -import eu.kanade.tachiyomi.util.system.isReleaseBuildType import tachiyomi.presentation.core.util.collectAsState import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get @@ -305,12 +304,6 @@ object SettingsReaderScreen : SearchableSettings { subtitle = stringResource(R.string.pref_dual_page_invert_summary), enabled = dualPageSplit, ), - Preference.PreferenceItem.SwitchPreference( - pref = readerPreferences.longStripSplitWebtoon(), - title = stringResource(R.string.pref_long_strip_split), - subtitle = stringResource(R.string.split_tall_images_summary), - enabled = !isReleaseBuildType, // TODO: Show in release build when the feature is stable - ), Preference.PreferenceItem.SwitchPreference( pref = readerPreferences.webtoonDoubleTapZoomEnabled(), title = stringResource(R.string.pref_double_tap_zoom), diff --git a/app/src/main/java/eu/kanade/presentation/reader/settings/ReadingModePage.kt b/app/src/main/java/eu/kanade/presentation/reader/settings/ReadingModePage.kt index 874a053cd9..07d6cb49a5 100644 --- a/app/src/main/java/eu/kanade/presentation/reader/settings/ReadingModePage.kt +++ b/app/src/main/java/eu/kanade/presentation/reader/settings/ReadingModePage.kt @@ -16,7 +16,6 @@ import eu.kanade.tachiyomi.ui.reader.setting.ReaderPreferences import eu.kanade.tachiyomi.ui.reader.setting.ReaderSettingsScreenModel import eu.kanade.tachiyomi.ui.reader.setting.ReadingModeType import eu.kanade.tachiyomi.ui.reader.viewer.webtoon.WebtoonViewer -import eu.kanade.tachiyomi.util.system.isReleaseBuildType import tachiyomi.presentation.core.components.CheckboxItem import tachiyomi.presentation.core.components.HeadingItem import tachiyomi.presentation.core.components.SettingsChipRow @@ -185,13 +184,6 @@ private fun ColumnScope.WebtoonViewerSettings(screenModel: ReaderSettingsScreenM ) } - if (!isReleaseBuildType) { - CheckboxItem( - label = stringResource(R.string.pref_long_strip_split), - pref = screenModel.preferences.longStripSplitWebtoon(), - ) - } - CheckboxItem( label = stringResource(R.string.pref_double_tap_zoom), pref = screenModel.preferences.webtoonDoubleTapZoomEnabled(), diff --git a/app/src/main/java/eu/kanade/tachiyomi/Migrations.kt b/app/src/main/java/eu/kanade/tachiyomi/Migrations.kt index f341e26a64..bbdcaa6eae 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/Migrations.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/Migrations.kt @@ -15,7 +15,6 @@ import eu.kanade.tachiyomi.network.PREF_DOH_CLOUDFLARE import eu.kanade.tachiyomi.ui.reader.setting.OrientationType import eu.kanade.tachiyomi.ui.reader.setting.ReaderPreferences import eu.kanade.tachiyomi.util.system.DeviceUtil -import eu.kanade.tachiyomi.util.system.isReleaseBuildType import eu.kanade.tachiyomi.util.system.toast import eu.kanade.tachiyomi.util.system.workManager import tachiyomi.core.preference.Preference @@ -363,13 +362,6 @@ object Migrations { if (oldVersion < 100) { BackupCreateJob.setupTask(context) } - if (oldVersion < 102) { - // This was accidentally visible from the reader settings sheet, but should always - // be disabled in release builds. - if (isReleaseBuildType) { - readerPreferences.longStripSplitWebtoon().set(false) - } - } if (oldVersion < 105) { val pref = libraryPreferences.autoUpdateDeviceRestrictions() if (pref.isSet() && "battery_not_low" in pref.get()) { diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/backup/BackupFileValidator.kt b/app/src/main/java/eu/kanade/tachiyomi/data/backup/BackupFileValidator.kt index ea8f3c9ea3..8450ab3677 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/backup/BackupFileValidator.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/backup/BackupFileValidator.kt @@ -58,5 +58,8 @@ class BackupFileValidator( return Results(missingSources, missingTrackers) } - data class Results(val missingSources: List, val missingTrackers: List) + data class Results( + val missingSources: List, + val missingTrackers: List, + ) } diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/backup/BackupRestoreJob.kt b/app/src/main/java/eu/kanade/tachiyomi/data/backup/BackupRestoreJob.kt index 4f1c45bc29..170ddb80fa 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/backup/BackupRestoreJob.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/backup/BackupRestoreJob.kt @@ -26,7 +26,7 @@ class BackupRestoreJob(private val context: Context, workerParams: WorkerParamet override suspend fun doWork(): Result { val uri = inputData.getString(LOCATION_URI_KEY)?.toUri() ?: return Result.failure() - val sync = inputData.getBoolean(SYNC, false) + val sync = inputData.getBoolean(SYNC_KEY, false) try { setForeground(getForegroundInfo()) @@ -67,7 +67,7 @@ class BackupRestoreJob(private val context: Context, workerParams: WorkerParamet fun start(context: Context, uri: Uri, sync: Boolean = false) { val inputData = workDataOf( LOCATION_URI_KEY to uri.toString(), - SYNC to sync, + SYNC_KEY to sync, ) val request = OneTimeWorkRequestBuilder() .addTag(TAG) @@ -85,5 +85,4 @@ class BackupRestoreJob(private val context: Context, workerParams: WorkerParamet private const val TAG = "BackupRestore" private const val LOCATION_URI_KEY = "location_uri" // String - -private const val SYNC = "sync" // Boolean +private const val SYNC_KEY = "sync" // Boolean diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderViewModel.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderViewModel.kt index 8d16c7b80d..ff098b92ea 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderViewModel.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderViewModel.kt @@ -27,7 +27,6 @@ import eu.kanade.tachiyomi.ui.reader.loader.DownloadPageLoader import eu.kanade.tachiyomi.ui.reader.model.InsertPage import eu.kanade.tachiyomi.ui.reader.model.ReaderChapter import eu.kanade.tachiyomi.ui.reader.model.ReaderPage -import eu.kanade.tachiyomi.ui.reader.model.StencilPage import eu.kanade.tachiyomi.ui.reader.model.ViewerChapters import eu.kanade.tachiyomi.ui.reader.setting.OrientationType import eu.kanade.tachiyomi.ui.reader.setting.ReaderPreferences @@ -405,8 +404,8 @@ class ReaderViewModel @JvmOverloads constructor( * [page]'s chapter is different from the currently active. */ fun onPageSelected(page: ReaderPage) { - // InsertPage and StencilPage doesn't change page progress - if (page is InsertPage || page is StencilPage) { + // InsertPage doesn't change page progress + if (page is InsertPage) { return } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/model/StencilPage.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/model/StencilPage.kt deleted file mode 100644 index c5a7ee79f3..0000000000 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/model/StencilPage.kt +++ /dev/null @@ -1,16 +0,0 @@ -package eu.kanade.tachiyomi.ui.reader.model - -import java.io.InputStream - -class StencilPage( - parent: ReaderPage, - stencilStream: () -> InputStream, -) : ReaderPage(parent.index, parent.url, parent.imageUrl) { - - override var chapter: ReaderChapter = parent.chapter - - init { - status = State.READY - stream = stencilStream - } -} diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/setting/ReaderPreferences.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/setting/ReaderPreferences.kt index 23a5beb137..a58cd90969 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/setting/ReaderPreferences.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/setting/ReaderPreferences.kt @@ -2,7 +2,6 @@ package eu.kanade.tachiyomi.ui.reader.setting import androidx.annotation.StringRes import eu.kanade.tachiyomi.R -import eu.kanade.tachiyomi.util.system.isReleaseBuildType import tachiyomi.core.preference.PreferenceStore import tachiyomi.core.preference.getEnum @@ -33,9 +32,6 @@ class ReaderPreferences( fun defaultOrientationType() = preferenceStore.getInt("pref_default_orientation_type_key", OrientationType.FREE.flagValue) - // TODO: Enable in release build when the feature is stable - fun longStripSplitWebtoon() = preferenceStore.getBoolean("pref_long_strip_split_webtoon", !isReleaseBuildType) - fun webtoonDoubleTapZoomEnabled() = preferenceStore.getBoolean("pref_enable_double_tap_zoom_webtoon", true) fun imageScaleType() = preferenceStore.getInt("pref_image_scale_type_key", 1) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonAdapter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonAdapter.kt index 87edd1da45..036f767f8c 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonAdapter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonAdapter.kt @@ -7,12 +7,10 @@ import androidx.recyclerview.widget.RecyclerView import eu.kanade.tachiyomi.ui.reader.model.ChapterTransition import eu.kanade.tachiyomi.ui.reader.model.ReaderChapter import eu.kanade.tachiyomi.ui.reader.model.ReaderPage -import eu.kanade.tachiyomi.ui.reader.model.StencilPage import eu.kanade.tachiyomi.ui.reader.model.ViewerChapters import eu.kanade.tachiyomi.ui.reader.viewer.ReaderPageImageView import eu.kanade.tachiyomi.ui.reader.viewer.calculateChapterGap import eu.kanade.tachiyomi.util.system.createReaderThemeContext -import tachiyomi.core.util.system.logcat /** * RecyclerView Adapter used by this [viewer] to where [ViewerChapters] updates are posted. @@ -27,27 +25,6 @@ class WebtoonAdapter(val viewer: WebtoonViewer) : RecyclerView.Adapter) { - if (newStrips.isEmpty()) return - if (currentStrip is StencilPage) return - - val placeAtIndex = items.indexOf(currentStrip) + 1 - // Stop constantly adding split images - if (items.getOrNull(placeAtIndex) is StencilPage) return - - val updatedItems = items.toMutableList() - updatedItems.addAll(placeAtIndex, newStrips) - updateItems(updatedItems) - logcat { "New adapter item count is $itemCount" } - } - - fun cleanupSplitStrips() { - if (items.any { it is StencilPage }) { - val updatedItems = items.filterNot { it is StencilPage } - updateItems(updatedItems) - } - } - /** * Context that has been wrapped to use the correct theme values based on the * current app theme and reader background color diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonConfig.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonConfig.kt index b2e0045b8f..a64826ab1d 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonConfig.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonConfig.kt @@ -32,11 +32,6 @@ class WebtoonConfig( var sidePadding = 0 private set - var longStripSplit = false - private set - - var longStripSplitChangedListener: ((Boolean) -> Unit)? = null - var doubleTapZoom = true private set @@ -67,15 +62,6 @@ class WebtoonConfig( readerPreferences.dualPageInvertWebtoon() .register({ dualPageInvert = it }, { imagePropertyChangedListener?.invoke() }) - readerPreferences.longStripSplitWebtoon() - .register( - { longStripSplit = it }, - { - imagePropertyChangedListener?.invoke() - longStripSplitChangedListener?.invoke(it) - }, - ) - readerPreferences.webtoonDoubleTapZoomEnabled() .register( { doubleTapZoom = it }, diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonPageHolder.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonPageHolder.kt index 749a48e334..7fa2058d66 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonPageHolder.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonPageHolder.kt @@ -13,7 +13,6 @@ import com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView import eu.kanade.tachiyomi.databinding.ReaderErrorBinding import eu.kanade.tachiyomi.source.model.Page import eu.kanade.tachiyomi.ui.reader.model.ReaderPage -import eu.kanade.tachiyomi.ui.reader.model.StencilPage import eu.kanade.tachiyomi.ui.reader.viewer.ReaderPageImageView import eu.kanade.tachiyomi.ui.reader.viewer.ReaderProgressIndicator import eu.kanade.tachiyomi.ui.webview.WebViewActivity @@ -24,12 +23,10 @@ import kotlinx.coroutines.flow.collectLatest import kotlinx.coroutines.launch import kotlinx.coroutines.supervisorScope import kotlinx.coroutines.suspendCancellableCoroutine -import logcat.LogPriority import tachiyomi.core.util.lang.launchIO import tachiyomi.core.util.lang.withIOContext import tachiyomi.core.util.lang.withUIContext import tachiyomi.core.util.system.ImageUtil -import tachiyomi.core.util.system.logcat import java.io.BufferedInputStream import java.io.InputStream @@ -221,40 +218,9 @@ class WebtoonPageHolder( } } - if (viewer.config.longStripSplit) { - if (page is StencilPage) { - return imageStream - } - val isStripSplitNeeded = ImageUtil.isStripSplitNeeded(imageStream) - if (isStripSplitNeeded) { - return onStripSplit(imageStream) - } - } - return imageStream } - private fun onStripSplit(imageStream: BufferedInputStream): InputStream { - try { - // If we have reached this point [page] and its stream shouldn't be null - val page = page!! - val stream = page.stream!! - val splitData = ImageUtil.getSplitDataForStream(imageStream).toMutableList() - val currentSplitData = splitData.removeFirst() - val newPages = splitData.map { - StencilPage(page) { ImageUtil.splitStrip(it, stream) } - } - return ImageUtil.splitStrip(currentSplitData) { imageStream } - .also { - // Running [onLongStripSplit] first results in issues with splitting - viewer.onLongStripSplit(page, newPages) - } - } catch (e: Exception) { - logcat(LogPriority.ERROR, e) { "Failed to split image" } - return imageStream - } - } - /** * Called when the page has an error. */ diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonViewer.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonViewer.kt index d7a0290f36..d85a5b04bd 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonViewer.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonViewer.kt @@ -15,7 +15,6 @@ import eu.kanade.tachiyomi.data.download.DownloadManager import eu.kanade.tachiyomi.ui.reader.ReaderActivity import eu.kanade.tachiyomi.ui.reader.model.ChapterTransition import eu.kanade.tachiyomi.ui.reader.model.ReaderPage -import eu.kanade.tachiyomi.ui.reader.model.StencilPage import eu.kanade.tachiyomi.ui.reader.model.ViewerChapters import eu.kanade.tachiyomi.ui.reader.setting.ReaderPreferences import eu.kanade.tachiyomi.ui.reader.viewer.Viewer @@ -151,12 +150,6 @@ class WebtoonViewer(val activity: ReaderActivity, val isContinuous: Boolean = tr activity.binding.navigationOverlay.setNavigation(config.navigator, showOnStart) } - config.longStripSplitChangedListener = { enabled -> - if (!enabled) { - cleanupSplitStrips() - } - } - frame.layoutParams = ViewGroup.LayoutParams(MATCH_PARENT, MATCH_PARENT) frame.addView(recycler) } @@ -205,11 +198,6 @@ class WebtoonViewer(val activity: ReaderActivity, val isContinuous: Boolean = tr logcat { "onPageSelected: ${page.number}/${pages.size}" } activity.onPageSelected(page) - // Skip preload on StencilPage - if (page is StencilPage) { - return - } - // Preload next chapter once we're within the last 5 pages of the current chapter val inPreloadRange = pages.size - page.number < 5 if (inPreloadRange && allowPreload && page.chapter == adapter.currentChapter) { @@ -359,15 +347,4 @@ class WebtoonViewer(val activity: ReaderActivity, val isContinuous: Boolean = tr min(position + 3, adapter.itemCount - 1), ) } - - fun onLongStripSplit(currentStrip: Any?, newStrips: List) { - activity.runOnUiThread { - // Need to insert on UI thread else images will go blank - adapter.onLongStripSplit(currentStrip, newStrips) - } - } - - private fun cleanupSplitStrips() { - adapter.cleanupSplitStrips() - } } diff --git a/core/src/main/java/tachiyomi/core/util/system/ImageUtil.kt b/core/src/main/java/tachiyomi/core/util/system/ImageUtil.kt index fdfff46030..62a0d347a3 100644 --- a/core/src/main/java/tachiyomi/core/util/system/ImageUtil.kt +++ b/core/src/main/java/tachiyomi/core/util/system/ImageUtil.kt @@ -273,48 +273,6 @@ object ImageUtil { private fun splitImageName(filenamePrefix: String, index: Int) = "${filenamePrefix}__${"%03d".format(index + 1)}.jpg" - /** - * Check whether the image is a long Strip that needs splitting - * @return true if the image is not animated and it's height is greater than image width and screen height - */ - fun isStripSplitNeeded(imageStream: BufferedInputStream): Boolean { - if (isAnimatedAndSupported(imageStream)) return false - - val options = extractImageOptions(imageStream) - val imageHeightIsBiggerThanWidth = options.outHeight > options.outWidth - val imageHeightBiggerThanScreenHeight = options.outHeight > optimalImageHeight - return imageHeightIsBiggerThanWidth && imageHeightBiggerThanScreenHeight - } - - /** - * Split the imageStream according to the provided splitData - */ - fun splitStrip(splitData: SplitData, streamFn: () -> InputStream): InputStream { - val bitmapRegionDecoder = getBitmapRegionDecoder(streamFn()) - ?: throw Exception("Failed to create new instance of BitmapRegionDecoder") - - logcat { - "WebtoonSplit #${splitData.index} with topOffset=${splitData.topOffset} " + - "splitHeight=${splitData.splitHeight} bottomOffset=${splitData.bottomOffset}" - } - - try { - val region = Rect(0, splitData.topOffset, splitData.splitWidth, splitData.bottomOffset) - val splitBitmap = bitmapRegionDecoder.decodeRegion(region, null) - val outputStream = ByteArrayOutputStream() - splitBitmap.compress(Bitmap.CompressFormat.JPEG, 100, outputStream) - return ByteArrayInputStream(outputStream.toByteArray()) - } catch (e: Throwable) { - throw e - } finally { - bitmapRegionDecoder.recycle() - } - } - - fun getSplitDataForStream(imageStream: InputStream): List { - return extractImageOptions(imageStream).splitData - } - private val BitmapFactory.Options.splitData get(): List { val imageHeight = outHeight diff --git a/i18n/src/main/res/values/strings.xml b/i18n/src/main/res/values/strings.xml index ac21d13f6b..612567f3f7 100644 --- a/i18n/src/main/res/values/strings.xml +++ b/i18n/src/main/res/values/strings.xml @@ -329,7 +329,6 @@ If the placement of the split wide pages don\'t match reading direction Rotate wide pages to fit Flip orientation of rotated wide pages - Split tall images (BETA) Double tap to zoom Show content in cutout area Animate page transitions