优化
This commit is contained in:
@@ -5,7 +5,6 @@ import android.content.pm.PackageManager
|
||||
import android.provider.Settings
|
||||
import androidx.annotation.Keep
|
||||
import io.legado.app.BuildConfig
|
||||
import io.legado.app.utils.channel
|
||||
import splitties.init.appCtx
|
||||
import java.text.SimpleDateFormat
|
||||
|
||||
@@ -14,8 +13,6 @@ 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"
|
||||
|
||||
@@ -5,7 +5,13 @@ import io.legado.app.help.CacheManager
|
||||
import io.legado.app.help.config.AppConfig
|
||||
import io.legado.app.help.http.CookieManager.cookieJarHeader
|
||||
import io.legado.app.utils.NetworkUtils
|
||||
import okhttp3.*
|
||||
import okhttp3.ConnectionSpec
|
||||
import okhttp3.Cookie
|
||||
import okhttp3.CookieJar
|
||||
import okhttp3.Credentials
|
||||
import okhttp3.HttpUrl
|
||||
import okhttp3.Interceptor
|
||||
import okhttp3.OkHttpClient
|
||||
import java.net.InetSocketAddress
|
||||
import java.net.Proxy
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
@@ -89,7 +95,7 @@ val okHttpClient: OkHttpClient by lazy {
|
||||
}
|
||||
networkResponse
|
||||
}
|
||||
if (!AppConst.isPlayChannel && AppConfig.isCronet) {
|
||||
if (AppConfig.isCronet) {
|
||||
if (Cronet.loader?.install() == true) {
|
||||
Cronet.interceptor?.let {
|
||||
builder.addInterceptor(it)
|
||||
|
||||
@@ -2,7 +2,6 @@ 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
|
||||
@@ -63,7 +62,6 @@ object SourceHelp {
|
||||
|
||||
private fun is18Plus(url: String?): Boolean {
|
||||
url ?: return false
|
||||
if (AppConst.isPlayChannel) return false
|
||||
val baseUrl = NetworkUtils.getBaseUrl(url) ?: return false
|
||||
kotlin.runCatching {
|
||||
val host = baseUrl.split("//", ".").let {
|
||||
|
||||
@@ -8,7 +8,6 @@ import android.view.Menu
|
||||
import android.view.MenuItem
|
||||
import io.legado.app.R
|
||||
import io.legado.app.base.BaseActivity
|
||||
import io.legado.app.constant.AppConst
|
||||
import io.legado.app.databinding.ActivityAboutBinding
|
||||
import io.legado.app.lib.theme.accentColor
|
||||
import io.legado.app.lib.theme.filletBackground
|
||||
@@ -46,7 +45,6 @@ class AboutActivity : BaseActivity<ActivityAboutBinding>() {
|
||||
|
||||
override fun onCompatCreateOptionsMenu(menu: Menu): Boolean {
|
||||
menuInflater.inflate(R.menu.about, menu)
|
||||
menu.findItem(R.id.menu_share_it)?.isVisible = !AppConst.isPlayChannel
|
||||
return super.onCompatCreateOptionsMenu(menu)
|
||||
}
|
||||
|
||||
|
||||
@@ -9,10 +9,8 @@ import androidx.lifecycle.lifecycleScope
|
||||
import androidx.preference.Preference
|
||||
import androidx.preference.PreferenceFragmentCompat
|
||||
import io.legado.app.R
|
||||
import io.legado.app.constant.AppConst
|
||||
import io.legado.app.constant.AppConst.appInfo
|
||||
import io.legado.app.help.AppUpdate
|
||||
import io.legado.app.lib.prefs.PreferenceCategory
|
||||
import io.legado.app.ui.widget.dialog.TextDialog
|
||||
import io.legado.app.ui.widget.dialog.WaitDialog
|
||||
import io.legado.app.utils.*
|
||||
@@ -30,12 +28,6 @@ class AboutFragment : PreferenceFragmentCompat() {
|
||||
addPreferencesFromResource(R.xml.about)
|
||||
findPreference<Preference>("update_log")?.summary =
|
||||
"${getString(R.string.version)} ${appInfo.versionName}"
|
||||
if (AppConst.isPlayChannel) {
|
||||
findPreference<PreferenceCategory>("lx")?.run {
|
||||
removePreferenceRecursively("home_page")
|
||||
removePreferenceRecursively("git")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
@@ -45,15 +37,10 @@ class AboutFragment : PreferenceFragmentCompat() {
|
||||
|
||||
override fun onPreferenceTreeClick(preference: Preference): Boolean {
|
||||
when (preference.key) {
|
||||
"contributors" -> if (!AppConst.isPlayChannel) {
|
||||
openUrl(R.string.contributors_url)
|
||||
}
|
||||
"contributors" -> openUrl(R.string.contributors_url)
|
||||
"update_log" -> showMdFile(getString(R.string.update_log), "updateLog.md")
|
||||
"check_update" -> checkUpdate()
|
||||
"mail" -> requireContext().sendMail(getString(R.string.email))
|
||||
"sourceRuleSummary" -> openUrl(R.string.source_rule_url)
|
||||
"git" -> openUrl(R.string.this_github_url)
|
||||
"home_page" -> openUrl(R.string.home_page_url)
|
||||
"license" -> showMdFile(getString(R.string.license), "LICENSE.md")
|
||||
"disclaimer" -> showMdFile(getString(R.string.disclaimer), "disclaimer.md")
|
||||
"privacyPolicy" -> showMdFile(getString(R.string.privacy_policy), "privacyPolicy.md")
|
||||
|
||||
@@ -5,7 +5,6 @@ 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.lib.theme.primaryColor
|
||||
@@ -53,21 +52,19 @@ class UpdateDialog() : BaseDialogFragment(R.layout.dialog_update) {
|
||||
.build()
|
||||
.setMarkdown(binding.textView, updateBody)
|
||||
}
|
||||
if (!AppConst.isPlayChannel) {
|
||||
binding.toolBar.inflateMenu(R.menu.app_update)
|
||||
binding.toolBar.setOnMenuItemClickListener {
|
||||
when (it.itemId) {
|
||||
R.id.menu_download -> {
|
||||
val url = arguments?.getString("url")
|
||||
val name = arguments?.getString("name")
|
||||
if (url != null && name != null) {
|
||||
Download.start(requireContext(), url, name)
|
||||
toastOnUi(R.string.download_start)
|
||||
}
|
||||
binding.toolBar.inflateMenu(R.menu.app_update)
|
||||
binding.toolBar.setOnMenuItemClickListener {
|
||||
when (it.itemId) {
|
||||
R.id.menu_download -> {
|
||||
val url = arguments?.getString("url")
|
||||
val name = arguments?.getString("name")
|
||||
if (url != null && name != null) {
|
||||
Download.start(requireContext(), url, name)
|
||||
toastOnUi(R.string.download_start)
|
||||
}
|
||||
}
|
||||
return@setOnMenuItemClickListener true
|
||||
}
|
||||
return@setOnMenuItemClickListener true
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,6 @@ import androidx.documentfile.provider.DocumentFile
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
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
|
||||
@@ -120,7 +119,7 @@ class FileAssociationActivity :
|
||||
intent.data?.let { data ->
|
||||
if (data.isContentScheme()) {
|
||||
viewModel.dispatchIndent(data)
|
||||
} else if (!AppConst.isPlayChannel || Build.VERSION.SDK_INT <= Build.VERSION_CODES.Q) {
|
||||
} else if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.Q) {
|
||||
PermissionsCompat.Builder()
|
||||
.addPermissions(*Permissions.Group.STORAGE)
|
||||
.rationale(R.string.tip_perm_request_storage)
|
||||
|
||||
@@ -12,7 +12,6 @@ import androidx.documentfile.provider.DocumentFile
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
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.databinding.DialogEditTextBinding
|
||||
import io.legado.app.help.config.AppConfig
|
||||
@@ -176,10 +175,6 @@ class ImportBookActivity : BaseImportBookActivity<ImportBookViewModel>(),
|
||||
selectFolder.launch()
|
||||
}
|
||||
}
|
||||
AppConst.isPlayChannel -> {
|
||||
binding.tvEmptyMsg.visible()
|
||||
selectFolder.launch()
|
||||
}
|
||||
else -> initRootPath(rootUri.path!!)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,6 @@ 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
|
||||
@@ -50,9 +49,6 @@ class OtherConfigFragment : PreferenceFragment(),
|
||||
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
||||
putPrefBoolean(PreferKey.processText, isProcessTextEnabled())
|
||||
addPreferencesFromResource(R.xml.pref_config_other)
|
||||
if (AppConst.isPlayChannel) {
|
||||
preferenceScreen.removePreferenceRecursively("Cronet")
|
||||
}
|
||||
upPreferenceSummary(PreferKey.userAgent, AppConfig.userAgent)
|
||||
upPreferenceSummary(PreferKey.preDownloadNum, AppConfig.preDownloadNum.toString())
|
||||
upPreferenceSummary(PreferKey.threadCount, AppConfig.threadCount.toString())
|
||||
|
||||
@@ -59,9 +59,6 @@ class ThemeConfigFragment : PreferenceFragment(),
|
||||
if (Build.VERSION.SDK_INT < 26) {
|
||||
preferenceScreen.removePreferenceRecursively(PreferKey.launcherIcon)
|
||||
}
|
||||
if (!AppConst.isPlayChannel) {
|
||||
preferenceScreen.removePreferenceRecursively("welcomeStyle")
|
||||
}
|
||||
upPreferenceSummary(PreferKey.bgImage, getPrefString(PreferKey.bgImage))
|
||||
upPreferenceSummary(PreferKey.bgImageN, getPrefString(PreferKey.bgImageN))
|
||||
upPreferenceSummary(PreferKey.barElevation, AppConfig.elevation.toString())
|
||||
|
||||
@@ -9,7 +9,6 @@ import androidx.activity.viewModels
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
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.IntentData
|
||||
@@ -167,7 +166,7 @@ class HandleFileActivity :
|
||||
}
|
||||
|
||||
private fun getDirActions(onlySys: Boolean = false): ArrayList<SelectItem<Int>> {
|
||||
return if (onlySys || (AppConst.isPlayChannel && Permissions.isManageExternalStorage())) {
|
||||
return if (onlySys) {
|
||||
arrayListOf(SelectItem(getString(R.string.sys_folder_picker), HandleFileContract.DIR))
|
||||
} else {
|
||||
arrayListOf(
|
||||
@@ -178,14 +177,10 @@ class HandleFileActivity :
|
||||
}
|
||||
|
||||
private fun getFileActions(): ArrayList<SelectItem<Int>> {
|
||||
return if (AppConst.isPlayChannel && Permissions.isManageExternalStorage()) {
|
||||
arrayListOf(SelectItem(getString(R.string.sys_file_picker), HandleFileContract.FILE))
|
||||
} else {
|
||||
arrayListOf(
|
||||
SelectItem(getString(R.string.sys_file_picker), HandleFileContract.FILE),
|
||||
SelectItem(getString(R.string.app_file_picker), 11)
|
||||
)
|
||||
}
|
||||
return arrayListOf(
|
||||
SelectItem(getString(R.string.sys_file_picker), HandleFileContract.FILE),
|
||||
SelectItem(getString(R.string.app_file_picker), 11)
|
||||
)
|
||||
}
|
||||
|
||||
private fun checkPermissions(success: (() -> Unit)? = null) {
|
||||
|
||||
Reference in New Issue
Block a user