添加背景透明度调节

pull/1560/head^2
kunfei 3 years ago
parent f917f77dde
commit e3f75f60d3
  1. 9
      app/src/main/java/io/legado/app/help/ReadBookConfig.kt
  2. 1
      app/src/main/java/io/legado/app/lib/theme/ThemeUtils.kt
  3. 1
      app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt
  4. 13
      app/src/main/java/io/legado/app/ui/book/read/config/BgTextConfigDialog.kt
  5. 7
      app/src/main/java/io/legado/app/ui/book/read/page/PageView.kt
  6. 8
      app/src/main/java/io/legado/app/ui/book/read/page/ReadView.kt
  7. 28
      app/src/main/res/layout/dialog_read_bg_text.xml
  8. 7
      app/src/main/res/layout/view_book_page.xml
  9. 1
      app/src/main/res/values-es-rES/strings.xml
  10. 1
      app/src/main/res/values-ja-rJP/strings.xml
  11. 3
      app/src/main/res/values-pt-rBR/strings.xml
  12. 1
      app/src/main/res/values-zh-rHK/strings.xml
  13. 1
      app/src/main/res/values-zh-rTW/strings.xml
  14. 1
      app/src/main/res/values-zh/strings.xml
  15. 3
      app/src/main/res/values/strings.xml

@ -163,6 +163,12 @@ object ReadBookConfig {
val config get() = if (shareLayout) shareConfig else durConfig val config get() = if (shareLayout) shareConfig else durConfig
var bgAlpha: Int
get() = config.bgAlpha
set(value) {
config.bgAlpha = value
}
var pageAnim: Int var pageAnim: Int
get() = config.curPageAnim() get() = config.curPageAnim()
set(value) { set(value) {
@ -419,7 +425,8 @@ object ReadBookConfig {
var name: String = "", var name: String = "",
var bgStr: String = "#EEEEEE",//白天背景 var bgStr: String = "#EEEEEE",//白天背景
var bgStrNight: String = "#000000",//夜间背景 var bgStrNight: String = "#000000",//夜间背景
var bgStrEInk: String = "#FFFFFF", var bgStrEInk: String = "#FFFFFF",//EInk背景
var bgAlpha: Int = 100,//背景透明度
var bgType: Int = 0,//白天背景类型 0:颜色, 1:assets图片, 2其它图片 var bgType: Int = 0,//白天背景类型 0:颜色, 1:assets图片, 2其它图片
var bgTypeNight: Int = 0,//夜间背景类型 var bgTypeNight: Int = 0,//夜间背景类型
var bgTypeEInk: Int = 0, var bgTypeEInk: Int = 0,

@ -33,7 +33,6 @@ object ThemeUtils {
} }
} }
@JvmOverloads
fun resolveDrawable(context: Context, @AttrRes attr: Int): Drawable? { fun resolveDrawable(context: Context, @AttrRes attr: Int): Drawable? {
val a = context.theme.obtainStyledAttributes(intArrayOf(attr)) val a = context.theme.obtainStyledAttributes(intArrayOf(attr))
return try { return try {

@ -1005,6 +1005,7 @@ class ReadBookActivity : BaseReadBookActivity(),
upSystemUiVisibility() upSystemUiVisibility()
readView.upBg() readView.upBg()
readView.upStyle() readView.upStyle()
readView.upBgAlpha()
if (it) { if (it) {
ReadBook.loadContent(resetPageOffset = false) ReadBook.loadContent(resetPageOffset = false)
} else { } else {

@ -9,6 +9,7 @@ import android.view.Gravity
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.view.WindowManager import android.view.WindowManager
import android.widget.SeekBar
import androidx.documentfile.provider.DocumentFile import androidx.documentfile.provider.DocumentFile
import com.jaredrummler.android.colorpicker.ColorPickerDialog import com.jaredrummler.android.colorpicker.ColorPickerDialog
import io.legado.app.R import io.legado.app.R
@ -29,6 +30,7 @@ import io.legado.app.lib.theme.getPrimaryTextColor
import io.legado.app.lib.theme.getSecondaryTextColor import io.legado.app.lib.theme.getSecondaryTextColor
import io.legado.app.ui.book.read.ReadBookActivity import io.legado.app.ui.book.read.ReadBookActivity
import io.legado.app.ui.document.HandleFileContract import io.legado.app.ui.document.HandleFileContract
import io.legado.app.ui.widget.seekbar.SeekBarChangeListener
import io.legado.app.utils.* import io.legado.app.utils.*
import io.legado.app.utils.viewbindingdelegate.viewBinding import io.legado.app.utils.viewbindingdelegate.viewBinding
import timber.log.Timber import timber.log.Timber
@ -108,6 +110,7 @@ class BgTextConfigDialog : BaseDialogFragment(R.layout.dialog_read_bg_text) {
ivImport.setColorFilter(primaryTextColor) ivImport.setColorFilter(primaryTextColor)
ivExport.setColorFilter(primaryTextColor) ivExport.setColorFilter(primaryTextColor)
ivDelete.setColorFilter(primaryTextColor) ivDelete.setColorFilter(primaryTextColor)
tvBgAlpha.setTextColor(primaryTextColor)
tvBgImage.setTextColor(primaryTextColor) tvBgImage.setTextColor(primaryTextColor)
recyclerView.adapter = adapter recyclerView.adapter = adapter
adapter.addHeaderView { adapter.addHeaderView {
@ -130,6 +133,7 @@ class BgTextConfigDialog : BaseDialogFragment(R.layout.dialog_read_bg_text) {
private fun initData() = with(ReadBookConfig.durConfig) { private fun initData() = with(ReadBookConfig.durConfig) {
binding.tvName.text = name.ifBlank { "文字" } binding.tvName.text = name.ifBlank { "文字" }
binding.swDarkStatusIcon.isChecked = curStatusIconDark() binding.swDarkStatusIcon.isChecked = curStatusIconDark()
binding.sbBgAlpha.progress = bgAlpha
} }
@SuppressLint("InflateParams") @SuppressLint("InflateParams")
@ -205,6 +209,15 @@ class BgTextConfigDialog : BaseDialogFragment(R.layout.dialog_read_bg_text) {
toastOnUi("数量已是最少,不能删除.") toastOnUi("数量已是最少,不能删除.")
} }
} }
binding.sbBgAlpha.setOnSeekBarChangeListener(object : SeekBarChangeListener {
override fun onProgressChanged(seekBar: SeekBar, progress: Int, fromUser: Boolean) {
ReadBookConfig.bgAlpha = progress
}
override fun onStopTrackingTouch(seekBar: SeekBar) {
postEvent(EventBus.UP_CONFIG, false)
}
})
} }
@Suppress("BlockingMethodInNonBlockingContext") @Suppress("BlockingMethodInNonBlockingContext")

@ -185,7 +185,12 @@ class PageView(context: Context) : FrameLayout(context) {
} }
fun setBg(bg: Drawable?) { fun setBg(bg: Drawable?) {
binding.pagePanel.background = bg binding.vwBg.background = bg
upBgAlpha()
}
fun upBgAlpha() {
binding.vwBg.alpha = ReadBookConfig.bgAlpha / 100f
} }
fun upTime() { fun upTime() {

@ -104,7 +104,7 @@ class ReadView(context: Context, attrs: AttributeSet) :
} }
} }
fun setRect9x() { private fun setRect9x() {
tlRect.set(0f, 0f, width * 0.33f, height * 0.33f) tlRect.set(0f, 0f, width * 0.33f, height * 0.33f)
tcRect.set(width * 0.33f, 0f, width * 0.66f, height * 0.33f) tcRect.set(width * 0.33f, 0f, width * 0.66f, height * 0.33f)
trRect.set(width * 0.36f, 0f, width.toFloat(), height * 0.33f) trRect.set(width * 0.36f, 0f, width.toFloat(), height * 0.33f)
@ -534,6 +534,12 @@ class ReadView(context: Context, attrs: AttributeSet) :
nextPage.setBg(ReadBookConfig.bg) nextPage.setBg(ReadBookConfig.bg)
} }
fun upBgAlpha() {
curPage.upBgAlpha()
prevPage.upBgAlpha()
nextPage.upBgAlpha()
}
fun upTime() { fun upTime() {
curPage.upTime() curPage.upTime()
prevPage.upTime() prevPage.upTime()

@ -12,8 +12,8 @@
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:padding="6dp" android:gravity="center_vertical"
android:gravity="center_vertical"> android:padding="6dp">
<TextView <TextView
android:id="@+id/tv_name_title" android:id="@+id/tv_name_title"
@ -36,9 +36,9 @@
android:id="@+id/iv_edit" android:id="@+id/iv_edit"
android:layout_width="20dp" android:layout_width="20dp"
android:layout_height="20dp" android:layout_height="20dp"
android:contentDescription="@string/edit"
android:src="@drawable/ic_edit" android:src="@drawable/ic_edit"
app:tint="@color/secondaryText" app:tint="@color/secondaryText" />
android:contentDescription="@string/edit" />
<Space <Space
android:layout_width="0dp" android:layout_width="0dp"
@ -59,7 +59,8 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:padding="6dp" android:padding="6dp"
android:text="@string/dark_status_icon" /> android:text="@string/dark_status_icon"
tools:ignore="TouchTargetSizeCheck" />
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
@ -140,6 +141,23 @@
</LinearLayout> </LinearLayout>
<TextView
android:id="@+id/tv_bg_alpha"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="6dp"
android:paddingRight="6dp"
android:text="@string/bg_alpha" />
<io.legado.app.lib.theme.view.ThemeSeekBar
android:id="@+id/sb_bg_alpha"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:min="10"
android:max="100"
android:padding="6dp"
tools:ignore="UnusedAttribute" />
<TextView <TextView
android:id="@+id/tv_bg_image" android:id="@+id/tv_bg_image"
android:layout_width="match_parent" android:layout_width="match_parent"

@ -3,11 +3,16 @@
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/page_panel" android:background="@color/background"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical"> android:orientation="vertical">
<View
android:id="@+id/vw_bg"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<FrameLayout <FrameLayout
android:id="@+id/vw_status_bar" android:id="@+id/vw_status_bar"
android:layout_width="match_parent" android:layout_width="match_parent"

@ -913,5 +913,6 @@
<string name="expand_text_menu">展开文本选择菜单</string> <string name="expand_text_menu">展开文本选择菜单</string>
<string name="book_tree_uri_t">书籍保存位置</string> <string name="book_tree_uri_t">书籍保存位置</string>
<string name="book_tree_uri_s">从其它应用打开的书籍保存位置</string> <string name="book_tree_uri_s">从其它应用打开的书籍保存位置</string>
<string name="bg_alpha">背景透明度</string>
</resources> </resources>

@ -916,5 +916,6 @@
<string name="expand_text_menu">展开文本选择菜单</string> <string name="expand_text_menu">展开文本选择菜单</string>
<string name="book_tree_uri_t">书籍保存位置</string> <string name="book_tree_uri_t">书籍保存位置</string>
<string name="book_tree_uri_s">从其它应用打开的书籍保存位置</string> <string name="book_tree_uri_s">从其它应用打开的书籍保存位置</string>
<string name="bg_alpha">背景透明度</string>
</resources> </resources>

@ -418,6 +418,7 @@
<string name="rule_chapter_list">目录列表规则(capítuloLista)</string> <string name="rule_chapter_list">目录列表规则(capítuloLista)</string>
<string name="rule_chapter_name">章节名称规则(capítuloNome)</string> <string name="rule_chapter_name">章节名称规则(capítuloNome)</string>
<string name="rule_chapter_url">章节URL规则(capítuloUrl)</string> <string name="rule_chapter_url">章节URL规则(capítuloUrl)</string>
<string name="rule_is_volume">卷标识(isVolume)</string>
<string name="rule_is_vip">VIP标识(éVip)</string> <string name="rule_is_vip">VIP标识(éVip)</string>
<string name="rule_update_time">更新时间(capítuloInfo)</string> <string name="rule_update_time">更新时间(capítuloInfo)</string>
<string name="rule_book_content">正文规则(conteúdo)</string> <string name="rule_book_content">正文规则(conteúdo)</string>
@ -426,6 +427,7 @@
<string name="rule_source_regex">资源正则(fonteRegex)</string> <string name="rule_source_regex">资源正则(fonteRegex)</string>
<string name="rule_replace_regex">替换规则(substRegex)</string> <string name="rule_replace_regex">替换规则(substRegex)</string>
<string name="rule_image_style">图片样式(imagemFormato)</string> <string name="rule_image_style">图片样式(imagemFormato)</string>
<string name="rule_pay_action">购买操作(payAction)</string>
<string name="source_icon">图标(fonteÍcone)</string> <string name="source_icon">图标(fonteÍcone)</string>
<string name="r_articles">列表规则(regrasArtigos)</string> <string name="r_articles">列表规则(regrasArtigos)</string>
@ -914,5 +916,6 @@
<string name="expand_text_menu">展开文本选择菜单</string> <string name="expand_text_menu">展开文本选择菜单</string>
<string name="book_tree_uri_t">书籍保存位置</string> <string name="book_tree_uri_t">书籍保存位置</string>
<string name="book_tree_uri_s">从其它应用打开的书籍保存位置</string> <string name="book_tree_uri_s">从其它应用打开的书籍保存位置</string>
<string name="bg_alpha">背景透明度</string>
</resources> </resources>

@ -913,5 +913,6 @@
<string name="expand_text_menu">展开文本选择菜单</string> <string name="expand_text_menu">展开文本选择菜单</string>
<string name="book_tree_uri_t">书籍保存位置</string> <string name="book_tree_uri_t">书籍保存位置</string>
<string name="book_tree_uri_s">从其它应用打开的书籍保存位置</string> <string name="book_tree_uri_s">从其它应用打开的书籍保存位置</string>
<string name="bg_alpha">背景透明度</string>
</resources> </resources>

@ -915,5 +915,6 @@
<string name="search_content_size">搜尋結果</string> <string name="search_content_size">搜尋結果</string>
<string name="book_tree_uri_t">書籍儲存位置</string> <string name="book_tree_uri_t">書籍儲存位置</string>
<string name="book_tree_uri_s">從其它應用程式打開的書籍儲存位置</string> <string name="book_tree_uri_s">從其它應用程式打開的書籍儲存位置</string>
<string name="bg_alpha">背景透明度</string>
</resources> </resources>

@ -915,5 +915,6 @@
<string name="expand_text_menu">展开文本选择菜单</string> <string name="expand_text_menu">展开文本选择菜单</string>
<string name="book_tree_uri_t">书籍保存位置</string> <string name="book_tree_uri_t">书籍保存位置</string>
<string name="book_tree_uri_s">从其它应用打开的书籍保存位置</string> <string name="book_tree_uri_s">从其它应用打开的书籍保存位置</string>
<string name="bg_alpha">背景透明度</string>
</resources> </resources>

@ -418,7 +418,7 @@
<string name="rule_chapter_list">目录列表规则(chapterList)</string> <string name="rule_chapter_list">目录列表规则(chapterList)</string>
<string name="rule_chapter_name">章节名称规则(ChapterName)</string> <string name="rule_chapter_name">章节名称规则(ChapterName)</string>
<string name="rule_chapter_url">章节URL规则(chapterUrl)</string> <string name="rule_chapter_url">章节URL规则(chapterUrl)</string>
<string name="rule_is_volume">Volume标识(isVolume)</string> <string name="rule_is_volume">标识(isVolume)</string>
<string name="rule_is_vip">VIP标识(isVip)</string> <string name="rule_is_vip">VIP标识(isVip)</string>
<string name="rule_update_time">更新时间(ChapterInfo)</string> <string name="rule_update_time">更新时间(ChapterInfo)</string>
<string name="rule_book_content">正文规则(content)</string> <string name="rule_book_content">正文规则(content)</string>
@ -916,5 +916,6 @@
<string name="expand_text_menu">展开文本选择菜单</string> <string name="expand_text_menu">展开文本选择菜单</string>
<string name="book_tree_uri_t">书籍保存位置</string> <string name="book_tree_uri_t">书籍保存位置</string>
<string name="book_tree_uri_s">从其它应用打开的书籍保存位置</string> <string name="book_tree_uri_s">从其它应用打开的书籍保存位置</string>
<string name="bg_alpha">背景透明度</string>
</resources> </resources>

Loading…
Cancel
Save