mirror of
https://github.com/gedoor/legado.git
synced 2024-07-06 23:47:49 +08:00
优化
This commit is contained in:
parent
8ea9c9c7ba
commit
ee33893c0e
@ -88,6 +88,7 @@ fun Activity.setStatusBarColorAuto(
|
||||
setLightStatusBar(isLightBar)
|
||||
}
|
||||
|
||||
@SuppressLint("ObsoleteSdkInt")
|
||||
fun Activity.setLightStatusBar(isLightBar: Boolean) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
||||
window.insetsController?.let {
|
||||
|
@ -1,7 +1,12 @@
|
||||
package io.legado.app.utils
|
||||
|
||||
|
||||
/**
|
||||
* 排序比较
|
||||
*/
|
||||
object AlphanumComparator : Comparator<String> {
|
||||
|
||||
|
||||
override fun compare(s1: String, s2: String): Int {
|
||||
var thisMarker = 0
|
||||
var thatMarker = 0
|
||||
|
@ -97,8 +97,9 @@ object ArchiveUtils {
|
||||
}
|
||||
|
||||
fun isArchive(name: String): Boolean {
|
||||
return if (archiveFileRegex.matches(name)) true else false
|
||||
return archiveFileRegex.matches(name)
|
||||
}
|
||||
|
||||
private fun checkAchieve(name: String) {
|
||||
if (!isArchive(name))
|
||||
throw IllegalArgumentException("Unexpected file suffix: Only 7z rar zip Accepted")
|
||||
|
@ -4,7 +4,11 @@ import android.graphics.Color
|
||||
import androidx.annotation.ColorInt
|
||||
import androidx.annotation.FloatRange
|
||||
import androidx.core.graphics.ColorUtils
|
||||
import kotlin.math.*
|
||||
import kotlin.math.max
|
||||
import kotlin.math.min
|
||||
import kotlin.math.pow
|
||||
import kotlin.math.roundToInt
|
||||
import kotlin.math.sqrt
|
||||
|
||||
@Suppress("unused", "MemberVisibilityCanBePrivate")
|
||||
object ColorUtils {
|
||||
@ -77,13 +81,13 @@ object ColorUtils {
|
||||
return Color.argb(a.toInt(), r.toInt(), g.toInt(), b.toInt())
|
||||
}
|
||||
|
||||
fun argb(R: Int, G: Int, B: Int): Int {
|
||||
return argb(Byte.MAX_VALUE.toInt(), R, G, B)
|
||||
fun argb(r: Int, g: Int, b: Int): Int {
|
||||
return argb(Byte.MAX_VALUE.toInt(), r, g, b)
|
||||
}
|
||||
|
||||
fun argb(A: Int, R: Int, G: Int, B: Int): Int {
|
||||
fun argb(alpha: Int, r: Int, g: Int, b: Int): Int {
|
||||
val colorByteArr =
|
||||
byteArrayOf(A.toByte(), R.toByte(), G.toByte(), B.toByte())
|
||||
byteArrayOf(alpha.toByte(), r.toByte(), g.toByte(), b.toByte())
|
||||
return byteArrToInt(colorByteArr)
|
||||
}
|
||||
|
||||
|
@ -1,3 +1,5 @@
|
||||
@file:Suppress("UnusedReceiverParameter")
|
||||
|
||||
package io.legado.app.utils
|
||||
|
||||
import android.webkit.CookieManager
|
||||
|
@ -94,7 +94,6 @@ object FileUtils {
|
||||
}
|
||||
|
||||
fun getSdCardPath(): String {
|
||||
@Suppress("DEPRECATION")
|
||||
var sdCardDirectory = Environment.getExternalStorageDirectory().absolutePath
|
||||
try {
|
||||
sdCardDirectory = File(sdCardDirectory).canonicalPath
|
||||
|
@ -1,9 +1,6 @@
|
||||
package io.legado.app.utils
|
||||
|
||||
import io.legado.app.constant.AppLog
|
||||
import io.legado.app.model.analyzeRule.AnalyzeUrl
|
||||
import org.apache.commons.text.StringEscapeUtils
|
||||
import org.jsoup.nodes.Entities
|
||||
import java.net.URL
|
||||
import java.util.regex.Pattern
|
||||
|
||||
|
@ -1,18 +1,31 @@
|
||||
package io.legado.app.utils
|
||||
|
||||
import android.graphics.*
|
||||
import android.graphics.Bitmap
|
||||
import android.graphics.BitmapFactory
|
||||
import android.graphics.Canvas
|
||||
import android.graphics.Color
|
||||
import android.graphics.Paint
|
||||
import android.text.TextPaint
|
||||
import android.text.TextUtils
|
||||
import androidx.annotation.ColorInt
|
||||
import androidx.annotation.FloatRange
|
||||
import com.google.zxing.*
|
||||
import com.google.zxing.BarcodeFormat
|
||||
import com.google.zxing.BinaryBitmap
|
||||
import com.google.zxing.DecodeHintType
|
||||
import com.google.zxing.EncodeHintType
|
||||
import com.google.zxing.LuminanceSource
|
||||
import com.google.zxing.MultiFormatReader
|
||||
import com.google.zxing.MultiFormatWriter
|
||||
import com.google.zxing.RGBLuminanceSource
|
||||
import com.google.zxing.Result
|
||||
import com.google.zxing.WriterException
|
||||
import com.google.zxing.common.GlobalHistogramBinarizer
|
||||
import com.google.zxing.common.HybridBinarizer
|
||||
import com.google.zxing.qrcode.QRCodeWriter
|
||||
import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel
|
||||
import com.king.zxing.DecodeFormatManager
|
||||
import com.king.zxing.util.LogUtils
|
||||
import java.util.*
|
||||
import java.util.EnumMap
|
||||
import kotlin.math.max
|
||||
|
||||
|
||||
@ -295,13 +308,13 @@ object QRCodeUtils {
|
||||
try {
|
||||
//采用HybridBinarizer解析
|
||||
result = reader.decodeWithState(BinaryBitmap(HybridBinarizer(source)))
|
||||
} catch (e: Exception) {
|
||||
} catch (_: Exception) {
|
||||
}
|
||||
if (result == null) {
|
||||
//如果没有解析成功,再采用GlobalHistogramBinarizer解析一次
|
||||
result = reader.decodeWithState(BinaryBitmap(GlobalHistogramBinarizer(source)))
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
} catch (_: Exception) {
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
@ -23,7 +23,6 @@ object RealPathUtil {
|
||||
*/
|
||||
private var filePathUri: Uri? = null
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
fun getPath(context: Context, uri: Uri): String? {
|
||||
//check here to KITKAT or new version
|
||||
@SuppressLint("ObsoleteSdkInt")
|
||||
|
@ -14,6 +14,7 @@ import splitties.systemservices.powerManager
|
||||
@Suppress("unused")
|
||||
object SystemUtils {
|
||||
|
||||
@SuppressLint("ObsoleteSdkInt")
|
||||
fun ignoreBatteryOptimization(activity: Activity) {
|
||||
if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.M) return
|
||||
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
package io.legado.app.utils
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.graphics.PorterDuff
|
||||
import android.graphics.PorterDuffColorFilter
|
||||
import android.os.Build
|
||||
@ -12,6 +13,7 @@ import io.legado.app.R
|
||||
/**
|
||||
* 设置toolBar更多图标颜色
|
||||
*/
|
||||
@SuppressLint("ObsoleteSdkInt")
|
||||
fun Toolbar.setMoreIconColor(color: Int) {
|
||||
val moreIcon = ContextCompat.getDrawable(context, R.drawable.ic_more)
|
||||
if (moreIcon != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
|
@ -1,4 +1,4 @@
|
||||
@file:Suppress("RedundantVisibilityModifier", "unused")
|
||||
@file:Suppress("RedundantVisibilityModifier", "unused", "UnusedReceiverParameter")
|
||||
@file:JvmName("ReflectionFragmentViewBindings")
|
||||
|
||||
package io.legado.app.utils.viewbindingdelegate
|
||||
|
Loading…
Reference in New Issue
Block a user