This commit is contained in:
kunfei
2023-01-27 19:31:21 +08:00
parent 814b8590d6
commit 86bd4a1dd9
15 changed files with 28 additions and 25 deletions
@@ -6,6 +6,7 @@ import android.provider.Settings
import androidx.annotation.Keep
import com.script.javascript.RhinoScriptEngine
import io.legado.app.BuildConfig
import io.legado.app.utils.channel
import splitties.init.appCtx
import java.text.SimpleDateFormat
@@ -14,6 +15,8 @@ object AppConst {
const val APP_TAG = "Legado"
val isPlayChannel = appCtx.channel == "google"
const val channelIdDownload = "channel_download"
const val channelIdReadAloud = "channel_read_aloud"
const val channelIdWeb = "channel_web"
@@ -12,7 +12,6 @@ import splitties.init.appCtx
@Suppress("MemberVisibilityCanBePrivate")
object AppConfig : SharedPreferences.OnSharedPreferenceChangeListener {
const val isGooglePlay = BuildConfig.isGoogle//appCtx.channel == "google"
val isCronet = appCtx.getPrefBoolean(PreferKey.cronet)
val useAntiAlias = appCtx.getPrefBoolean(PreferKey.antiAlias)
var userAgent: String = getPrefUserAgent()
@@ -69,7 +69,7 @@ val okHttpClient: OkHttpClient by lazy {
builder.addHeader("Cache-Control", "no-cache")
chain.proceed(builder.build())
})
if (!AppConfig.isGooglePlay && AppConfig.isCronet) {
if (!AppConst.isPlayChannel && AppConfig.isCronet) {
if (Cronet.loader?.install() == true) {
Cronet.interceptor?.let {
builder.addInterceptor(it)
@@ -2,11 +2,11 @@ package io.legado.app.help.source
import android.os.Handler
import android.os.Looper
import io.legado.app.constant.AppConst
import io.legado.app.data.appDb
import io.legado.app.data.entities.BaseSource
import io.legado.app.data.entities.BookSource
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.NetworkUtils
import io.legado.app.utils.splitNotBlank
@@ -59,7 +59,7 @@ object SourceHelp {
url ?: return false
val baseUrl = NetworkUtils.getBaseUrl(url)
baseUrl ?: return false
if (AppConfig.isGooglePlay) return false
if (AppConst.isPlayChannel) return false
kotlin.runCatching {
val host = baseUrl.split("//", ".")
val base64Url = EncoderUtils.base64Encode("${host[host.lastIndex - 1]}.${host.last()}")
@@ -5,9 +5,9 @@ import android.view.View
import android.view.ViewGroup
import io.legado.app.R
import io.legado.app.base.BaseDialogFragment
import io.legado.app.constant.AppConst
import io.legado.app.databinding.DialogUpdateBinding
import io.legado.app.help.AppUpdate
import io.legado.app.help.config.AppConfig
import io.legado.app.lib.theme.primaryColor
import io.legado.app.model.Download
import io.legado.app.utils.setLayout
@@ -53,7 +53,7 @@ class UpdateDialog() : BaseDialogFragment(R.layout.dialog_update) {
.build()
.setMarkdown(binding.textView, updateBody)
}
if (!AppConfig.isGooglePlay) {
if (!AppConst.isPlayChannel) {
binding.toolBar.inflateMenu(R.menu.app_update)
binding.toolBar.setOnMenuItemClickListener {
when (it.itemId) {
@@ -7,6 +7,7 @@ import androidx.activity.viewModels
import androidx.documentfile.provider.DocumentFile
import io.legado.app.R
import io.legado.app.base.VMBaseActivity
import io.legado.app.constant.AppConst
import io.legado.app.constant.AppLog
import io.legado.app.databinding.ActivityTranslucenceBinding
import io.legado.app.help.config.AppConfig
@@ -107,7 +108,7 @@ class FileAssociationActivity :
intent.data?.let { data ->
if (data.isContentScheme()) {
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)
.addPermissions(*Permissions.Group.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 {
if (!(AppConfig.isGooglePlay || appCtx.packageName.contains(
if (!(AppConst.isPlayChannel || appCtx.packageName.contains(
"debug",
true
))
@@ -10,6 +10,7 @@ import androidx.appcompat.widget.PopupMenu
import androidx.documentfile.provider.DocumentFile
import androidx.recyclerview.widget.LinearLayoutManager
import io.legado.app.R
import io.legado.app.constant.AppConst
import io.legado.app.constant.PreferKey
import io.legado.app.data.appDb
import io.legado.app.databinding.ActivityImportBookBinding
@@ -176,7 +177,7 @@ class ImportBookActivity : BaseImportBookActivity<ActivityImportBookBinding, Imp
selectFolder.launch()
}
}
AppConfig.isGooglePlay -> {
AppConst.isPlayChannel -> {
binding.tvEmptyMsg.visible()
selectFolder.launch()
}
@@ -11,6 +11,7 @@ import androidx.fragment.app.activityViewModels
import androidx.preference.ListPreference
import androidx.preference.Preference
import io.legado.app.R
import io.legado.app.constant.AppConst
import io.legado.app.constant.EventBus
import io.legado.app.constant.PreferKey
import io.legado.app.databinding.DialogEditTextBinding
@@ -48,7 +49,7 @@ class OtherConfigFragment : PreferenceFragment(),
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
putPrefBoolean(PreferKey.processText, isProcessTextEnabled())
addPreferencesFromResource(R.xml.pref_config_other)
if (AppConfig.isGooglePlay) {
if (AppConst.isPlayChannel) {
preferenceScreen.removePreferenceRecursively("Cronet")
}
upPreferenceSummary(PreferKey.userAgent, AppConfig.userAgent)
@@ -59,7 +59,7 @@ class ThemeConfigFragment : PreferenceFragment(),
if (Build.VERSION.SDK_INT < 26) {
preferenceScreen.removePreferenceRecursively(PreferKey.launcherIcon)
}
if (!AppConfig.isGooglePlay) {
if (!AppConst.isPlayChannel) {
preferenceScreen.removePreferenceRecursively("welcomeStyle")
}
upPreferenceSummary(PreferKey.bgImage, getPrefString(PreferKey.bgImage))
@@ -8,11 +8,11 @@ import androidx.activity.result.contract.ActivityResultContracts
import androidx.activity.viewModels
import io.legado.app.R
import io.legado.app.base.VMBaseActivity
import io.legado.app.constant.AppConst
import io.legado.app.constant.AppLog
import io.legado.app.constant.Theme
import io.legado.app.databinding.ActivityTranslucenceBinding
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.alert
import io.legado.app.lib.permission.Permissions
@@ -160,7 +160,7 @@ class HandleFileActivity :
}
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))
} else {
arrayListOf(
@@ -171,7 +171,7 @@ class HandleFileActivity :
}
private fun getFileActions(): ArrayList<SelectItem<Int>> {
return if (AppConfig.isGooglePlay) {
return if (AppConst.isPlayChannel) {
arrayListOf(SelectItem(getString(R.string.sys_file_picker), HandleFileContract.FILE))
} else {
arrayListOf(
@@ -8,10 +8,10 @@ import android.view.View
import androidx.preference.Preference
import io.legado.app.R
import io.legado.app.base.BaseFragment
import io.legado.app.constant.AppConst
import io.legado.app.constant.EventBus
import io.legado.app.constant.PreferKey
import io.legado.app.databinding.FragmentMyConfigBinding
import io.legado.app.help.config.AppConfig
import io.legado.app.help.config.ThemeConfig
import io.legado.app.lib.dialogs.selector
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?) {
putPrefBoolean(PreferKey.webService, WebService.isRun)
addPreferencesFromResource(R.xml.pref_main)
if (AppConfig.isGooglePlay) {
if (AppConst.isPlayChannel) {
findPreference<PreferenceCategory>("aboutCategory")
?.removePreferenceRecursively("donate")
}