优化
This commit is contained in:
@@ -136,6 +136,7 @@ class App : Application() {
|
|||||||
enableLights(false)
|
enableLights(false)
|
||||||
enableVibration(false)
|
enableVibration(false)
|
||||||
setSound(null, null)
|
setSound(null, null)
|
||||||
|
importance = NotificationManager.IMPORTANCE_LOW
|
||||||
}
|
}
|
||||||
|
|
||||||
val readAloudChannel = NotificationChannel(
|
val readAloudChannel = NotificationChannel(
|
||||||
@@ -146,6 +147,7 @@ class App : Application() {
|
|||||||
enableLights(false)
|
enableLights(false)
|
||||||
enableVibration(false)
|
enableVibration(false)
|
||||||
setSound(null, null)
|
setSound(null, null)
|
||||||
|
importance = NotificationManager.IMPORTANCE_LOW
|
||||||
}
|
}
|
||||||
|
|
||||||
val webChannel = NotificationChannel(
|
val webChannel = NotificationChannel(
|
||||||
@@ -156,6 +158,7 @@ class App : Application() {
|
|||||||
enableLights(false)
|
enableLights(false)
|
||||||
enableVibration(false)
|
enableVibration(false)
|
||||||
setSound(null, null)
|
setSound(null, null)
|
||||||
|
importance = NotificationManager.IMPORTANCE_LOW
|
||||||
}
|
}
|
||||||
|
|
||||||
//向notification manager 提交channel
|
//向notification manager 提交channel
|
||||||
|
|||||||
@@ -398,6 +398,9 @@ abstract class BaseReadAloudService : BaseService(),
|
|||||||
.setContentIntent(
|
.setContentIntent(
|
||||||
activityPendingIntent<ReadBookActivity>("activity")
|
activityPendingIntent<ReadBookActivity>("activity")
|
||||||
)
|
)
|
||||||
|
.setVibrate(null)
|
||||||
|
.setSound(null)
|
||||||
|
.setLights(0, 0, 0)
|
||||||
builder.setLargeIcon(cover)
|
builder.setLargeIcon(cover)
|
||||||
if (pause) {
|
if (pause) {
|
||||||
builder.addAction(
|
builder.addAction(
|
||||||
|
|||||||
@@ -667,6 +667,10 @@ class ReadBookActivity : BaseReadBookActivity(),
|
|||||||
textActionMenu.dismiss()
|
textActionMenu.dismiss()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onLongScreenshotTouchEvent(event: MotionEvent): Boolean {
|
||||||
|
return binding.readView.onTouchEvent(event)
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 显示文本操作菜单
|
* 显示文本操作菜单
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import android.graphics.Paint
|
|||||||
import android.graphics.RectF
|
import android.graphics.RectF
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.util.AttributeSet
|
import android.util.AttributeSet
|
||||||
|
import android.view.MotionEvent
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import io.legado.app.R
|
import io.legado.app.R
|
||||||
import io.legado.app.constant.AppLog
|
import io.legado.app.constant.AppLog
|
||||||
@@ -47,6 +48,7 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at
|
|||||||
var isMainView = false
|
var isMainView = false
|
||||||
private var drawVisibleImageOnly = false
|
private var drawVisibleImageOnly = false
|
||||||
private var cacheIncreased = false
|
private var cacheIncreased = false
|
||||||
|
private var longScreenshot = false
|
||||||
private val increaseSize = 8 * 1024 * 1024
|
private val increaseSize = 8 * 1024 * 1024
|
||||||
private val maxCacheSize = if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.N_MR1) {
|
private val maxCacheSize = if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.N_MR1) {
|
||||||
min(128 * 1024 * 1024, Runtime.getRuntime().maxMemory())
|
min(128 * 1024 * 1024, Runtime.getRuntime().maxMemory())
|
||||||
@@ -100,6 +102,9 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at
|
|||||||
|
|
||||||
override fun onDraw(canvas: Canvas) {
|
override fun onDraw(canvas: Canvas) {
|
||||||
super.onDraw(canvas)
|
super.onDraw(canvas)
|
||||||
|
if (longScreenshot) {
|
||||||
|
canvas.translate(0f, scrollY.toFloat())
|
||||||
|
}
|
||||||
canvas.clipRect(visibleRect)
|
canvas.clipRect(visibleRect)
|
||||||
drawPage(canvas)
|
drawPage(canvas)
|
||||||
drawVisibleImageOnly = false
|
drawVisibleImageOnly = false
|
||||||
@@ -193,6 +198,7 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at
|
|||||||
canvas.drawRect(it.start, lineTop, it.end, lineBottom, selectedPaint)
|
canvas.drawRect(it.start, lineTop, it.end, lineBottom, selectedPaint)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
is ImageColumn -> drawImage(canvas, textPage, textLine, it, lineTop, lineBottom)
|
is ImageColumn -> drawImage(canvas, textPage, textLine, it, lineTop, lineBottom)
|
||||||
is ReviewColumn -> it.drawToCanvas(canvas, lineBase, textPaint.textSize)
|
is ReviewColumn -> it.drawToCanvas(canvas, lineBase, textPaint.textSize)
|
||||||
}
|
}
|
||||||
@@ -267,6 +273,9 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at
|
|||||||
fun scroll(mOffset: Int) {
|
fun scroll(mOffset: Int) {
|
||||||
if (mOffset == 0) return
|
if (mOffset == 0) return
|
||||||
pageOffset += mOffset
|
pageOffset += mOffset
|
||||||
|
if (longScreenshot) {
|
||||||
|
scrollY += -mOffset
|
||||||
|
}
|
||||||
if (!pageFactory.hasPrev() && pageOffset > 0) {
|
if (!pageFactory.hasPrev() && pageOffset > 0) {
|
||||||
pageOffset = 0
|
pageOffset = 0
|
||||||
} else if (!pageFactory.hasNext()
|
} else if (!pageFactory.hasNext()
|
||||||
@@ -659,6 +668,25 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun canScrollVertically(direction: Int): Boolean {
|
||||||
|
return callBack.isScroll && pageFactory.hasNext()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun dispatchTouchEvent(event: MotionEvent): Boolean {
|
||||||
|
when (event.action) {
|
||||||
|
MotionEvent.ACTION_DOWN -> {
|
||||||
|
longScreenshot = true
|
||||||
|
scrollY = 0
|
||||||
|
}
|
||||||
|
|
||||||
|
MotionEvent.ACTION_UP -> {
|
||||||
|
longScreenshot = false
|
||||||
|
scrollY = 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return callBack.onLongScreenshotTouchEvent(event)
|
||||||
|
}
|
||||||
|
|
||||||
interface CallBack {
|
interface CallBack {
|
||||||
val headerHeight: Int
|
val headerHeight: Int
|
||||||
val pageFactory: TextPageFactory
|
val pageFactory: TextPageFactory
|
||||||
@@ -668,5 +696,6 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at
|
|||||||
fun upSelectedEnd(x: Float, y: Float)
|
fun upSelectedEnd(x: Float, y: Float)
|
||||||
fun onImageLongPress(x: Float, y: Float, src: String)
|
fun onImageLongPress(x: Float, y: Float, src: String)
|
||||||
fun onCancelSelect()
|
fun onCancelSelect()
|
||||||
|
fun onLongScreenshotTouchEvent(event: MotionEvent): Boolean
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user