kunfei 3 лет назад
Родитель
Сommit
86bd4a1dd9

+ 0 - 2
app/build.gradle

@@ -49,7 +49,6 @@ android {
 
         buildConfigField "String", "Cronet_Version", "\"$CronetVersion\""
         buildConfigField "String", "Cronet_Main_Version", "\"$CronetMainVersion\""
-        buildConfigField "boolean", "isGoogle", "false"
 
         javaCompileOptions {
             annotationProcessorOptions {
@@ -105,7 +104,6 @@ android {
             dimension "mode"
             applicationId "io.legado.play"
             manifestPlaceholders.put("APP_CHANNEL_VALUE", "google")
-            buildConfigField "boolean", "isGoogle", "true"
         }
     }
     compileOptions {

+ 3 - 3
app/src/app/java/io/legado/app/lib/cronet/CronetHelper.kt

@@ -3,8 +3,8 @@
 package io.legado.app.lib.cronet
 
 import androidx.annotation.Keep
+import io.legado.app.constant.AppConst
 import io.legado.app.constant.AppLog
-import io.legado.app.help.config.AppConfig
 import io.legado.app.help.http.okHttpClient
 import io.legado.app.utils.DebugLog
 import okhttp3.Headers
@@ -20,11 +20,11 @@ import splitties.init.appCtx
 internal const val BUFFER_SIZE = 32 * 1024
 
 val cronetEngine: ExperimentalCronetEngine? by lazy {
-    if (!AppConfig.isGooglePlay) {
+    if (!AppConst.isPlayChannel) {
         CronetLoader.preDownload()
     }
     val builder = ExperimentalCronetEngine.Builder(appCtx).apply {
-        if (!AppConfig.isGooglePlay && CronetLoader.install()) {
+        if (!AppConst.isPlayChannel && CronetLoader.install()) {
             setLibraryLoader(CronetLoader)//设置自定义so库加载
         }
         setStoragePath(appCtx.externalCacheDir?.absolutePath)//设置缓存路径

+ 4 - 4
app/src/app/java/io/legado/app/lib/cronet/CronetLoader.kt

@@ -7,7 +7,7 @@ import android.os.Build
 import android.text.TextUtils
 import androidx.annotation.Keep
 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.http.cronet.CronetLoaderInterface
 import io.legado.app.utils.DebugLog
@@ -64,7 +64,7 @@ object CronetLoader : CronetEngine.Builder.LibraryLoader(), CronetLoaderInterfac
             }
         }
 
-        if (AppConfig.isGooglePlay) {
+        if (AppConst.isPlayChannel) {
             return false
         }
         if (md5.length != 32 || !soFile.exists() || md5 != getFileMD5(soFile)) {
@@ -80,7 +80,7 @@ object CronetLoader : CronetEngine.Builder.LibraryLoader(), CronetLoaderInterfac
      * 预加载Cronet
      */
     override fun preDownload() {
-        if (AppConfig.isGooglePlay) {
+        if (AppConst.isPlayChannel) {
             return
         }
         Coroutine.async {
@@ -266,7 +266,7 @@ object CronetLoader : CronetEngine.Builder.LibraryLoader(), CronetLoaderInterfac
         downloadTempFile: File,
         destSuccessFile: File
     ) {
-        if (download || AppConfig.isGooglePlay) {
+        if (download || AppConst.isPlayChannel) {
             return
         }
         download = true

+ 3 - 0
app/src/main/java/io/legado/app/constant/AppConst.kt

@@ -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"

+ 0 - 1
app/src/main/java/io/legado/app/help/config/AppConfig.kt

@@ -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()

+ 1 - 1
app/src/main/java/io/legado/app/help/http/HttpHelper.kt

@@ -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 - 2
app/src/main/java/io/legado/app/help/source/SourceHelp.kt

@@ -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()}")

+ 2 - 2
app/src/main/java/io/legado/app/ui/about/UpdateDialog.kt

@@ -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) {

+ 2 - 1
app/src/main/java/io/legado/app/ui/association/FileAssociationActivity.kt

@@ -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)

+ 1 - 1
app/src/main/java/io/legado/app/ui/book/cache/CacheViewModel.kt

@@ -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
             ))

+ 2 - 1
app/src/main/java/io/legado/app/ui/book/import/local/ImportBookActivity.kt

@@ -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()
                     }

+ 2 - 1
app/src/main/java/io/legado/app/ui/config/OtherConfigFragment.kt

@@ -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)

+ 1 - 1
app/src/main/java/io/legado/app/ui/config/ThemeConfigFragment.kt

@@ -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))

+ 3 - 3
app/src/main/java/io/legado/app/ui/document/HandleFileActivity.kt

@@ -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(

+ 2 - 2
app/src/main/java/io/legado/app/ui/main/my/MyFragment.kt

@@ -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")
             }