优化
This commit is contained in:
@@ -49,7 +49,6 @@ android {
|
|||||||
|
|
||||||
buildConfigField "String", "Cronet_Version", "\"$CronetVersion\""
|
buildConfigField "String", "Cronet_Version", "\"$CronetVersion\""
|
||||||
buildConfigField "String", "Cronet_Main_Version", "\"$CronetMainVersion\""
|
buildConfigField "String", "Cronet_Main_Version", "\"$CronetMainVersion\""
|
||||||
buildConfigField "boolean", "isGoogle", "false"
|
|
||||||
|
|
||||||
javaCompileOptions {
|
javaCompileOptions {
|
||||||
annotationProcessorOptions {
|
annotationProcessorOptions {
|
||||||
@@ -105,7 +104,6 @@ android {
|
|||||||
dimension "mode"
|
dimension "mode"
|
||||||
applicationId "io.legado.play"
|
applicationId "io.legado.play"
|
||||||
manifestPlaceholders.put("APP_CHANNEL_VALUE", "google")
|
manifestPlaceholders.put("APP_CHANNEL_VALUE", "google")
|
||||||
buildConfigField "boolean", "isGoogle", "true"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
compileOptions {
|
compileOptions {
|
||||||
|
|||||||
@@ -3,8 +3,8 @@
|
|||||||
package io.legado.app.lib.cronet
|
package io.legado.app.lib.cronet
|
||||||
|
|
||||||
import androidx.annotation.Keep
|
import androidx.annotation.Keep
|
||||||
|
import io.legado.app.constant.AppConst
|
||||||
import io.legado.app.constant.AppLog
|
import io.legado.app.constant.AppLog
|
||||||
import io.legado.app.help.config.AppConfig
|
|
||||||
import io.legado.app.help.http.okHttpClient
|
import io.legado.app.help.http.okHttpClient
|
||||||
import io.legado.app.utils.DebugLog
|
import io.legado.app.utils.DebugLog
|
||||||
import okhttp3.Headers
|
import okhttp3.Headers
|
||||||
@@ -20,11 +20,11 @@ import splitties.init.appCtx
|
|||||||
internal const val BUFFER_SIZE = 32 * 1024
|
internal const val BUFFER_SIZE = 32 * 1024
|
||||||
|
|
||||||
val cronetEngine: ExperimentalCronetEngine? by lazy {
|
val cronetEngine: ExperimentalCronetEngine? by lazy {
|
||||||
if (!AppConfig.isGooglePlay) {
|
if (!AppConst.isPlayChannel) {
|
||||||
CronetLoader.preDownload()
|
CronetLoader.preDownload()
|
||||||
}
|
}
|
||||||
val builder = ExperimentalCronetEngine.Builder(appCtx).apply {
|
val builder = ExperimentalCronetEngine.Builder(appCtx).apply {
|
||||||
if (!AppConfig.isGooglePlay && CronetLoader.install()) {
|
if (!AppConst.isPlayChannel && CronetLoader.install()) {
|
||||||
setLibraryLoader(CronetLoader)//设置自定义so库加载
|
setLibraryLoader(CronetLoader)//设置自定义so库加载
|
||||||
}
|
}
|
||||||
setStoragePath(appCtx.externalCacheDir?.absolutePath)//设置缓存路径
|
setStoragePath(appCtx.externalCacheDir?.absolutePath)//设置缓存路径
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import android.os.Build
|
|||||||
import android.text.TextUtils
|
import android.text.TextUtils
|
||||||
import androidx.annotation.Keep
|
import androidx.annotation.Keep
|
||||||
import io.legado.app.BuildConfig
|
import io.legado.app.BuildConfig
|
||||||
import io.legado.app.help.config.AppConfig
|
import io.legado.app.constant.AppConst
|
||||||
import io.legado.app.help.coroutine.Coroutine
|
import io.legado.app.help.coroutine.Coroutine
|
||||||
import io.legado.app.help.http.cronet.CronetLoaderInterface
|
import io.legado.app.help.http.cronet.CronetLoaderInterface
|
||||||
import io.legado.app.utils.DebugLog
|
import io.legado.app.utils.DebugLog
|
||||||
@@ -64,7 +64,7 @@ object CronetLoader : CronetEngine.Builder.LibraryLoader(), CronetLoaderInterfac
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (AppConfig.isGooglePlay) {
|
if (AppConst.isPlayChannel) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
if (md5.length != 32 || !soFile.exists() || md5 != getFileMD5(soFile)) {
|
if (md5.length != 32 || !soFile.exists() || md5 != getFileMD5(soFile)) {
|
||||||
@@ -80,7 +80,7 @@ object CronetLoader : CronetEngine.Builder.LibraryLoader(), CronetLoaderInterfac
|
|||||||
* 预加载Cronet
|
* 预加载Cronet
|
||||||
*/
|
*/
|
||||||
override fun preDownload() {
|
override fun preDownload() {
|
||||||
if (AppConfig.isGooglePlay) {
|
if (AppConst.isPlayChannel) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
Coroutine.async {
|
Coroutine.async {
|
||||||
@@ -266,7 +266,7 @@ object CronetLoader : CronetEngine.Builder.LibraryLoader(), CronetLoaderInterfac
|
|||||||
downloadTempFile: File,
|
downloadTempFile: File,
|
||||||
destSuccessFile: File
|
destSuccessFile: File
|
||||||
) {
|
) {
|
||||||
if (download || AppConfig.isGooglePlay) {
|
if (download || AppConst.isPlayChannel) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
download = true
|
download = true
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import android.provider.Settings
|
|||||||
import androidx.annotation.Keep
|
import androidx.annotation.Keep
|
||||||
import com.script.javascript.RhinoScriptEngine
|
import com.script.javascript.RhinoScriptEngine
|
||||||
import io.legado.app.BuildConfig
|
import io.legado.app.BuildConfig
|
||||||
|
import io.legado.app.utils.channel
|
||||||
import splitties.init.appCtx
|
import splitties.init.appCtx
|
||||||
import java.text.SimpleDateFormat
|
import java.text.SimpleDateFormat
|
||||||
|
|
||||||
@@ -14,6 +15,8 @@ object AppConst {
|
|||||||
|
|
||||||
const val APP_TAG = "Legado"
|
const val APP_TAG = "Legado"
|
||||||
|
|
||||||
|
val isPlayChannel = appCtx.channel == "google"
|
||||||
|
|
||||||
const val channelIdDownload = "channel_download"
|
const val channelIdDownload = "channel_download"
|
||||||
const val channelIdReadAloud = "channel_read_aloud"
|
const val channelIdReadAloud = "channel_read_aloud"
|
||||||
const val channelIdWeb = "channel_web"
|
const val channelIdWeb = "channel_web"
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ import splitties.init.appCtx
|
|||||||
|
|
||||||
@Suppress("MemberVisibilityCanBePrivate")
|
@Suppress("MemberVisibilityCanBePrivate")
|
||||||
object AppConfig : SharedPreferences.OnSharedPreferenceChangeListener {
|
object AppConfig : SharedPreferences.OnSharedPreferenceChangeListener {
|
||||||
const val isGooglePlay = BuildConfig.isGoogle//appCtx.channel == "google"
|
|
||||||
val isCronet = appCtx.getPrefBoolean(PreferKey.cronet)
|
val isCronet = appCtx.getPrefBoolean(PreferKey.cronet)
|
||||||
val useAntiAlias = appCtx.getPrefBoolean(PreferKey.antiAlias)
|
val useAntiAlias = appCtx.getPrefBoolean(PreferKey.antiAlias)
|
||||||
var userAgent: String = getPrefUserAgent()
|
var userAgent: String = getPrefUserAgent()
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ val okHttpClient: OkHttpClient by lazy {
|
|||||||
builder.addHeader("Cache-Control", "no-cache")
|
builder.addHeader("Cache-Control", "no-cache")
|
||||||
chain.proceed(builder.build())
|
chain.proceed(builder.build())
|
||||||
})
|
})
|
||||||
if (!AppConfig.isGooglePlay && AppConfig.isCronet) {
|
if (!AppConst.isPlayChannel && AppConfig.isCronet) {
|
||||||
if (Cronet.loader?.install() == true) {
|
if (Cronet.loader?.install() == true) {
|
||||||
Cronet.interceptor?.let {
|
Cronet.interceptor?.let {
|
||||||
builder.addInterceptor(it)
|
builder.addInterceptor(it)
|
||||||
|
|||||||
@@ -2,11 +2,11 @@ package io.legado.app.help.source
|
|||||||
|
|
||||||
import android.os.Handler
|
import android.os.Handler
|
||||||
import android.os.Looper
|
import android.os.Looper
|
||||||
|
import io.legado.app.constant.AppConst
|
||||||
import io.legado.app.data.appDb
|
import io.legado.app.data.appDb
|
||||||
import io.legado.app.data.entities.BaseSource
|
import io.legado.app.data.entities.BaseSource
|
||||||
import io.legado.app.data.entities.BookSource
|
import io.legado.app.data.entities.BookSource
|
||||||
import io.legado.app.data.entities.RssSource
|
import io.legado.app.data.entities.RssSource
|
||||||
import io.legado.app.help.config.AppConfig
|
|
||||||
import io.legado.app.utils.EncoderUtils
|
import io.legado.app.utils.EncoderUtils
|
||||||
import io.legado.app.utils.NetworkUtils
|
import io.legado.app.utils.NetworkUtils
|
||||||
import io.legado.app.utils.splitNotBlank
|
import io.legado.app.utils.splitNotBlank
|
||||||
@@ -59,7 +59,7 @@ object SourceHelp {
|
|||||||
url ?: return false
|
url ?: return false
|
||||||
val baseUrl = NetworkUtils.getBaseUrl(url)
|
val baseUrl = NetworkUtils.getBaseUrl(url)
|
||||||
baseUrl ?: return false
|
baseUrl ?: return false
|
||||||
if (AppConfig.isGooglePlay) return false
|
if (AppConst.isPlayChannel) return false
|
||||||
kotlin.runCatching {
|
kotlin.runCatching {
|
||||||
val host = baseUrl.split("//", ".")
|
val host = baseUrl.split("//", ".")
|
||||||
val base64Url = EncoderUtils.base64Encode("${host[host.lastIndex - 1]}.${host.last()}")
|
val base64Url = EncoderUtils.base64Encode("${host[host.lastIndex - 1]}.${host.last()}")
|
||||||
|
|||||||
@@ -5,9 +5,9 @@ import android.view.View
|
|||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import io.legado.app.R
|
import io.legado.app.R
|
||||||
import io.legado.app.base.BaseDialogFragment
|
import io.legado.app.base.BaseDialogFragment
|
||||||
|
import io.legado.app.constant.AppConst
|
||||||
import io.legado.app.databinding.DialogUpdateBinding
|
import io.legado.app.databinding.DialogUpdateBinding
|
||||||
import io.legado.app.help.AppUpdate
|
import io.legado.app.help.AppUpdate
|
||||||
import io.legado.app.help.config.AppConfig
|
|
||||||
import io.legado.app.lib.theme.primaryColor
|
import io.legado.app.lib.theme.primaryColor
|
||||||
import io.legado.app.model.Download
|
import io.legado.app.model.Download
|
||||||
import io.legado.app.utils.setLayout
|
import io.legado.app.utils.setLayout
|
||||||
@@ -53,7 +53,7 @@ class UpdateDialog() : BaseDialogFragment(R.layout.dialog_update) {
|
|||||||
.build()
|
.build()
|
||||||
.setMarkdown(binding.textView, updateBody)
|
.setMarkdown(binding.textView, updateBody)
|
||||||
}
|
}
|
||||||
if (!AppConfig.isGooglePlay) {
|
if (!AppConst.isPlayChannel) {
|
||||||
binding.toolBar.inflateMenu(R.menu.app_update)
|
binding.toolBar.inflateMenu(R.menu.app_update)
|
||||||
binding.toolBar.setOnMenuItemClickListener {
|
binding.toolBar.setOnMenuItemClickListener {
|
||||||
when (it.itemId) {
|
when (it.itemId) {
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import androidx.activity.viewModels
|
|||||||
import androidx.documentfile.provider.DocumentFile
|
import androidx.documentfile.provider.DocumentFile
|
||||||
import io.legado.app.R
|
import io.legado.app.R
|
||||||
import io.legado.app.base.VMBaseActivity
|
import io.legado.app.base.VMBaseActivity
|
||||||
|
import io.legado.app.constant.AppConst
|
||||||
import io.legado.app.constant.AppLog
|
import io.legado.app.constant.AppLog
|
||||||
import io.legado.app.databinding.ActivityTranslucenceBinding
|
import io.legado.app.databinding.ActivityTranslucenceBinding
|
||||||
import io.legado.app.help.config.AppConfig
|
import io.legado.app.help.config.AppConfig
|
||||||
@@ -107,7 +108,7 @@ class FileAssociationActivity :
|
|||||||
intent.data?.let { data ->
|
intent.data?.let { data ->
|
||||||
if (data.isContentScheme()) {
|
if (data.isContentScheme()) {
|
||||||
viewModel.dispatchIndent(data)
|
viewModel.dispatchIndent(data)
|
||||||
} else if (!AppConfig.isGooglePlay || Build.VERSION.SDK_INT <= Build.VERSION_CODES.Q) {
|
} else if (!AppConst.isPlayChannel || Build.VERSION.SDK_INT <= Build.VERSION_CODES.Q) {
|
||||||
PermissionsCompat.Builder(this)
|
PermissionsCompat.Builder(this)
|
||||||
.addPermissions(*Permissions.Group.STORAGE)
|
.addPermissions(*Permissions.Group.STORAGE)
|
||||||
.rationale(R.string.tip_perm_request_storage)
|
.rationale(R.string.tip_perm_request_storage)
|
||||||
|
|||||||
@@ -342,7 +342,7 @@ class CacheViewModel(application: Application) : BaseViewModel(application) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun setAssets(doc: DocumentFile, book: Book, epubBook: EpubBook): String {
|
private fun setAssets(doc: DocumentFile, book: Book, epubBook: EpubBook): String {
|
||||||
if (!(AppConfig.isGooglePlay || appCtx.packageName.contains(
|
if (!(AppConst.isPlayChannel || appCtx.packageName.contains(
|
||||||
"debug",
|
"debug",
|
||||||
true
|
true
|
||||||
))
|
))
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import androidx.appcompat.widget.PopupMenu
|
|||||||
import androidx.documentfile.provider.DocumentFile
|
import androidx.documentfile.provider.DocumentFile
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import io.legado.app.R
|
import io.legado.app.R
|
||||||
|
import io.legado.app.constant.AppConst
|
||||||
import io.legado.app.constant.PreferKey
|
import io.legado.app.constant.PreferKey
|
||||||
import io.legado.app.data.appDb
|
import io.legado.app.data.appDb
|
||||||
import io.legado.app.databinding.ActivityImportBookBinding
|
import io.legado.app.databinding.ActivityImportBookBinding
|
||||||
@@ -176,7 +177,7 @@ class ImportBookActivity : BaseImportBookActivity<ActivityImportBookBinding, Imp
|
|||||||
selectFolder.launch()
|
selectFolder.launch()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
AppConfig.isGooglePlay -> {
|
AppConst.isPlayChannel -> {
|
||||||
binding.tvEmptyMsg.visible()
|
binding.tvEmptyMsg.visible()
|
||||||
selectFolder.launch()
|
selectFolder.launch()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import androidx.fragment.app.activityViewModels
|
|||||||
import androidx.preference.ListPreference
|
import androidx.preference.ListPreference
|
||||||
import androidx.preference.Preference
|
import androidx.preference.Preference
|
||||||
import io.legado.app.R
|
import io.legado.app.R
|
||||||
|
import io.legado.app.constant.AppConst
|
||||||
import io.legado.app.constant.EventBus
|
import io.legado.app.constant.EventBus
|
||||||
import io.legado.app.constant.PreferKey
|
import io.legado.app.constant.PreferKey
|
||||||
import io.legado.app.databinding.DialogEditTextBinding
|
import io.legado.app.databinding.DialogEditTextBinding
|
||||||
@@ -48,7 +49,7 @@ class OtherConfigFragment : PreferenceFragment(),
|
|||||||
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
||||||
putPrefBoolean(PreferKey.processText, isProcessTextEnabled())
|
putPrefBoolean(PreferKey.processText, isProcessTextEnabled())
|
||||||
addPreferencesFromResource(R.xml.pref_config_other)
|
addPreferencesFromResource(R.xml.pref_config_other)
|
||||||
if (AppConfig.isGooglePlay) {
|
if (AppConst.isPlayChannel) {
|
||||||
preferenceScreen.removePreferenceRecursively("Cronet")
|
preferenceScreen.removePreferenceRecursively("Cronet")
|
||||||
}
|
}
|
||||||
upPreferenceSummary(PreferKey.userAgent, AppConfig.userAgent)
|
upPreferenceSummary(PreferKey.userAgent, AppConfig.userAgent)
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ class ThemeConfigFragment : PreferenceFragment(),
|
|||||||
if (Build.VERSION.SDK_INT < 26) {
|
if (Build.VERSION.SDK_INT < 26) {
|
||||||
preferenceScreen.removePreferenceRecursively(PreferKey.launcherIcon)
|
preferenceScreen.removePreferenceRecursively(PreferKey.launcherIcon)
|
||||||
}
|
}
|
||||||
if (!AppConfig.isGooglePlay) {
|
if (!AppConst.isPlayChannel) {
|
||||||
preferenceScreen.removePreferenceRecursively("welcomeStyle")
|
preferenceScreen.removePreferenceRecursively("welcomeStyle")
|
||||||
}
|
}
|
||||||
upPreferenceSummary(PreferKey.bgImage, getPrefString(PreferKey.bgImage))
|
upPreferenceSummary(PreferKey.bgImage, getPrefString(PreferKey.bgImage))
|
||||||
|
|||||||
@@ -8,11 +8,11 @@ import androidx.activity.result.contract.ActivityResultContracts
|
|||||||
import androidx.activity.viewModels
|
import androidx.activity.viewModels
|
||||||
import io.legado.app.R
|
import io.legado.app.R
|
||||||
import io.legado.app.base.VMBaseActivity
|
import io.legado.app.base.VMBaseActivity
|
||||||
|
import io.legado.app.constant.AppConst
|
||||||
import io.legado.app.constant.AppLog
|
import io.legado.app.constant.AppLog
|
||||||
import io.legado.app.constant.Theme
|
import io.legado.app.constant.Theme
|
||||||
import io.legado.app.databinding.ActivityTranslucenceBinding
|
import io.legado.app.databinding.ActivityTranslucenceBinding
|
||||||
import io.legado.app.help.IntentData
|
import io.legado.app.help.IntentData
|
||||||
import io.legado.app.help.config.AppConfig
|
|
||||||
import io.legado.app.lib.dialogs.SelectItem
|
import io.legado.app.lib.dialogs.SelectItem
|
||||||
import io.legado.app.lib.dialogs.alert
|
import io.legado.app.lib.dialogs.alert
|
||||||
import io.legado.app.lib.permission.Permissions
|
import io.legado.app.lib.permission.Permissions
|
||||||
@@ -160,7 +160,7 @@ class HandleFileActivity :
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun getDirActions(onlySys: Boolean = false): ArrayList<SelectItem<Int>> {
|
private fun getDirActions(onlySys: Boolean = false): ArrayList<SelectItem<Int>> {
|
||||||
return if (onlySys || AppConfig.isGooglePlay) {
|
return if (onlySys || AppConst.isPlayChannel) {
|
||||||
arrayListOf(SelectItem(getString(R.string.sys_folder_picker), HandleFileContract.DIR))
|
arrayListOf(SelectItem(getString(R.string.sys_folder_picker), HandleFileContract.DIR))
|
||||||
} else {
|
} else {
|
||||||
arrayListOf(
|
arrayListOf(
|
||||||
@@ -171,7 +171,7 @@ class HandleFileActivity :
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun getFileActions(): ArrayList<SelectItem<Int>> {
|
private fun getFileActions(): ArrayList<SelectItem<Int>> {
|
||||||
return if (AppConfig.isGooglePlay) {
|
return if (AppConst.isPlayChannel) {
|
||||||
arrayListOf(SelectItem(getString(R.string.sys_file_picker), HandleFileContract.FILE))
|
arrayListOf(SelectItem(getString(R.string.sys_file_picker), HandleFileContract.FILE))
|
||||||
} else {
|
} else {
|
||||||
arrayListOf(
|
arrayListOf(
|
||||||
|
|||||||
@@ -8,10 +8,10 @@ import android.view.View
|
|||||||
import androidx.preference.Preference
|
import androidx.preference.Preference
|
||||||
import io.legado.app.R
|
import io.legado.app.R
|
||||||
import io.legado.app.base.BaseFragment
|
import io.legado.app.base.BaseFragment
|
||||||
|
import io.legado.app.constant.AppConst
|
||||||
import io.legado.app.constant.EventBus
|
import io.legado.app.constant.EventBus
|
||||||
import io.legado.app.constant.PreferKey
|
import io.legado.app.constant.PreferKey
|
||||||
import io.legado.app.databinding.FragmentMyConfigBinding
|
import io.legado.app.databinding.FragmentMyConfigBinding
|
||||||
import io.legado.app.help.config.AppConfig
|
|
||||||
import io.legado.app.help.config.ThemeConfig
|
import io.legado.app.help.config.ThemeConfig
|
||||||
import io.legado.app.lib.dialogs.selector
|
import io.legado.app.lib.dialogs.selector
|
||||||
import io.legado.app.lib.prefs.NameListPreference
|
import io.legado.app.lib.prefs.NameListPreference
|
||||||
@@ -67,7 +67,7 @@ class MyFragment : BaseFragment(R.layout.fragment_my_config) {
|
|||||||
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
||||||
putPrefBoolean(PreferKey.webService, WebService.isRun)
|
putPrefBoolean(PreferKey.webService, WebService.isRun)
|
||||||
addPreferencesFromResource(R.xml.pref_main)
|
addPreferencesFromResource(R.xml.pref_main)
|
||||||
if (AppConfig.isGooglePlay) {
|
if (AppConst.isPlayChannel) {
|
||||||
findPreference<PreferenceCategory>("aboutCategory")
|
findPreference<PreferenceCategory>("aboutCategory")
|
||||||
?.removePreferenceRecursively("donate")
|
?.removePreferenceRecursively("donate")
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user