mirror of
https://github.com/gedoor/legado.git
synced 2025-01-05 10:17:15 +08:00
优化
This commit is contained in:
parent
ae4b362c9b
commit
30ec23390a
@ -49,7 +49,7 @@ android {
|
||||
defaultConfig {
|
||||
applicationId "io.legado.app"
|
||||
minSdk 21
|
||||
targetSdk 34
|
||||
targetSdk 35
|
||||
versionCode 10000 + gitCommits
|
||||
versionName version
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
|
@ -64,7 +64,7 @@ object AppConst {
|
||||
@Suppress("DEPRECATION")
|
||||
appCtx.packageManager.getPackageInfo(appCtx.packageName, PackageManager.GET_ACTIVITIES)
|
||||
?.let {
|
||||
appInfo.versionName = it.versionName
|
||||
appInfo.versionName = it.versionName!!
|
||||
appInfo.appVariant = when {
|
||||
it.packageName.contains("releaseA") -> AppVariant.BETA_RELEASEA
|
||||
isBeta -> AppVariant.BETA_RELEASE
|
||||
@ -86,7 +86,7 @@ object AppConst {
|
||||
private val sha256Signature: String by lazy {
|
||||
val packageInfo =
|
||||
appCtx.packageManager.getPackageInfo(appCtx.packageName, PackageManager.GET_SIGNATURES)
|
||||
DigestUtil.sha256Hex(packageInfo.signatures[0].toByteArray()).uppercase()
|
||||
DigestUtil.sha256Hex(packageInfo.signatures!![0].toByteArray()).uppercase()
|
||||
}
|
||||
|
||||
private val isOfficial = sha256Signature == OFFICIAL_SIGNATURE
|
||||
|
@ -21,4 +21,5 @@ object IntentAction {
|
||||
const val moveTo = "moveTo"
|
||||
const val init = "init"
|
||||
const val remove = "remove"
|
||||
const val stopPlay = "stopPlay"
|
||||
}
|
@ -233,7 +233,7 @@ object AudioPlay : CoroutineScope by MainScope() {
|
||||
|
||||
fun skipTo(index: Int) {
|
||||
Coroutine.async {
|
||||
stop()
|
||||
stopPlay()
|
||||
durChapterIndex = index
|
||||
durChapterPos = 0
|
||||
durPlayUrl = ""
|
||||
@ -244,7 +244,7 @@ object AudioPlay : CoroutineScope by MainScope() {
|
||||
|
||||
fun prev() {
|
||||
Coroutine.async {
|
||||
stop()
|
||||
stopPlay()
|
||||
if (durChapterIndex > 0) {
|
||||
durChapterIndex -= 1
|
||||
durChapterPos = 0
|
||||
@ -256,7 +256,7 @@ object AudioPlay : CoroutineScope by MainScope() {
|
||||
}
|
||||
|
||||
fun next() {
|
||||
stop()
|
||||
stopPlay()
|
||||
if (durChapterIndex + 1 < simulatedChapterSize) {
|
||||
durChapterIndex += 1
|
||||
durChapterPos = 0
|
||||
@ -284,6 +284,14 @@ object AudioPlay : CoroutineScope by MainScope() {
|
||||
context.startService(intent)
|
||||
}
|
||||
|
||||
fun stopPlay() {
|
||||
if (AudioPlayService.isRun) {
|
||||
context.startService<AudioPlayService> {
|
||||
action = IntentAction.stopPlay
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun saveRead() {
|
||||
val book = book ?: return
|
||||
Coroutine.async {
|
||||
|
@ -157,6 +157,13 @@ class AudioPlayService : BaseService(),
|
||||
play()
|
||||
}
|
||||
|
||||
IntentAction.stopPlay -> {
|
||||
exoPlayer.stop()
|
||||
upPlayProgressJob?.cancel()
|
||||
AudioPlay.status = Status.STOP
|
||||
postEvent(EventBus.AUDIO_STATE, Status.STOP)
|
||||
}
|
||||
|
||||
IntentAction.pause -> pause()
|
||||
IntentAction.resume -> resume()
|
||||
IntentAction.prev -> AudioPlay.prev()
|
||||
|
@ -103,7 +103,7 @@ class VerificationCodeDialog() : BaseDialogFragment(R.layout.dialog_verification
|
||||
transition: Transition<in Bitmap>?
|
||||
) {
|
||||
view ?: return
|
||||
val bitmap = resource.copy(resource.config, true)
|
||||
val bitmap = resource.copy(resource.config ?: Bitmap.Config.ARGB_8888, true)
|
||||
ImageProvider.bitmapLruCache.put(url, bitmap)
|
||||
binding.verificationCodeImageView.setImageBitmap(bitmap)
|
||||
}
|
||||
|
@ -6,7 +6,13 @@ import android.graphics.Color
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.util.DisplayMetrics
|
||||
import android.view.*
|
||||
import android.view.Gravity
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.view.WindowInsets
|
||||
import android.view.WindowInsetsController
|
||||
import android.view.WindowManager
|
||||
import android.view.WindowMetrics
|
||||
import android.widget.FrameLayout
|
||||
import androidx.annotation.ColorInt
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
@ -54,14 +60,13 @@ val WindowManager.windowSize: DisplayMetrics
|
||||
return displayMetrics
|
||||
}
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
fun Activity.fullScreen() {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
||||
window.setDecorFitsSystemWindows(true)
|
||||
}
|
||||
@Suppress("DEPRECATION")
|
||||
window.decorView.systemUiVisibility =
|
||||
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or View.SYSTEM_UI_FLAG_LAYOUT_STABLE
|
||||
@Suppress("DEPRECATION")
|
||||
window.clearFlags(
|
||||
WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS
|
||||
or WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION
|
||||
@ -72,6 +77,7 @@ fun Activity.fullScreen() {
|
||||
/**
|
||||
* 设置状态栏颜色
|
||||
*/
|
||||
@Suppress("DEPRECATION")
|
||||
fun Activity.setStatusBarColorAuto(
|
||||
@ColorInt color: Int,
|
||||
isTransparent: Boolean,
|
||||
@ -124,6 +130,7 @@ fun Activity.setLightStatusBar(isLightBar: Boolean) {
|
||||
/**
|
||||
* 设置导航栏颜色
|
||||
*/
|
||||
@Suppress("DEPRECATION")
|
||||
fun Activity.setNavigationBarColorAuto(@ColorInt color: Int) {
|
||||
val isLightBor = ColorUtils.isColorLight(color)
|
||||
window.navigationBarColor = color
|
||||
|
@ -82,7 +82,7 @@ object BitmapPool {
|
||||
/**
|
||||
* A helper function to return the byte usage per pixel of a bitmap based on its configuration.
|
||||
*/
|
||||
private fun getBytesPerPixel(config: Bitmap.Config): Int {
|
||||
private fun getBytesPerPixel(config: Bitmap.Config?): Int {
|
||||
return when (config) {
|
||||
Bitmap.Config.ARGB_8888 -> 4
|
||||
Bitmap.Config.RGB_565, Bitmap.Config.ARGB_4444 -> 2
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
buildscript {
|
||||
ext{
|
||||
compile_sdk_version = 34
|
||||
compile_sdk_version = 35
|
||||
build_tool_version = '34.0.0'
|
||||
// kotlin_version = '1.9.22'
|
||||
// ksp_version = "1.0.17"
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
kotlin = "2.0.20"
|
||||
ksp = "2.0.20-1.0.24"
|
||||
agp = "8.5.2"
|
||||
agp = "8.6.0"
|
||||
appcompat = "1.7.0"
|
||||
colorpicker = "1.1.0"
|
||||
commonsText = "1.12.0"
|
||||
|
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@ -1,6 +1,6 @@
|
||||
#Tue Aug 27 18:19:17 CST 2024
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
@ -13,7 +13,7 @@ android {
|
||||
}
|
||||
defaultConfig {
|
||||
minSdk 21
|
||||
targetSdk 34
|
||||
targetSdk 35
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
consumerProguardFiles "consumer-rules.pro"
|
||||
|
@ -15,7 +15,7 @@ android {
|
||||
}
|
||||
defaultConfig {
|
||||
minSdk 21
|
||||
targetSdk 34
|
||||
targetSdk 35
|
||||
|
||||
consumerProguardFiles "consumer-rules.pro"
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user