feat: 修复EInk bug

pull/248/head
gedoor 5 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. 26
      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**
* fadeapp.widgets:scrollless-recyclerView导致有些手机重影,暂时去除
* 下载界面添加分组

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

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

@ -6,7 +6,6 @@ import android.text.Layout
import android.text.StaticLayout
import android.text.TextPaint
import android.text.TextUtils
import com.hankcs.hanlp.HanLP
import io.legado.app.App
import io.legado.app.constant.PreferKey
import io.legado.app.data.entities.BookChapter
@ -293,14 +292,14 @@ object ChapterProvider {
//标题
titlePaint = TextPaint()
titlePaint.color = ReadBookConfig.durConfig.textColor()
titlePaint.color = ReadBookConfig.textColor
titlePaint.letterSpacing = ReadBookConfig.letterSpacing
titlePaint.typeface = titleFont
titlePaint.textSize = with(ReadBookConfig) { textSize + titleSize }.sp.toFloat()
titlePaint.isAntiAlias = true
//正文
contentPaint = TextPaint()
contentPaint.color = ReadBookConfig.durConfig.textColor()
contentPaint.color = ReadBookConfig.textColor
contentPaint.letterSpacing = ReadBookConfig.letterSpacing
contentPaint.typeface = textFont
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
textPaint.color =
if (isReadAloud) context.accentColor else ReadBookConfig.durConfig.textColor()
if (isReadAloud) context.accentColor else ReadBookConfig.textColor
textChars.forEach {
canvas.drawText(it.charData, it.start, lineBase, textPaint)
if (it.selected) {

@ -7,10 +7,8 @@ import android.view.MotionEvent
import android.widget.FrameLayout
import androidx.core.view.isGone
import androidx.core.view.isInvisible
import com.hankcs.hanlp.HanLP
import io.legado.app.R
import io.legado.app.constant.AppConst.timeFormat
import io.legado.app.help.AppConfig
import io.legado.app.help.ReadBookConfig
import io.legado.app.help.ReadTipConfig
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_middle.typeface = ChapterProvider.typeface
tv_footer_right.typeface = ChapterProvider.typeface
bv_header_left.setColor(durConfig.textColor())
tv_header_left.setColor(durConfig.textColor())
tv_header_middle.setColor(durConfig.textColor())
tv_header_right.setColor(durConfig.textColor())
bv_footer_left.setColor(durConfig.textColor())
tv_footer_left.setColor(durConfig.textColor())
tv_footer_middle.setColor(durConfig.textColor())
tv_footer_right.setColor(durConfig.textColor())
bv_header_left.setColor(textColor)
tv_header_left.setColor(textColor)
tv_header_middle.setColor(textColor)
tv_header_right.setColor(textColor)
bv_footer_left.setColor(textColor)
tv_footer_left.setColor(textColor)
tv_footer_middle.setColor(textColor)
tv_footer_right.setColor(textColor)
//显示状态栏时隐藏header
vw_status_bar.setPadding(0, context.statusBarHeight, 0, 0)
vw_status_bar.isGone = hideStatusBar

@ -53,13 +53,19 @@
tools:ignore="UnusedAttribute" />
</LinearLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycler_view"
<FrameLayout
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_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
android:id="@+id/select_action_bar"

Loading…
Cancel
Save