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