pull/1565/head
gedoor 3 years ago
parent c3e02d8617
commit 8d260f7f92
  1. 4
      app/src/main/java/io/legado/app/ui/about/AboutFragment.kt
  2. 4
      app/src/main/java/io/legado/app/ui/about/DonateFragment.kt
  3. 8
      app/src/main/java/io/legado/app/ui/book/read/config/MoreConfigDialog.kt
  4. 8
      app/src/main/java/io/legado/app/ui/book/read/config/ReadAloudConfigDialog.kt
  5. 8
      app/src/main/java/io/legado/app/ui/config/BackupConfigFragment.kt
  6. 38
      app/src/main/java/io/legado/app/ui/config/CheckSourceConfig.kt
  7. 8
      app/src/main/java/io/legado/app/ui/config/CoverConfigFragment.kt
  8. 8
      app/src/main/java/io/legado/app/ui/config/OtherConfigFragment.kt
  9. 8
      app/src/main/java/io/legado/app/ui/config/ThemeConfigFragment.kt
  10. 8
      app/src/main/java/io/legado/app/ui/main/my/MyFragment.kt
  11. 4
      app/src/main/java/io/legado/app/ui/widget/prefs/ColorPreference.kt
  12. 2
      app/src/main/java/io/legado/app/ui/widget/prefs/PreferenceCategory.kt

@ -46,8 +46,8 @@ class AboutFragment : PreferenceFragmentCompat() {
listView.overScrollMode = View.OVER_SCROLL_NEVER
}
override fun onPreferenceTreeClick(preference: Preference?): Boolean {
when (preference?.key) {
override fun onPreferenceTreeClick(preference: Preference): Boolean {
when (preference.key) {
"contributors" -> openUrl(R.string.contributors_url)
"update_log" -> show("updateLog.md")
"check_update" -> checkUpdate()

@ -29,8 +29,8 @@ class DonateFragment : PreferenceFragmentCompat() {
listView.overScrollMode = View.OVER_SCROLL_NEVER
}
override fun onPreferenceTreeClick(preference: Preference?): Boolean {
when (preference?.key) {
override fun onPreferenceTreeClick(preference: Preference): Boolean {
when (preference.key) {
"wxZsm" -> requireContext().openUrl(wxZsRwmUrl)
"zfbHbRwm" -> requireContext().openUrl(zfbHbRwmUrl)
"zfbSkRwm" -> requireContext().openUrl(zfbSkRwmUrl)

@ -84,13 +84,13 @@ class MoreConfigDialog : DialogFragment() {
super.onResume()
preferenceManager
.sharedPreferences
.registerOnSharedPreferenceChangeListener(this)
?.registerOnSharedPreferenceChangeListener(this)
}
override fun onPause() {
preferenceManager
.sharedPreferences
.unregisterOnSharedPreferenceChangeListener(this)
?.unregisterOnSharedPreferenceChangeListener(this)
super.onPause()
}
@ -131,8 +131,8 @@ class MoreConfigDialog : DialogFragment() {
}
}
override fun onPreferenceTreeClick(preference: Preference?): Boolean {
when (preference?.key) {
override fun onPreferenceTreeClick(preference: Preference): Boolean {
when (preference.key) {
"customPageKey" -> PageKeyDialog(requireContext()).show()
"clickRegionalConfig" -> {
(activity as? ReadBookActivity)?.showClickRegionalConfig()

@ -85,16 +85,16 @@ class ReadAloudConfigDialog : DialogFragment() {
override fun onResume() {
super.onResume()
preferenceManager.sharedPreferences.registerOnSharedPreferenceChangeListener(this)
preferenceManager.sharedPreferences?.registerOnSharedPreferenceChangeListener(this)
}
override fun onPause() {
preferenceManager.sharedPreferences.unregisterOnSharedPreferenceChangeListener(this)
preferenceManager.sharedPreferences?.unregisterOnSharedPreferenceChangeListener(this)
super.onPause()
}
override fun onPreferenceTreeClick(preference: Preference?): Boolean {
when (preference?.key) {
override fun onPreferenceTreeClick(preference: Preference): Boolean {
when (preference.key) {
PreferKey.ttsEngine -> showDialogFragment(SpeakEngineDialog())
}
return super.onPreferenceTreeClick(preference)

@ -129,7 +129,7 @@ class BackupConfigFragment : BasePreferenceFragment(),
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
activity?.setTitle(R.string.backup_restore)
preferenceManager.sharedPreferences.registerOnSharedPreferenceChangeListener(this)
preferenceManager.sharedPreferences?.registerOnSharedPreferenceChangeListener(this)
listView.setEdgeEffectColor(primaryColor)
setHasOptionsMenu(true)
if (!LocalConfig.backupHelpVersionIsLast) {
@ -157,7 +157,7 @@ class BackupConfigFragment : BasePreferenceFragment(),
override fun onDestroy() {
super.onDestroy()
preferenceManager.sharedPreferences.unregisterOnSharedPreferenceChangeListener(this)
preferenceManager.sharedPreferences?.unregisterOnSharedPreferenceChangeListener(this)
}
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences?, key: String?) {
@ -204,8 +204,8 @@ class BackupConfigFragment : BasePreferenceFragment(),
}
}
override fun onPreferenceTreeClick(preference: Preference?): Boolean {
when (preference?.key) {
override fun onPreferenceTreeClick(preference: Preference): Boolean {
when (preference.key) {
PreferKey.backupPath -> selectBackupPath.launch()
PreferKey.restoreIgnore -> backupIgnore()
"web_dav_backup" -> backup()

@ -6,11 +6,11 @@ import android.view.ViewGroup
import io.legado.app.R
import io.legado.app.base.BaseDialogFragment
import io.legado.app.databinding.DialogCheckSourceConfigBinding
import io.legado.app.model.CheckSource
import io.legado.app.lib.theme.primaryColor
import io.legado.app.model.CheckSource
import io.legado.app.utils.setLayout
import io.legado.app.utils.viewbindingdelegate.viewBinding
import io.legado.app.utils.toastOnUi
import io.legado.app.utils.viewbindingdelegate.viewBinding
import splitties.views.onClick
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)
CheckSource.run {
binding.checkSourceTimeout.setText((timeout / 1000).toString())
binding.checkSearch?.isChecked = checkSearch
binding.checkDiscovery?.isChecked = checkDiscovery
binding.checkInfo?.isChecked = checkInfo
binding.checkCategory?.isChecked = checkCategory
binding.checkContent?.isChecked = checkContent
binding.checkSearch.isChecked = checkSearch
binding.checkDiscovery.isChecked = checkDiscovery
binding.checkInfo.isChecked = checkInfo
binding.checkCategory.isChecked = checkCategory
binding.checkContent.isChecked = checkContent
binding.tvCancel.onClick {
dismiss()
}
@ -47,22 +47,28 @@ class CheckSourceConfig : BaseDialogFragment(R.layout.dialog_check_source_config
return@onClick
}
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
}
else -> timeout = text.toLong() * 1000
}
val _checkSearch = binding.checkSearch?.isChecked
val _checkDiscovery = binding.checkDiscovery?.isChecked
if (!_checkSearch && !_checkDiscovery) {
val mCheckSearch = binding.checkSearch.isChecked
val mCheckDiscovery = binding.checkDiscovery.isChecked
if (!mCheckSearch && !mCheckDiscovery) {
toastOnUi(getString(R.string.error_check_source_config))
return@onClick
}
checkSearch = _checkSearch
checkDiscovery = _checkDiscovery
checkInfo = binding.checkInfo?.isChecked
checkCategory = binding.checkCategory?.isChecked
checkContent = binding.checkContent?.isChecked
checkSearch = mCheckSearch
checkDiscovery = mCheckDiscovery
checkInfo = binding.checkInfo.isChecked
checkCategory = binding.checkCategory.isChecked
checkContent = binding.checkContent.isChecked
putConfig()
dismiss()
}

@ -48,12 +48,12 @@ class CoverConfigFragment : BasePreferenceFragment(),
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
preferenceManager.sharedPreferences.registerOnSharedPreferenceChangeListener(this)
preferenceManager.sharedPreferences?.registerOnSharedPreferenceChangeListener(this)
}
override fun onDestroy() {
super.onDestroy()
preferenceManager.sharedPreferences.unregisterOnSharedPreferenceChangeListener(this)
preferenceManager.sharedPreferences?.unregisterOnSharedPreferenceChangeListener(this)
}
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences?, key: String?) {
@ -81,8 +81,8 @@ class CoverConfigFragment : BasePreferenceFragment(),
}
@SuppressLint("PrivateResource")
override fun onPreferenceTreeClick(preference: Preference?): Boolean {
when (preference?.key) {
override fun onPreferenceTreeClick(preference: Preference): Boolean {
when (preference.key) {
PreferKey.defaultCover ->
if (getPrefString(PreferKey.defaultCover).isNullOrEmpty()) {
selectImage.launch(requestCodeCover)

@ -57,17 +57,17 @@ class OtherConfigFragment : BasePreferenceFragment(),
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
activity?.setTitle(R.string.other_setting)
preferenceManager.sharedPreferences.registerOnSharedPreferenceChangeListener(this)
preferenceManager.sharedPreferences?.registerOnSharedPreferenceChangeListener(this)
listView.setEdgeEffectColor(primaryColor)
}
override fun onDestroy() {
super.onDestroy()
preferenceManager.sharedPreferences.unregisterOnSharedPreferenceChangeListener(this)
preferenceManager.sharedPreferences?.unregisterOnSharedPreferenceChangeListener(this)
}
override fun onPreferenceTreeClick(preference: Preference?): Boolean {
when (preference?.key) {
override fun onPreferenceTreeClick(preference: Preference): Boolean {
when (preference.key) {
PreferKey.userAgent -> showUserAgentDialog()
PreferKey.defaultBookTreeUri -> localBookTreeSelect.launch {
title = getString(R.string.select_book_folder)

@ -90,12 +90,12 @@ class ThemeConfigFragment : BasePreferenceFragment(),
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
preferenceManager.sharedPreferences.registerOnSharedPreferenceChangeListener(this)
preferenceManager.sharedPreferences?.registerOnSharedPreferenceChangeListener(this)
}
override fun onDestroy() {
super.onDestroy()
preferenceManager.sharedPreferences.unregisterOnSharedPreferenceChangeListener(this)
preferenceManager.sharedPreferences?.unregisterOnSharedPreferenceChangeListener(this)
}
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
@ -140,8 +140,8 @@ class ThemeConfigFragment : BasePreferenceFragment(),
}
@SuppressLint("PrivateResource")
override fun onPreferenceTreeClick(preference: Preference?): Boolean {
when (val key = preference?.key) {
override fun onPreferenceTreeClick(preference: Preference): Boolean {
when (val key = preference.key) {
PreferKey.barElevation -> NumberPickerDialog(requireContext())
.setTitle(getString(R.string.bar_elevation))
.setMaxValue(32)

@ -107,11 +107,11 @@ class MyFragment : BaseFragment(R.layout.fragment_my_config) {
override fun onResume() {
super.onResume()
preferenceManager.sharedPreferences.registerOnSharedPreferenceChangeListener(this)
preferenceManager.sharedPreferences?.registerOnSharedPreferenceChangeListener(this)
}
override fun onPause() {
preferenceManager.sharedPreferences.unregisterOnSharedPreferenceChangeListener(this)
preferenceManager.sharedPreferences?.unregisterOnSharedPreferenceChangeListener(this)
super.onPause()
}
@ -131,8 +131,8 @@ class MyFragment : BaseFragment(R.layout.fragment_my_config) {
}
}
override fun onPreferenceTreeClick(preference: Preference?): Boolean {
when (preference?.key) {
override fun onPreferenceTreeClick(preference: Preference): Boolean {
when (preference.key) {
"bookSourceManage" -> startActivity<BookSourceActivity>()
"replaceManage" -> startActivity<ReplaceRuleActivity>()
"setting" -> startActivity<ConfigActivity> {

@ -138,8 +138,8 @@ class ColorPreference(context: Context, attrs: AttributeSet) : Preference(contex
}
}
override fun onGetDefaultValue(a: TypedArray?, index: Int): Any {
return a!!.getInteger(index, Color.BLACK)
override fun onGetDefaultValue(a: TypedArray, index: Int): Any {
return a.getInteger(index, Color.BLACK)
}
override fun onColorSelected(dialogId: Int, @ColorInt color: Int) {

@ -29,7 +29,7 @@ class PreferenceCategory(context: Context, attrs: AttributeSet) :
view.text = title
if (view.isInEditMode) return
view.setTextColor(context.accentColor)
view.isVisible = title != null && title.isNotEmpty()
view.isVisible = !title.isNullOrEmpty()
val da = holder.findViewById(R.id.preference_divider_above)
val dividerColor = if (AppConfig.isNightTheme) {

Loading…
Cancel
Save