优化主题色选择

pull/300/head
gedoor 4 years ago
parent 64853b5f02
commit c5bf741249
  1. 20
      app/src/main/java/io/legado/app/ui/config/ThemeConfigFragment.kt
  2. 9
      app/src/main/res/values-zh-rHK/arrays.xml
  3. 7
      app/src/main/res/values-zh-rHK/strings.xml
  4. 9
      app/src/main/res/values-zh-rTW/arrays.xml
  5. 7
      app/src/main/res/values-zh-rTW/strings.xml
  6. 8
      app/src/main/res/values-zh/arrays.xml
  7. 7
      app/src/main/res/values-zh/strings.xml
  8. 12
      app/src/main/res/values/arrays.xml
  9. 7
      app/src/main/res/values/strings.xml

@ -28,7 +28,7 @@ import io.legado.app.utils.*
class ThemeConfigFragment : BasePreferenceFragment(),
SharedPreferences.OnSharedPreferenceChangeListener {
val items = arrayListOf("极简", "曜夜", "经典", "黑白", "A屏黑")
val items = App.INSTANCE.resources.getStringArray(R.array.default_themes).toList()
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
addPreferencesFromResource(R.xml.pref_config_theme)
@ -41,7 +41,7 @@ class ThemeConfigFragment : BasePreferenceFragment(),
findPreference<ColorPreference>(PreferKey.cBackground)?.let {
it.onSaveColor = { color ->
if (!ColorUtils.isColorLight(color)) {
toast("白天背景不能太暗")
toast(R.string.day_background_too_dark)
true
} else {
false
@ -51,7 +51,7 @@ class ThemeConfigFragment : BasePreferenceFragment(),
findPreference<ColorPreference>(PreferKey.cBBackground)?.let {
it.onSaveColor = { color ->
if (!ColorUtils.isColorLight(color)) {
toast("白天底栏不能太暗")
toast(R.string.day_bottom_bar_too_dark)
true
} else {
false
@ -61,7 +61,7 @@ class ThemeConfigFragment : BasePreferenceFragment(),
findPreference<ColorPreference>(PreferKey.cNBackground)?.let {
it.onSaveColor = { color ->
if (ColorUtils.isColorLight(color)) {
toast("夜间背景不能太亮")
toast(R.string.night_background_too_light)
true
} else {
false
@ -71,7 +71,7 @@ class ThemeConfigFragment : BasePreferenceFragment(),
findPreference<ColorPreference>(PreferKey.cNBBackground)?.let {
it.onSaveColor = { color ->
if (ColorUtils.isColorLight(color)) {
toast("夜间底栏不能太亮")
toast(R.string.night_bottom_bar_too_light)
true
} else {
false
@ -85,11 +85,11 @@ class ThemeConfigFragment : BasePreferenceFragment(),
val textColor = getCompatColor(R.color.tv_text_default)
when {
ColorUtils.getColorDifference(color, background) <= 60 -> {
toast("强调色不能和背景颜色相似")
toast(R.string.accent_background_diff)
true
}
ColorUtils.getColorDifference(color, textColor) <= 60 -> {
toast("强调色不能和文字颜色相似")
toast(R.string.accent_text_diff)
true
}
else -> false
@ -103,11 +103,11 @@ class ThemeConfigFragment : BasePreferenceFragment(),
val textColor = getCompatColor(R.color.tv_text_default)
when {
ColorUtils.getColorDifference(color, background) <= 60 -> {
toast("强调色不能和背景颜色相似")
toast(R.string.accent_background_diff)
true
}
ColorUtils.getColorDifference(color, textColor) <= 60 -> {
toast("强调色不能和文字颜色相似")
toast(R.string.accent_text_diff)
true
}
else -> false
@ -191,7 +191,7 @@ class ThemeConfigFragment : BasePreferenceFragment(),
}
private fun changeTheme() {
alert(title = "切换默认主题") {
alert(title = getString(R.string.select_theme)) {
items(items) { _, which ->
when (which) {
0 -> {

@ -55,4 +55,13 @@
<item>粗體</item>
<item>細體</item>
</string-array>
<string-array name="default_themes">
<item>极简</item>
<item>曜夜</item>
<item>经典</item>
<item>黑白</item>
<item>A屏黑</item>
</string-array>
</resources>

@ -732,4 +732,11 @@
<string name="replace_enable_default_t">默认启用替换净化</string>
<string name="replace_enable_default_s">新加入书架的书是否启用替换净化</string>
<string name="select_restore_file">选择恢复文件</string>
<string name="select_theme">切换默认主题</string>
<string name="day_background_too_dark">白天背景不能太暗</string>
<string name="day_bottom_bar_too_dark">白天底栏不能太暗</string>
<string name="night_background_too_light">夜间背景不能太亮</string>
<string name="night_bottom_bar_too_light">夜间底栏不能太亮</string>
<string name="accent_background_diff">强调色不能和背景颜色相似</string>
<string name="accent_text_diff">强调色不能和文字颜色相似</string>
</resources>

@ -112,4 +112,13 @@
<item>粗體</item>
<item>細體</item>
</string-array>
<string-array name="default_themes">
<item>极简</item>
<item>曜夜</item>
<item>经典</item>
<item>黑白</item>
<item>A屏黑</item>
</string-array>
</resources>

@ -732,5 +732,12 @@
<string name="replace_enable_default_t">默认启用替换净化</string>
<string name="replace_enable_default_s">新加入书架的书是否启用替换净化</string>
<string name="select_restore_file">选择恢复文件</string>
<string name="select_theme">切换默认主题</string>
<string name="day_background_too_dark">白天背景不能太暗</string>
<string name="day_bottom_bar_too_dark">白天底栏不能太暗</string>
<string name="night_background_too_light">夜间背景不能太亮</string>
<string name="night_bottom_bar_too_light">夜间底栏不能太亮</string>
<string name="accent_background_diff">强调色不能和背景颜色相似</string>
<string name="accent_text_diff">强调色不能和文字颜色相似</string>
</resources>

@ -113,4 +113,12 @@
<item>细体</item>
</string-array>
<string-array name="default_themes">
<item>极简</item>
<item>曜夜</item>
<item>经典</item>
<item>黑白</item>
<item>A屏黑</item>
</string-array>
</resources>

@ -732,4 +732,11 @@
<string name="replace_enable_default_t">默认启用替换净化</string>
<string name="replace_enable_default_s">新加入书架的书是否启用替换净化</string>
<string name="select_restore_file">选择恢复文件</string>
<string name="select_theme">切换默认主题</string>
<string name="day_background_too_dark">白天背景不能太暗</string>
<string name="day_bottom_bar_too_dark">白天底栏不能太暗</string>
<string name="night_background_too_light">夜间背景不能太亮</string>
<string name="night_bottom_bar_too_light">夜间底栏不能太亮</string>
<string name="accent_background_diff">强调色不能和背景颜色相似</string>
<string name="accent_text_diff">强调色不能和文字颜色相似</string>
</resources>

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<resources>
<string-array name="book_type">
<item>@string/book_type_text</item>
<item>@string/book_type_audio</item>
@ -113,4 +113,12 @@
<item>Light</item>
</string-array>
</resources>
<string-array name="default_themes">
<item>极简</item>
<item>曜夜</item>
<item>经典</item>
<item>黑白</item>
<item>A屏黑</item>
</string-array>
</resources>

@ -733,5 +733,12 @@
<string name="replace_enable_default_t">默认启用替换净化</string>
<string name="replace_enable_default_s">新加入书架的书是否启用替换净化</string>
<string name="select_restore_file">选择恢复文件</string>
<string name="select_theme">切换默认主题</string>
<string name="day_background_too_dark">白天背景不能太暗</string>
<string name="day_bottom_bar_too_dark">白天底栏不能太暗</string>
<string name="night_background_too_light">夜间背景不能太亮</string>
<string name="night_bottom_bar_too_light">夜间底栏不能太亮</string>
<string name="accent_background_diff">强调色不能和背景颜色相似</string>
<string name="accent_text_diff">强调色不能和文字颜色相似</string>
</resources>
Loading…
Cancel
Save