diff --git a/app/build.gradle b/app/build.gradle
index 126bc2244..2adc27bb0 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -81,8 +81,9 @@ dependencies {
//androidX
implementation 'androidx.core:core-ktx:1.2.0-alpha01'
implementation 'androidx.appcompat:appcompat:1.1.0-alpha05'
+ implementation 'androidx.preference:preference:1.1.0-alpha05'
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta1'
- implementation 'com.google.android.material:material:1.1.0-alpha06'
+ implementation 'com.google.android.material:material:1.1.0-alpha07'
//lifecycle
def lifecycle_version = '2.0.0'
@@ -121,4 +122,7 @@ dependencies {
//Glide
implementation 'com.github.bumptech.glide:glide:4.9.0'
+
+ //颜色选择
+ implementation 'com.jaredrummler:colorpicker:1.1.0'
}
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index cdaf66439..4663ae81d 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -41,6 +41,7 @@
+
\ No newline at end of file
diff --git a/app/src/main/java/io/legado/app/App.kt b/app/src/main/java/io/legado/app/App.kt
index 868748389..be31f9309 100644
--- a/app/src/main/java/io/legado/app/App.kt
+++ b/app/src/main/java/io/legado/app/App.kt
@@ -13,6 +13,7 @@ import io.legado.app.constant.AppConst.channelIdReadAloud
import io.legado.app.constant.AppConst.channelIdWeb
import io.legado.app.data.AppDatabase
import io.legado.app.lib.theme.ThemeStore
+import io.legado.app.utils.getCompatColor
import io.legado.app.utils.getPrefBoolean
import io.legado.app.utils.getPrefInt
import java.util.*
@@ -63,15 +64,15 @@ class App : Application() {
fun upThemeStore() {
if (getPrefBoolean("isNightTheme", false)) {
ThemeStore.editTheme(this)
- .primaryColor(getPrefInt("colorPrimaryNight", resources.getColor(R.color.md_grey_800)))
- .accentColor(getPrefInt("colorAccentNight", resources.getColor(R.color.md_pink_800)))
- .backgroundColor(getPrefInt("colorBackgroundNight", resources.getColor(R.color.md_grey_800)))
+ .primaryColor(getPrefInt("colorPrimaryNight", getCompatColor(R.color.colorPrimary)))
+ .accentColor(getPrefInt("colorAccentNight", getCompatColor(R.color.colorAccent)))
+ .backgroundColor(getPrefInt("colorBackgroundNight", getCompatColor(R.color.md_grey_800)))
.apply()
} else {
ThemeStore.editTheme(this)
- .primaryColor(getPrefInt("colorPrimary", resources.getColor(R.color.md_grey_100)))
- .accentColor(getPrefInt("colorAccent", resources.getColor(R.color.md_pink_600)))
- .backgroundColor(getPrefInt("colorBackground", resources.getColor(R.color.md_grey_100)))
+ .primaryColor(getPrefInt("colorPrimary", getCompatColor(R.color.colorPrimary)))
+ .accentColor(getPrefInt("colorAccent", getCompatColor(R.color.colorAccent)))
+ .backgroundColor(getPrefInt("colorBackground", getCompatColor(R.color.md_grey_100)))
.apply()
}
}
diff --git a/app/src/main/java/io/legado/app/base/BaseActivity.kt b/app/src/main/java/io/legado/app/base/BaseActivity.kt
index 87ec5121e..364327656 100644
--- a/app/src/main/java/io/legado/app/base/BaseActivity.kt
+++ b/app/src/main/java/io/legado/app/base/BaseActivity.kt
@@ -7,16 +7,11 @@ import android.view.MenuItem
import android.view.View
import android.view.WindowManager
import androidx.appcompat.app.AppCompatActivity
-import androidx.appcompat.view.menu.MenuBuilder
-import androidx.appcompat.view.menu.MenuItemImpl
-import androidx.core.view.forEach
import androidx.lifecycle.ViewModel
import io.legado.app.R
import io.legado.app.lib.theme.ColorUtils
-import io.legado.app.lib.theme.DrawableUtils
import io.legado.app.lib.theme.ThemeStore
-import io.legado.app.lib.theme.getPrimaryTextColor
-import io.legado.app.utils.getCompatColor
+import io.legado.app.utils.setIconColor
abstract class BaseActivity : AppCompatActivity() {
@@ -37,21 +32,8 @@ abstract class BaseActivity : AppCompatActivity() {
final override fun onCreateOptionsMenu(menu: Menu?): Boolean {
return menu?.let {
- if (it is MenuBuilder) {
- it.setOptionalIconsVisible(true)
- }
val bool = onCompatCreateOptionsMenu(it)
- val primaryTextColor = getPrimaryTextColor(ColorUtils.isColorLight(ThemeStore.primaryColor(this)))
- val defaultTextColor = getCompatColor(R.color.tv_text_default)
- menu.forEach { item ->
- (item as MenuItemImpl).let { impl ->
- //overflow:展开的item
- DrawableUtils.setTint(
- impl.icon,
- if (impl.requiresOverflow()) defaultTextColor else primaryTextColor
- )
- }
- }
+ it.setIconColor(this)
bool
} ?: super.onCreateOptionsMenu(menu)
}
diff --git a/app/src/main/java/io/legado/app/lib/theme/prefs/ATEPreferenceCategory.kt b/app/src/main/java/io/legado/app/lib/theme/prefs/ATEPreferenceCategory.kt
index 2029744ed..c2d39f3a7 100644
--- a/app/src/main/java/io/legado/app/lib/theme/prefs/ATEPreferenceCategory.kt
+++ b/app/src/main/java/io/legado/app/lib/theme/prefs/ATEPreferenceCategory.kt
@@ -2,11 +2,11 @@ package io.legado.app.lib.theme.prefs
import android.content.Context
import android.os.Build
-import android.preference.PreferenceCategory
import android.util.AttributeSet
-import android.view.View
import android.widget.TextView
import androidx.annotation.RequiresApi
+import androidx.preference.PreferenceCategory
+import androidx.preference.PreferenceViewHolder
import io.legado.app.lib.theme.ThemeStore
@@ -26,10 +26,13 @@ class ATEPreferenceCategory : PreferenceCategory {
constructor(context: Context) : super(context)
- override fun onBindView(view: View) {
- super.onBindView(view)
- if (view is TextView) {
- view.setTextColor(ThemeStore.accentColor(view.getContext()))//设置title文本的颜色
+ override fun onBindViewHolder(holder: PreferenceViewHolder?) {
+ super.onBindViewHolder(holder)
+ holder?.let {
+ val view = it.itemView
+ if (view is TextView) {
+ view.setTextColor(ThemeStore.accentColor(view.getContext()))//设置title文本的颜色
+ }
}
}
diff --git a/app/src/main/java/io/legado/app/lib/theme/prefs/ATESwitchPreference.kt b/app/src/main/java/io/legado/app/lib/theme/prefs/ATESwitchPreference.kt
index 8d3ca5f56..7c4b54ec8 100644
--- a/app/src/main/java/io/legado/app/lib/theme/prefs/ATESwitchPreference.kt
+++ b/app/src/main/java/io/legado/app/lib/theme/prefs/ATESwitchPreference.kt
@@ -2,17 +2,17 @@ package io.legado.app.lib.theme.prefs
import android.content.Context
import android.os.Build
-import android.preference.SwitchPreference
import android.util.AttributeSet
-import android.view.View
import android.view.ViewGroup
import android.widget.Switch
import androidx.annotation.RequiresApi
+import androidx.preference.PreferenceViewHolder
+import androidx.preference.SwitchPreferenceCompat
import io.legado.app.lib.theme.ATH
import io.legado.app.lib.theme.ThemeStore
import java.util.*
-class ATESwitchPreference : SwitchPreference {
+class ATESwitchPreference : SwitchPreferenceCompat {
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int, defStyleRes: Int) : super(
@@ -28,25 +28,26 @@ class ATESwitchPreference : SwitchPreference {
constructor(context: Context) : super(context)
- override fun onBindView(view: View) {
- super.onBindView(view)
-
- if (view is ViewGroup) {
- val queue = LinkedList()
- queue.add(view)
- while (!queue.isEmpty()) {
- val current = queue.removeFirst()
- for (i in 0 until current.childCount) {
- if (current.getChildAt(i) is Switch) {
- ATH.setTint(current.getChildAt(i), ThemeStore.accentColor(view.getContext()))
- return
- } else if (current.getChildAt(i) is ViewGroup) {
- queue.addLast(current.getChildAt(i) as ViewGroup)
+ override fun onBindViewHolder(holder: PreferenceViewHolder?) {
+ super.onBindViewHolder(holder)
+ holder?.let {
+ val view = it.itemView
+ if (view is ViewGroup) {
+ val queue = LinkedList()
+ queue.add(view)
+ while (!queue.isEmpty()) {
+ val current = queue.removeFirst()
+ for (i in 0 until current.childCount) {
+ if (current.getChildAt(i) is Switch) {
+ ATH.setTint(current.getChildAt(i), ThemeStore.accentColor(view.getContext()))
+ return
+ } else if (current.getChildAt(i) is ViewGroup) {
+ queue.addLast(current.getChildAt(i) as ViewGroup)
+ }
}
}
}
}
-
}
}
diff --git a/app/src/main/java/io/legado/app/ui/config/ConfigActivity.kt b/app/src/main/java/io/legado/app/ui/config/ConfigActivity.kt
new file mode 100644
index 000000000..d4fc7734e
--- /dev/null
+++ b/app/src/main/java/io/legado/app/ui/config/ConfigActivity.kt
@@ -0,0 +1,36 @@
+package io.legado.app.ui.config
+
+import android.os.Bundle
+import io.legado.app.R
+import io.legado.app.base.BaseActivity
+import io.legado.app.utils.getViewModel
+import kotlinx.android.synthetic.main.activity_config.*
+import kotlinx.android.synthetic.main.view_titlebar.*
+
+class ConfigActivity : BaseActivity() {
+ override val viewModel: ConfigViewModel
+ get() = getViewModel(ConfigViewModel::class.java)
+ override val layoutID: Int
+ get() = R.layout.activity_config
+
+ override fun onViewModelCreated(viewModel: ConfigViewModel, savedInstanceState: Bundle?) {
+ intent.getIntExtra("configType", -1).let {
+ if (it != -1) viewModel.configType = it
+ }
+ this.setSupportActionBar(toolbar)
+
+ when (viewModel.configType) {
+ ConfigViewModel.TYPE_CONFIG -> {
+ title_bar.title = "设置"
+ supportFragmentManager.beginTransaction().replace(R.id.configFrameLayout, ConfigFragment()).commit()
+ }
+ ConfigViewModel.TYPE_THEME_CONFIG -> {
+ title_bar.title = "主题设置"
+ supportFragmentManager.beginTransaction().replace(R.id.configFrameLayout, ThemeConfigFragment())
+ .commit()
+ }
+ }
+
+ }
+
+}
\ No newline at end of file
diff --git a/app/src/main/java/io/legado/app/ui/config/ConfigFragment.kt b/app/src/main/java/io/legado/app/ui/config/ConfigFragment.kt
new file mode 100644
index 000000000..42cecb541
--- /dev/null
+++ b/app/src/main/java/io/legado/app/ui/config/ConfigFragment.kt
@@ -0,0 +1,15 @@
+package io.legado.app.ui.config
+
+import android.os.Bundle
+import androidx.preference.PreferenceFragmentCompat
+import io.legado.app.R
+
+
+class ConfigFragment : PreferenceFragmentCompat() {
+
+ override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
+ addPreferencesFromResource(R.xml.pref_config)
+ }
+
+
+}
\ No newline at end of file
diff --git a/app/src/main/java/io/legado/app/ui/config/ConfigViewModel.kt b/app/src/main/java/io/legado/app/ui/config/ConfigViewModel.kt
new file mode 100644
index 000000000..b9a085099
--- /dev/null
+++ b/app/src/main/java/io/legado/app/ui/config/ConfigViewModel.kt
@@ -0,0 +1,14 @@
+package io.legado.app.ui.config
+
+import android.app.Application
+import androidx.lifecycle.AndroidViewModel
+
+class ConfigViewModel(application: Application) : AndroidViewModel(application) {
+ companion object {
+ val TYPE_CONFIG = 0
+ val TYPE_THEME_CONFIG = 1
+ }
+
+ var configType: Int = TYPE_CONFIG
+
+}
\ No newline at end of file
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
new file mode 100644
index 000000000..a6a2b451c
--- /dev/null
+++ b/app/src/main/java/io/legado/app/ui/config/ThemeConfigFragment.kt
@@ -0,0 +1,86 @@
+package io.legado.app.ui.config
+
+import android.content.SharedPreferences
+import android.os.Bundle
+import androidx.appcompat.app.AlertDialog
+import androidx.preference.PreferenceFragmentCompat
+import io.legado.app.App
+import io.legado.app.R
+import io.legado.app.lib.theme.ColorUtils
+import io.legado.app.utils.getCompatColor
+import io.legado.app.utils.getPrefBoolean
+import io.legado.app.utils.putPrefInt
+import io.legado.app.utils.upTint
+
+
+class ThemeConfigFragment : PreferenceFragmentCompat(), SharedPreferences.OnSharedPreferenceChangeListener {
+
+ override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
+ addPreferencesFromResource(R.xml.pref_config_theme)
+ }
+
+ override fun onResume() {
+ super.onResume()
+ preferenceManager.sharedPreferences.registerOnSharedPreferenceChangeListener(this)
+ }
+
+ override fun onPause() {
+ preferenceManager.sharedPreferences.unregisterOnSharedPreferenceChangeListener(this)
+ super.onPause()
+ }
+
+ override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences?, key: String?) {
+ sharedPreferences ?: return
+ when (key) {
+ "colorPrimary", "colorAccent", "colorBackground" -> if (!ColorUtils.isColorLight(
+ sharedPreferences.getInt(
+ "colorBackground",
+ App.INSTANCE.getCompatColor(R.color.md_grey_100)
+ )
+ )
+ ) {
+ AlertDialog.Builder(App.INSTANCE)
+ .setTitle("白天背景太暗")
+ .setMessage("将会恢复默认背景?")
+ .setPositiveButton(R.string.ok) { dialog, which ->
+ App.INSTANCE.putPrefInt("colorBackground", App.INSTANCE.getCompatColor(R.color.md_grey_100))
+ upTheme(false)
+ }
+ .setNegativeButton(R.string.cancel) { dialogInterface, i -> upTheme(false) }
+ .show().upTint
+ } else {
+ upTheme(false)
+ }
+ "colorPrimaryNight", "colorAccentNight", "colorBackgroundNight" -> if (ColorUtils.isColorLight(
+ sharedPreferences.getInt(
+ "colorBackgroundNight",
+ App.INSTANCE.getCompatColor(R.color.md_grey_800)
+ )
+ )
+ ) {
+ AlertDialog.Builder(App.INSTANCE)
+ .setTitle("夜间背景太亮")
+ .setMessage("将会恢复默认背景?")
+ .setPositiveButton(R.string.ok) { dialog, which ->
+ App.INSTANCE.putPrefInt(
+ "colorBackgroundNight",
+ App.INSTANCE.getCompatColor(R.color.md_grey_800)
+ )
+ upTheme(true)
+ }
+ .setNegativeButton(R.string.cancel) { dialogInterface, i -> upTheme(true) }
+ .show()
+ } else {
+ upTheme(true)
+ }
+ }
+
+ }
+
+ private fun upTheme(isNightTheme: Boolean) {
+ if (App.INSTANCE.getPrefBoolean("isNightTheme", false) == isNightTheme) {
+ App.INSTANCE.upThemeStore()
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfFragment.kt b/app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfFragment.kt
index 7d3d21755..fa5963220 100644
--- a/app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfFragment.kt
+++ b/app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfFragment.kt
@@ -6,7 +6,9 @@ import android.view.MenuItem
import android.view.View
import androidx.appcompat.widget.Toolbar
import androidx.fragment.app.Fragment
+import io.legado.app.App
import io.legado.app.R
+import io.legado.app.utils.setIconColor
import kotlinx.android.synthetic.main.view_titlebar.*
class BookshelfFragment : Fragment(R.layout.fragment_bookshelf), Toolbar.OnMenuItemClickListener {
@@ -15,6 +17,7 @@ class BookshelfFragment : Fragment(R.layout.fragment_bookshelf), Toolbar.OnMenuI
super.onViewCreated(view, savedInstanceState)
Log.e("TAG", "BookshelfFragment")
toolbar.inflateMenu(R.menu.bookshelf)
+ toolbar.menu.setIconColor(App.INSTANCE)
toolbar.setOnMenuItemClickListener(this)
}
diff --git a/app/src/main/java/io/legado/app/ui/main/booksource/BookSourceFragment.kt b/app/src/main/java/io/legado/app/ui/main/booksource/BookSourceFragment.kt
index 7e00b19c9..e20872cd6 100644
--- a/app/src/main/java/io/legado/app/ui/main/booksource/BookSourceFragment.kt
+++ b/app/src/main/java/io/legado/app/ui/main/booksource/BookSourceFragment.kt
@@ -6,7 +6,9 @@ import android.view.MenuItem
import android.view.View
import androidx.appcompat.widget.Toolbar
import androidx.fragment.app.Fragment
+import io.legado.app.App
import io.legado.app.R
+import io.legado.app.utils.setIconColor
import kotlinx.android.synthetic.main.view_titlebar.*
class BookSourceFragment : Fragment(R.layout.fragment_book_source), Toolbar.OnMenuItemClickListener {
@@ -15,6 +17,7 @@ class BookSourceFragment : Fragment(R.layout.fragment_book_source), Toolbar.OnMe
super.onViewCreated(view, savedInstanceState)
Log.e("TAG", "BookSourceFragment")
toolbar.inflateMenu(R.menu.book_source)
+ toolbar.menu.setIconColor(App.INSTANCE)
toolbar.setOnMenuItemClickListener(this)
}
diff --git a/app/src/main/java/io/legado/app/ui/main/findbook/FindBookFragment.kt b/app/src/main/java/io/legado/app/ui/main/findbook/FindBookFragment.kt
index 3650f62f9..8a9da36b5 100644
--- a/app/src/main/java/io/legado/app/ui/main/findbook/FindBookFragment.kt
+++ b/app/src/main/java/io/legado/app/ui/main/findbook/FindBookFragment.kt
@@ -6,7 +6,9 @@ import android.view.MenuItem
import android.view.View
import androidx.appcompat.widget.Toolbar
import androidx.fragment.app.Fragment
+import io.legado.app.App
import io.legado.app.R
+import io.legado.app.utils.setIconColor
import kotlinx.android.synthetic.main.view_titlebar.*
class FindBookFragment : Fragment(R.layout.fragment_find_book), Toolbar.OnMenuItemClickListener {
@@ -15,6 +17,7 @@ class FindBookFragment : Fragment(R.layout.fragment_find_book), Toolbar.OnMenuIt
super.onViewCreated(view, savedInstanceState)
Log.e("TAG", "FindBookFragment")
toolbar.inflateMenu(R.menu.find_book)
+ toolbar.menu.setIconColor(App.INSTANCE)
toolbar.setOnMenuItemClickListener(this)
}
diff --git a/app/src/main/java/io/legado/app/ui/main/myconfig/MyConfigFragment.kt b/app/src/main/java/io/legado/app/ui/main/myconfig/MyConfigFragment.kt
index 2d431297d..b7d27e01c 100644
--- a/app/src/main/java/io/legado/app/ui/main/myconfig/MyConfigFragment.kt
+++ b/app/src/main/java/io/legado/app/ui/main/myconfig/MyConfigFragment.kt
@@ -1,20 +1,18 @@
package io.legado.app.ui.main.myconfig
+import android.content.Intent
import android.os.Bundle
import android.util.Log
import android.view.MenuItem
import android.view.View
-import androidx.appcompat.view.menu.MenuBuilder
-import androidx.appcompat.view.menu.MenuItemImpl
import androidx.appcompat.widget.Toolbar
-import androidx.core.view.forEach
import androidx.fragment.app.Fragment
+import io.legado.app.App
import io.legado.app.R
-import io.legado.app.lib.theme.ColorUtils
-import io.legado.app.lib.theme.DrawableUtils
-import io.legado.app.lib.theme.ThemeStore
-import io.legado.app.lib.theme.getPrimaryTextColor
-import io.legado.app.utils.getCompatColor
+import io.legado.app.ui.config.ConfigActivity
+import io.legado.app.ui.config.ConfigViewModel
+import io.legado.app.utils.setIconColor
+import kotlinx.android.synthetic.main.fragment_my_config.*
import kotlinx.android.synthetic.main.view_titlebar.*
class MyConfigFragment : Fragment(R.layout.fragment_my_config), Toolbar.OnMenuItemClickListener {
@@ -23,25 +21,13 @@ class MyConfigFragment : Fragment(R.layout.fragment_my_config), Toolbar.OnMenuIt
super.onViewCreated(view, savedInstanceState)
Log.e("TAG", "MyConfigFragment")
toolbar.inflateMenu(R.menu.my_config)
- toolbar.menu?.let {
- if (it is MenuBuilder) {
- it.setOptionalIconsVisible(true)
- }
- context?.let { context ->
- val primaryTextColor = getPrimaryTextColor(ColorUtils.isColorLight(ThemeStore.primaryColor(context)))
- val defaultTextColor = getCompatColor(R.color.tv_text_default)
- it.forEach { item ->
- (item as MenuItemImpl).let { impl ->
- //overflow:展开的item
- DrawableUtils.setTint(
- impl.icon,
- if (impl.requiresOverflow()) defaultTextColor else primaryTextColor
- )
- }
- }
- }
- }
+ toolbar.menu.setIconColor(App.INSTANCE)
toolbar.setOnMenuItemClickListener(this)
+ tv_theme_config.setOnClickListener {
+ val intent = Intent(context, ConfigActivity::class.java)
+ intent.putExtra("configType", ConfigViewModel.TYPE_THEME_CONFIG)
+ startActivity(intent)
+ }
}
override fun onMenuItemClick(item: MenuItem?): Boolean {
diff --git a/app/src/main/java/io/legado/app/ui/widget/TitleBar.kt b/app/src/main/java/io/legado/app/ui/widget/TitleBar.kt
index 01597a940..b3af419e3 100644
--- a/app/src/main/java/io/legado/app/ui/widget/TitleBar.kt
+++ b/app/src/main/java/io/legado/app/ui/widget/TitleBar.kt
@@ -14,6 +14,7 @@ import androidx.appcompat.widget.Toolbar
import androidx.core.graphics.drawable.DrawableCompat
import com.google.android.material.appbar.AppBarLayout
import io.legado.app.R
+import io.legado.app.lib.theme.ThemeStore
import io.legado.app.utils.getStatusBarHeight
import org.jetbrains.anko.bottomPadding
import org.jetbrains.anko.topPadding
@@ -40,6 +41,7 @@ class TitleBar(context: Context, attrs: AttributeSet?) : AppBarLayout(context, a
init {
inflate(context, R.layout.view_titlebar, this)
+ setBackgroundColor(ThemeStore.primaryColor(context))
toolbar = findViewById(R.id.toolbar)
val a = context.obtainStyledAttributes(
attrs, R.styleable.TitleBar,
diff --git a/app/src/main/java/io/legado/app/utils/MenuExtensions.kt b/app/src/main/java/io/legado/app/utils/MenuExtensions.kt
index 656da42d1..cb5f85d20 100644
--- a/app/src/main/java/io/legado/app/utils/MenuExtensions.kt
+++ b/app/src/main/java/io/legado/app/utils/MenuExtensions.kt
@@ -1,2 +1,30 @@
package io.legado.app.utils
+import android.content.Context
+import android.view.Menu
+import androidx.appcompat.view.menu.MenuBuilder
+import androidx.appcompat.view.menu.MenuItemImpl
+import androidx.core.view.forEach
+import io.legado.app.R
+import io.legado.app.lib.theme.ColorUtils
+import io.legado.app.lib.theme.DrawableUtils
+import io.legado.app.lib.theme.ThemeStore
+import io.legado.app.lib.theme.getPrimaryTextColor
+
+fun Menu.setIconColor(context: Context): Menu = this.let { menu ->
+ if (menu is MenuBuilder) {
+ menu.setOptionalIconsVisible(true)
+ }
+ val primaryTextColor = context.getPrimaryTextColor(ColorUtils.isColorLight(ThemeStore.primaryColor(context)))
+ val defaultTextColor = context.getCompatColor(R.color.tv_text_default)
+ menu.forEach { item ->
+ (item as MenuItemImpl).let { impl ->
+ //overflow:展开的item
+ DrawableUtils.setTint(
+ impl.icon,
+ if (impl.requiresOverflow()) defaultTextColor else primaryTextColor
+ )
+ }
+ }
+ return menu
+}
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_config.xml b/app/src/main/res/layout/activity_config.xml
new file mode 100644
index 000000000..70d5ad0f7
--- /dev/null
+++ b/app/src/main/res/layout/activity_config.xml
@@ -0,0 +1,21 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_search.xml b/app/src/main/res/layout/activity_search.xml
index c09d5b9e7..33b3b9ddb 100644
--- a/app/src/main/res/layout/activity_search.xml
+++ b/app/src/main/res/layout/activity_search.xml
@@ -10,7 +10,6 @@
android:id="@+id/title_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:fitsSystemWindows="true"
app:layout_constraintTop_toTopOf="parent"
app:title="搜索"/>
diff --git a/app/src/main/res/layout/fragment_my_config.xml b/app/src/main/res/layout/fragment_my_config.xml
index 5ef6b80c9..5f568b619 100644
--- a/app/src/main/res/layout/fragment_my_config.xml
+++ b/app/src/main/res/layout/fragment_my_config.xml
@@ -13,5 +13,18 @@
app:layout_constraintTop_toTopOf="parent"
app:title="我的"/>
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/xml/pref_config.xml b/app/src/main/res/xml/pref_config.xml
new file mode 100644
index 000000000..5d498d953
--- /dev/null
+++ b/app/src/main/res/xml/pref_config.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/xml/pref_config_theme.xml b/app/src/main/res/xml/pref_config_theme.xml
new file mode 100644
index 000000000..a6ce80b0e
--- /dev/null
+++ b/app/src/main/res/xml/pref_config_theme.xml
@@ -0,0 +1,101 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file