Merge remote-tracking branch 'origin/master'

This commit is contained in:
kunfei 2022-09-16 23:43:27 +08:00
commit bb82f60e67
12 changed files with 24 additions and 3 deletions

View File

@ -111,6 +111,7 @@ object PreferKey {
const val welcomeShowIconDark = "welcomeShowIconDark"
const val pageTouchSlop = "pageTouchSlop"
const val showAddToShelfAlert = "showAddToShelfAlert"
const val asyncLoadImage = "asyncLoadImage"
const val cPrimary = "colorPrimary"
const val cAccent = "colorAccent"

View File

@ -320,6 +320,8 @@ object AppConfig : SharedPreferences.OnSharedPreferenceChangeListener {
val showAddToShelfAlert get() = appCtx.getPrefBoolean(PreferKey.showAddToShelfAlert, true)
val asyncLoadImage get() = appCtx.getPrefBoolean(PreferKey.asyncLoadImage, false)
val doublePageHorizontal: String?
get() = appCtx.getPrefString(PreferKey.doublePageHorizontal)

View File

@ -4,6 +4,7 @@ import android.content.Context
import android.graphics.Canvas
import android.graphics.Paint
import android.graphics.RectF
import android.os.Build
import android.util.AttributeSet
import android.view.View
import io.legado.app.R
@ -51,7 +52,11 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at
private var drawVisibleImageOnly = false
private var cacheIncreased = false
private val increaseSize = 8 * 1024 * 1024
private val maxCacheSize = 256 * 1024 * 1024
private val maxCacheSize = if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.N_MR1) {
min(128 * 1024 * 1024, Runtime.getRuntime().maxMemory())
} else {
256 * 1024 * 1024
}
//滚动参数
private val pageFactory: TextPageFactory get() = callBack.pageFactory
@ -203,7 +208,6 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at
return
}
if (drawVisibleImageOnly &&
isVisible &&
!cacheIncreased &&
ImageProvider.isTriggerRecycled() &&
!ImageProvider.isImageAlive(book, column.src)

View File

@ -131,7 +131,7 @@ object ImageProvider {
//bitmapLruCache的key同一改成缓存文件的路径
val cacheBitmap = bitmapLruCache.get(vFile.absolutePath)
if (cacheBitmap != null) return cacheBitmap
if (height != null && ReadBook.pageAnim() == PageAnim.scrollPageAnim) {
if (height != null && AppConfig.asyncLoadImage && ReadBook.pageAnim() == PageAnim.scrollPageAnim) {
Coroutine.async {
kotlin.runCatching {
val bitmap = BitmapUtils.decodeBitmap(vFile.absolutePath, width, height)

View File

@ -1028,4 +1028,5 @@
<string name="rule_image_decode">Decode Image(imageDecode)</string>
<string name="like_source"></string>
<string name="not_like_source"></string>
<string name="async_load_image">异步加载图片</string>
</resources>

View File

@ -1031,4 +1031,5 @@
<string name="rule_image_decode">Decode Image(imageDecode)</string>
<string name="like_source"></string>
<string name="not_like_source"></string>
<string name="async_load_image">异步加载图片</string>
</resources>

View File

@ -1031,4 +1031,5 @@
<string name="rule_image_decode">Decode Image(imageDecode)</string>
<string name="like_source"></string>
<string name="not_like_source"></string>
<string name="async_load_image">异步加载图片</string>
</resources>

View File

@ -1028,4 +1028,5 @@
<string name="rule_image_decode">图片解密imageDecode</string>
<string name="like_source"></string>
<string name="not_like_source"></string>
<string name="async_load_image">异步加载图片</string>
</resources>

View File

@ -1030,4 +1030,5 @@
<string name="rule_image_decode">图片解密imageDecode</string>
<string name="like_source"></string>
<string name="not_like_source"></string>
<string name="async_load_image">异步加载图片</string>
</resources>

View File

@ -1030,4 +1030,5 @@
<string name="rule_image_decode">图片解密imageDecode</string>
<string name="like_source"></string>
<string name="not_like_source"></string>
<string name="async_load_image">异步加载图片</string>
</resources>

View File

@ -1031,4 +1031,5 @@
<string name="rule_image_decode">Decode Image(imageDecode)</string>
<string name="like_source"></string>
<string name="not_like_source"></string>
<string name="async_load_image">异步加载图片</string>
</resources>

View File

@ -120,6 +120,13 @@
app:iconSpaceReserved="false"
app:isBottomBackground="true" />
<io.legado.app.lib.prefs.SwitchPreference
android:defaultValue="false"
android:key="asyncLoadImage"
android:title="@string/async_load_image"
app:iconSpaceReserved="false"
app:isBottomBackground="true" />
<io.legado.app.lib.prefs.Preference
android:key="clickRegionalConfig"
android:title="@string/click_regional_config"