Merge branch 'gedoor:master' into master

pull/1905/head
Xwite 2 years ago committed by GitHub
commit 69e192bf87
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      app/src/main/assets/updateLog.md
  2. 1
      app/src/main/assets/web/bookshelf/css/detail.833fd4ba.css
  3. 1
      app/src/main/assets/web/bookshelf/css/detail.ac2331a7.css
  4. 4
      app/src/main/assets/web/bookshelf/index.html
  5. 0
      app/src/main/assets/web/bookshelf/js/about.1df2289f.js
  6. 1
      app/src/main/assets/web/bookshelf/js/app.5dac055e.js
  7. 1
      app/src/main/assets/web/bookshelf/js/app.7cd09a57.js
  8. 4
      app/src/main/assets/web/bookshelf/js/chunk-vendors.02b772b1.js
  9. 1
      app/src/main/assets/web/bookshelf/js/detail.d5b3eb30.js
  10. 1
      app/src/main/assets/web/bookshelf/js/detail.e994f0fb.js
  11. 4
      app/src/main/java/io/legado/app/help/config/ReadBookConfig.kt
  12. 12
      app/src/main/java/io/legado/app/ui/book/read/page/provider/ImageProvider.kt
  13. 41
      app/src/main/java/io/legado/app/ui/main/MainActivity.kt
  14. 21
      app/src/main/java/io/legado/app/utils/BitmapUtils.kt
  15. 2
      app/src/main/java/io/legado/app/utils/QRCodeUtils.kt

@ -17,6 +17,7 @@
* 优化翻页流畅度 * 优化翻页流畅度
* js添加des HMac * js添加des HMac
* 登录ui用户信息默认加密方式改变,需要重新登录 * 登录ui用户信息默认加密方式改变,需要重新登录
* 修复图片加载错误时一直重复获取图片导致卡顿的bug
**2022/05/21** **2022/05/21**

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -1,3 +1,3 @@
<!DOCTYPE html><html lang="zh-CN" style="padding: 0;height:100%"><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=0"><link rel="icon" href="../favicon.ico" type="image/x-icon"><link rel="shortcut icon" href="../favicon.ico" type="image/x-icon"><title>Legado Bookshelf</title><link href="css/about.65a00131.css" rel="prefetch"><link href="css/detail.ac2331a7.css" rel="prefetch"><link href="js/about.74ccd735.js" rel="prefetch"><link href="js/detail.d5b3eb30.js" rel="prefetch"><link href="css/app.e4c919b7.css" rel="preload" as="style"><link href="css/chunk-vendors.bd1373b6.css" rel="preload" as="style"><link href="js/app.7cd09a57.js" rel="preload" as="script"><link href="js/chunk-vendors.d7fcc132.js" rel="preload" as="script"><link href="css/chunk-vendors.bd1373b6.css" rel="stylesheet"><link href="css/app.e4c919b7.css" rel="stylesheet"></head><style>body::-webkit-scrollbar { <!DOCTYPE html><html lang="zh-CN" style="padding: 0;height:100%"><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=0"><link rel="icon" href="../favicon.ico" type="image/x-icon"><link rel="shortcut icon" href="../favicon.ico" type="image/x-icon"><title>Legado Bookshelf</title><link href="css/about.65a00131.css" rel="prefetch"><link href="css/detail.833fd4ba.css" rel="prefetch"><link href="js/about.1df2289f.js" rel="prefetch"><link href="js/detail.e994f0fb.js" rel="prefetch"><link href="css/app.e4c919b7.css" rel="preload" as="style"><link href="css/chunk-vendors.bd1373b6.css" rel="preload" as="style"><link href="js/app.5dac055e.js" rel="preload" as="script"><link href="js/chunk-vendors.02b772b1.js" rel="preload" as="script"><link href="css/chunk-vendors.bd1373b6.css" rel="stylesheet"><link href="css/app.e4c919b7.css" rel="stylesheet"></head><style>body::-webkit-scrollbar {
display: none; display: none;
}</style><body style="margin: 0;height:100%"><noscript><strong>We're sorry but yd-web-tool doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"></div><script src="js/chunk-vendors.d7fcc132.js"></script><script src="js/app.7cd09a57.js"></script></body></html> }</style><body style="margin: 0;height:100%"><noscript><strong>We're sorry but yd-web-tool doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"></div><script src="js/chunk-vendors.02b772b1.js"></script><script src="js/app.5dac055e.js"></script></body></html>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -568,11 +568,11 @@ object ReadBookConfig {
1 -> { 1 -> {
val path = "bg" + File.separator + curBgStr() val path = "bg" + File.separator + curBgStr()
val bitmap = BitmapUtils.decodeAssetsBitmap(appCtx, path, width, height) val bitmap = BitmapUtils.decodeAssetsBitmap(appCtx, path, width, height)
BitmapDrawable(resources, bitmap?.copyAndRecycle(width, height)) BitmapDrawable(resources, bitmap?.resizeAndRecycle(width, height))
} }
else -> { else -> {
val bitmap = BitmapUtils.decodeBitmap(curBgStr(), width, height) val bitmap = BitmapUtils.decodeBitmap(curBgStr(), width, height)
BitmapDrawable(resources, bitmap?.copyAndRecycle(width, height)) BitmapDrawable(resources, bitmap?.resizeAndRecycle(width, height))
} }
} }
} catch (e: OutOfMemoryError) { } catch (e: OutOfMemoryError) {

@ -35,6 +35,7 @@ object ImageProvider {
private val cacheSize = private val cacheSize =
max(50 * M, min(100 * M, (Runtime.getRuntime().maxMemory() / 8).toInt())) max(50 * M, min(100 * M, (Runtime.getRuntime().maxMemory() / 8).toInt()))
val bitmapLruCache = object : LruCache<String, Bitmap>(cacheSize) { val bitmapLruCache = object : LruCache<String, Bitmap>(cacheSize) {
override fun sizeOf(key: String, bitmap: Bitmap): Int { override fun sizeOf(key: String, bitmap: Bitmap): Int {
return bitmap.byteCount return bitmap.byteCount
} }
@ -45,9 +46,12 @@ object ImageProvider {
oldBitmap: Bitmap, oldBitmap: Bitmap,
newBitmap: Bitmap? newBitmap: Bitmap?
) { ) {
oldBitmap.recycle() //错误图片不能释放,占位用,防止一直重复获取图片
putDebug("ImageProvider: trigger bitmap recycle. URI: $key") if (oldBitmap != errorBitmap) {
putDebug("ImageProvider : cacheUsage ${size()}bytes / ${maxSize()}bytes") oldBitmap.recycle()
putDebug("ImageProvider: trigger bitmap recycle. URI: $key")
putDebug("ImageProvider : cacheUsage ${size()}bytes / ${maxSize()}bytes")
}
} }
} }
@ -121,6 +125,8 @@ object ImageProvider {
bitmapLruCache.put(src, bitmap) bitmapLruCache.put(src, bitmap)
bitmap bitmap
}.onFailure { }.onFailure {
//错误图片占位,防止重复获取
bitmapLruCache.put(src, errorBitmap)
putDebug( putDebug(
"ImageProvider: decode bitmap failed. path: ${vFile.absolutePath}\n$it", "ImageProvider: decode bitmap failed. path: ${vFile.absolutePath}\n$it",
it it

@ -96,19 +96,7 @@ class MainActivity : VMBaseActivity<ActivityMainBinding, MainViewModel>(),
binding.viewPagerMain.postDelayed(3000) { binding.viewPagerMain.postDelayed(3000) {
viewModel.postLoad() viewModel.postLoad()
} }
launch { syncAlert()
val lastBackupFile = withContext(IO) { AppWebDav.lastBackUp().getOrNull() }
?: return@launch
if (lastBackupFile.lastModify - LocalConfig.lastBackup > DateUtils.MINUTE_IN_MILLIS) {
alert("恢复", "webDav书源比本地新,是否恢复") {
cancelButton()
okButton {
LocalConfig.lastBackup = lastBackupFile.lastModify
viewModel.restoreWebDav(lastBackupFile.displayName)
}
}
}
}
} }
override fun onNavigationItemSelected(item: MenuItem): Boolean = binding.run { override fun onNavigationItemSelected(item: MenuItem): Boolean = binding.run {
@ -158,16 +146,37 @@ class MainActivity : VMBaseActivity<ActivityMainBinding, MainViewModel>(),
} }
} }
/**
* 同步提示
*/
private fun syncAlert() = launch {
val lastBackupFile = withContext(IO) { AppWebDav.lastBackUp().getOrNull() }
?: return@launch
if (lastBackupFile.lastModify - LocalConfig.lastBackup > DateUtils.MINUTE_IN_MILLIS) {
LocalConfig.lastBackup = lastBackupFile.lastModify
alert("恢复", "webDav书源比本地新,是否恢复") {
cancelButton()
okButton {
viewModel.restoreWebDav(lastBackupFile.displayName)
}
}
}
}
/**
* 用户隐私与协议
*/
private fun privacyPolicy() { private fun privacyPolicy() {
if (LocalConfig.privacyPolicyOk) return if (LocalConfig.privacyPolicyOk) return
val privacyPolicy = String(assets.open("privacyPolicy.md").readBytes()) val privacyPolicy = String(assets.open("privacyPolicy.md").readBytes())
alert("用户隐私与协议", privacyPolicy) { alert("用户隐私与协议", privacyPolicy) {
noButton { noButton()
finish()
}
yesButton { yesButton {
LocalConfig.privacyPolicyOk = true LocalConfig.privacyPolicyOk = true
} }
onCancelled {
finish()
}
} }
} }

@ -7,7 +7,6 @@ import android.graphics.Bitmap
import android.graphics.Bitmap.Config import android.graphics.Bitmap.Config
import android.graphics.BitmapFactory import android.graphics.BitmapFactory
import android.graphics.Color import android.graphics.Color
import android.graphics.Matrix
import com.google.android.renderscript.Toolkit import com.google.android.renderscript.Toolkit
import java.io.FileInputStream import java.io.FileInputStream
import java.io.IOException import java.io.IOException
@ -213,23 +212,10 @@ object BitmapUtils {
/** /**
* 获取指定宽高的图片 * 获取指定宽高的图片
*/ */
fun Bitmap.copyAndRecycle(newWidth: Int, newHeight: Int): Bitmap { fun Bitmap.resizeAndRecycle(newWidth: Int, newHeight: Int): Bitmap {
val width = this.width
val height = this.height
//计算压缩的比率
val scaleWidth = newWidth.toFloat() / width
val scaleHeight = newHeight.toFloat() / height
//获取想要缩放的matrix
val matrix = Matrix()
matrix.postScale(scaleWidth, scaleHeight)
//获取新的bitmap //获取新的bitmap
val bitmap = Bitmap.createBitmap(this, 0, 0, width, height, matrix, true) val bitmap = Toolkit.resize(this, newWidth, newHeight)
recycle() recycle()
return bitmap return bitmap
} }
@ -237,8 +223,7 @@ fun Bitmap.copyAndRecycle(newWidth: Int, newHeight: Int): Bitmap {
* 高斯模糊 * 高斯模糊
*/ */
fun Bitmap.stackBlur(radius: Int = 8): Bitmap { fun Bitmap.stackBlur(radius: Int = 8): Bitmap {
val blurredBitmap = this.copy(Config.ARGB_8888, true) return Toolkit.blur(this, radius)
return Toolkit.blur(blurredBitmap, radius)
} }
/** /**

@ -182,7 +182,7 @@ object QRCodeUtils {
hints: Map<DecodeHintType?, Any?> = DecodeFormatManager.ALL_HINTS hints: Map<DecodeHintType?, Any?> = DecodeFormatManager.ALL_HINTS
): Result? { ): Result? {
if (bitmap.width > reqWidth || bitmap.height > reqHeight) { if (bitmap.width > reqWidth || bitmap.height > reqHeight) {
val bm = bitmap.copyAndRecycle(reqWidth, reqHeight) val bm = bitmap.resizeAndRecycle(reqWidth, reqHeight)
return parseCodeResult(getRGBLuminanceSource(bm), hints) return parseCodeResult(getRGBLuminanceSource(bm), hints)
} }
return parseCodeResult(getRGBLuminanceSource(bitmap), hints) return parseCodeResult(getRGBLuminanceSource(bitmap), hints)

Loading…
Cancel
Save