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