Merge pull request #2306 from 821938089/little-fix

修复阅读背景分主题设置bug
pull/2309/head
kunfei 2 years ago committed by GitHub
commit 87289bb9ed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      app/src/main/java/io/legado/app/ui/book/read/config/BgTextConfigDialog.kt
  2. 6
      app/src/main/java/io/legado/app/utils/MD5Utils.kt

@ -353,7 +353,11 @@ class BgTextConfigDialog : BaseDialogFragment(R.layout.dialog_read_bg_text) {
private fun setBgFromUri(uri: Uri) {
readUri(uri) { fileDoc, inputStream ->
var file = requireContext().externalFiles
file = FileUtils.createFileIfNotExist(file, "bg", fileDoc.name)
val suffix = fileDoc.name.substringAfterLast(".")
val fileName = uri.inputStream(requireContext())!!.use {
MD5Utils.md5Encode(it) + ".$suffix"
}
file = FileUtils.createFileIfNotExist(file, "bg", fileName)
FileOutputStream(file).use { outputStream ->
inputStream.copyTo(outputStream)
}

@ -1,6 +1,8 @@
package io.legado.app.utils
import cn.hutool.crypto.digest.DigestUtil
import java.io.InputStream
/**
* 将字符串转化为MD5
*/
@ -11,6 +13,10 @@ object MD5Utils {
return DigestUtil.digester("MD5").digestHex(str)
}
fun md5Encode(inputStream: InputStream): String {
return DigestUtil.digester("MD5").digestHex(inputStream)
}
fun md5Encode16(str: String): String {
var reStr = md5Encode(str)
reStr = reStr.substring(8, 24)

Loading…
Cancel
Save