Compare commits

...
6 Commits
Author SHA1 Message Date
FooIbar 8cde607e9a Release 1.8.10.3
Releases / Build (push) Has been cancelled
2023-10-29 03:33:24 +08:00
FooIbar 2f39359b47 Fix reader not loading under certain circumstances (#128)
* Revert "Fix reader bug on certain orientation settings"

This reverts commit 6e59583dea.

* Revert "Skip `buildProvider` if the activity will restart"

This reverts commit a880f801fb.

* Preserve gallery provider in view model

(cherry picked from commit e2f024ae29)
2023-10-29 03:29:34 +08:00
FooIbar d1e3965d62 Add missing color filter modes
(cherry picked from commit 6458eb090a)
2023-10-29 03:28:57 +08:00
FooIbar 10c7019aeb Release 1.8.10.2
Releases / Build (push) Has been cancelled
2023-10-27 19:47:48 +08:00
FooIbar 76aa401800 Sync with upstream API changes
(cherry picked from commit 44a6253bfc)
2023-10-27 19:46:50 +08:00
FooIbar dab5878f74 Fix unexpected touch scale behavior in PageViewer
(cherry picked from commit 0c78673870)
2023-10-27 19:46:42 +08:00
10 changed files with 58 additions and 30 deletions

No files matched your search

+2 -2
View File
@@ -64,8 +64,8 @@ android {
applicationId = "moe.tarsin.ehviewer" applicationId = "moe.tarsin.ehviewer"
minSdk = 28 minSdk = 28
targetSdk = 34 targetSdk = 34
versionCode = 180044 versionCode = 180045
versionName = "1.8.10.1" versionName = "1.8.10.3"
resourceConfigurations.addAll( resourceConfigurations.addAll(
listOf( listOf(
"zh", "zh",
@@ -601,7 +601,7 @@ open class SubsamplingScaleImageView @JvmOverloads constructor(
private fun onTouchEventInternal(event: MotionEvent): Boolean { private fun onTouchEventInternal(event: MotionEvent): Boolean {
val touchCount = event.pointerCount val touchCount = event.pointerCount
when (event.action) { when (event.actionMasked) {
MotionEvent.ACTION_DOWN, MotionEvent.ACTION_POINTER_DOWN -> { MotionEvent.ACTION_DOWN, MotionEvent.ACTION_POINTER_DOWN -> {
anim = null anim = null
requestDisallowInterceptTouchEvent(true) requestDisallowInterceptTouchEvent(true)
@@ -31,10 +31,10 @@ object GalleryPageApiParser {
val imageUrl = PATTERN_IMAGE_URL.find(res.imageUrl)?.run { val imageUrl = PATTERN_IMAGE_URL.find(res.imageUrl)?.run {
groupValues[1].trim().unescapeXml() groupValues[1].trim().unescapeXml()
} }
val skipHathKey = PATTERN_SKIP_HATH_KEY.find(res.skipHathKey)?.run { val skipHathKey = PATTERN_SKIP_HATH_KEY.find(res.skipHathKeyAndOriginImageUrl)?.run {
groupValues[1].trim().unescapeXml() groupValues[1].trim().unescapeXml()
} }
val originImageUrl = PATTERN_ORIGIN_IMAGE_URL.find(res.originImageUrl)?.run { val originImageUrl = PATTERN_ORIGIN_IMAGE_URL.find(res.skipHathKeyAndOriginImageUrl)?.run {
groupValues[1].unescapeXml() + "fullimg.php" + groupValues[2].unescapeXml() groupValues[1].unescapeXml() + "fullimg.php" + groupValues[2].unescapeXml()
} }
check(!imageUrl.isNullOrEmpty()) check(!imageUrl.isNullOrEmpty())
@@ -49,9 +49,7 @@ object GalleryPageApiParser {
@SerialName("i3") @SerialName("i3")
val imageUrl: String, val imageUrl: String,
@SerialName("i6") @SerialName("i6")
val skipHathKey: String, val skipHathKeyAndOriginImageUrl: String,
@SerialName("i7")
val originImageUrl: String,
) )
class Result(val imageUrl: String, val skipHathKey: String?, val originImageUrl: String?) class Result(val imageUrl: String, val skipHathKey: String?, val originImageUrl: String?)
@@ -28,8 +28,10 @@ import java.util.Locale
class EhPageLoader(private val mGalleryInfo: GalleryInfo) : PageLoader2(), OnSpiderListener { class EhPageLoader(private val mGalleryInfo: GalleryInfo) : PageLoader2(), OnSpiderListener {
private lateinit var mSpiderQueen: SpiderQueen private lateinit var mSpiderQueen: SpiderQueen
override fun start() { override fun start() {
mSpiderQueen = obtainSpiderQueen(mGalleryInfo, SpiderQueen.MODE_READ) if (!::mSpiderQueen.isInitialized) {
mSpiderQueen.addOnSpiderListener(this) mSpiderQueen = obtainSpiderQueen(mGalleryInfo, SpiderQueen.MODE_READ)
mSpiderQueen.addOnSpiderListener(this)
}
} }
override fun stop() { override fun stop() {
@@ -45,6 +45,7 @@ import android.webkit.MimeTypeMap
import android.widget.Toast import android.widget.Toast
import androidx.activity.result.contract.ActivityResultContracts import androidx.activity.result.contract.ActivityResultContracts
import androidx.activity.result.contract.ActivityResultContracts.CreateDocument import androidx.activity.result.contract.ActivityResultContracts.CreateDocument
import androidx.activity.viewModels
import androidx.annotation.ChecksSdkIntAtLeast import androidx.annotation.ChecksSdkIntAtLeast
import androidx.annotation.RequiresApi import androidx.annotation.RequiresApi
import androidx.appcompat.app.AlertDialog import androidx.appcompat.app.AlertDialog
@@ -59,6 +60,7 @@ import androidx.core.view.WindowCompat
import androidx.core.view.WindowInsetsCompat import androidx.core.view.WindowInsetsCompat
import androidx.core.view.WindowInsetsControllerCompat import androidx.core.view.WindowInsetsControllerCompat
import androidx.core.view.isVisible import androidx.core.view.isVisible
import androidx.lifecycle.ViewModel
import androidx.lifecycle.lifecycleScope import androidx.lifecycle.lifecycleScope
import com.google.android.material.shape.MaterialShapeDrawable import com.google.android.material.shape.MaterialShapeDrawable
import com.hippo.ehviewer.BuildConfig import com.hippo.ehviewer.BuildConfig
@@ -78,9 +80,12 @@ import com.hippo.ehviewer.util.ExceptionUtils
import com.hippo.ehviewer.util.FileUtils import com.hippo.ehviewer.util.FileUtils
import com.hippo.ehviewer.util.getParcelableCompat import com.hippo.ehviewer.util.getParcelableCompat
import com.hippo.ehviewer.util.getParcelableExtraCompat import com.hippo.ehviewer.util.getParcelableExtraCompat
import com.hippo.ehviewer.util.getValue
import com.hippo.ehviewer.util.isAtLeastO import com.hippo.ehviewer.util.isAtLeastO
import com.hippo.ehviewer.util.isAtLeastP import com.hippo.ehviewer.util.isAtLeastP
import com.hippo.ehviewer.util.lazyMut
import com.hippo.ehviewer.util.sendTo import com.hippo.ehviewer.util.sendTo
import com.hippo.ehviewer.util.setValue
import com.hippo.unifile.UniFile import com.hippo.unifile.UniFile
import dev.chrisbanes.insetter.applyInsetter import dev.chrisbanes.insetter.applyInsetter
import eu.kanade.tachiyomi.ui.reader.model.ReaderPage import eu.kanade.tachiyomi.ui.reader.model.ReaderPage
@@ -116,6 +121,15 @@ import kotlinx.coroutines.flow.sample
import kotlinx.coroutines.suspendCancellableCoroutine import kotlinx.coroutines.suspendCancellableCoroutine
import splitties.systemservices.clipboardManager import splitties.systemservices.clipboardManager
class GalleryModel : ViewModel() {
var galleryProvider: PageLoader2? = null
override fun onCleared() {
super.onCleared()
galleryProvider?.stop()
galleryProvider = null
}
}
class ReaderActivity : EhActivity() { class ReaderActivity : EhActivity() {
lateinit var binding: ReaderActivityBinding lateinit var binding: ReaderActivityBinding
private var mAction: String? = null private var mAction: String? = null
@@ -124,6 +138,7 @@ class ReaderActivity : EhActivity() {
private var mGalleryInfo: BaseGalleryInfo? = null private var mGalleryInfo: BaseGalleryInfo? = null
private var mPage: Int = 0 private var mPage: Int = 0
private var mCacheFileName: String? = null private var mCacheFileName: String? = null
private val vm: GalleryModel by viewModels()
/** /**
* Whether the menu is currently visible. * Whether the menu is currently visible.
@@ -159,7 +174,7 @@ class ReaderActivity : EhActivity() {
} }
} }
} }
var mGalleryProvider: PageLoader2? = null var mGalleryProvider by lazyMut { vm::galleryProvider }
private var mCurrentIndex: Int = 0 private var mCurrentIndex: Int = 0
private var mSavingPage = -1 private var mSavingPage = -1
private lateinit var builder: EditTextDialogBuilder private lateinit var builder: EditTextDialogBuilder
@@ -190,13 +205,6 @@ class ReaderActivity : EhActivity() {
} }
private fun buildProvider(replace: Boolean = false) { private fun buildProvider(replace: Boolean = false) {
// TODO: Better solution for this dirty workaround
if (setOrientation(ReaderPreferences.defaultOrientationType().get())) {
// Orientation changed, we don't know if the activity will recreate, just recreate anyway
recreate()
return
}
if (mGalleryProvider != null) { if (mGalleryProvider != null) {
if (replace) mGalleryProvider!!.stop() else return if (replace) mGalleryProvider!!.stop() else return
} }
@@ -271,7 +279,6 @@ class ReaderActivity : EhActivity() {
private fun onInit() { private fun onInit() {
handleIntent(intent) handleIntent(intent)
buildProvider()
} }
private fun onRestore(savedInstanceState: Bundle) { private fun onRestore(savedInstanceState: Bundle) {
@@ -281,7 +288,6 @@ class ReaderActivity : EhActivity() {
mGalleryInfo = savedInstanceState.getParcelableCompat(KEY_GALLERY_INFO) mGalleryInfo = savedInstanceState.getParcelableCompat(KEY_GALLERY_INFO)
mPage = savedInstanceState.getInt(KEY_PAGE, -1) mPage = savedInstanceState.getInt(KEY_PAGE, -1)
mCurrentIndex = savedInstanceState.getInt(KEY_CURRENT_INDEX) mCurrentIndex = savedInstanceState.getInt(KEY_CURRENT_INDEX)
buildProvider()
} }
override fun onNewIntent(intent: Intent?) { override fun onNewIntent(intent: Intent?) {
@@ -328,6 +334,7 @@ class ReaderActivity : EhActivity() {
} else { } else {
onRestore(savedInstanceState) onRestore(savedInstanceState)
} }
buildProvider()
binding = ReaderActivityBinding.inflate(layoutInflater) binding = ReaderActivityBinding.inflate(layoutInflater)
setContentView(binding.root) setContentView(binding.root)
builder = EditTextDialogBuilder(this, null, getString(R.string.archive_passwd)) builder = EditTextDialogBuilder(this, null, getString(R.string.archive_passwd))
@@ -338,6 +345,7 @@ class ReaderActivity : EhActivity() {
mGalleryProvider.let { mGalleryProvider.let {
if (it == null) { if (it == null) {
finish()
return return
} }
lifecycleScope.launchIO { lifecycleScope.launchIO {
@@ -368,7 +376,6 @@ class ReaderActivity : EhActivity() {
updateViewerInset(ReaderPreferences.fullscreen().get()) updateViewerInset(ReaderPreferences.fullscreen().get())
binding.viewerContainer.removeAllViews() binding.viewerContainer.removeAllViews()
setOrientation(ReaderPreferences.defaultOrientationType().get()) setOrientation(ReaderPreferences.defaultOrientationType().get())
updateOrientationShortcut(ReaderPreferences.defaultOrientationType().get())
binding.viewerContainer.addView(viewer?.getView()) binding.viewerContainer.addView(viewer?.getView())
viewer?.setGalleryProvider(mGalleryProvider!!) viewer?.setGalleryProvider(mGalleryProvider!!)
moveToPageIndex(mCurrentIndex) moveToPageIndex(mCurrentIndex)
@@ -379,10 +386,6 @@ class ReaderActivity : EhActivity() {
config = null config = null
viewer?.destroy() viewer?.destroy()
viewer = null viewer = null
if (mGalleryProvider != null) {
mGalleryProvider!!.stop()
mGalleryProvider = null
}
readerSettingSheetDialog?.dismiss() readerSettingSheetDialog?.dismiss()
readerSettingSheetDialog = null readerSettingSheetDialog = null
} }
@@ -856,15 +859,13 @@ class ReaderActivity : EhActivity() {
/** /**
* Forces the user preferred [orientation] on the activity. * Forces the user preferred [orientation] on the activity.
* Returns true if a restart is required.
*/ */
private fun setOrientation(orientation: Int): Boolean { private fun setOrientation(orientation: Int) {
val newOrientation = OrientationType.fromPreference(orientation) val newOrientation = OrientationType.fromPreference(orientation)
val restart = newOrientation.flag != requestedOrientation if (newOrientation.flag != requestedOrientation) {
if (restart) {
requestedOrientation = newOrientation.flag requestedOrientation = newOrientation.flag
} }
return restart updateOrientationShortcut(ReaderPreferences.defaultOrientationType().get())
} }
/** /**
+15
View File
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string-array name="color_filter_modes">
<item>@string/label_default</item>
<item>@string/filter_mode_multiply</item>
<item>@string/filter_mode_screen</item>
<!-- Attributes specific for SDK 28 and up -->
<item>@string/filter_mode_overlay</item>
<item>@string/filter_mode_lighten</item>
<item>@string/filter_mode_darken</item>
</string-array>
</resources>
@@ -585,6 +585,9 @@
<string name="pref_color_filter_mode">滤镜调和模式</string> <string name="pref_color_filter_mode">滤镜调和模式</string>
<string name="filter_mode_multiply">色彩增值</string> <string name="filter_mode_multiply">色彩增值</string>
<string name="filter_mode_screen">滤色</string> <string name="filter_mode_screen">滤色</string>
<string name="filter_mode_overlay">覆盖</string>
<string name="filter_mode_lighten">减淡/变亮</string>
<string name="filter_mode_darken">加深/变暗</string>
<string name="pref_cutout_short">在刘海屏区域显示内容</string> <string name="pref_cutout_short">在刘海屏区域显示内容</string>
<string name="action_menu">菜单</string> <string name="action_menu">菜单</string>
<string name="webtoon_side_padding_25">25%</string> <string name="webtoon_side_padding_25">25%</string>
@@ -496,6 +496,9 @@
<string name="pref_color_filter_mode">濾鏡融合機制</string> <string name="pref_color_filter_mode">濾鏡融合機制</string>
<string name="filter_mode_multiply">色彩增值</string> <string name="filter_mode_multiply">色彩增值</string>
<string name="filter_mode_screen">濾色</string> <string name="filter_mode_screen">濾色</string>
<string name="filter_mode_overlay">覆蓋</string>
<string name="filter_mode_lighten">減淡/變亮</string>
<string name="filter_mode_darken">加深/變暗</string>
<string name="pref_read_with_long_tap">長按顯示</string> <string name="pref_read_with_long_tap">長按顯示</string>
<string name="pref_reader_theme">背景顏色</string> <string name="pref_reader_theme">背景顏色</string>
<string name="white_background">白色</string> <string name="white_background">白色</string>
@@ -554,6 +554,9 @@
<string name="pref_color_filter_mode">濾鏡融合機制</string> <string name="pref_color_filter_mode">濾鏡融合機制</string>
<string name="filter_mode_multiply">色彩增值</string> <string name="filter_mode_multiply">色彩增值</string>
<string name="filter_mode_screen">濾色</string> <string name="filter_mode_screen">濾色</string>
<string name="filter_mode_overlay">覆蓋</string>
<string name="filter_mode_lighten">減淡/變亮</string>
<string name="filter_mode_darken">加深/變暗</string>
<string name="pref_cutout_short">使用螢幕凹口區域</string> <string name="pref_cutout_short">使用螢幕凹口區域</string>
<string name="action_menu">選單</string> <string name="action_menu">選單</string>
<string name="webtoon_side_padding_25">25%</string> <string name="webtoon_side_padding_25">25%</string>
+3
View File
@@ -635,6 +635,9 @@
<string name="pref_color_filter_mode">Color filter blend mode</string> <string name="pref_color_filter_mode">Color filter blend mode</string>
<string name="filter_mode_multiply">Multiply</string> <string name="filter_mode_multiply">Multiply</string>
<string name="filter_mode_screen">Screen</string> <string name="filter_mode_screen">Screen</string>
<string name="filter_mode_overlay">Overlay</string>
<string name="filter_mode_lighten">Dodge / Lighten</string>
<string name="filter_mode_darken">Burn / Darken</string>
<string name="pref_keep_screen_on">Keep screen on</string> <string name="pref_keep_screen_on">Keep screen on</string>
<string name="pref_read_with_tapping_inverted">Invert tap zones</string> <string name="pref_read_with_tapping_inverted">Invert tap zones</string>
<string name="tapping_inverted_none">None</string> <string name="tapping_inverted_none">None</string>