Switch of AntiAlias

pull/1859/head
ag2s20150909 3 years ago
parent a6bf5d696c
commit b219391470
  1. 2
      app/build.gradle
  2. 2
      app/src/main/java/io/legado/app/constant/PreferKey.kt
  3. 3
      app/src/main/java/io/legado/app/help/config/AppConfig.kt
  4. 6
      app/src/main/java/io/legado/app/help/http/cronet/AbsCallBack.kt
  5. 6
      app/src/main/java/io/legado/app/help/http/cronet/CronetInterceptor.kt
  6. 15
      app/src/main/java/io/legado/app/ui/book/read/page/ContentTextView.kt
  7. 2
      app/src/main/res/values-es-rES/strings.xml
  8. 2
      app/src/main/res/values-ja-rJP/strings.xml
  9. 2
      app/src/main/res/values-pt-rBR/strings.xml
  10. 2
      app/src/main/res/values-zh-rHK/strings.xml
  11. 2
      app/src/main/res/values-zh-rTW/strings.xml
  12. 2
      app/src/main/res/values-zh/strings.xml
  13. 4
      app/src/main/res/values/strings.xml
  14. 5
      app/src/main/res/xml/pref_config_other.xml

@ -157,7 +157,7 @@ dependencies {
implementation('androidx.webkit:webkit:1.4.0') implementation('androidx.webkit:webkit:1.4.0')
//google //google
implementation('com.google.android.material:material:1.5.0') implementation('com.google.android.material:material:1.6.0')
implementation('com.google.android.flexbox:flexbox:3.0.0') implementation('com.google.android.flexbox:flexbox:3.0.0')
implementation('com.google.code.gson:gson:2.9.0') implementation('com.google.code.gson:gson:2.9.0')

@ -80,6 +80,8 @@ object PreferKey {
const val importKeepName = "importKeepName" const val importKeepName = "importKeepName"
const val screenOrientation = "screenOrientation" const val screenOrientation = "screenOrientation"
const val syncBookProgress = "syncBookProgress" const val syncBookProgress = "syncBookProgress"
const val cronet = "Cronet"
const val antiAlias = "antiAlias"
const val preDownloadNum = "preDownloadNum" const val preDownloadNum = "preDownloadNum"
const val autoRefresh = "auto_refresh" const val autoRefresh = "auto_refresh"
const val defaultToRead = "defaultToRead" const val defaultToRead = "defaultToRead"

@ -11,7 +11,8 @@ import splitties.init.appCtx
@Suppress("MemberVisibilityCanBePrivate") @Suppress("MemberVisibilityCanBePrivate")
object AppConfig : SharedPreferences.OnSharedPreferenceChangeListener { object AppConfig : SharedPreferences.OnSharedPreferenceChangeListener {
val isGooglePlay = appCtx.channel == "google" val isGooglePlay = appCtx.channel == "google"
val isCronet = appCtx.getPrefBoolean("Cronet") val isCronet = appCtx.getPrefBoolean(PreferKey.cronet)
val useAntiAlias = appCtx.getPrefBoolean(PreferKey.antiAlias)
var userAgent: String = getPrefUserAgent() var userAgent: String = getPrefUserAgent()
var isEInkMode = appCtx.getPrefString(PreferKey.themeMode) == "3" var isEInkMode = appCtx.getPrefString(PreferKey.themeMode) == "3"
var clickActionTL = appCtx.getPrefInt(PreferKey.clickActionTL, 2) var clickActionTL = appCtx.getPrefInt(PreferKey.clickActionTL, 2)

@ -21,7 +21,7 @@ abstract class AbsCallBack(
private val eventListener: EventListener? = null, private val eventListener: EventListener? = null,
private val responseCallback: Callback? = null private val responseCallback: Callback? = null
) : UrlRequest.Callback() { ) : UrlRequest.Callback(), AutoCloseable {
val buffer = Buffer() val buffer = Buffer()
@ -225,4 +225,8 @@ abstract class AbsCallBack(
.build() .build()
} }
} }
override fun close() {
buffer.clear()
}
} }

@ -4,11 +4,15 @@ import android.os.Build
import io.legado.app.utils.printOnDebug import io.legado.app.utils.printOnDebug
import okhttp3.* import okhttp3.*
import okhttp3.internal.http.receiveHeaders import okhttp3.internal.http.receiveHeaders
import java.io.IOException
class CronetInterceptor(private val cookieJar: CookieJar = CookieJar.NO_COOKIES) : Interceptor { class CronetInterceptor(private val cookieJar: CookieJar = CookieJar.NO_COOKIES) : Interceptor {
@Throws(IOException::class)
override fun intercept(chain: Interceptor.Chain): Response { override fun intercept(chain: Interceptor.Chain): Response {
if (chain.call().isCanceled()) {
throw IOException("Canceled")
}
val original: Request = chain.request() val original: Request = chain.request()
//Cronet未初始化 //Cronet未初始化
return if (!CronetLoader.install() || cronetEngine == null) { return if (!CronetLoader.install() || cronetEngine == null) {

@ -3,13 +3,13 @@ package io.legado.app.ui.book.read.page
import android.content.Context import android.content.Context
import android.graphics.Canvas import android.graphics.Canvas
import android.graphics.Paint import android.graphics.Paint
import android.graphics.PaintFlagsDrawFilter
import android.graphics.RectF import android.graphics.RectF
import android.util.AttributeSet import android.util.AttributeSet
import android.view.View import android.view.View
import io.legado.app.R import io.legado.app.R
import io.legado.app.constant.PreferKey import io.legado.app.constant.PreferKey
import io.legado.app.data.entities.Bookmark import io.legado.app.data.entities.Bookmark
import io.legado.app.help.config.AppConfig
import io.legado.app.help.config.ReadBookConfig import io.legado.app.help.config.ReadBookConfig
import io.legado.app.lib.theme.accentColor import io.legado.app.lib.theme.accentColor
import io.legado.app.model.ReadBook import io.legado.app.model.ReadBook
@ -49,12 +49,20 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at
private val pageFactory: TextPageFactory get() = callBack.pageFactory private val pageFactory: TextPageFactory get() = callBack.pageFactory
private var pageOffset = 0 private var pageOffset = 0
//绘制图片的paint
private val imagePaint by lazy {
Paint().apply {
isAntiAlias = AppConfig.useAntiAlias
}
}
init { init {
callBack = activity as CallBack callBack = activity as CallBack
} }
fun setContent(textPage: TextPage) { fun setContent(textPage: TextPage) {
this.textPage = textPage this.textPage = textPage
imagePaint.isAntiAlias = AppConfig.useAntiAlias
invalidate() invalidate()
} }
@ -163,8 +171,7 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at
lineTop: Float, lineTop: Float,
lineBottom: Float lineBottom: Float
) { ) {
canvas.drawFilter =
PaintFlagsDrawFilter(0, Paint.ANTI_ALIAS_FLAG or Paint.FILTER_BITMAP_FLAG)
val book = ReadBook.book ?: return val book = ReadBook.book ?: return
val bitmap = ImageProvider.getImage( val bitmap = ImageProvider.getImage(
book, book,
@ -181,7 +188,7 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at
RectF(textChar.start, lineTop + div, textChar.end, lineBottom - div) RectF(textChar.start, lineTop + div, textChar.end, lineBottom - div)
} }
kotlin.runCatching { kotlin.runCatching {
canvas.drawBitmap(bitmap, null, rectF, null) canvas.drawBitmap(bitmap, null, rectF, imagePaint)
}.onFailure { e -> }.onFailure { e ->
context.toastOnUi(e.localizedMessage) context.toastOnUi(e.localizedMessage)
} }

@ -866,6 +866,8 @@
<string name="background_image_hint">Disabled when 0, enable range from 1 to 25\nThe greater the radius, the stronger the effect of blurring</string> <string name="background_image_hint">Disabled when 0, enable range from 1 to 25\nThe greater the radius, the stronger the effect of blurring</string>
<string name="need_login">需登录</string> <string name="need_login">需登录</string>
<string name="pref_cronet_summary">使用Cronet网络组件</string> <string name="pref_cronet_summary">使用Cronet网络组件</string>
<string name="anti_alias">Anti-Aliasing</string>
<string name="pref_anti_alias_summary">Anti-Aliasing when draw picture</string>
<string name="upload_url">上传URL</string> <string name="upload_url">上传URL</string>
<string name="download_url_rule">下载URL规则</string> <string name="download_url_rule">下载URL规则</string>
<string name="sort_by_respondTime">Ordenar por tiempo de respuesta</string> <string name="sort_by_respondTime">Ordenar por tiempo de respuesta</string>

@ -869,6 +869,8 @@
<string name="background_image_hint">Disabled when 0, enable range from 1 to 25\nThe greater the radius, the stronger the effect of blurring</string> <string name="background_image_hint">Disabled when 0, enable range from 1 to 25\nThe greater the radius, the stronger the effect of blurring</string>
<string name="need_login">需登录</string> <string name="need_login">需登录</string>
<string name="pref_cronet_summary">使用Cronet网络组件</string> <string name="pref_cronet_summary">使用Cronet网络组件</string>
<string name="anti_alias">Anti-Aliasing</string>
<string name="pref_anti_alias_summary">Anti-Aliasing when draw picture</string>
<string name="upload_url">上传URL</string> <string name="upload_url">上传URL</string>
<string name="download_url_rule">下载URL规则</string> <string name="download_url_rule">下载URL规则</string>
<string name="sort_by_respondTime">Sort by respond time</string> <string name="sort_by_respondTime">Sort by respond time</string>

@ -867,6 +867,8 @@
<string name="background_image_hint">Desativado quando 0, Ativado entre 1 e 25\n Quanto maior o raio, mais forte o efeito de desfocagem</string> <string name="background_image_hint">Desativado quando 0, Ativado entre 1 e 25\n Quanto maior o raio, mais forte o efeito de desfocagem</string>
<string name="need_login">Login necessário</string> <string name="need_login">Login necessário</string>
<string name="pref_cronet_summary">Usando componentes de rede Cronet</string> <string name="pref_cronet_summary">Usando componentes de rede Cronet</string>
<string name="anti_alias">Anti-Aliasing</string>
<string name="pref_anti_alias_summary">Anti-Aliasing when draw picture</string>
<string name="upload_url">上传URL</string> <string name="upload_url">上传URL</string>
<string name="download_url_rule">下载URL规则</string> <string name="download_url_rule">下载URL规则</string>
<string name="sort_by_respondTime">Classificar por tempo de resposta</string> <string name="sort_by_respondTime">Classificar por tempo de resposta</string>

@ -866,6 +866,8 @@
<string name="check_source_show_debug_message_summary">書源校驗時顯示網絡請求步驟和時間</string> <string name="check_source_show_debug_message_summary">書源校驗時顯示網絡請求步驟和時間</string>
<string name="need_login">需登錄</string> <string name="need_login">需登錄</string>
<string name="pref_cronet_summary">使用Cronet網絡組件</string> <string name="pref_cronet_summary">使用Cronet網絡組件</string>
<string name="anti_alias">抗鋸齒</string>
<string name="pref_anti_alias_summary">繪製圖片時抗鋸齒</string>
<string name="upload_url">上傳URL</string> <string name="upload_url">上傳URL</string>
<string name="download_url_rule">下載URL規則</string> <string name="download_url_rule">下載URL規則</string>
<string name="sort_by_respondTime">響應時間排序</string> <string name="sort_by_respondTime">響應時間排序</string>

@ -868,6 +868,8 @@
<string name="check_source_show_debug_message_summary">書源校驗時顯示網路請求步驟和時間</string> <string name="check_source_show_debug_message_summary">書源校驗時顯示網路請求步驟和時間</string>
<string name="need_login">需登入</string> <string name="need_login">需登入</string>
<string name="pref_cronet_summary">使用Cronet網路元件</string> <string name="pref_cronet_summary">使用Cronet網路元件</string>
<string name="anti_alias">抗鋸齒</string>
<string name="pref_anti_alias_summary">繪製圖片時抗鋸齒</string>
<string name="upload_url">上傳URL</string> <string name="upload_url">上傳URL</string>
<string name="download_url_rule">下載URL規則</string> <string name="download_url_rule">下載URL規則</string>
<string name="sort_by_respondTime">反應時間排序</string> <string name="sort_by_respondTime">反應時間排序</string>

@ -870,6 +870,8 @@
<string name="check_source_show_debug_message_summary">书源校验时显示网络请求步骤和时间</string> <string name="check_source_show_debug_message_summary">书源校验时显示网络请求步骤和时间</string>
<string name="need_login">需登录</string> <string name="need_login">需登录</string>
<string name="pref_cronet_summary">使用Cronet网络组件</string> <string name="pref_cronet_summary">使用Cronet网络组件</string>
<string name="anti_alias">抗锯齿</string>
<string name="pref_anti_alias_summary">绘制图片时抗锯齿</string>
<string name="upload_url">上传URL</string> <string name="upload_url">上传URL</string>
<string name="download_url_rule">下载URL规则</string> <string name="download_url_rule">下载URL规则</string>
<string name="sort_by_respondTime">响应时间排序</string> <string name="sort_by_respondTime">响应时间排序</string>

@ -870,6 +870,8 @@
<string name="check_source_show_debug_message_summary">Show network status and timestamp during source checking</string> <string name="check_source_show_debug_message_summary">Show network status and timestamp during source checking</string>
<string name="need_login">need login</string> <string name="need_login">need login</string>
<string name="pref_cronet_summary">use Cronet access network</string> <string name="pref_cronet_summary">use Cronet access network</string>
<string name="anti_alias">Anti-Aliasing</string>
<string name="pref_anti_alias_summary">Anti-Aliasing when draw picture</string>
<string name="upload_url">upload url</string> <string name="upload_url">upload url</string>
<string name="download_url_rule">下载URL规则</string> <string name="download_url_rule">下载URL规则</string>
<string name="export_success">export success</string> <string name="export_success">export success</string>
@ -974,5 +976,7 @@
<string name="soure_change_source">是否确认换源</string> <string name="soure_change_source">是否确认换源</string>
<string name="input_verification_code">输入验证码</string> <string name="input_verification_code">输入验证码</string>
<string name="verification_code">验证码</string> <string name="verification_code">验证码</string>
<!-- string end --> <!-- string end -->
</resources> </resources>

@ -75,6 +75,11 @@
android:key="Cronet" android:key="Cronet"
android:summary="@string/pref_cronet_summary" android:summary="@string/pref_cronet_summary"
android:title="Cronet" /> android:title="Cronet" />
<io.legado.app.ui.widget.prefs.SwitchPreference
android:defaultValue="false"
android:key="antiAlias"
android:summary="@string/pref_anti_alias_summary"
android:title="@string/anti_alias" />
<io.legado.app.ui.widget.prefs.Preference <io.legado.app.ui.widget.prefs.Preference
android:key="preDownloadNum" android:key="preDownloadNum"

Loading…
Cancel
Save