feat: 修复EInk bug

pull/248/head
gedoor 4 years ago
parent 28011069c6
commit 0d81d3f030
  1. 3
      app/src/main/assets/updateLog.md
  2. 1
      app/src/main/java/io/legado/app/constant/PreferKey.kt
  3. 36
      app/src/main/java/io/legado/app/help/ReadBookConfig.kt
  4. 5
      app/src/main/java/io/legado/app/ui/book/read/page/ChapterProvider.kt
  5. 2
      app/src/main/java/io/legado/app/ui/book/read/page/ContentTextView.kt
  6. 18
      app/src/main/java/io/legado/app/ui/book/read/page/ContentView.kt
  7. 16
      app/src/main/res/layout/activity_import_book.xml

@ -3,6 +3,9 @@
* 请关注公众号[开源阅读]()支持我,同时关注合作公众号[小说拾遗](),阅读公众号小编。 * 请关注公众号[开源阅读]()支持我,同时关注合作公众号[小说拾遗](),阅读公众号小编。
* 新公众号[开源阅读]()已启用,[开源阅读软件]()备用 * 新公众号[开源阅读]()已启用,[开源阅读软件]()备用
**2020/06/19**
* 修复eInk bug
**2020/06/18** **2020/06/18**
* fadeapp.widgets:scrollless-recyclerView导致有些手机重影,暂时去除 * fadeapp.widgets:scrollless-recyclerView导致有些手机重影,暂时去除
* 下载界面添加分组 * 下载界面添加分组

@ -63,6 +63,5 @@ object PreferKey {
const val cLBBackground = "lastColorBottomBackground" const val cLBBackground = "lastColorBottomBackground"
const val lastPageAnim = "lastPageAnim" const val lastPageAnim = "lastPageAnim"
const val lastIsNight = "lastIsNightTheme"
const val lastThemeMode = "lastThemeMode" const val lastThemeMode = "lastThemeMode"
} }

@ -26,25 +26,20 @@ object ReadBookConfig {
val json = String(App.INSTANCE.assets.open(readConfigFileName).readBytes()) val json = String(App.INSTANCE.assets.open(readConfigFileName).readBytes())
GSON.fromJsonArray<Config>(json)!! GSON.fromJsonArray<Config>(json)!!
} }
val durConfig get() = val durConfig get() = getConfig(styleSelect)
if (AppConfig.isEInkMode)
einkConfig
else
getConfig(styleSelect)
var bg: Drawable? = null var bg: Drawable? = null
var bgMeanColor: Int = 0 var bgMeanColor: Int = 0
private val einkConfig: Config val textColor: Int
get() =
if (AppConfig.isEInkMode && !AppConfig.isNightTheme) {
Color.BLACK
} else {
durConfig.textColor()
}
init { init {
upConfig() upConfig()
einkConfig = Config(
bgStr = "#FFFFFF",
bgStrNight = "#FFFFFF",
textColor = "#000000",
textColorNight = "#000000",
darkStatusIconNight = true
)
} }
@Synchronized @Synchronized
@ -83,11 +78,16 @@ object ReadBookConfig {
val dm = resources.displayMetrics val dm = resources.displayMetrics
val width = dm.widthPixels val width = dm.widthPixels
val height = dm.heightPixels val height = dm.heightPixels
bg = durConfig.bgDrawable(width, height).apply { if (AppConfig.isEInkMode && !AppConfig.isNightTheme) {
if (this is BitmapDrawable) { bg = ColorDrawable(Color.WHITE)
bgMeanColor = BitmapUtils.getMeanColor(bitmap) bgMeanColor = Color.WHITE
} else if (this is ColorDrawable) { } else {
bgMeanColor = color bg = durConfig.bgDrawable(width, height).apply {
if (this is BitmapDrawable) {
bgMeanColor = BitmapUtils.getMeanColor(bitmap)
} else if (this is ColorDrawable) {
bgMeanColor = color
}
} }
} }
} }

@ -6,7 +6,6 @@ import android.text.Layout
import android.text.StaticLayout import android.text.StaticLayout
import android.text.TextPaint import android.text.TextPaint
import android.text.TextUtils import android.text.TextUtils
import com.hankcs.hanlp.HanLP
import io.legado.app.App import io.legado.app.App
import io.legado.app.constant.PreferKey import io.legado.app.constant.PreferKey
import io.legado.app.data.entities.BookChapter import io.legado.app.data.entities.BookChapter
@ -293,14 +292,14 @@ object ChapterProvider {
//标题 //标题
titlePaint = TextPaint() titlePaint = TextPaint()
titlePaint.color = ReadBookConfig.durConfig.textColor() titlePaint.color = ReadBookConfig.textColor
titlePaint.letterSpacing = ReadBookConfig.letterSpacing titlePaint.letterSpacing = ReadBookConfig.letterSpacing
titlePaint.typeface = titleFont titlePaint.typeface = titleFont
titlePaint.textSize = with(ReadBookConfig) { textSize + titleSize }.sp.toFloat() titlePaint.textSize = with(ReadBookConfig) { textSize + titleSize }.sp.toFloat()
titlePaint.isAntiAlias = true titlePaint.isAntiAlias = true
//正文 //正文
contentPaint = TextPaint() contentPaint = TextPaint()
contentPaint.color = ReadBookConfig.durConfig.textColor() contentPaint.color = ReadBookConfig.textColor
contentPaint.letterSpacing = ReadBookConfig.letterSpacing contentPaint.letterSpacing = ReadBookConfig.letterSpacing
contentPaint.typeface = textFont contentPaint.typeface = textFont
contentPaint.textSize = ReadBookConfig.textSize.sp.toFloat() contentPaint.textSize = ReadBookConfig.textSize.sp.toFloat()

@ -144,7 +144,7 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at
) { ) {
val textPaint = if (isTitle) ChapterProvider.titlePaint else ChapterProvider.contentPaint val textPaint = if (isTitle) ChapterProvider.titlePaint else ChapterProvider.contentPaint
textPaint.color = textPaint.color =
if (isReadAloud) context.accentColor else ReadBookConfig.durConfig.textColor() if (isReadAloud) context.accentColor else ReadBookConfig.textColor
textChars.forEach { textChars.forEach {
canvas.drawText(it.charData, it.start, lineBase, textPaint) canvas.drawText(it.charData, it.start, lineBase, textPaint)
if (it.selected) { if (it.selected) {

@ -7,10 +7,8 @@ import android.view.MotionEvent
import android.widget.FrameLayout import android.widget.FrameLayout
import androidx.core.view.isGone import androidx.core.view.isGone
import androidx.core.view.isInvisible import androidx.core.view.isInvisible
import com.hankcs.hanlp.HanLP
import io.legado.app.R import io.legado.app.R
import io.legado.app.constant.AppConst.timeFormat import io.legado.app.constant.AppConst.timeFormat
import io.legado.app.help.AppConfig
import io.legado.app.help.ReadBookConfig import io.legado.app.help.ReadBookConfig
import io.legado.app.help.ReadTipConfig import io.legado.app.help.ReadTipConfig
import io.legado.app.ui.book.read.page.entities.TextPage import io.legado.app.ui.book.read.page.entities.TextPage
@ -57,14 +55,14 @@ class ContentView(context: Context) : FrameLayout(context) {
tv_footer_left.typeface = ChapterProvider.typeface tv_footer_left.typeface = ChapterProvider.typeface
tv_footer_middle.typeface = ChapterProvider.typeface tv_footer_middle.typeface = ChapterProvider.typeface
tv_footer_right.typeface = ChapterProvider.typeface tv_footer_right.typeface = ChapterProvider.typeface
bv_header_left.setColor(durConfig.textColor()) bv_header_left.setColor(textColor)
tv_header_left.setColor(durConfig.textColor()) tv_header_left.setColor(textColor)
tv_header_middle.setColor(durConfig.textColor()) tv_header_middle.setColor(textColor)
tv_header_right.setColor(durConfig.textColor()) tv_header_right.setColor(textColor)
bv_footer_left.setColor(durConfig.textColor()) bv_footer_left.setColor(textColor)
tv_footer_left.setColor(durConfig.textColor()) tv_footer_left.setColor(textColor)
tv_footer_middle.setColor(durConfig.textColor()) tv_footer_middle.setColor(textColor)
tv_footer_right.setColor(durConfig.textColor()) tv_footer_right.setColor(textColor)
//显示状态栏时隐藏header //显示状态栏时隐藏header
vw_status_bar.setPadding(0, context.statusBarHeight, 0, 0) vw_status_bar.setPadding(0, context.statusBarHeight, 0, 0)
vw_status_bar.isGone = hideStatusBar vw_status_bar.isGone = hideStatusBar

@ -53,13 +53,19 @@
tools:ignore="UnusedAttribute" /> tools:ignore="UnusedAttribute" />
</LinearLayout> </LinearLayout>
<androidx.recyclerview.widget.RecyclerView <FrameLayout
android:id="@+id/recycler_view"
android:layout_width="match_parent" android:layout_width="match_parent"
app:layout_constraintTop_toBottomOf="@id/layTop"
app:layout_constraintBottom_toTopOf="@id/select_action_bar"
android:layout_height="0dp" android:layout_height="0dp"
android:layout_weight="1" /> android:layout_weight="1"
app:layout_constraintTop_toBottomOf="@id/layTop"
app:layout_constraintBottom_toTopOf="@id/select_action_bar">
<io.legado.app.ui.widget.recycler.scroller.FastScrollRecyclerView
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</FrameLayout>
<io.legado.app.ui.widget.SelectActionBar <io.legado.app.ui.widget.SelectActionBar
android:id="@+id/select_action_bar" android:id="@+id/select_action_bar"

Loading…
Cancel
Save