Merge branch 'gedoor:master' into master

This commit is contained in:
Xwite
2022-05-25 15:48:00 +08:00
committed by GitHub
15 changed files with 48 additions and 47 deletions

View File

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

View File

@@ -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;
}</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

View File

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

View File

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

View File

@@ -96,19 +96,7 @@ class MainActivity : VMBaseActivity<ActivityMainBinding, MainViewModel>(),
binding.viewPagerMain.postDelayed(3000) {
viewModel.postLoad()
}
launch {
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)
}
}
}
}
syncAlert()
}
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() {
if (LocalConfig.privacyPolicyOk) return
val privacyPolicy = String(assets.open("privacyPolicy.md").readBytes())
alert("用户隐私与协议", privacyPolicy) {
noButton {
finish()
}
noButton()
yesButton {
LocalConfig.privacyPolicyOk = true
}
onCancelled {
finish()
}
}
}

View File

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

View File

@@ -182,7 +182,7 @@ object QRCodeUtils {
hints: Map<DecodeHintType?, Any?> = DecodeFormatManager.ALL_HINTS
): Result? {
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(bitmap), hints)