|
|
@ -4,6 +4,9 @@ import android.annotation.SuppressLint |
|
|
|
import android.content.SharedPreferences |
|
|
|
import android.content.SharedPreferences |
|
|
|
import android.os.Build |
|
|
|
import android.os.Build |
|
|
|
import android.os.Bundle |
|
|
|
import android.os.Bundle |
|
|
|
|
|
|
|
import android.view.Menu |
|
|
|
|
|
|
|
import android.view.MenuInflater |
|
|
|
|
|
|
|
import android.view.MenuItem |
|
|
|
import android.view.View |
|
|
|
import android.view.View |
|
|
|
import androidx.preference.Preference |
|
|
|
import androidx.preference.Preference |
|
|
|
import androidx.preference.PreferenceFragmentCompat |
|
|
|
import androidx.preference.PreferenceFragmentCompat |
|
|
@ -20,7 +23,6 @@ import io.legado.app.lib.theme.ATH |
|
|
|
import io.legado.app.lib.theme.ColorUtils |
|
|
|
import io.legado.app.lib.theme.ColorUtils |
|
|
|
import io.legado.app.ui.widget.number.NumberPickerDialog |
|
|
|
import io.legado.app.ui.widget.number.NumberPickerDialog |
|
|
|
import io.legado.app.ui.widget.prefs.IconListPreference |
|
|
|
import io.legado.app.ui.widget.prefs.IconListPreference |
|
|
|
import io.legado.app.ui.widget.prefs.NameListPreference |
|
|
|
|
|
|
|
import io.legado.app.utils.* |
|
|
|
import io.legado.app.utils.* |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -35,18 +37,13 @@ class ThemeConfigFragment : PreferenceFragmentCompat(), SharedPreferences.OnShar |
|
|
|
preferenceScreen.removePreference(it) |
|
|
|
preferenceScreen.removePreference(it) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
findPreference<NameListPreference>(PreferKey.themeMode)?.let { |
|
|
|
|
|
|
|
it.setOnPreferenceChangeListener { _, _ -> |
|
|
|
|
|
|
|
view?.post { App.INSTANCE.applyDayNight() } |
|
|
|
|
|
|
|
true |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
upPreferenceSummary("barElevation", AppConfig.elevation.toString()) |
|
|
|
upPreferenceSummary("barElevation", AppConfig.elevation.toString()) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { |
|
|
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { |
|
|
|
super.onViewCreated(view, savedInstanceState) |
|
|
|
super.onViewCreated(view, savedInstanceState) |
|
|
|
ATH.applyEdgeEffectColor(listView) |
|
|
|
ATH.applyEdgeEffectColor(listView) |
|
|
|
|
|
|
|
setHasOptionsMenu(true) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
override fun onResume() { |
|
|
|
override fun onResume() { |
|
|
@ -59,6 +56,21 @@ class ThemeConfigFragment : PreferenceFragmentCompat(), SharedPreferences.OnShar |
|
|
|
super.onPause() |
|
|
|
super.onPause() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) { |
|
|
|
|
|
|
|
super.onCreateOptionsMenu(menu, inflater) |
|
|
|
|
|
|
|
inflater.inflate(R.menu.theme_config, menu) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
override fun onOptionsItemSelected(item: MenuItem): Boolean { |
|
|
|
|
|
|
|
when (item.itemId) { |
|
|
|
|
|
|
|
R.id.menu_theme_mode -> { |
|
|
|
|
|
|
|
AppConfig.isNightTheme = !AppConfig.isNightTheme |
|
|
|
|
|
|
|
App.INSTANCE.applyDayNight() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return super.onOptionsItemSelected(item) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences?, key: String?) { |
|
|
|
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences?, key: String?) { |
|
|
|
sharedPreferences ?: return |
|
|
|
sharedPreferences ?: return |
|
|
|
when (key) { |
|
|
|
when (key) { |
|
|
|