mirror of
https://github.com/gedoor/legado.git
synced 2024-09-01 09:34:25 +08:00
优化
This commit is contained in:
parent
c3e02d8617
commit
8d260f7f92
@ -46,8 +46,8 @@ class AboutFragment : PreferenceFragmentCompat() {
|
|||||||
listView.overScrollMode = View.OVER_SCROLL_NEVER
|
listView.overScrollMode = View.OVER_SCROLL_NEVER
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onPreferenceTreeClick(preference: Preference?): Boolean {
|
override fun onPreferenceTreeClick(preference: Preference): Boolean {
|
||||||
when (preference?.key) {
|
when (preference.key) {
|
||||||
"contributors" -> openUrl(R.string.contributors_url)
|
"contributors" -> openUrl(R.string.contributors_url)
|
||||||
"update_log" -> show("updateLog.md")
|
"update_log" -> show("updateLog.md")
|
||||||
"check_update" -> checkUpdate()
|
"check_update" -> checkUpdate()
|
||||||
|
@ -29,8 +29,8 @@ class DonateFragment : PreferenceFragmentCompat() {
|
|||||||
listView.overScrollMode = View.OVER_SCROLL_NEVER
|
listView.overScrollMode = View.OVER_SCROLL_NEVER
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onPreferenceTreeClick(preference: Preference?): Boolean {
|
override fun onPreferenceTreeClick(preference: Preference): Boolean {
|
||||||
when (preference?.key) {
|
when (preference.key) {
|
||||||
"wxZsm" -> requireContext().openUrl(wxZsRwmUrl)
|
"wxZsm" -> requireContext().openUrl(wxZsRwmUrl)
|
||||||
"zfbHbRwm" -> requireContext().openUrl(zfbHbRwmUrl)
|
"zfbHbRwm" -> requireContext().openUrl(zfbHbRwmUrl)
|
||||||
"zfbSkRwm" -> requireContext().openUrl(zfbSkRwmUrl)
|
"zfbSkRwm" -> requireContext().openUrl(zfbSkRwmUrl)
|
||||||
|
@ -84,13 +84,13 @@ class MoreConfigDialog : DialogFragment() {
|
|||||||
super.onResume()
|
super.onResume()
|
||||||
preferenceManager
|
preferenceManager
|
||||||
.sharedPreferences
|
.sharedPreferences
|
||||||
.registerOnSharedPreferenceChangeListener(this)
|
?.registerOnSharedPreferenceChangeListener(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onPause() {
|
override fun onPause() {
|
||||||
preferenceManager
|
preferenceManager
|
||||||
.sharedPreferences
|
.sharedPreferences
|
||||||
.unregisterOnSharedPreferenceChangeListener(this)
|
?.unregisterOnSharedPreferenceChangeListener(this)
|
||||||
super.onPause()
|
super.onPause()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -131,8 +131,8 @@ class MoreConfigDialog : DialogFragment() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onPreferenceTreeClick(preference: Preference?): Boolean {
|
override fun onPreferenceTreeClick(preference: Preference): Boolean {
|
||||||
when (preference?.key) {
|
when (preference.key) {
|
||||||
"customPageKey" -> PageKeyDialog(requireContext()).show()
|
"customPageKey" -> PageKeyDialog(requireContext()).show()
|
||||||
"clickRegionalConfig" -> {
|
"clickRegionalConfig" -> {
|
||||||
(activity as? ReadBookActivity)?.showClickRegionalConfig()
|
(activity as? ReadBookActivity)?.showClickRegionalConfig()
|
||||||
|
@ -85,16 +85,16 @@ class ReadAloudConfigDialog : DialogFragment() {
|
|||||||
|
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
preferenceManager.sharedPreferences.registerOnSharedPreferenceChangeListener(this)
|
preferenceManager.sharedPreferences?.registerOnSharedPreferenceChangeListener(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onPause() {
|
override fun onPause() {
|
||||||
preferenceManager.sharedPreferences.unregisterOnSharedPreferenceChangeListener(this)
|
preferenceManager.sharedPreferences?.unregisterOnSharedPreferenceChangeListener(this)
|
||||||
super.onPause()
|
super.onPause()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onPreferenceTreeClick(preference: Preference?): Boolean {
|
override fun onPreferenceTreeClick(preference: Preference): Boolean {
|
||||||
when (preference?.key) {
|
when (preference.key) {
|
||||||
PreferKey.ttsEngine -> showDialogFragment(SpeakEngineDialog())
|
PreferKey.ttsEngine -> showDialogFragment(SpeakEngineDialog())
|
||||||
}
|
}
|
||||||
return super.onPreferenceTreeClick(preference)
|
return super.onPreferenceTreeClick(preference)
|
||||||
|
@ -129,7 +129,7 @@ class BackupConfigFragment : BasePreferenceFragment(),
|
|||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
activity?.setTitle(R.string.backup_restore)
|
activity?.setTitle(R.string.backup_restore)
|
||||||
preferenceManager.sharedPreferences.registerOnSharedPreferenceChangeListener(this)
|
preferenceManager.sharedPreferences?.registerOnSharedPreferenceChangeListener(this)
|
||||||
listView.setEdgeEffectColor(primaryColor)
|
listView.setEdgeEffectColor(primaryColor)
|
||||||
setHasOptionsMenu(true)
|
setHasOptionsMenu(true)
|
||||||
if (!LocalConfig.backupHelpVersionIsLast) {
|
if (!LocalConfig.backupHelpVersionIsLast) {
|
||||||
@ -157,7 +157,7 @@ class BackupConfigFragment : BasePreferenceFragment(),
|
|||||||
|
|
||||||
override fun onDestroy() {
|
override fun onDestroy() {
|
||||||
super.onDestroy()
|
super.onDestroy()
|
||||||
preferenceManager.sharedPreferences.unregisterOnSharedPreferenceChangeListener(this)
|
preferenceManager.sharedPreferences?.unregisterOnSharedPreferenceChangeListener(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences?, key: String?) {
|
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences?, key: String?) {
|
||||||
@ -204,8 +204,8 @@ class BackupConfigFragment : BasePreferenceFragment(),
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onPreferenceTreeClick(preference: Preference?): Boolean {
|
override fun onPreferenceTreeClick(preference: Preference): Boolean {
|
||||||
when (preference?.key) {
|
when (preference.key) {
|
||||||
PreferKey.backupPath -> selectBackupPath.launch()
|
PreferKey.backupPath -> selectBackupPath.launch()
|
||||||
PreferKey.restoreIgnore -> backupIgnore()
|
PreferKey.restoreIgnore -> backupIgnore()
|
||||||
"web_dav_backup" -> backup()
|
"web_dav_backup" -> backup()
|
||||||
|
@ -6,11 +6,11 @@ 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.databinding.DialogCheckSourceConfigBinding
|
import io.legado.app.databinding.DialogCheckSourceConfigBinding
|
||||||
import io.legado.app.model.CheckSource
|
|
||||||
import io.legado.app.lib.theme.primaryColor
|
import io.legado.app.lib.theme.primaryColor
|
||||||
|
import io.legado.app.model.CheckSource
|
||||||
import io.legado.app.utils.setLayout
|
import io.legado.app.utils.setLayout
|
||||||
import io.legado.app.utils.viewbindingdelegate.viewBinding
|
|
||||||
import io.legado.app.utils.toastOnUi
|
import io.legado.app.utils.toastOnUi
|
||||||
|
import io.legado.app.utils.viewbindingdelegate.viewBinding
|
||||||
import splitties.views.onClick
|
import splitties.views.onClick
|
||||||
|
|
||||||
class CheckSourceConfig : BaseDialogFragment(R.layout.dialog_check_source_config) {
|
class CheckSourceConfig : BaseDialogFragment(R.layout.dialog_check_source_config) {
|
||||||
@ -31,11 +31,11 @@ class CheckSourceConfig : BaseDialogFragment(R.layout.dialog_check_source_config
|
|||||||
binding.toolBar.setBackgroundColor(primaryColor)
|
binding.toolBar.setBackgroundColor(primaryColor)
|
||||||
CheckSource.run {
|
CheckSource.run {
|
||||||
binding.checkSourceTimeout.setText((timeout / 1000).toString())
|
binding.checkSourceTimeout.setText((timeout / 1000).toString())
|
||||||
binding.checkSearch?.isChecked = checkSearch
|
binding.checkSearch.isChecked = checkSearch
|
||||||
binding.checkDiscovery?.isChecked = checkDiscovery
|
binding.checkDiscovery.isChecked = checkDiscovery
|
||||||
binding.checkInfo?.isChecked = checkInfo
|
binding.checkInfo.isChecked = checkInfo
|
||||||
binding.checkCategory?.isChecked = checkCategory
|
binding.checkCategory.isChecked = checkCategory
|
||||||
binding.checkContent?.isChecked = checkContent
|
binding.checkContent.isChecked = checkContent
|
||||||
binding.tvCancel.onClick {
|
binding.tvCancel.onClick {
|
||||||
dismiss()
|
dismiss()
|
||||||
}
|
}
|
||||||
@ -47,22 +47,28 @@ class CheckSourceConfig : BaseDialogFragment(R.layout.dialog_check_source_config
|
|||||||
return@onClick
|
return@onClick
|
||||||
}
|
}
|
||||||
text.toLong() < minTimeout -> {
|
text.toLong() < minTimeout -> {
|
||||||
toastOnUi("${getString(R.string.timeout)}${getString(R.string.less_than)}${minTimeout}${getString(R.string.seconds)}")
|
toastOnUi(
|
||||||
|
"${getString(R.string.timeout)}${getString(R.string.less_than)}${minTimeout}${
|
||||||
|
getString(
|
||||||
|
R.string.seconds
|
||||||
|
)
|
||||||
|
}"
|
||||||
|
)
|
||||||
return@onClick
|
return@onClick
|
||||||
}
|
}
|
||||||
else -> timeout = text.toLong() * 1000
|
else -> timeout = text.toLong() * 1000
|
||||||
}
|
}
|
||||||
val _checkSearch = binding.checkSearch?.isChecked
|
val mCheckSearch = binding.checkSearch.isChecked
|
||||||
val _checkDiscovery = binding.checkDiscovery?.isChecked
|
val mCheckDiscovery = binding.checkDiscovery.isChecked
|
||||||
if (!_checkSearch && !_checkDiscovery) {
|
if (!mCheckSearch && !mCheckDiscovery) {
|
||||||
toastOnUi(getString(R.string.error_check_source_config))
|
toastOnUi(getString(R.string.error_check_source_config))
|
||||||
return@onClick
|
return@onClick
|
||||||
}
|
}
|
||||||
checkSearch = _checkSearch
|
checkSearch = mCheckSearch
|
||||||
checkDiscovery = _checkDiscovery
|
checkDiscovery = mCheckDiscovery
|
||||||
checkInfo = binding.checkInfo?.isChecked
|
checkInfo = binding.checkInfo.isChecked
|
||||||
checkCategory = binding.checkCategory?.isChecked
|
checkCategory = binding.checkCategory.isChecked
|
||||||
checkContent = binding.checkContent?.isChecked
|
checkContent = binding.checkContent.isChecked
|
||||||
putConfig()
|
putConfig()
|
||||||
dismiss()
|
dismiss()
|
||||||
}
|
}
|
||||||
|
@ -48,12 +48,12 @@ class CoverConfigFragment : BasePreferenceFragment(),
|
|||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
preferenceManager.sharedPreferences.registerOnSharedPreferenceChangeListener(this)
|
preferenceManager.sharedPreferences?.registerOnSharedPreferenceChangeListener(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onDestroy() {
|
override fun onDestroy() {
|
||||||
super.onDestroy()
|
super.onDestroy()
|
||||||
preferenceManager.sharedPreferences.unregisterOnSharedPreferenceChangeListener(this)
|
preferenceManager.sharedPreferences?.unregisterOnSharedPreferenceChangeListener(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences?, key: String?) {
|
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences?, key: String?) {
|
||||||
@ -81,8 +81,8 @@ class CoverConfigFragment : BasePreferenceFragment(),
|
|||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("PrivateResource")
|
@SuppressLint("PrivateResource")
|
||||||
override fun onPreferenceTreeClick(preference: Preference?): Boolean {
|
override fun onPreferenceTreeClick(preference: Preference): Boolean {
|
||||||
when (preference?.key) {
|
when (preference.key) {
|
||||||
PreferKey.defaultCover ->
|
PreferKey.defaultCover ->
|
||||||
if (getPrefString(PreferKey.defaultCover).isNullOrEmpty()) {
|
if (getPrefString(PreferKey.defaultCover).isNullOrEmpty()) {
|
||||||
selectImage.launch(requestCodeCover)
|
selectImage.launch(requestCodeCover)
|
||||||
|
@ -57,17 +57,17 @@ class OtherConfigFragment : BasePreferenceFragment(),
|
|||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
activity?.setTitle(R.string.other_setting)
|
activity?.setTitle(R.string.other_setting)
|
||||||
preferenceManager.sharedPreferences.registerOnSharedPreferenceChangeListener(this)
|
preferenceManager.sharedPreferences?.registerOnSharedPreferenceChangeListener(this)
|
||||||
listView.setEdgeEffectColor(primaryColor)
|
listView.setEdgeEffectColor(primaryColor)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onDestroy() {
|
override fun onDestroy() {
|
||||||
super.onDestroy()
|
super.onDestroy()
|
||||||
preferenceManager.sharedPreferences.unregisterOnSharedPreferenceChangeListener(this)
|
preferenceManager.sharedPreferences?.unregisterOnSharedPreferenceChangeListener(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onPreferenceTreeClick(preference: Preference?): Boolean {
|
override fun onPreferenceTreeClick(preference: Preference): Boolean {
|
||||||
when (preference?.key) {
|
when (preference.key) {
|
||||||
PreferKey.userAgent -> showUserAgentDialog()
|
PreferKey.userAgent -> showUserAgentDialog()
|
||||||
PreferKey.defaultBookTreeUri -> localBookTreeSelect.launch {
|
PreferKey.defaultBookTreeUri -> localBookTreeSelect.launch {
|
||||||
title = getString(R.string.select_book_folder)
|
title = getString(R.string.select_book_folder)
|
||||||
|
@ -90,12 +90,12 @@ class ThemeConfigFragment : BasePreferenceFragment(),
|
|||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
preferenceManager.sharedPreferences.registerOnSharedPreferenceChangeListener(this)
|
preferenceManager.sharedPreferences?.registerOnSharedPreferenceChangeListener(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onDestroy() {
|
override fun onDestroy() {
|
||||||
super.onDestroy()
|
super.onDestroy()
|
||||||
preferenceManager.sharedPreferences.unregisterOnSharedPreferenceChangeListener(this)
|
preferenceManager.sharedPreferences?.unregisterOnSharedPreferenceChangeListener(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
|
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
|
||||||
@ -140,8 +140,8 @@ class ThemeConfigFragment : BasePreferenceFragment(),
|
|||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("PrivateResource")
|
@SuppressLint("PrivateResource")
|
||||||
override fun onPreferenceTreeClick(preference: Preference?): Boolean {
|
override fun onPreferenceTreeClick(preference: Preference): Boolean {
|
||||||
when (val key = preference?.key) {
|
when (val key = preference.key) {
|
||||||
PreferKey.barElevation -> NumberPickerDialog(requireContext())
|
PreferKey.barElevation -> NumberPickerDialog(requireContext())
|
||||||
.setTitle(getString(R.string.bar_elevation))
|
.setTitle(getString(R.string.bar_elevation))
|
||||||
.setMaxValue(32)
|
.setMaxValue(32)
|
||||||
|
@ -107,11 +107,11 @@ class MyFragment : BaseFragment(R.layout.fragment_my_config) {
|
|||||||
|
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
preferenceManager.sharedPreferences.registerOnSharedPreferenceChangeListener(this)
|
preferenceManager.sharedPreferences?.registerOnSharedPreferenceChangeListener(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onPause() {
|
override fun onPause() {
|
||||||
preferenceManager.sharedPreferences.unregisterOnSharedPreferenceChangeListener(this)
|
preferenceManager.sharedPreferences?.unregisterOnSharedPreferenceChangeListener(this)
|
||||||
super.onPause()
|
super.onPause()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -131,8 +131,8 @@ class MyFragment : BaseFragment(R.layout.fragment_my_config) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onPreferenceTreeClick(preference: Preference?): Boolean {
|
override fun onPreferenceTreeClick(preference: Preference): Boolean {
|
||||||
when (preference?.key) {
|
when (preference.key) {
|
||||||
"bookSourceManage" -> startActivity<BookSourceActivity>()
|
"bookSourceManage" -> startActivity<BookSourceActivity>()
|
||||||
"replaceManage" -> startActivity<ReplaceRuleActivity>()
|
"replaceManage" -> startActivity<ReplaceRuleActivity>()
|
||||||
"setting" -> startActivity<ConfigActivity> {
|
"setting" -> startActivity<ConfigActivity> {
|
||||||
|
@ -138,8 +138,8 @@ class ColorPreference(context: Context, attrs: AttributeSet) : Preference(contex
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onGetDefaultValue(a: TypedArray?, index: Int): Any {
|
override fun onGetDefaultValue(a: TypedArray, index: Int): Any {
|
||||||
return a!!.getInteger(index, Color.BLACK)
|
return a.getInteger(index, Color.BLACK)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onColorSelected(dialogId: Int, @ColorInt color: Int) {
|
override fun onColorSelected(dialogId: Int, @ColorInt color: Int) {
|
||||||
|
@ -29,7 +29,7 @@ class PreferenceCategory(context: Context, attrs: AttributeSet) :
|
|||||||
view.text = title
|
view.text = title
|
||||||
if (view.isInEditMode) return
|
if (view.isInEditMode) return
|
||||||
view.setTextColor(context.accentColor)
|
view.setTextColor(context.accentColor)
|
||||||
view.isVisible = title != null && title.isNotEmpty()
|
view.isVisible = !title.isNullOrEmpty()
|
||||||
|
|
||||||
val da = holder.findViewById(R.id.preference_divider_above)
|
val da = holder.findViewById(R.id.preference_divider_above)
|
||||||
val dividerColor = if (AppConfig.isNightTheme) {
|
val dividerColor = if (AppConfig.isNightTheme) {
|
||||||
|
Loading…
Reference in New Issue
Block a user