From 8f9a93236a33aa2ed48c59456b42a0e0b996c965 Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 11 Oct 2019 15:06:44 +0800 Subject: [PATCH] up --- app/src/main/java/io/legado/app/help/JsExtensions.kt | 4 ++-- app/src/main/java/io/legado/app/help/ReadBookConfig.kt | 4 ++-- .../java/io/legado/app/model/analyzeRule/AnalyzeRule.kt | 2 +- .../java/io/legado/app/model/analyzeRule/AnalyzeUrl.kt | 2 +- .../legado/app/ui/widget/recycler/scroller/FastScroller.kt | 7 ++++--- .../io/legado/app/utils/{BitmapUtil.kt => BitmapUtils.kt} | 2 +- .../io/legado/app/utils/{ColorUtil.kt => ColorUtils.kt} | 5 +++-- .../io/legado/app/utils/{Encoder.kt => EncoderUtils.kt} | 2 +- app/src/main/java/io/legado/app/utils/TimeUtils.kt | 2 ++ 9 files changed, 17 insertions(+), 13 deletions(-) rename app/src/main/java/io/legado/app/utils/{BitmapUtil.kt => BitmapUtils.kt} (99%) rename app/src/main/java/io/legado/app/utils/{ColorUtil.kt => ColorUtils.kt} (94%) rename app/src/main/java/io/legado/app/utils/{Encoder.kt => EncoderUtils.kt} (97%) create mode 100644 app/src/main/java/io/legado/app/utils/TimeUtils.kt diff --git a/app/src/main/java/io/legado/app/help/JsExtensions.kt b/app/src/main/java/io/legado/app/help/JsExtensions.kt index 643630121..d449d553c 100644 --- a/app/src/main/java/io/legado/app/help/JsExtensions.kt +++ b/app/src/main/java/io/legado/app/help/JsExtensions.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) } /** diff --git a/app/src/main/java/io/legado/app/help/ReadBookConfig.kt b/app/src/main/java/io/legado/app/help/ReadBookConfig.kt index 9238c1341..89899d3cc 100644 --- a/app/src/main/java/io/legado/app/help/ReadBookConfig.kt +++ b/app/src/main/java/io/legado/app/help/ReadBookConfig.kt @@ -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) { diff --git a/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeRule.kt b/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeRule.kt index c04981cdd..328d6cab4 100644 --- a/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeRule.kt +++ b/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeRule.kt @@ -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) } /** diff --git a/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeUrl.kt b/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeUrl.kt index 654882cc2..bc45a46f9 100644 --- a/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeUrl.kt +++ b/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeUrl.kt @@ -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) } diff --git a/app/src/main/java/io/legado/app/ui/widget/recycler/scroller/FastScroller.kt b/app/src/main/java/io/legado/app/ui/widget/recycler/scroller/FastScroller.kt index 9086f50db..25af39c6a 100644 --- a/app/src/main/java/io/legado/app/ui/widget/recycler/scroller/FastScroller.kt +++ b/app/src/main/java/io/legado/app/ui/widget/recycler/scroller/FastScroller.kt @@ -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 diff --git a/app/src/main/java/io/legado/app/utils/BitmapUtil.kt b/app/src/main/java/io/legado/app/utils/BitmapUtils.kt similarity index 99% rename from app/src/main/java/io/legado/app/utils/BitmapUtil.kt rename to app/src/main/java/io/legado/app/utils/BitmapUtils.kt index 2b72e17db..00f1d4c58 100644 --- a/app/src/main/java/io/legado/app/utils/BitmapUtil.kt +++ b/app/src/main/java/io/legado/app/utils/BitmapUtils.kt @@ -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这个类。 diff --git a/app/src/main/java/io/legado/app/utils/ColorUtil.kt b/app/src/main/java/io/legado/app/utils/ColorUtils.kt similarity index 94% rename from app/src/main/java/io/legado/app/utils/ColorUtil.kt rename to app/src/main/java/io/legado/app/utils/ColorUtils.kt index bce3ea27c..b592bb6c9 100644 --- a/app/src/main/java/io/legado/app/utils/ColorUtil.kt +++ b/app/src/main/java/io/legado/app/utils/ColorUtils.kt @@ -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 } diff --git a/app/src/main/java/io/legado/app/utils/Encoder.kt b/app/src/main/java/io/legado/app/utils/EncoderUtils.kt similarity index 97% rename from app/src/main/java/io/legado/app/utils/Encoder.kt rename to app/src/main/java/io/legado/app/utils/EncoderUtils.kt index f14785af9..112ac65f9 100644 --- a/app/src/main/java/io/legado/app/utils/Encoder.kt +++ b/app/src/main/java/io/legado/app/utils/EncoderUtils.kt @@ -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() diff --git a/app/src/main/java/io/legado/app/utils/TimeUtils.kt b/app/src/main/java/io/legado/app/utils/TimeUtils.kt new file mode 100644 index 000000000..656da42d1 --- /dev/null +++ b/app/src/main/java/io/legado/app/utils/TimeUtils.kt @@ -0,0 +1,2 @@ +package io.legado.app.utils +