pull/37/head
kunfei 5 years ago
parent ac773c8749
commit 8f9a93236a
  1. 4
      app/src/main/java/io/legado/app/help/JsExtensions.kt
  2. 4
      app/src/main/java/io/legado/app/help/ReadBookConfig.kt
  3. 2
      app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeRule.kt
  4. 2
      app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeUrl.kt
  5. 7
      app/src/main/java/io/legado/app/ui/widget/recycler/scroller/FastScroller.kt
  6. 2
      app/src/main/java/io/legado/app/utils/BitmapUtils.kt
  7. 5
      app/src/main/java/io/legado/app/utils/ColorUtils.kt
  8. 2
      app/src/main/java/io/legado/app/utils/EncoderUtils.kt
  9. 2
      app/src/main/java/io/legado/app/utils/TimeUtils.kt

@ -1,7 +1,7 @@
package io.legado.app.help
import io.legado.app.model.analyzeRule.AnalyzeUrl
import io.legado.app.utils.Encoder
import io.legado.app.utils.EncoderUtils
import io.legado.app.utils.StringUtils
import java.util.regex.Pattern
@ -27,7 +27,7 @@ class JsExtensions {
* js实现解码,不能删
*/
fun base64Decoder(str: String): String {
return Encoder.base64Decoder(str)
return EncoderUtils.base64Decoder(str)
}
/**

@ -176,7 +176,7 @@ object ReadBookConfig {
1 -> {
BitmapDrawable(
resources,
BitmapUtil.decodeBitmap(
BitmapUtils.decodeBitmap(
App.INSTANCE,
"bg" + File.separator + bgStr(),
width,
@ -186,7 +186,7 @@ object ReadBookConfig {
}
else -> BitmapDrawable(
resources,
BitmapUtil.decodeBitmap(bgStr(), width, height)
BitmapUtils.decodeBitmap(bgStr(), width, height)
)
}
} catch (e: Exception) {

@ -547,7 +547,7 @@ class AnalyzeRule(private var book: BaseBook? = null) {
* js实现解码,不能删
*/
fun base64Decoder(str: String): String {
return Encoder.base64Decoder(str)
return EncoderUtils.base64Decoder(str)
}
/**

@ -179,7 +179,7 @@ class AnalyzeUrl(
fieldMap[queryM[0]] = URLEncoder.encode(value, "UTF-8")
}
} else if (charset == "escape") {
fieldMap[queryM[0]] = Encoder.escape(value)
fieldMap[queryM[0]] = EncoderUtils.escape(value)
} else {
fieldMap[queryM[0]] = URLEncoder.encode(value, charset)
}

@ -26,7 +26,7 @@ import androidx.recyclerview.widget.RecyclerView
import androidx.recyclerview.widget.StaggeredGridLayoutManager
import io.legado.app.R
import io.legado.app.lib.theme.accentColor
import io.legado.app.utils.ColorUtil
import io.legado.app.utils.ColorUtils
import io.legado.app.utils.getCompatColor
import kotlin.math.max
import kotlin.math.min
@ -472,10 +472,11 @@ class FastScroller : LinearLayout {
mHandleView = findViewById(R.id.fastscroll_handle)
mTrackView = findViewById(R.id.fastscroll_track)
mScrollbar = findViewById(R.id.fastscroll_scrollbar)
@ColorInt var bubbleColor = ColorUtil.adjustAlpha(context.accentColor, 0.8f)
@ColorInt var bubbleColor = ColorUtils.adjustAlpha(context.accentColor, 0.8f)
@ColorInt var handleColor = context.accentColor
@ColorInt var trackColor = context.getCompatColor(R.color.transparent30)
@ColorInt var textColor = if (ColorUtil.isColorLight(bubbleColor)) Color.BLACK else Color.WHITE
@ColorInt var textColor =
if (ColorUtils.isColorLight(bubbleColor)) Color.BLACK else Color.WHITE
var fadeScrollbar = true
var showBubble = false
var showTrack = true

@ -19,7 +19,7 @@ import kotlin.math.sqrt
@Suppress("unused", "WeakerAccess")
object BitmapUtil {
object BitmapUtils {
/**
* 从path中获取图片信息,在通过BitmapFactory.decodeFile(String path)方法将突破转成Bitmap时
* 遇到大一些的图片我们经常会遇到OOM(Out Of Memory)的问题所以用到了我们上面提到的BitmapFactory.Options这个类

@ -5,7 +5,7 @@ import android.graphics.Color
import androidx.annotation.ColorInt
import androidx.annotation.FloatRange
object ColorUtil {
object ColorUtils {
fun intToString(intColor: Int): String {
return String.format("#%06X", 0xFFFFFF and intColor)
@ -37,7 +37,8 @@ object ColorUtil {
}
fun isColorLight(@ColorInt color: Int): Boolean {
val darkness = 1 - (0.299 * Color.red(color) + 0.587 * Color.green(color) + 0.114 * Color.blue(color)) / 255
val darkness =
1 - (0.299 * Color.red(color) + 0.587 * Color.green(color) + 0.114 * Color.blue(color)) / 255
return darkness < 0.4
}

@ -3,7 +3,7 @@ package io.legado.app.utils
import android.util.Base64
import java.nio.charset.StandardCharsets
object Encoder {
object EncoderUtils {
fun escape(src: String): String {
val tmp = StringBuilder()
Loading…
Cancel
Save