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