diff --git a/app/src/main/java/io/legado/app/App.kt b/app/src/main/java/io/legado/app/App.kt index 37dd40e25..1b757bde7 100644 --- a/app/src/main/java/io/legado/app/App.kt +++ b/app/src/main/java/io/legado/app/App.kt @@ -70,22 +70,22 @@ class App : Application() { if (isNightTheme) { ThemeStore.editTheme(this) .primaryColor( - getPrefInt("colorPrimaryNight", getCompatColor(R.color.md_grey_900)) + getPrefInt("colorPrimaryNight", getCompatColor(R.color.shine_color)) ) .accentColor( - getPrefInt("colorAccentNight", getCompatColor(R.color.md_deep_orange_800)) + getPrefInt("colorAccentNight", getCompatColor(R.color.lightBlue_color)) ) .backgroundColor( - getPrefInt("colorBackgroundNight", getCompatColor(R.color.md_black_1000)) + getPrefInt("colorBackgroundNight", getCompatColor(R.color.shine_color)) ) .apply() } else { ThemeStore.editTheme(this) .primaryColor( - getPrefInt("colorPrimary", getCompatColor(R.color.md_light_blue_500)) + getPrefInt("colorPrimary", getCompatColor(R.color.md_grey_100)) ) .accentColor( - getPrefInt("colorAccent", getCompatColor(R.color.md_pink_800)) + getPrefInt("colorAccent", getCompatColor(R.color.lightBlue_color)) ) .backgroundColor( getPrefInt("colorBackground", getCompatColor(R.color.md_grey_100)) diff --git a/app/src/main/java/io/legado/app/lib/theme/ATH.kt b/app/src/main/java/io/legado/app/lib/theme/ATH.kt index 52dfb5431..57c7c8403 100644 --- a/app/src/main/java/io/legado/app/lib/theme/ATH.kt +++ b/app/src/main/java/io/legado/app/lib/theme/ATH.kt @@ -206,6 +206,10 @@ object ATH { .setSelectedColor(ThemeStore.accentColor(bottom_navigation_view.context)).create() itemIconTintList = colorStateList itemTextColor = colorStateList + itemBackgroundResource = when(context.isNightTheme) { + true -> R.drawable.item_bg_dark + false -> R.drawable.item_bg_light + } } } diff --git a/app/src/main/java/io/legado/app/ui/config/ThemeConfigFragment.kt b/app/src/main/java/io/legado/app/ui/config/ThemeConfigFragment.kt index a47fb4360..6c87ff0af 100644 --- a/app/src/main/java/io/legado/app/ui/config/ThemeConfigFragment.kt +++ b/app/src/main/java/io/legado/app/ui/config/ThemeConfigFragment.kt @@ -20,8 +20,12 @@ import io.legado.app.utils.* class ThemeConfigFragment : PreferenceFragmentCompat(), SharedPreferences.OnSharedPreferenceChangeListener { + val items = arrayOf("极简","曜夜","经典") + override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) { addPreferencesFromResource(R.xml.pref_config_theme) + + findPreference("defaultTheme")?.summary = "${items[getPrefInt("default_theme", 0)]}" } override fun onViewCreated(view: View, savedInstanceState: Bundle?) { @@ -96,23 +100,34 @@ class ThemeConfigFragment : PreferenceFragmentCompat(), SharedPreferences.OnShar "defaultTheme" -> { activity?.let { AlertDialog.Builder(it) - .setTitle("恢复默认主题") - .setMessage("是否确认恢复?") - .setPositiveButton(R.string.ok) { _, _ -> - preferenceManager.sharedPreferences.edit() - // light mode - .putInt("colorPrimary", getCompatColor(R.color.md_light_blue_500)) - .putInt("colorAccent", getCompatColor(R.color.md_pink_800)) - .putInt("colorBackground", getCompatColor(R.color.md_grey_100)) - // dark mode - .putInt("colorPrimaryNight", getCompatColor(R.color.md_grey_900)) - .putInt("colorAccentNight", getCompatColor(R.color.md_deep_orange_800)) - .putInt("colorBackgroundNight", getCompatColor(R.color.md_black_1000)) - .apply() - App.INSTANCE.applyTheme() + .setTitle("切换默认主题") + .setItems(items){ + _,which -> + preference.summary = "${items[which]}" + putPrefInt("default_theme", which) + when (which) { + 0 -> { + putPrefInt("colorPrimary", getCompatColor(R.color.md_grey_100)) + putPrefInt("colorAccent", getCompatColor(R.color.lightBlue_color)) + putPrefInt("colorBackground", getCompatColor(R.color.md_grey_100)) + putPrefBoolean("isNightTheme", false) + } + 1 -> { + putPrefInt("colorPrimaryNight", getCompatColor(R.color.shine_color)) + putPrefInt("colorAccentNight", getCompatColor(R.color.lightBlue_color)) + putPrefInt("colorBackgroundNight", getCompatColor(R.color.shine_color)) + putPrefBoolean("isNightTheme", true) + } + 2 -> { + putPrefInt("colorPrimary", getCompatColor(R.color.md_light_blue_500)) + putPrefInt("colorAccent", getCompatColor(R.color.md_pink_800)) + putPrefInt("colorBackground", getCompatColor(R.color.md_grey_100)) + putPrefBoolean("isNightTheme", false) + } + } + App.INSTANCE.applyDayNight() recreateActivities() } - .setNegativeButton(R.string.cancel, null) .show().applyTint() } } diff --git a/app/src/main/res/drawable/item_bg_dark.xml b/app/src/main/res/drawable/item_bg_dark.xml new file mode 100644 index 000000000..054b06f9a --- /dev/null +++ b/app/src/main/res/drawable/item_bg_dark.xml @@ -0,0 +1,3 @@ + + \ No newline at end of file diff --git a/app/src/main/res/drawable/item_bg_light.xml b/app/src/main/res/drawable/item_bg_light.xml new file mode 100644 index 000000000..ef3428fe4 --- /dev/null +++ b/app/src/main/res/drawable/item_bg_light.xml @@ -0,0 +1,3 @@ + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index a124291b5..6b4eb4487 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -6,8 +6,6 @@ @color/md_pink_800 #66666666 + #FF578FCC + #FF212227 + #FF272731 + #eb4333 #439b53 diff --git a/app/src/main/res/xml/pref_main.xml b/app/src/main/res/xml/pref_main.xml index 6deeed4de..abe6e9b08 100644 --- a/app/src/main/res/xml/pref_main.xml +++ b/app/src/main/res/xml/pref_main.xml @@ -12,12 +12,6 @@ android:title="@string/replace_purify" app:iconSpaceReserved="false" /> - -