mirror of
https://github.com/gedoor/legado.git
synced 2025-08-10 00:52:30 +00:00
优化
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package io.legado.app.base
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.content.res.Configuration
|
||||
import android.content.res.Resources
|
||||
@@ -15,8 +16,8 @@ import java.util.*
|
||||
@Suppress("unused")
|
||||
object AppContextWrapper {
|
||||
|
||||
@SuppressLint("ObsoleteSdkInt")
|
||||
fun wrap(context: Context): Context {
|
||||
|
||||
val resources: Resources = context.resources
|
||||
val configuration: Configuration = resources.configuration
|
||||
val targetLocale = getSetLocale(context)
|
||||
@@ -42,6 +43,7 @@ object AppContextWrapper {
|
||||
/**
|
||||
* 当前系统语言
|
||||
*/
|
||||
@SuppressLint("ObsoleteSdkInt")
|
||||
private fun getSystemLocale(): Locale {
|
||||
val locale: Locale
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { //7.0有多语言设置获取顶部的语言
|
||||
@@ -56,6 +58,7 @@ object AppContextWrapper {
|
||||
/**
|
||||
* 当前App语言
|
||||
*/
|
||||
@SuppressLint("ObsoleteSdkInt")
|
||||
private fun getAppLocale(context: Context): Locale {
|
||||
val locale: Locale
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package io.legado.app.base
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.content.res.Configuration
|
||||
import android.graphics.drawable.BitmapDrawable
|
||||
@@ -64,6 +65,7 @@ abstract class BaseActivity<VB : ViewBinding>(
|
||||
return super.onCreateView(parent, name, context, attrs)
|
||||
}
|
||||
|
||||
@SuppressLint("ObsoleteSdkInt")
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
window.decorView.disableAutoFill()
|
||||
initTheme()
|
||||
|
||||
@@ -13,6 +13,7 @@ import splitties.systemservices.connectivityManager
|
||||
/**
|
||||
* 监测网络变化
|
||||
*/
|
||||
@SuppressLint("ObsoleteSdkInt")
|
||||
class NetworkChangedListener(private val context: Context) {
|
||||
|
||||
var onNetworkChanged: (() -> Unit)? = null
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package io.legado.app.service
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Build
|
||||
@@ -161,6 +162,7 @@ class WebService : BaseService() {
|
||||
startForeground(AppConst.notificationIdWeb, notification)
|
||||
}
|
||||
|
||||
@SuppressLint("ObsoleteSdkInt")
|
||||
private fun upTile(active: Boolean) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
kotlin.runCatching {
|
||||
|
||||
@@ -46,6 +46,7 @@ import java.util.*
|
||||
/**
|
||||
* 音频播放
|
||||
*/
|
||||
@SuppressLint("ObsoleteSdkInt")
|
||||
class AudioPlayActivity :
|
||||
VMBaseActivity<ActivityAudioPlayBinding, AudioPlayViewModel>(toolBarTheme = Theme.Dark),
|
||||
ChangeBookSourceDialog.CallBack {
|
||||
|
||||
@@ -170,6 +170,7 @@ fun RadioGroup.checkByIndex(index: Int) {
|
||||
check(get(index).id)
|
||||
}
|
||||
|
||||
@SuppressLint("ObsoleteSdkInt")
|
||||
fun TextView.setHtml(html: String) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
text = Html.fromHtml(html, Html.FROM_HTML_MODE_COMPACT)
|
||||
|
||||
Reference in New Issue
Block a user