diff --git a/app/src/main/java/io/legado/app/utils/BatteryUtils.kt b/app/src/main/java/io/legado/app/utils/BatteryUtils.kt deleted file mode 100644 index c7d49a3aa..000000000 --- a/app/src/main/java/io/legado/app/utils/BatteryUtils.kt +++ /dev/null @@ -1,16 +0,0 @@ -package io.legado.app.utils - -import android.content.Context -import android.content.Intent -import android.content.IntentFilter -import android.os.BatteryManager - -object BatteryUtils { - - fun getLevel(context: Context): Int { - val iFilter = IntentFilter(Intent.ACTION_BATTERY_CHANGED) - val batteryStatus = context.registerReceiver(null, iFilter) - - return batteryStatus?.getIntExtra(BatteryManager.EXTRA_LEVEL, -1) ?: -1 - } -} diff --git a/app/src/main/java/io/legado/app/utils/ContextExtensions.kt b/app/src/main/java/io/legado/app/utils/ContextExtensions.kt index de1eedaa8..1ad897272 100644 --- a/app/src/main/java/io/legado/app/utils/ContextExtensions.kt +++ b/app/src/main/java/io/legado/app/utils/ContextExtensions.kt @@ -3,10 +3,12 @@ package io.legado.app.utils import android.annotation.SuppressLint import android.content.Context import android.content.Intent +import android.content.IntentFilter import android.content.res.ColorStateList import android.content.res.Configuration import android.graphics.Bitmap import android.graphics.drawable.Drawable +import android.os.BatteryManager import android.provider.Settings import androidx.annotation.ColorRes import androidx.annotation.DrawableRes @@ -133,4 +135,13 @@ fun Context.shareWithQr(title: String, text: String) { fun Context.sysIsDarkMode(): Boolean { val mode = resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK return mode == Configuration.UI_MODE_NIGHT_YES +} + +/** + * 获取电量 + */ +fun Context.getBettery(): Int { + val iFilter = IntentFilter(Intent.ACTION_BATTERY_CHANGED) + val batteryStatus = registerReceiver(null, iFilter) + return batteryStatus?.getIntExtra(BatteryManager.EXTRA_LEVEL, -1) ?: -1 } \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/utils/DocumentUtils.kt b/app/src/main/java/io/legado/app/utils/DocumentUtils.kt index 15b1a7754..2adfcddf4 100644 --- a/app/src/main/java/io/legado/app/utils/DocumentUtils.kt +++ b/app/src/main/java/io/legado/app/utils/DocumentUtils.kt @@ -7,6 +7,7 @@ import android.provider.DocumentsContract import androidx.documentfile.provider.DocumentFile import java.util.* +@Suppress("unused") object DocumentUtils { fun exists(root: DocumentFile, fileName: String, vararg subDirs: String): Boolean { diff --git a/app/src/main/java/io/legado/app/utils/EncoderUtils.kt b/app/src/main/java/io/legado/app/utils/EncoderUtils.kt index 4858113e3..406aa3815 100644 --- a/app/src/main/java/io/legado/app/utils/EncoderUtils.kt +++ b/app/src/main/java/io/legado/app/utils/EncoderUtils.kt @@ -3,6 +3,7 @@ package io.legado.app.utils import android.util.Base64 import java.nio.charset.StandardCharsets +@Suppress("unused") object EncoderUtils { fun escape(src: String): String { diff --git a/app/src/main/java/io/legado/app/utils/FileUtils.kt b/app/src/main/java/io/legado/app/utils/FileUtils.kt index 8dbfa318f..2b4cbce61 100644 --- a/app/src/main/java/io/legado/app/utils/FileUtils.kt +++ b/app/src/main/java/io/legado/app/utils/FileUtils.kt @@ -10,7 +10,7 @@ import io.legado.app.App import java.io.File import java.io.IOException - +@Suppress("unused") object FileUtils { fun exists(root: File, fileName: String, vararg subDirs: String): Boolean { diff --git a/app/src/main/java/io/legado/app/utils/LogUtils.kt b/app/src/main/java/io/legado/app/utils/LogUtils.kt index 7953259f5..8c5070d11 100644 --- a/app/src/main/java/io/legado/app/utils/LogUtils.kt +++ b/app/src/main/java/io/legado/app/utils/LogUtils.kt @@ -8,7 +8,7 @@ import java.util.* import java.util.logging.* import java.util.logging.Formatter - +@Suppress("unused") object LogUtils { const val TIME_PATTERN = "yyyy-MM-dd HH:mm:ss" diff --git a/app/src/main/java/io/legado/app/utils/MD5Utils.kt b/app/src/main/java/io/legado/app/utils/MD5Utils.kt index a83345bc6..f0044a999 100644 --- a/app/src/main/java/io/legado/app/utils/MD5Utils.kt +++ b/app/src/main/java/io/legado/app/utils/MD5Utils.kt @@ -6,7 +6,7 @@ import java.security.NoSuchAlgorithmException /** * 将字符串转化为MD5 */ - +@Suppress("unused") object MD5Utils { fun md5Encode(str: String?): String? { diff --git a/app/src/main/java/io/legado/app/utils/NetworkUtils.kt b/app/src/main/java/io/legado/app/utils/NetworkUtils.kt index 616aa0006..0c59f05a3 100644 --- a/app/src/main/java/io/legado/app/utils/NetworkUtils.kt +++ b/app/src/main/java/io/legado/app/utils/NetworkUtils.kt @@ -8,6 +8,7 @@ import java.net.URL import java.util.* import java.util.regex.Pattern +@Suppress("unused") object NetworkUtils { fun getUrl(response: Response<*>): String { val networkResponse = response.raw().networkResponse diff --git a/app/src/main/java/io/legado/app/utils/StringUtils.kt b/app/src/main/java/io/legado/app/utils/StringUtils.kt index 46053cad8..dda534eed 100644 --- a/app/src/main/java/io/legado/app/utils/StringUtils.kt +++ b/app/src/main/java/io/legado/app/utils/StringUtils.kt @@ -12,6 +12,7 @@ import kotlin.math.abs import kotlin.math.log10 import kotlin.math.pow +@Suppress("unused") object StringUtils { private const val HOUR_OF_DAY = 24 private const val DAY_OF_YESTERDAY = 2 diff --git a/app/src/main/java/io/legado/app/utils/SystemUtils.kt b/app/src/main/java/io/legado/app/utils/SystemUtils.kt index 91121c000..c29381bbf 100644 --- a/app/src/main/java/io/legado/app/utils/SystemUtils.kt +++ b/app/src/main/java/io/legado/app/utils/SystemUtils.kt @@ -9,6 +9,8 @@ import android.net.Uri import android.os.PowerManager import android.provider.Settings + +@Suppress("unused") object SystemUtils { fun getScreenOffTime(context: Context): Int { diff --git a/app/src/main/java/io/legado/app/utils/UTF8BOMFighter.kt b/app/src/main/java/io/legado/app/utils/UTF8BOMFighter.kt index 5ced93613..3f502f8b6 100644 --- a/app/src/main/java/io/legado/app/utils/UTF8BOMFighter.kt +++ b/app/src/main/java/io/legado/app/utils/UTF8BOMFighter.kt @@ -1,5 +1,6 @@ package io.legado.app.utils +@Suppress("unused") object UTF8BOMFighter { private val UTF8_BOM_BYTES = byteArrayOf(0xEF.toByte(), 0xBB.toByte(), 0xBF.toByte()) diff --git a/app/src/main/java/io/legado/app/utils/ZipUtils.kt b/app/src/main/java/io/legado/app/utils/ZipUtils.kt index 44d547e5c..a8ec51d45 100644 --- a/app/src/main/java/io/legado/app/utils/ZipUtils.kt +++ b/app/src/main/java/io/legado/app/utils/ZipUtils.kt @@ -7,14 +7,7 @@ import java.util.zip.ZipEntry import java.util.zip.ZipFile import java.util.zip.ZipOutputStream -/** - *
- * author: Blankj
- * blog  : http://blankj.com
- * time  : 2016/08/27
- * desc  : utils about zip
-
* - */ +@Suppress("unused") object ZipUtils { /**