Compare commits

..
3 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
8 changed files with 54 additions and 24 deletions

No files matched your search

+2 -2
View File
@@ -64,8 +64,8 @@ android {
applicationId = "moe.tarsin.ehviewer"
minSdk = 28
targetSdk = 34
versionCode = 180044
versionName = "1.8.10.2"
versionCode = 180045
versionName = "1.8.10.3"
resourceConfigurations.addAll(
listOf(
"zh",
@@ -28,8 +28,10 @@ import java.util.Locale
class EhPageLoader(private val mGalleryInfo: GalleryInfo) : PageLoader2(), OnSpiderListener {
private lateinit var mSpiderQueen: SpiderQueen
override fun start() {
mSpiderQueen = obtainSpiderQueen(mGalleryInfo, SpiderQueen.MODE_READ)
mSpiderQueen.addOnSpiderListener(this)
if (!::mSpiderQueen.isInitialized) {
mSpiderQueen = obtainSpiderQueen(mGalleryInfo, SpiderQueen.MODE_READ)
mSpiderQueen.addOnSpiderListener(this)
}
}
override fun stop() {
@@ -45,6 +45,7 @@ import android.webkit.MimeTypeMap
import android.widget.Toast
import androidx.activity.result.contract.ActivityResultContracts
import androidx.activity.result.contract.ActivityResultContracts.CreateDocument
import androidx.activity.viewModels
import androidx.annotation.ChecksSdkIntAtLeast
import androidx.annotation.RequiresApi
import androidx.appcompat.app.AlertDialog
@@ -59,6 +60,7 @@ import androidx.core.view.WindowCompat
import androidx.core.view.WindowInsetsCompat
import androidx.core.view.WindowInsetsControllerCompat
import androidx.core.view.isVisible
import androidx.lifecycle.ViewModel
import androidx.lifecycle.lifecycleScope
import com.google.android.material.shape.MaterialShapeDrawable
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.getParcelableCompat
import com.hippo.ehviewer.util.getParcelableExtraCompat
import com.hippo.ehviewer.util.getValue
import com.hippo.ehviewer.util.isAtLeastO
import com.hippo.ehviewer.util.isAtLeastP
import com.hippo.ehviewer.util.lazyMut
import com.hippo.ehviewer.util.sendTo
import com.hippo.ehviewer.util.setValue
import com.hippo.unifile.UniFile
import dev.chrisbanes.insetter.applyInsetter
import eu.kanade.tachiyomi.ui.reader.model.ReaderPage
@@ -116,6 +121,15 @@ import kotlinx.coroutines.flow.sample
import kotlinx.coroutines.suspendCancellableCoroutine
import splitties.systemservices.clipboardManager
class GalleryModel : ViewModel() {
var galleryProvider: PageLoader2? = null
override fun onCleared() {
super.onCleared()
galleryProvider?.stop()
galleryProvider = null
}
}
class ReaderActivity : EhActivity() {
lateinit var binding: ReaderActivityBinding
private var mAction: String? = null
@@ -124,6 +138,7 @@ class ReaderActivity : EhActivity() {
private var mGalleryInfo: BaseGalleryInfo? = null
private var mPage: Int = 0
private var mCacheFileName: String? = null
private val vm: GalleryModel by viewModels()
/**
* 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 mSavingPage = -1
private lateinit var builder: EditTextDialogBuilder
@@ -190,13 +205,6 @@ class ReaderActivity : EhActivity() {
}
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 (replace) mGalleryProvider!!.stop() else return
}
@@ -271,7 +279,6 @@ class ReaderActivity : EhActivity() {
private fun onInit() {
handleIntent(intent)
buildProvider()
}
private fun onRestore(savedInstanceState: Bundle) {
@@ -281,7 +288,6 @@ class ReaderActivity : EhActivity() {
mGalleryInfo = savedInstanceState.getParcelableCompat(KEY_GALLERY_INFO)
mPage = savedInstanceState.getInt(KEY_PAGE, -1)
mCurrentIndex = savedInstanceState.getInt(KEY_CURRENT_INDEX)
buildProvider()
}
override fun onNewIntent(intent: Intent?) {
@@ -328,6 +334,7 @@ class ReaderActivity : EhActivity() {
} else {
onRestore(savedInstanceState)
}
buildProvider()
binding = ReaderActivityBinding.inflate(layoutInflater)
setContentView(binding.root)
builder = EditTextDialogBuilder(this, null, getString(R.string.archive_passwd))
@@ -338,6 +345,7 @@ class ReaderActivity : EhActivity() {
mGalleryProvider.let {
if (it == null) {
finish()
return
}
lifecycleScope.launchIO {
@@ -368,7 +376,6 @@ class ReaderActivity : EhActivity() {
updateViewerInset(ReaderPreferences.fullscreen().get())
binding.viewerContainer.removeAllViews()
setOrientation(ReaderPreferences.defaultOrientationType().get())
updateOrientationShortcut(ReaderPreferences.defaultOrientationType().get())
binding.viewerContainer.addView(viewer?.getView())
viewer?.setGalleryProvider(mGalleryProvider!!)
moveToPageIndex(mCurrentIndex)
@@ -379,10 +386,6 @@ class ReaderActivity : EhActivity() {
config = null
viewer?.destroy()
viewer = null
if (mGalleryProvider != null) {
mGalleryProvider!!.stop()
mGalleryProvider = null
}
readerSettingSheetDialog?.dismiss()
readerSettingSheetDialog = null
}
@@ -856,15 +859,13 @@ class ReaderActivity : EhActivity() {
/**
* 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 restart = newOrientation.flag != requestedOrientation
if (restart) {
if (newOrientation.flag != requestedOrientation) {
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="filter_mode_multiply">色彩增值</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="action_menu">菜单</string>
<string name="webtoon_side_padding_25">25%</string>
@@ -496,6 +496,9 @@
<string name="pref_color_filter_mode">濾鏡融合機制</string>
<string name="filter_mode_multiply">色彩增值</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_reader_theme">背景顏色</string>
<string name="white_background">白色</string>
@@ -554,6 +554,9 @@
<string name="pref_color_filter_mode">濾鏡融合機制</string>
<string name="filter_mode_multiply">色彩增值</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="action_menu">選單</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="filter_mode_multiply">Multiply</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_read_with_tapping_inverted">Invert tap zones</string>
<string name="tapping_inverted_none">None</string>