pull/2042/head
kunfei 2 years ago
parent 88d13d86ab
commit 6c97d29635
  1. 17
      app/src/main/java/io/legado/app/ui/config/BackupConfigFragment.kt
  2. 1
      app/src/main/java/io/legado/app/ui/config/CoverConfigFragment.kt
  3. 18
      app/src/main/java/io/legado/app/ui/config/ThemeConfigFragment.kt
  4. 1
      app/src/main/java/io/legado/app/ui/config/WelcomeConfigFragment.kt

@ -8,6 +8,7 @@ import android.view.Menu
import android.view.MenuInflater
import android.view.MenuItem
import android.view.View
import androidx.core.view.MenuProvider
import androidx.documentfile.provider.DocumentFile
import androidx.fragment.app.activityViewModels
import androidx.lifecycle.lifecycleScope
@ -39,7 +40,8 @@ import splitties.init.appCtx
import kotlin.collections.set
class BackupConfigFragment : PreferenceFragment(),
SharedPreferences.OnSharedPreferenceChangeListener {
SharedPreferences.OnSharedPreferenceChangeListener,
MenuProvider {
private val viewModel by activityViewModels<ConfigViewModel>()
@ -124,23 +126,22 @@ class BackupConfigFragment : PreferenceFragment(),
activity?.setTitle(R.string.backup_restore)
preferenceManager.sharedPreferences?.registerOnSharedPreferenceChangeListener(this)
listView.setEdgeEffectColor(primaryColor)
setHasOptionsMenu(true)
activity?.addMenuProvider(this, viewLifecycleOwner)
if (!LocalConfig.backupHelpVersionIsLast) {
showHelp()
}
}
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
super.onCreateOptionsMenu(menu, inflater)
inflater.inflate(R.menu.backup_restore, menu)
override fun onCreateMenu(menu: Menu, menuInflater: MenuInflater) {
menuInflater.inflate(R.menu.backup_restore, menu)
menu.applyTint(requireContext())
}
override fun onOptionsItemSelected(item: MenuItem): Boolean {
when (item.itemId) {
override fun onMenuItemSelected(menuItem: MenuItem): Boolean {
when (menuItem.itemId) {
R.id.menu_help -> showHelp()
}
return super.onOptionsItemSelected(item)
return true
}
private fun showHelp() {

@ -44,7 +44,6 @@ class CoverConfigFragment : PreferenceFragment(),
super.onViewCreated(view, savedInstanceState)
activity?.setTitle(R.string.cover_config)
listView.setEdgeEffectColor(primaryColor)
setHasOptionsMenu(true)
}
override fun onCreate(savedInstanceState: Bundle?) {

@ -10,6 +10,7 @@ import android.view.MenuInflater
import android.view.MenuItem
import android.view.View
import android.widget.SeekBar
import androidx.core.view.MenuProvider
import androidx.preference.Preference
import io.legado.app.R
import io.legado.app.base.AppContextWrapper
@ -34,7 +35,8 @@ import java.io.FileOutputStream
@Suppress("SameParameterValue")
class ThemeConfigFragment : PreferenceFragment(),
SharedPreferences.OnSharedPreferenceChangeListener {
SharedPreferences.OnSharedPreferenceChangeListener,
MenuProvider {
private val requestCodeBgLight = 121
private val requestCodeBgDark = 122
@ -89,7 +91,7 @@ class ThemeConfigFragment : PreferenceFragment(),
super.onViewCreated(view, savedInstanceState)
activity?.setTitle(R.string.theme_setting)
listView.setEdgeEffectColor(primaryColor)
setHasOptionsMenu(true)
activity?.addMenuProvider(this, viewLifecycleOwner)
}
override fun onCreate(savedInstanceState: Bundle?) {
@ -102,19 +104,19 @@ class ThemeConfigFragment : PreferenceFragment(),
preferenceManager.sharedPreferences?.unregisterOnSharedPreferenceChangeListener(this)
}
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
super.onCreateOptionsMenu(menu, inflater)
inflater.inflate(R.menu.theme_config, menu)
override fun onCreateMenu(menu: Menu, menuInflater: MenuInflater) {
menuInflater.inflate(R.menu.theme_config, menu)
menu.applyTint(requireContext())
}
override fun onOptionsItemSelected(item: MenuItem): Boolean {
when (item.itemId) {
override fun onMenuItemSelected(menuItem: MenuItem): Boolean {
when (menuItem.itemId) {
R.id.menu_theme_mode -> {
AppConfig.isNightTheme = !AppConfig.isNightTheme
ThemeConfig.applyDayNight(requireContext())
}
}
return super.onOptionsItemSelected(item)
return true
}
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences?, key: String?) {

@ -39,7 +39,6 @@ class WelcomeConfigFragment : PreferenceFragment(),
super.onViewCreated(view, savedInstanceState)
activity?.setTitle(R.string.welcome_style)
listView.setEdgeEffectColor(primaryColor)
setHasOptionsMenu(true)
}
override fun onCreate(savedInstanceState: Bundle?) {

Loading…
Cancel
Save