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