From 1f771d4fc0f0775c98161a2311fd7938d1f7fa17 Mon Sep 17 00:00:00 2001 From: kunfei Date: Tue, 25 Feb 2020 21:28:29 +0800 Subject: [PATCH 01/72] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../page/delegate/SimulationPageDelegate.kt | 46 ++++++++++--------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/delegate/SimulationPageDelegate.kt b/app/src/main/java/io/legado/app/ui/book/read/page/delegate/SimulationPageDelegate.kt index ca4048c8d..6e41fcac5 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/delegate/SimulationPageDelegate.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/delegate/SimulationPageDelegate.kt @@ -221,13 +221,13 @@ class SimulationPageDelegate(pageView: PageView) : HorizontalPageDelegate(pageVi override fun onDraw(canvas: Canvas) { if (mDirection === Direction.NEXT) { calcPoints() - drawCurrentPageArea(canvas, curBitmap, mPath0) + drawCurrentPageArea(canvas, curBitmap) drawNextPageAreaAndShadow(canvas, nextBitmap) drawCurrentPageShadow(canvas) drawCurrentBackArea(canvas, curBitmap) } else { calcPoints() - drawCurrentPageArea(canvas, prevBitmap, mPath0) + drawCurrentPageArea(canvas, prevBitmap) drawNextPageAreaAndShadow(canvas, curBitmap) drawCurrentPageShadow(canvas) drawCurrentBackArea(canvas, prevBitmap) @@ -258,7 +258,7 @@ class SimulationPageDelegate(pageView: PageView) : HorizontalPageDelegate(pageVi val left: Int val right: Int if (mIsRtOrLb) { - left = mBezierStart1.x.toInt() - 1 + left = (mBezierStart1.x - 1).toInt() right = (mBezierStart1.x + f3 + 1).toInt() mFolderShadowDrawable = mFolderShadowDrawableLR } else { @@ -337,17 +337,16 @@ class SimulationPageDelegate(pageView: PageView) : HorizontalPageDelegate(pageVi var mCurrentPageShadow: GradientDrawable if (mIsRtOrLb) { leftX = mBezierControl1.x.toInt() - rightX = mBezierControl1.x.toInt() + 25 + rightX = (mBezierControl1.x + 25).toInt() mCurrentPageShadow = mFrontShadowDrawableVLR } else { - leftX = mBezierControl1.x.toInt() - 25 - rightX = mBezierControl1.x.toInt() + 1 + leftX = (mBezierControl1.x - 25).toInt() + rightX = (mBezierControl1.x + 1).toInt() mCurrentPageShadow = mFrontShadowDrawableVRL } - var rotateDegrees: Float = - Math.toDegrees( - atan2(mTouchX - mBezierControl1.x, mBezierControl1.y - mTouchY).toDouble() - ).toFloat() + var rotateDegrees = Math.toDegrees( + atan2(mTouchX - mBezierControl1.x, mBezierControl1.y - mTouchY).toDouble() + ).toFloat() canvas.rotate(rotateDegrees, mBezierControl1.x, mBezierControl1.y) mCurrentPageShadow.setBounds( leftX, (mBezierControl1.y - mMaxLength).toInt(), @@ -372,24 +371,25 @@ class SimulationPageDelegate(pageView: PageView) : HorizontalPageDelegate(pageVi if (mIsRtOrLb) { leftX = mBezierControl2.y.toInt() - rightX = mBezierControl2.y.toInt() + 25 + rightX = (mBezierControl2.y + 25).toInt() mCurrentPageShadow = mFrontShadowDrawableHTB } else { - leftX = mBezierControl2.y.toInt() - 25 - rightX = mBezierControl2.y.toInt() + 1 + leftX = (mBezierControl2.y - 25).toInt() + rightX = (mBezierControl2.y + 1).toInt() mCurrentPageShadow = mFrontShadowDrawableHBT } rotateDegrees = Math.toDegrees( atan2(mBezierControl2.y - mTouchY, mBezierControl2.x - mTouchX).toDouble() ).toFloat() canvas.rotate(rotateDegrees, mBezierControl2.x, mBezierControl2.y) - val temp: Float = - if (mBezierControl2.y < 0) mBezierControl2.y - viewHeight else mBezierControl2.y - val hmg = hypot(mBezierControl2.x.toDouble(), temp.toDouble()).toInt() + val temp = + if (mBezierControl2.y < 0) (mBezierControl2.y - viewHeight).toDouble() + else mBezierControl2.y.toDouble() + val hmg = hypot(mBezierControl2.x.toDouble(), temp) if (hmg > mMaxLength) mCurrentPageShadow.setBounds( - (mBezierControl2.x - 25).toInt() - hmg, leftX, - (mBezierControl2.x + mMaxLength).toInt() - hmg, rightX + (mBezierControl2.x - 25 - hmg).toInt(), leftX, + (mBezierControl2.x + mMaxLength - hmg).toInt(), rightX ) else mCurrentPageShadow.setBounds( @@ -400,6 +400,7 @@ class SimulationPageDelegate(pageView: PageView) : HorizontalPageDelegate(pageVi canvas.restore() } + // private fun drawNextPageAreaAndShadow( canvas: Canvas, bitmap: Bitmap? @@ -447,10 +448,10 @@ class SimulationPageDelegate(pageView: PageView) : HorizontalPageDelegate(pageVi canvas.restore() } + // private fun drawCurrentPageArea( canvas: Canvas, - bitmap: Bitmap?, - path: Path + bitmap: Bitmap? ) { bitmap ?: return mPath0.reset() @@ -461,11 +462,12 @@ class SimulationPageDelegate(pageView: PageView) : HorizontalPageDelegate(pageVi mPath0.quadTo(mBezierControl2.x, mBezierControl2.y, mBezierStart2.x, mBezierStart2.y) mPath0.lineTo(mCornerX.toFloat(), mCornerY.toFloat()) mPath0.close() + canvas.save() if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { - canvas.clipOutPath(path) + canvas.clipOutPath(mPath0) } else { - canvas.clipPath(path, Region.Op.XOR) + canvas.clipPath(mPath0, Region.Op.XOR) } canvas.drawBitmap(bitmap, 0f, 0f, null) canvas.restore() From 764c362af1e1931ec33e7a617da934585b18cd6d Mon Sep 17 00:00:00 2001 From: kunfei Date: Tue, 25 Feb 2020 21:33:37 +0800 Subject: [PATCH 02/72] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/ui/book/read/page/delegate/SimulationPageDelegate.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/delegate/SimulationPageDelegate.kt b/app/src/main/java/io/legado/app/ui/book/read/page/delegate/SimulationPageDelegate.kt index 6e41fcac5..385ed7140 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/delegate/SimulationPageDelegate.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/delegate/SimulationPageDelegate.kt @@ -40,7 +40,7 @@ class SimulationPageDelegate(pageView: PageView) : HorizontalPageDelegate(pageVi private var mMiddleY = 0f private var mDegrees = 0f private var mTouchToCornerDis = 0f - private var mColorMatrixFilter: ColorMatrixColorFilter = ColorMatrixColorFilter( + private var mColorMatrixFilter = ColorMatrixColorFilter( ColorMatrix( floatArrayOf( 1f, 0f, 0f, 0f, 0f, From 0cdea9b7d97388a5bbbac358b2af877ee0a2fd85 Mon Sep 17 00:00:00 2001 From: kunfei Date: Tue, 25 Feb 2020 21:52:15 +0800 Subject: [PATCH 03/72] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../page/delegate/SimulationPageDelegate.kt | 28 +++++++++++-------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/delegate/SimulationPageDelegate.kt b/app/src/main/java/io/legado/app/ui/book/read/page/delegate/SimulationPageDelegate.kt index 385ed7140..713748aed 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/delegate/SimulationPageDelegate.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/delegate/SimulationPageDelegate.kt @@ -219,18 +219,22 @@ class SimulationPageDelegate(pageView: PageView) : HorizontalPageDelegate(pageVi } override fun onDraw(canvas: Canvas) { - if (mDirection === Direction.NEXT) { - calcPoints() - drawCurrentPageArea(canvas, curBitmap) - drawNextPageAreaAndShadow(canvas, nextBitmap) - drawCurrentPageShadow(canvas) - drawCurrentBackArea(canvas, curBitmap) - } else { - calcPoints() - drawCurrentPageArea(canvas, prevBitmap) - drawNextPageAreaAndShadow(canvas, curBitmap) - drawCurrentPageShadow(canvas) - drawCurrentBackArea(canvas, prevBitmap) + when (mDirection) { + Direction.NEXT -> { + calcPoints() + drawCurrentPageArea(canvas, curBitmap) + drawNextPageAreaAndShadow(canvas, nextBitmap) + drawCurrentPageShadow(canvas) + drawCurrentBackArea(canvas, curBitmap) + } + Direction.PREV -> { + calcPoints() + drawCurrentPageArea(canvas, prevBitmap) + drawNextPageAreaAndShadow(canvas, curBitmap) + drawCurrentPageShadow(canvas) + drawCurrentBackArea(canvas, prevBitmap) + } + else -> Unit } } From 183d5d78325fb01c23f7a9bdba8ab1f7d59052a6 Mon Sep 17 00:00:00 2001 From: kunfei Date: Tue, 25 Feb 2020 22:02:52 +0800 Subject: [PATCH 04/72] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/ui/book/read/page/delegate/SimulationPageDelegate.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/delegate/SimulationPageDelegate.kt b/app/src/main/java/io/legado/app/ui/book/read/page/delegate/SimulationPageDelegate.kt index 713748aed..b7a5b1666 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/delegate/SimulationPageDelegate.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/delegate/SimulationPageDelegate.kt @@ -126,7 +126,7 @@ class SimulationPageDelegate(pageView: PageView) : HorizontalPageDelegate(pageVi } override fun setTouchPoint(x: Float, y: Float, invalidate: Boolean) { - super.setTouchPoint(x, y, invalidate) + super.setTouchPoint(x, y, false) //触摸y中间位置吧y变成屏幕高度 if ((startY > viewHeight * 0.33 && startY < viewHeight * 0.66) || mDirection == Direction.PREV @@ -139,6 +139,7 @@ class SimulationPageDelegate(pageView: PageView) : HorizontalPageDelegate(pageVi ) { touchY = 1f } + pageView.invalidate() } override fun setDirection(direction: Direction) { @@ -234,7 +235,7 @@ class SimulationPageDelegate(pageView: PageView) : HorizontalPageDelegate(pageVi drawCurrentPageShadow(canvas) drawCurrentBackArea(canvas, prevBitmap) } - else -> Unit + else -> return } } From 716b2f4caf2334975ad06164406056b343ed40ab Mon Sep 17 00:00:00 2001 From: kunfei Date: Tue, 25 Feb 2020 22:13:13 +0800 Subject: [PATCH 05/72] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ui/book/read/page/delegate/SimulationPageDelegate.kt | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/delegate/SimulationPageDelegate.kt b/app/src/main/java/io/legado/app/ui/book/read/page/delegate/SimulationPageDelegate.kt index b7a5b1666..6d7dd7bf8 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/delegate/SimulationPageDelegate.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/delegate/SimulationPageDelegate.kt @@ -55,7 +55,7 @@ class SimulationPageDelegate(pageView: PageView) : HorizontalPageDelegate(pageVi // 是否属于右上左下 private var mIsRtOrLb = false - private var mMaxLength = 0f + private var mMaxLength = hypot(viewWidth.toDouble(), viewHeight.toDouble()).toFloat() // 背面颜色组 private var mBackShadowColors: IntArray // 前面颜色组 @@ -71,15 +71,13 @@ class SimulationPageDelegate(pageView: PageView) : HorizontalPageDelegate(pageVi private var mFrontShadowDrawableVLR: GradientDrawable private var mFrontShadowDrawableVRL: GradientDrawable - private val mPaint: Paint = Paint() + private val mPaint: Paint = Paint().apply { style = Paint.Style.FILL } private var curBitmap: Bitmap? = null private var prevBitmap: Bitmap? = null private var nextBitmap: Bitmap? = null init { - mMaxLength = hypot(viewWidth.toDouble(), viewWidth.toDouble()).toFloat() - mPaint.style = Paint.Style.FILL //设置颜色数组 val color = intArrayOf(0x333333, -0x4fcccccd) mFolderShadowDrawableRL = GradientDrawable(GradientDrawable.Orientation.RIGHT_LEFT, color) @@ -117,7 +115,7 @@ class SimulationPageDelegate(pageView: PageView) : HorizontalPageDelegate(pageVi override fun setViewSize(width: Int, height: Int) { super.setViewSize(width, height) - mMaxLength = hypot(viewWidth.toDouble(), viewWidth.toDouble()).toFloat() + mMaxLength = hypot(viewWidth.toDouble(), viewHeight.toDouble()).toFloat() } override fun setStartPoint(x: Float, y: Float, invalidate: Boolean) { From b0b62f73dc19e24bca13fbdb886f3572f3194c26 Mon Sep 17 00:00:00 2001 From: hingbong Date: Wed, 26 Feb 2020 00:15:25 +0800 Subject: [PATCH 06/72] =?UTF-8?q?=E5=8A=9F=E8=83=BD=E6=B7=BB=E5=8A=A0:=20?= =?UTF-8?q?=E9=80=89=E6=8B=A9=E9=BB=98=E8=AE=A4=E5=AD=97=E4=BD=93=E6=97=B6?= =?UTF-8?q?,=20=E5=8F=AF=E9=80=89=E6=8B=A9=E5=AD=97=E4=BD=93=E9=BB=98?= =?UTF-8?q?=E8=AE=A4=E5=AD=97=E4=BD=93(=E9=9D=9E=E8=A1=AC=E7=BA=BF),=20?= =?UTF-8?q?=E7=B3=BB=E7=BB=9F=E8=A1=AC=E7=BA=BF=E5=AD=97=E4=BD=93,=20?= =?UTF-8?q?=E7=B3=BB=E7=BB=9F=E7=AD=89=E5=AE=BD=E5=AD=97=E4=BD=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Android 10 开始, 谷歌给安卓提供了思源宋体作为中日韩三文的衬线字体, 或者有些手机可以自行更改, 并且加载系统内置字体性能也更佳 --- .../java/io/legado/app/constant/PreferKey.kt | 1 + .../main/java/io/legado/app/help/AppConfig.kt | 6 ++++++ .../app/ui/book/read/page/ChapterProvider.kt | 7 ++++++- .../app/ui/widget/font/FontSelectDialog.kt | 20 ++++++++++++++++--- app/src/main/res/values/arrays.xml | 5 +++++ app/src/main/res/values/strings.xml | 1 + 6 files changed, 36 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/io/legado/app/constant/PreferKey.kt b/app/src/main/java/io/legado/app/constant/PreferKey.kt index 50ab1c873..6be087f05 100644 --- a/app/src/main/java/io/legado/app/constant/PreferKey.kt +++ b/app/src/main/java/io/legado/app/constant/PreferKey.kt @@ -38,4 +38,5 @@ object PreferKey { const val bodyIndent = "textIndent" const val shareLayout = "shareLayout" const val readStyleSelect = "readStyleSelect" + const val systemTypefaces = "system_typefaces" } \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/help/AppConfig.kt b/app/src/main/java/io/legado/app/help/AppConfig.kt index 1f4302fdc..f71652c23 100644 --- a/app/src/main/java/io/legado/app/help/AppConfig.kt +++ b/app/src/main/java/io/legado/app/help/AppConfig.kt @@ -86,4 +86,10 @@ object AppConfig { set(value) { App.INSTANCE.putPrefInt(PreferKey.chineseConverterType, value) } + + var systemTypefaces: Int + get() = App.INSTANCE.getPrefInt(PreferKey.systemTypefaces) + set(value) { + App.INSTANCE.putPrefInt(PreferKey.systemTypefaces, value) + } } diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/ChapterProvider.kt b/app/src/main/java/io/legado/app/ui/book/read/page/ChapterProvider.kt index 7618ddc51..4b133a001 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/ChapterProvider.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/ChapterProvider.kt @@ -8,6 +8,7 @@ import android.text.TextUtils import io.legado.app.App import io.legado.app.constant.PreferKey import io.legado.app.data.entities.BookChapter +import io.legado.app.help.AppConfig import io.legado.app.help.BookHelp import io.legado.app.help.ReadBookConfig import io.legado.app.ui.book.read.page.entities.TextChapter @@ -308,7 +309,11 @@ object ChapterProvider { if (!TextUtils.isEmpty(fontPath)) { Typeface.createFromFile(fontPath) } else { - Typeface.SANS_SERIF + when (AppConfig.systemTypefaces) { + 1 -> Typeface.SERIF + 2 -> Typeface.MONOSPACE + else -> Typeface.SANS_SERIF + } } } catch (e: Exception) { App.INSTANCE.removePref(PreferKey.readBookFont) diff --git a/app/src/main/java/io/legado/app/ui/widget/font/FontSelectDialog.kt b/app/src/main/java/io/legado/app/ui/widget/font/FontSelectDialog.kt index be5523b58..128415769 100644 --- a/app/src/main/java/io/legado/app/ui/widget/font/FontSelectDialog.kt +++ b/app/src/main/java/io/legado/app/ui/widget/font/FontSelectDialog.kt @@ -16,7 +16,9 @@ import androidx.recyclerview.widget.LinearLayoutManager import io.legado.app.App import io.legado.app.R import io.legado.app.base.BaseDialogFragment +import io.legado.app.constant.EventBus import io.legado.app.constant.PreferKey +import io.legado.app.help.AppConfig import io.legado.app.help.permission.Permissions import io.legado.app.help.permission.PermissionsCompat import io.legado.app.lib.dialogs.alert @@ -89,9 +91,13 @@ class FontSelectDialog : BaseDialogFragment(), R.id.menu_default -> { val cb = (parentFragment as? CallBack) ?: (activity as? CallBack) cb?.let { - if (it.curFontPath != "") { - it.selectFile("") - } + val requireContext = requireContext() + requireContext.alert(titleResource = R.string.system_typeface) { + items(requireContext.resources.getStringArray(R.array.system_typefaces).toList()) { _, i -> + AppConfig.systemTypefaces = i + onDefaultFontChange(it) + } + }.show() } dismiss() } @@ -255,6 +261,14 @@ class FontSelectDialog : BaseDialogFragment(), } } + private fun onDefaultFontChange(callBack: CallBack){ + if (curFilePath() == "") { + postEvent(EventBus.UP_CONFIG, true) + } else { + callBack.selectFile("") + } + } + interface CallBack { fun selectFile(path: String) val curFontPath: String diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml index 87fd0d8e0..ff1fc875c 100644 --- a/app/src/main/res/values/arrays.xml +++ b/app/src/main/res/values/arrays.xml @@ -152,4 +152,9 @@ 简体转繁体 + + 系统默认字体 + 系统衬线字体 + 系统等宽等宽 + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index f64f60c5a..8da65e500 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -627,4 +627,5 @@ 其它朗读设置 + 系统内置字体样式 From d86bd0117f4be7cfafbaa442691c8f8b682bc55c Mon Sep 17 00:00:00 2001 From: kunfei Date: Wed, 26 Feb 2020 08:30:56 +0800 Subject: [PATCH 07/72] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/io/legado/app/help/storage/Backup.kt | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/io/legado/app/help/storage/Backup.kt b/app/src/main/java/io/legado/app/help/storage/Backup.kt index 4076c96a7..1e3c77489 100644 --- a/app/src/main/java/io/legado/app/help/storage/Backup.kt +++ b/app/src/main/java/io/legado/app/help/storage/Backup.kt @@ -100,17 +100,9 @@ object Backup { for (fileName in backupFileNames) { val file = File(backupPath + File.separator + fileName) if (file.exists()) { - var doc = treeDoc.findFile(fileName) - if (null != doc && doc.exists()) { - doc.delete() - } - doc = treeDoc.createFile("", fileName) - doc?.let { - DocumentUtils.writeText( - context, - file.readText(), - it.uri - ) + treeDoc.findFile(fileName)?.delete() + treeDoc.createFile("", fileName)?.let { + DocumentUtils.writeText(context, file.readText(), it.uri) } } } From 54b3add99a4dce6524fd12f8bee30fcf002f6318 Mon Sep 17 00:00:00 2001 From: kunfei Date: Wed, 26 Feb 2020 10:34:54 +0800 Subject: [PATCH 08/72] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/assets/updateLog.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/src/main/assets/updateLog.md b/app/src/main/assets/updateLog.md index b9379ed02..fdcc66d5d 100644 --- a/app/src/main/assets/updateLog.md +++ b/app/src/main/assets/updateLog.md @@ -2,6 +2,10 @@ * 旧版数据导入教程: * 先在旧版阅读(2.x)中进行备份,然后在新版阅读(3.x)【我的】->【备份与恢复】,选择【导入旧版本数据】。 +**2020/02/26** +* 修复仿真翻页 +* 功能添加: 选择默认字体时, 可选择字体默认字体(非衬线), 系统衬线字体, 系统等宽字体by hingbong + **2020/02/25** * 优化文本选择和滚动,感觉很完美了 From e0e412e85aaae9df5f8ce2aedde2c85596628adc Mon Sep 17 00:00:00 2001 From: kunfei Date: Wed, 26 Feb 2020 14:24:48 +0800 Subject: [PATCH 09/72] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle | 5 +- app/google-services.json | 29 ++++++++ app/src/debug/google-services.json | 69 ------------------- .../io/legado/app/ui/about/AboutActivity.kt | 8 +-- .../legado/app/ui/book/read/TextActionMenu.kt | 32 ++++++--- .../source/edit/BookSourceEditActivity.kt | 10 +-- .../legado/app/ui/rss/read/ReadRssActivity.kt | 4 +- .../rss/source/edit/RssSourceEditActivity.kt | 8 ++- .../io/legado/app/utils/ContextExtensions.kt | 11 --- app/src/main/res/layout/popup_action_menu.xml | 27 ++++++-- .../main/res/menu/content_select_action.xml | 3 + 11 files changed, 100 insertions(+), 106 deletions(-) delete mode 100644 app/src/debug/google-services.json diff --git a/app/build.gradle b/app/build.gradle index 585099975..d6f63988d 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -54,6 +54,7 @@ android { if (project.hasProperty("RELEASE_STORE_FILE")) { signingConfig signingConfigs.myConfig } + applicationIdSuffix '.release' minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } @@ -123,7 +124,7 @@ dependencies { implementation "androidx.lifecycle:lifecycle-common-java8:$lifecycle_version" //room - def room_version = '2.2.3' + def room_version = '2.2.4' implementation "androidx.room:room-runtime:$room_version" kapt "androidx.room:room-compiler:$room_version" @@ -175,7 +176,7 @@ dependencies { //MarkDown implementation 'ru.noties.markwon:core:3.0.2' - // 转换繁体 + //转换繁体 implementation 'com.github.houbb:opencc4j:1.4.0' } diff --git a/app/google-services.json b/app/google-services.json index 8cc19b1d5..fb88090cb 100644 --- a/app/google-services.json +++ b/app/google-services.json @@ -63,6 +63,35 @@ ] } } + }, + { + "client_info": { + "mobilesdk_app_id": "1:453392274790:android:c1481c1c3d3f51eff624a7", + "android_client_info": { + "package_name": "io.legado.app.release" + } + }, + "oauth_client": [ + { + "client_id": "453392274790-hnbpatpce9hbjiggj76hgo7queu86atq.apps.googleusercontent.com", + "client_type": 3 + } + ], + "api_key": [ + { + "current_key": "AIzaSyD90mfNLhA7cAzzI9SonpSz5mrF5BnmyJA" + } + ], + "services": { + "appinvite_service": { + "other_platform_oauth_client": [ + { + "client_id": "453392274790-hnbpatpce9hbjiggj76hgo7queu86atq.apps.googleusercontent.com", + "client_type": 3 + } + ] + } + } } ], "configuration_version": "1" diff --git a/app/src/debug/google-services.json b/app/src/debug/google-services.json deleted file mode 100644 index 8cc19b1d5..000000000 --- a/app/src/debug/google-services.json +++ /dev/null @@ -1,69 +0,0 @@ -{ - "project_info": { - "project_number": "453392274790", - "firebase_url": "https://legado-fca69.firebaseio.com", - "project_id": "legado-fca69", - "storage_bucket": "legado-fca69.appspot.com" - }, - "client": [ - { - "client_info": { - "mobilesdk_app_id": "1:453392274790:android:1d2b1eefbe0e78cff624a7", - "android_client_info": { - "package_name": "io.legado.app" - } - }, - "oauth_client": [ - { - "client_id": "453392274790-hnbpatpce9hbjiggj76hgo7queu86atq.apps.googleusercontent.com", - "client_type": 3 - } - ], - "api_key": [ - { - "current_key": "AIzaSyD90mfNLhA7cAzzI9SonpSz5mrF5BnmyJA" - } - ], - "services": { - "appinvite_service": { - "other_platform_oauth_client": [ - { - "client_id": "453392274790-hnbpatpce9hbjiggj76hgo7queu86atq.apps.googleusercontent.com", - "client_type": 3 - } - ] - } - } - }, - { - "client_info": { - "mobilesdk_app_id": "1:453392274790:android:c4eac14b1410eec5f624a7", - "android_client_info": { - "package_name": "io.legado.app.debug" - } - }, - "oauth_client": [ - { - "client_id": "453392274790-hnbpatpce9hbjiggj76hgo7queu86atq.apps.googleusercontent.com", - "client_type": 3 - } - ], - "api_key": [ - { - "current_key": "AIzaSyD90mfNLhA7cAzzI9SonpSz5mrF5BnmyJA" - } - ], - "services": { - "appinvite_service": { - "other_platform_oauth_client": [ - { - "client_id": "453392274790-hnbpatpce9hbjiggj76hgo7queu86atq.apps.googleusercontent.com", - "client_type": 3 - } - ] - } - } - } - ], - "configuration_version": "1" -} \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/ui/about/AboutActivity.kt b/app/src/main/java/io/legado/app/ui/about/AboutActivity.kt index 33587d0a2..8fc7d1294 100644 --- a/app/src/main/java/io/legado/app/ui/about/AboutActivity.kt +++ b/app/src/main/java/io/legado/app/ui/about/AboutActivity.kt @@ -6,7 +6,7 @@ import android.view.MenuItem import io.legado.app.R import io.legado.app.base.BaseActivity import io.legado.app.utils.openUrl -import io.legado.app.utils.shareText +import org.jetbrains.anko.share class AboutActivity : BaseActivity(R.layout.activity_about) { @@ -27,9 +27,9 @@ class AboutActivity : BaseActivity(R.layout.activity_about) { override fun onCompatOptionsItemSelected(item: MenuItem): Boolean { when (item.itemId) { R.id.menu_scoring -> openUrl("market://details?id=$packageName") - R.id.menu_share_it -> shareText( - "App Share", - getString(R.string.app_share_description) + R.id.menu_share_it -> share( + getString(R.string.app_share_description), + getString(R.string.app_name) ) } return super.onCompatOptionsItemSelected(item) diff --git a/app/src/main/java/io/legado/app/ui/book/read/TextActionMenu.kt b/app/src/main/java/io/legado/app/ui/book/read/TextActionMenu.kt index 9d0959177..4dc9ba7da 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/TextActionMenu.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/TextActionMenu.kt @@ -15,6 +15,8 @@ import androidx.annotation.RequiresApi import androidx.appcompat.view.SupportMenuInflater import androidx.appcompat.view.menu.MenuBuilder import androidx.appcompat.view.menu.MenuItemImpl +import androidx.appcompat.widget.PopupMenu +import androidx.core.view.size import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView import io.legado.app.R @@ -22,9 +24,11 @@ import io.legado.app.base.adapter.ItemViewHolder import io.legado.app.base.adapter.SimpleRecyclerAdapter import io.legado.app.utils.isAbsUrl import io.legado.app.utils.sendToClip +import io.legado.app.utils.visible import kotlinx.android.synthetic.main.item_fillet_text.view.* import kotlinx.android.synthetic.main.popup_action_menu.view.* import org.jetbrains.anko.sdk27.listeners.onClick +import org.jetbrains.anko.share import org.jetbrains.anko.toast @SuppressLint("RestrictedApi") @@ -48,10 +52,27 @@ class TextActionMenu(private val context: Context, private val callBack: CallBac recycler_view.adapter = adapter val menu = MenuBuilder(context) SupportMenuInflater(context).inflate(R.menu.content_select_action, menu) + adapter.setItems(menu.visibleItems) if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - onInitializeMenu(menu) + val popupMenu = PopupMenu(context, iv_menu_more) + onInitializeMenu(popupMenu.menu) + if (popupMenu.menu.size > 0) { + iv_menu_more.visible() + popupMenu.setOnMenuItemClickListener { item -> + item.intent?.let { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + it.putExtra(Intent.EXTRA_PROCESS_TEXT, callBack.selectedText) + context.startActivity(it) + } + } + this@TextActionMenu.dismiss() + true + } + } + iv_menu_more.onClick { + popupMenu.show() + } } - adapter.setItems(menu.visibleItems) } inner class Adapter(context: Context) : @@ -81,6 +102,7 @@ class TextActionMenu(private val context: Context, private val callBack: CallBac private fun onMenuItemSelected(item: MenuItemImpl) { when (item.itemId) { R.id.menu_copy -> context.sendToClip(callBack.selectedText) + R.id.menu_share_str -> context.share(callBack.selectedText) R.id.menu_browser -> { try { val intent = if (callBack.selectedText.isAbsUrl()) { @@ -98,12 +120,6 @@ class TextActionMenu(private val context: Context, private val callBack: CallBac context.toast(e.localizedMessage ?: "ERROR") } } - else -> item.intent?.let { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - it.putExtra(Intent.EXTRA_PROCESS_TEXT, callBack.selectedText) - context.startActivity(it) - } - } } callBack.onMenuActionFinally() } diff --git a/app/src/main/java/io/legado/app/ui/book/source/edit/BookSourceEditActivity.kt b/app/src/main/java/io/legado/app/ui/book/source/edit/BookSourceEditActivity.kt index f693c07ed..c0eab1b32 100644 --- a/app/src/main/java/io/legado/app/ui/book/source/edit/BookSourceEditActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/source/edit/BookSourceEditActivity.kt @@ -25,9 +25,13 @@ import io.legado.app.lib.dialogs.alert import io.legado.app.lib.theme.ATH import io.legado.app.ui.book.source.debug.BookSourceDebugActivity import io.legado.app.ui.widget.KeyboardToolPop -import io.legado.app.utils.* +import io.legado.app.utils.GSON +import io.legado.app.utils.applyTint +import io.legado.app.utils.getViewModel +import io.legado.app.utils.shareWithQr import kotlinx.android.synthetic.main.activity_book_source_edit.* import org.jetbrains.anko.displayMetrics +import org.jetbrains.anko.share import org.jetbrains.anko.startActivity import org.jetbrains.anko.toast import kotlin.math.abs @@ -84,9 +88,7 @@ class BookSourceEditActivity : } } R.id.menu_paste_source -> viewModel.pasteSource { upRecyclerView(it) } - R.id.menu_share_str -> GSON.toJson(getSource())?.let { sourceStr -> - shareText(getString(R.string.share_book_source), sourceStr) - } + R.id.menu_share_str -> GSON.toJson(getSource())?.let { share(it) } R.id.menu_share_qr -> GSON.toJson(getSource())?.let { sourceStr -> shareWithQr(getString(R.string.share_book_source), sourceStr) } diff --git a/app/src/main/java/io/legado/app/ui/rss/read/ReadRssActivity.kt b/app/src/main/java/io/legado/app/ui/rss/read/ReadRssActivity.kt index c68db66a1..ebaf05233 100644 --- a/app/src/main/java/io/legado/app/ui/rss/read/ReadRssActivity.kt +++ b/app/src/main/java/io/legado/app/ui/rss/read/ReadRssActivity.kt @@ -14,10 +14,10 @@ import io.legado.app.lib.theme.DrawableUtils import io.legado.app.lib.theme.primaryTextColor import io.legado.app.utils.NetworkUtils import io.legado.app.utils.getViewModel -import io.legado.app.utils.shareText import kotlinx.android.synthetic.main.activity_rss_read.* import kotlinx.coroutines.launch import org.apache.commons.text.StringEscapeUtils +import org.jetbrains.anko.share import org.jsoup.Jsoup import org.jsoup.safety.Whitelist @@ -54,7 +54,7 @@ class ReadRssActivity : VMBaseActivity(R.layout.activity_rss_r when (item.itemId) { R.id.menu_rss_star -> viewModel.favorite() R.id.menu_share_it -> viewModel.rssArticle?.let { - shareText("链接分享", it.link) + share(it.link) } R.id.menu_aloud -> readAloud() } diff --git a/app/src/main/java/io/legado/app/ui/rss/source/edit/RssSourceEditActivity.kt b/app/src/main/java/io/legado/app/ui/rss/source/edit/RssSourceEditActivity.kt index 09839e458..22aaab453 100644 --- a/app/src/main/java/io/legado/app/ui/rss/source/edit/RssSourceEditActivity.kt +++ b/app/src/main/java/io/legado/app/ui/rss/source/edit/RssSourceEditActivity.kt @@ -21,9 +21,13 @@ import io.legado.app.lib.dialogs.alert import io.legado.app.lib.theme.ATH import io.legado.app.ui.rss.source.debug.RssSourceDebugActivity import io.legado.app.ui.widget.KeyboardToolPop -import io.legado.app.utils.* +import io.legado.app.utils.GSON +import io.legado.app.utils.applyTint +import io.legado.app.utils.getViewModel +import io.legado.app.utils.shareWithQr import kotlinx.android.synthetic.main.activity_rss_source_edit.* import org.jetbrains.anko.displayMetrics +import org.jetbrains.anko.share import org.jetbrains.anko.startActivity import org.jetbrains.anko.toast import kotlin.math.abs @@ -101,7 +105,7 @@ class RssSourceEditActivity : } R.id.menu_paste_source -> viewModel.pasteSource { upRecyclerView(it) } R.id.menu_share_str -> GSON.toJson(getRssSource())?.let { sourceStr -> - shareText(getString(R.string.share_rss_source), sourceStr) + share(sourceStr) } R.id.menu_share_qr -> GSON.toJson(getRssSource())?.let { sourceStr -> shareWithQr(getString(R.string.share_rss_source), sourceStr) diff --git a/app/src/main/java/io/legado/app/utils/ContextExtensions.kt b/app/src/main/java/io/legado/app/utils/ContextExtensions.kt index 90415484a..2f05fa014 100644 --- a/app/src/main/java/io/legado/app/utils/ContextExtensions.kt +++ b/app/src/main/java/io/legado/app/utils/ContextExtensions.kt @@ -92,17 +92,6 @@ val Context.navigationBarHeight: Int return resources.getDimensionPixelSize(resourceId) } -fun Context.shareText(title: String, text: String) { - try { - val textIntent = Intent(Intent.ACTION_SEND) - textIntent.type = "text/plain" - textIntent.putExtra(Intent.EXTRA_TEXT, text) - startActivity(Intent.createChooser(textIntent, title)) - } catch (e: Exception) { - toast(R.string.can_not_share) - } -} - @SuppressLint("SetWorldReadable") fun Context.shareWithQr(title: String, text: String) { QRCodeEncoder.HINTS[EncodeHintType.ERROR_CORRECTION] = ErrorCorrectionLevel.L diff --git a/app/src/main/res/layout/popup_action_menu.xml b/app/src/main/res/layout/popup_action_menu.xml index b5273a77a..c6b9067d7 100644 --- a/app/src/main/res/layout/popup_action_menu.xml +++ b/app/src/main/res/layout/popup_action_menu.xml @@ -1,8 +1,27 @@ - + android:padding="5dp" + android:orientation="horizontal"> + + + + + + + diff --git a/app/src/main/res/menu/content_select_action.xml b/app/src/main/res/menu/content_select_action.xml index 52ac3e0f6..d11ee6154 100644 --- a/app/src/main/res/menu/content_select_action.xml +++ b/app/src/main/res/menu/content_select_action.xml @@ -13,4 +13,7 @@ android:id="@+id/menu_browser" android:title="@string/browser" /> + \ No newline at end of file From 95c14b99a3dbcb5c5ded1931e4d88b0daa97efc0 Mon Sep 17 00:00:00 2001 From: hingbong Date: Wed, 26 Feb 2020 14:43:19 +0800 Subject: [PATCH 10/72] =?UTF-8?q?=E9=80=89=E6=8B=A9=E5=AD=97=E4=BD=93?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E5=A4=B9=E5=BC=B9=E5=87=BA=E6=A1=86=E7=94=A8?= =?UTF-8?q?=E5=8D=8F=E7=A8=8B=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 这样就不会遮盖住了, 优化一点代码 --- .../java/io/legado/app/help/storage/Backup.kt | 2 +- .../app/ui/widget/font/FontSelectDialog.kt | 66 ++++++++++--------- 2 files changed, 35 insertions(+), 33 deletions(-) diff --git a/app/src/main/java/io/legado/app/help/storage/Backup.kt b/app/src/main/java/io/legado/app/help/storage/Backup.kt index 1e3c77489..921910f34 100644 --- a/app/src/main/java/io/legado/app/help/storage/Backup.kt +++ b/app/src/main/java/io/legado/app/help/storage/Backup.kt @@ -102,7 +102,7 @@ object Backup { if (file.exists()) { treeDoc.findFile(fileName)?.delete() treeDoc.createFile("", fileName)?.let { - DocumentUtils.writeText(context, file.readText(), it.uri) + DocumentUtils.writeBytes(context, file.readBytes(), it.uri) } } } diff --git a/app/src/main/java/io/legado/app/ui/widget/font/FontSelectDialog.kt b/app/src/main/java/io/legado/app/ui/widget/font/FontSelectDialog.kt index 128415769..0e2f21213 100644 --- a/app/src/main/java/io/legado/app/ui/widget/font/FontSelectDialog.kt +++ b/app/src/main/java/io/legado/app/ui/widget/font/FontSelectDialog.kt @@ -109,41 +109,43 @@ class FontSelectDialog : BaseDialogFragment(), } private fun openFolder() { - alert { - titleResource = R.string.select_folder - items(resources.getStringArray(R.array.select_folder).toList()) { _, index -> - when (index) { - 0 -> { - val path = "${FileUtils.getSdCardPath()}${File.separator}Fonts" - putPrefString(PreferKey.fontFolder, path) - getFontFilesByPermission(path) - } - 1 -> { - try { - val intent = Intent(Intent.ACTION_OPEN_DOCUMENT_TREE) - intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION) - startActivityForResult(intent, fontFolderRequestCode) - } catch (e: java.lang.Exception) { - e.printStackTrace() - requireContext().toast(e.localizedMessage ?: "ERROR") + launch(Main) { + alert { + titleResource = R.string.select_folder + items(resources.getStringArray(R.array.select_folder).toList()) { _, index -> + when (index) { + 0 -> { + val path = "${FileUtils.getSdCardPath()}${File.separator}Fonts" + putPrefString(PreferKey.fontFolder, path) + getFontFilesByPermission(path) } - } - 2 -> { - PermissionsCompat.Builder(this@FontSelectDialog) - .addPermissions(*Permissions.Group.STORAGE) - .rationale(R.string.tip_perm_request_storage) - .onGranted { - FileChooserDialog.show( - childFragmentManager, - fontFolderRequestCode, - mode = FileChooserDialog.DIRECTORY - ) + 1 -> { + try { + val intent = Intent(Intent.ACTION_OPEN_DOCUMENT_TREE) + intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION) + startActivityForResult(intent, fontFolderRequestCode) + } catch (e: java.lang.Exception) { + e.printStackTrace() + requireContext().toast(e.localizedMessage ?: "ERROR") } - .request() + } + 2 -> { + PermissionsCompat.Builder(this@FontSelectDialog) + .addPermissions(*Permissions.Group.STORAGE) + .rationale(R.string.tip_perm_request_storage) + .onGranted { + FileChooserDialog.show( + childFragmentManager, + fontFolderRequestCode, + mode = FileChooserDialog.DIRECTORY + ) + } + .request() + } } } - } - }.show() + }.show() + } } @SuppressLint("DefaultLocale") @@ -261,7 +263,7 @@ class FontSelectDialog : BaseDialogFragment(), } } - private fun onDefaultFontChange(callBack: CallBack){ + private fun onDefaultFontChange(callBack: CallBack) { if (curFilePath() == "") { postEvent(EventBus.UP_CONFIG, true) } else { From d17099ba5c01f770319c8c827a2313e99a8c0895 Mon Sep 17 00:00:00 2001 From: kunfei Date: Wed, 26 Feb 2020 16:39:10 +0800 Subject: [PATCH 11/72] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/io/legado/app/ui/book/read/page/ContentView.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/ContentView.kt b/app/src/main/java/io/legado/app/ui/book/read/page/ContentView.kt index c39ca8f14..98eff7aad 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/ContentView.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/ContentView.kt @@ -37,8 +37,9 @@ class ContentView(context: Context) : FrameLayout(context) { tv_bottom_right.typeface = ChapterProvider.typeface //显示状态栏时隐藏header if (hideStatusBar) { - ll_header.layoutParams = - ll_header.layoutParams.apply { height = context.statusBarHeight } + ll_header.layoutParams = ll_header.layoutParams.apply { + height = context.statusBarHeight + headerPaddingTop.dp + headerPaddingBottom.dp + } ll_header.setPadding( headerPaddingLeft.dp, headerPaddingTop.dp, From ad19ebc2584a957fe04d7bfeaf2089052ae52097 Mon Sep 17 00:00:00 2001 From: kunfei Date: Wed, 26 Feb 2020 18:33:26 +0800 Subject: [PATCH 12/72] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../rss/source/edit/RssSourceEditActivity.kt | 58 +++++++++++-------- .../rss/source/edit/RssSourceEditViewModel.kt | 12 ++++ .../ui/rss/source/manage/RssSourceActivity.kt | 2 +- 3 files changed, 48 insertions(+), 24 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/rss/source/edit/RssSourceEditActivity.kt b/app/src/main/java/io/legado/app/ui/rss/source/edit/RssSourceEditActivity.kt index 22aaab453..944135b45 100644 --- a/app/src/main/java/io/legado/app/ui/rss/source/edit/RssSourceEditActivity.kt +++ b/app/src/main/java/io/legado/app/ui/rss/source/edit/RssSourceEditActivity.kt @@ -4,6 +4,7 @@ import android.app.Activity import android.content.ClipData import android.content.ClipboardManager import android.content.Context +import android.content.Intent import android.graphics.Rect import android.os.Bundle import android.view.Gravity @@ -19,6 +20,7 @@ import io.legado.app.constant.AppConst import io.legado.app.data.entities.RssSource import io.legado.app.lib.dialogs.alert import io.legado.app.lib.theme.ATH +import io.legado.app.ui.qrcode.QrCodeActivity import io.legado.app.ui.rss.source.debug.RssSourceDebugActivity import io.legado.app.ui.widget.KeyboardToolPop import io.legado.app.utils.GSON @@ -26,19 +28,17 @@ import io.legado.app.utils.applyTint import io.legado.app.utils.getViewModel import io.legado.app.utils.shareWithQr import kotlinx.android.synthetic.main.activity_rss_source_edit.* -import org.jetbrains.anko.displayMetrics -import org.jetbrains.anko.share -import org.jetbrains.anko.startActivity -import org.jetbrains.anko.toast +import org.jetbrains.anko.* import kotlin.math.abs class RssSourceEditActivity : VMBaseActivity(R.layout.activity_rss_source_edit, false), + ViewTreeObserver.OnGlobalLayoutListener, KeyboardToolPop.CallBack { private var mSoftKeyboardTool: PopupWindow? = null private var mIsSoftKeyBoardShowing = false - + private val qrRequestCode = 101 private val adapter = RssSourceEditAdapter() private val sourceEntities: ArrayList = ArrayList() @@ -103,6 +103,7 @@ class RssSourceEditActivity : clipboard?.setPrimaryClip(ClipData.newPlainText(null, sourceStr)) } } + R.id.menu_qr_code_camera -> startActivityForResult(qrRequestCode) R.id.menu_paste_source -> viewModel.pasteSource { upRecyclerView(it) } R.id.menu_share_str -> GSON.toJson(getRssSource())?.let { sourceStr -> share(sourceStr) @@ -117,7 +118,7 @@ class RssSourceEditActivity : private fun initView() { ATH.applyEdgeEffectColor(recycler_view) mSoftKeyboardTool = KeyboardToolPop(this, AppConst.keyboardToolChars, this) - window.decorView.viewTreeObserver.addOnGlobalLayoutListener(KeyboardOnGlobalChangeListener()) + window.decorView.viewTreeObserver.addOnGlobalLayoutListener(this) recycler_view.layoutManager = LinearLayoutManager(this) recycler_view.adapter = adapter } @@ -208,23 +209,34 @@ class RssSourceEditActivity : mSoftKeyboardTool?.dismiss() } - private inner class KeyboardOnGlobalChangeListener : ViewTreeObserver.OnGlobalLayoutListener { - override fun onGlobalLayout() { - val rect = Rect() - // 获取当前页面窗口的显示范围 - window.decorView.getWindowVisibleDisplayFrame(rect) - val screenHeight = this@RssSourceEditActivity.displayMetrics.heightPixels - val keyboardHeight = screenHeight - rect.bottom // 输入法的高度 - val preShowing = mIsSoftKeyBoardShowing - if (abs(keyboardHeight) > screenHeight / 5) { - mIsSoftKeyBoardShowing = true // 超过屏幕五分之一则表示弹出了输入法 - recycler_view.setPadding(0, 0, 0, 100) - showKeyboardTopPopupWindow() - } else { - mIsSoftKeyBoardShowing = false - recycler_view.setPadding(0, 0, 0, 0) - if (preShowing) { - closePopupWindow() + override fun onGlobalLayout() { + val rect = Rect() + // 获取当前页面窗口的显示范围 + window.decorView.getWindowVisibleDisplayFrame(rect) + val screenHeight = this@RssSourceEditActivity.displayMetrics.heightPixels + val keyboardHeight = screenHeight - rect.bottom // 输入法的高度 + val preShowing = mIsSoftKeyBoardShowing + if (abs(keyboardHeight) > screenHeight / 5) { + mIsSoftKeyBoardShowing = true // 超过屏幕五分之一则表示弹出了输入法 + recycler_view.setPadding(0, 0, 0, 100) + showKeyboardTopPopupWindow() + } else { + mIsSoftKeyBoardShowing = false + recycler_view.setPadding(0, 0, 0, 0) + if (preShowing) { + closePopupWindow() + } + } + } + + override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { + super.onActivityResult(requestCode, resultCode, data) + when (requestCode) { + qrRequestCode -> if (resultCode == RESULT_OK) { + data?.getStringExtra("result")?.let { + viewModel.importSource(it) { source: RssSource -> + upRecyclerView(source) + } } } } diff --git a/app/src/main/java/io/legado/app/ui/rss/source/edit/RssSourceEditViewModel.kt b/app/src/main/java/io/legado/app/ui/rss/source/edit/RssSourceEditViewModel.kt index ae6e8c739..eb9c4e034 100644 --- a/app/src/main/java/io/legado/app/ui/rss/source/edit/RssSourceEditViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/rss/source/edit/RssSourceEditViewModel.kt @@ -71,4 +71,16 @@ class RssSourceEditViewModel(application: Application) : BaseViewModel(applicati } } } + + fun importSource(text: String, finally: (source: RssSource) -> Unit) { + execute { + val text1 = text.trim() + GSON.fromJsonObject(text1)?.let { + finally.invoke(it) + } + }.onError { + toast(it.localizedMessage ?: "Error") + } + } + } \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceActivity.kt b/app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceActivity.kt index 0af2de45b..517290130 100644 --- a/app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceActivity.kt +++ b/app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceActivity.kt @@ -50,7 +50,7 @@ class RssSourceActivity : VMBaseActivity(R.layout.activity_r get() = getViewModel(RssSourceViewModel::class.java) private val importRecordKey = "rssSourceRecordKey" private val qrRequestCode = 101 - private val importSource = 13141 + private val importSource = 124 private lateinit var adapter: RssSourceAdapter private var sourceLiveData: LiveData>? = null private var groups = hashSetOf() From bfa4e10b4aeb7cd392917a331b6aa389a16d1f4f Mon Sep 17 00:00:00 2001 From: kunfei Date: Wed, 26 Feb 2020 18:56:00 +0800 Subject: [PATCH 13/72] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../legado/app/model/webBook/BookContent.kt | 45 ++++++++++--------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/app/src/main/java/io/legado/app/model/webBook/BookContent.kt b/app/src/main/java/io/legado/app/model/webBook/BookContent.kt index 47396ad9c..d8e874195 100644 --- a/app/src/main/java/io/legado/app/model/webBook/BookContent.kt +++ b/app/src/main/java/io/legado/app/model/webBook/BookContent.kt @@ -33,10 +33,14 @@ object BookContent { ) ) Debug.log(bookSource.bookSourceUrl, "≡获取成功:${baseUrl}") + val analyzeRule = AnalyzeRule(book) val content = StringBuilder() val nextUrlList = arrayListOf(baseUrl) val contentRule = bookSource.getContentRule() - var contentData = analyzeContent(body, contentRule, book, bookChapter, bookSource, baseUrl) + var contentData = analyzeContent( + analyzeRule.setContent(body, baseUrl), + contentRule, bookChapter, bookSource + ) content.append(contentData.content.replace(bookChapter.title, "")) if (contentData.nextUrl.size == 1) { var nextUrl = contentData.nextUrl[0] @@ -56,15 +60,15 @@ object BookContent { headerMapF = bookSource.getHeaderMap() ).getResponseAwait() .body?.let { nextBody -> - contentData = - analyzeContent( - nextBody, contentRule, book, - bookChapter, bookSource, baseUrl, false - ) - nextUrl = - if (contentData.nextUrl.isNotEmpty()) contentData.nextUrl[0] else "" - content.append(contentData.content) - } + contentData = + analyzeContent( + analyzeRule.setContent(nextBody, nextUrl), + contentRule, bookChapter, bookSource, false + ) + nextUrl = + if (contentData.nextUrl.isNotEmpty()) contentData.nextUrl[0] else "" + content.append(contentData.content) + } } Debug.log(bookSource.bookSourceUrl, "◇本章总页数:${nextUrlList.size}") } else if (contentData.nextUrl.size > 1) { @@ -81,19 +85,20 @@ object BookContent { headerMapF = bookSource.getHeaderMap() ).getResponseAwait() .body?.let { - contentData = - analyzeContent( - it, contentRule, book, bookChapter, - bookSource, item.nextUrl, false - ) - item.content = contentData.content - } + contentData = + analyzeContent( + analyzeRule.setContent(it, item.nextUrl), + contentRule, bookChapter, bookSource, false + ) + item.content = contentData.content + } } } for (item in contentDataList) { content.append(item.content) } } + Debug.log(bookSource.bookSourceUrl, "┌获取章节名称") Debug.log(bookSource.bookSourceUrl, "└${bookChapter.title}") Debug.log(bookSource.bookSourceUrl, "┌获取正文内容") @@ -103,17 +108,13 @@ object BookContent { @Throws(Exception::class) private fun analyzeContent( - body: String, + analyzeRule: AnalyzeRule, contentRule: ContentRule, - book: Book, chapter: BookChapter, bookSource: BookSource, - baseUrl: String, printLog: Boolean = true ): ContentData> { val nextUrlList = arrayListOf() - val analyzeRule = AnalyzeRule(book) - analyzeRule.setContent(body, baseUrl) analyzeRule.chapter = chapter val nextUrlRule = contentRule.nextContentUrl if (!nextUrlRule.isNullOrEmpty()) { From d8c1721a8d2ad0de4ed34c62510ed25720c8e09f Mon Sep 17 00:00:00 2001 From: kunfei Date: Wed, 26 Feb 2020 19:15:16 +0800 Subject: [PATCH 14/72] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/legado/app/data/entities/BaseBook.kt | 1 + .../java/io/legado/app/data/entities/Book.kt | 2 +- .../io/legado/app/data/entities/SearchBook.kt | 2 +- .../app/model/webBook/BookChapterList.kt | 22 +++++++++++-------- 4 files changed, 16 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/io/legado/app/data/entities/BaseBook.kt b/app/src/main/java/io/legado/app/data/entities/BaseBook.kt index 0c96c2123..62d322b6c 100644 --- a/app/src/main/java/io/legado/app/data/entities/BaseBook.kt +++ b/app/src/main/java/io/legado/app/data/entities/BaseBook.kt @@ -3,6 +3,7 @@ package io.legado.app.data.entities import io.legado.app.utils.splitNotBlank interface BaseBook { + var bookUrl: String var variableMap: HashMap? var kind: String? var wordCount: String? diff --git a/app/src/main/java/io/legado/app/data/entities/Book.kt b/app/src/main/java/io/legado/app/data/entities/Book.kt index d01919a94..d29ce696e 100644 --- a/app/src/main/java/io/legado/app/data/entities/Book.kt +++ b/app/src/main/java/io/legado/app/data/entities/Book.kt @@ -17,7 +17,7 @@ import kotlin.math.max @Entity(tableName = "books", indices = [(Index(value = ["bookUrl"], unique = true))]) data class Book( @PrimaryKey - var bookUrl: String = "", // 详情页Url(本地书源存储完整文件路径) + override var bookUrl: String = "", // 详情页Url(本地书源存储完整文件路径) var tocUrl: String = "", // 目录页Url (toc=table of Contents) var origin: String = BookType.local, // 书源URL(默认BookType.local) var originName: String = "", //书源名称 or 本地书籍文件名 diff --git a/app/src/main/java/io/legado/app/data/entities/SearchBook.kt b/app/src/main/java/io/legado/app/data/entities/SearchBook.kt index 2baf259e4..edd6f6e56 100644 --- a/app/src/main/java/io/legado/app/data/entities/SearchBook.kt +++ b/app/src/main/java/io/legado/app/data/entities/SearchBook.kt @@ -21,7 +21,7 @@ import kotlinx.android.parcel.Parcelize ) data class SearchBook( @PrimaryKey - var bookUrl: String = "", + override var bookUrl: String = "", var origin: String = "", // 书源规则 var originName: String = "", var type: Int = 0, // @BookType diff --git a/app/src/main/java/io/legado/app/model/webBook/BookChapterList.kt b/app/src/main/java/io/legado/app/model/webBook/BookChapterList.kt index ff3467a8a..aa0b7de74 100644 --- a/app/src/main/java/io/legado/app/model/webBook/BookChapterList.kt +++ b/app/src/main/java/io/legado/app/model/webBook/BookChapterList.kt @@ -31,6 +31,7 @@ object BookChapterList { App.INSTANCE.getString(R.string.error_get_web_content, baseUrl) ) Debug.log(bookSource.bookSourceUrl, "≡获取成功:${baseUrl}") + val analyzeRule = AnalyzeRule(book) val tocRule = bookSource.getTocRule() val nextUrlList = arrayListOf(baseUrl) var reverse = false @@ -43,7 +44,10 @@ object BookChapterList { listRule = listRule.substring(1) } var chapterData = - analyzeChapterList(body, baseUrl, tocRule, listRule, book, bookSource, log = true) + analyzeChapterList( + analyzeRule.setContent(body, baseUrl), + book.bookUrl, baseUrl, tocRule, listRule, bookSource, log = true + ) chapterData.chapterList?.let { chapterList.addAll(it) } @@ -63,8 +67,8 @@ object BookChapterList { ).getResponseAwait() .body?.let { nextBody -> chapterData = analyzeChapterList( - nextBody, nextUrl, tocRule, listRule, - book, bookSource, log = false + analyzeRule.setContent(nextBody, nextUrl), + book.bookUrl, nextUrl, tocRule, listRule, bookSource ) nextUrl = if (chapterData.nextUrl.isNotEmpty()) { chapterData.nextUrl[0] @@ -98,7 +102,9 @@ object BookChapterList { headerMapF = bookSource.getHeaderMap() ).getResponseAwait().body val nextChapterData = analyzeChapterList( - nextBody, item.nextUrl, tocRule, listRule, book, bookSource + analyzeRule.setContent(nextBody, item.nextUrl), + book.bookUrl, item.nextUrl, tocRule, listRule, bookSource, + false ) synchronized(chapterDataList) { val isFinished = addChapterListIsFinish( @@ -167,19 +173,17 @@ object BookChapterList { } private fun analyzeChapterList( - body: String?, + analyzeRule: AnalyzeRule, + bookUrl: String, baseUrl: String, tocRule: TocRule, listRule: String, - book: Book, bookSource: BookSource, getNextUrl: Boolean = true, log: Boolean = false ): ChapterData> { val chapterList = arrayListOf() val nextUrlList = arrayListOf() - val analyzeRule = AnalyzeRule(book) - analyzeRule.setContent(body, baseUrl) val nextTocRule = tocRule.nextTocUrl if (getNextUrl && !nextTocRule.isNullOrEmpty()) { Debug.log(bookSource.bookSourceUrl, "┌获取目录下一页列表", log) @@ -208,7 +212,7 @@ object BookChapterList { var isVip: String? for (item in elements) { analyzeRule.setContent(item) - val bookChapter = BookChapter(bookUrl = book.bookUrl) + val bookChapter = BookChapter(bookUrl = bookUrl) analyzeRule.chapter = bookChapter bookChapter.title = analyzeRule.getString(nameRule) bookChapter.url = analyzeRule.getString(urlRule, true) From 310d89d23a7d6cca63f4ac360ffdbfb7276fc8c3 Mon Sep 17 00:00:00 2001 From: kunfei Date: Wed, 26 Feb 2020 19:30:08 +0800 Subject: [PATCH 15/72] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../legado/app/ui/config/BackupRestoreUi.kt | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/config/BackupRestoreUi.kt b/app/src/main/java/io/legado/app/ui/config/BackupRestoreUi.kt index 16fd3941b..ddc41afce 100644 --- a/app/src/main/java/io/legado/app/ui/config/BackupRestoreUi.kt +++ b/app/src/main/java/io/legado/app/ui/config/BackupRestoreUi.kt @@ -26,7 +26,7 @@ import kotlinx.coroutines.Dispatchers.Main import org.jetbrains.anko.toast object BackupRestoreUi { - + private const val selectFolderRequestCode = 21 private const val backupSelectRequestCode = 22 private const val restoreSelectRequestCode = 33 private const val oldDataRequestCode = 11 @@ -34,7 +34,7 @@ object BackupRestoreUi { fun backup(fragment: Fragment) { val backupPath = AppConfig.backupPath if (backupPath.isNullOrEmpty()) { - selectBackupFolder(fragment) + selectBackupFolder(fragment, backupSelectRequestCode) } else { if (backupPath.isContentPath()) { val uri = Uri.parse(backupPath) @@ -46,7 +46,7 @@ object BackupRestoreUi { fragment.toast(R.string.backup_success) } } else { - selectBackupFolder(fragment) + selectBackupFolder(fragment, backupSelectRequestCode) } } else { backupUsePermission(fragment) @@ -69,7 +69,7 @@ object BackupRestoreUi { .request() } - fun selectBackupFolder(fragment: Fragment) { + fun selectBackupFolder(fragment: Fragment, requestCode: Int = selectFolderRequestCode) { fragment.alert { titleResource = R.string.select_folder items(fragment.resources.getStringArray(R.array.select_folder).toList()) { _, index -> @@ -79,7 +79,7 @@ object BackupRestoreUi { try { val intent = Intent(Intent.ACTION_OPEN_DOCUMENT_TREE) intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION) - fragment.startActivityForResult(intent, backupSelectRequestCode) + fragment.startActivityForResult(intent, requestCode) } catch (e: java.lang.Exception) { e.printStackTrace() fragment.toast(e.localizedMessage ?: "ERROR") @@ -88,7 +88,7 @@ object BackupRestoreUi { 2 -> { FileChooserDialog.show( fragment.childFragmentManager, - backupSelectRequestCode, + requestCode, mode = FileChooserDialog.DIRECTORY ) } @@ -264,6 +264,15 @@ object BackupRestoreUi { } } } + selectFolderRequestCode -> if (resultCode == RESULT_OK) { + data?.data?.let { uri -> + App.INSTANCE.contentResolver.takePersistableUriPermission( + uri, + Intent.FLAG_GRANT_READ_URI_PERMISSION or Intent.FLAG_GRANT_WRITE_URI_PERMISSION + ) + AppConfig.backupPath = uri.toString() + } + } oldDataRequestCode -> if (resultCode == RESULT_OK) data?.data?.let { uri -> ImportOldData.importUri(uri) From ea3db51478fce62d0caa924f68a5735a573af6ed Mon Sep 17 00:00:00 2001 From: kunfei Date: Wed, 26 Feb 2020 20:32:02 +0800 Subject: [PATCH 16/72] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/io/legado/app/model/WebBook.kt | 77 ++++++++++--------- 1 file changed, 40 insertions(+), 37 deletions(-) diff --git a/app/src/main/java/io/legado/app/model/WebBook.kt b/app/src/main/java/io/legado/app/model/WebBook.kt index 4cc2544f5..bb3f80b8d 100644 --- a/app/src/main/java/io/legado/app/model/WebBook.kt +++ b/app/src/main/java/io/legado/app/model/WebBook.kt @@ -86,17 +86,18 @@ class WebBook(val bookSource: BookSource) { ): Coroutine { book.type = bookSource.bookSourceType return Coroutine.async(scope, context) { - val body = if (!book.infoHtml.isNullOrEmpty()) { - book.infoHtml - } else { - val analyzeUrl = AnalyzeUrl( - book = book, - ruleUrl = book.bookUrl, - baseUrl = sourceUrl, - headerMapF = bookSource.getHeaderMap() - ) - analyzeUrl.getResponseAwait().body - } + val body = + if (!book.infoHtml.isNullOrEmpty()) { + book.infoHtml + } else { + val analyzeUrl = AnalyzeUrl( + book = book, + ruleUrl = book.bookUrl, + baseUrl = sourceUrl, + headerMapF = bookSource.getHeaderMap() + ) + analyzeUrl.getResponseAwait().body + } BookInfo.analyzeBookInfo(book, body, bookSource, book.bookUrl) book } @@ -112,16 +113,17 @@ class WebBook(val bookSource: BookSource) { ): Coroutine> { book.type = bookSource.bookSourceType return Coroutine.async(scope, context) { - val body = if (book.bookUrl == book.tocUrl && !book.tocHtml.isNullOrEmpty()) { - book.tocHtml - } else { - AnalyzeUrl( - book = book, - ruleUrl = book.tocUrl, - baseUrl = book.bookUrl, - headerMapF = bookSource.getHeaderMap() - ).getResponseAwait().body - } + val body = + if (book.bookUrl == book.tocUrl && !book.tocHtml.isNullOrEmpty()) { + book.tocHtml + } else { + AnalyzeUrl( + book = book, + ruleUrl = book.tocUrl, + baseUrl = book.bookUrl, + headerMapF = bookSource.getHeaderMap() + ).getResponseAwait().body + } BookChapterList.analyzeChapterList(this, book, body, bookSource, book.tocUrl) } } @@ -141,22 +143,23 @@ class WebBook(val bookSource: BookSource) { Debug.log(sourceUrl, "⇒正文规则为空,使用章节链接:${bookChapter.url}") return@async bookChapter.url } - val body = if (bookChapter.url == book.bookUrl && !book.tocHtml.isNullOrEmpty()) { - book.tocHtml - } else { - val analyzeUrl = - AnalyzeUrl( - book = book, - ruleUrl = bookChapter.url, - baseUrl = book.tocUrl, - headerMapF = bookSource.getHeaderMap() - ) - analyzeUrl.getResponseAwait( - bookSource.bookSourceUrl, - jsStr = bookSource.getContentRule().webJs, - sourceRegex = bookSource.getContentRule().sourceRegex - ).body - } + val body = + if (bookChapter.url == book.bookUrl && !book.tocHtml.isNullOrEmpty()) { + book.tocHtml + } else { + val analyzeUrl = + AnalyzeUrl( + book = book, + ruleUrl = bookChapter.url, + baseUrl = book.tocUrl, + headerMapF = bookSource.getHeaderMap() + ) + analyzeUrl.getResponseAwait( + bookSource.bookSourceUrl, + jsStr = bookSource.getContentRule().webJs, + sourceRegex = bookSource.getContentRule().sourceRegex + ).body + } BookContent.analyzeContent( this, body, From 6b31896cf556f3d8b2ef45072149bbb6284cd7c3 Mon Sep 17 00:00:00 2001 From: kunfei Date: Wed, 26 Feb 2020 21:12:09 +0800 Subject: [PATCH 17/72] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/legado/app/ui/book/arrange/ArrangeBookActivity.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/app/src/main/java/io/legado/app/ui/book/arrange/ArrangeBookActivity.kt b/app/src/main/java/io/legado/app/ui/book/arrange/ArrangeBookActivity.kt index 671736dc8..95dd84d51 100644 --- a/app/src/main/java/io/legado/app/ui/book/arrange/ArrangeBookActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/arrange/ArrangeBookActivity.kt @@ -101,6 +101,7 @@ class ArrangeBookActivity : VMBaseActivity(R.layout.activi App.db.bookDao().observeByGroup(groupId) } booksLiveData?.observe(this, Observer { + adapter.selectedBooks.clear() adapter.setItems(it) upSelectCount() }) From 8fce75a788bb23c84e3023c666731f642fbcc005 Mon Sep 17 00:00:00 2001 From: kunfei Date: Wed, 26 Feb 2020 21:19:26 +0800 Subject: [PATCH 18/72] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/legado/app/ui/book/arrange/ArrangeBookActivity.kt | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/arrange/ArrangeBookActivity.kt b/app/src/main/java/io/legado/app/ui/book/arrange/ArrangeBookActivity.kt index 95dd84d51..c0907f002 100644 --- a/app/src/main/java/io/legado/app/ui/book/arrange/ArrangeBookActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/arrange/ArrangeBookActivity.kt @@ -95,10 +95,11 @@ class ArrangeBookActivity : VMBaseActivity(R.layout.activi private fun initBookData() { booksLiveData?.removeObservers(this) booksLiveData = - if (groupId == -1) { - App.db.bookDao().observeAll() - } else { - App.db.bookDao().observeByGroup(groupId) + when (groupId) { + -1 -> App.db.bookDao().observeAll() + -2 -> App.db.bookDao().observeLocal() + -3 -> App.db.bookDao().observeAudio() + else -> App.db.bookDao().observeByGroup(groupId) } booksLiveData?.observe(this, Observer { adapter.selectedBooks.clear() From b2d0bd5de27960ad2161ed48810e29620abae2d9 Mon Sep 17 00:00:00 2001 From: kunfei Date: Wed, 26 Feb 2020 22:12:47 +0800 Subject: [PATCH 19/72] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/legado/app/ui/book/search/DiffCallBack.kt | 10 ++++++---- .../io/legado/app/ui/book/search/SearchViewModel.kt | 4 ++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/search/DiffCallBack.kt b/app/src/main/java/io/legado/app/ui/book/search/DiffCallBack.kt index 8db633cf8..5dc166987 100644 --- a/app/src/main/java/io/legado/app/ui/book/search/DiffCallBack.kt +++ b/app/src/main/java/io/legado/app/ui/book/search/DiffCallBack.kt @@ -16,10 +16,6 @@ class DiffCallBack(private val oldItems: List, private val newItems: } override fun areItemsTheSame(oldItemPosition: Int, newItemPosition: Int): Boolean { - return true - } - - override fun areContentsTheSame(oldItemPosition: Int, newItemPosition: Int): Boolean { val oldItem = oldItems[oldItemPosition] val newItem = newItems[newItemPosition] if (oldItem.name != newItem.name) { @@ -28,6 +24,12 @@ class DiffCallBack(private val oldItems: List, private val newItems: if (oldItem.author != newItem.author) { return false } + return true + } + + override fun areContentsTheSame(oldItemPosition: Int, newItemPosition: Int): Boolean { + val oldItem = oldItems[oldItemPosition] + val newItem = newItems[newItemPosition] if (oldItem.origins?.size != newItem.origins?.size) { return false } diff --git a/app/src/main/java/io/legado/app/ui/book/search/SearchViewModel.kt b/app/src/main/java/io/legado/app/ui/book/search/SearchViewModel.kt index df104de88..1e780737e 100644 --- a/app/src/main/java/io/legado/app/ui/book/search/SearchViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/book/search/SearchViewModel.kt @@ -130,9 +130,9 @@ class SearchViewModel(application: Application) : BaseViewModel(application) { } } } else if (searchKey == item.author) { - for ((i, searchBook) in copyDataS.withIndex()) { + for ((index, searchBook) in copyDataS.withIndex()) { if (searchKey != searchBook.name && searchKey == searchBook.author) { - copyDataS.add(i, item) + copyDataS.add(index, item) break } } From 37bdfee1950ae27d60a706e169615675112d236c Mon Sep 17 00:00:00 2001 From: kunfei Date: Wed, 26 Feb 2020 23:03:43 +0800 Subject: [PATCH 20/72] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/ui/book/read/page/ContentTextView.kt | 14 +++++++++----- .../io/legado/app/ui/book/read/page/ContentView.kt | 7 +------ .../legado/app/ui/book/search/SearchViewModel.kt | 1 + 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/ContentTextView.kt b/app/src/main/java/io/legado/app/ui/book/read/page/ContentTextView.kt index c31fedde6..35f43c811 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/ContentTextView.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/ContentTextView.kt @@ -47,17 +47,21 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at invalidate() } - override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) { - super.onSizeChanged(w, h, oldw, oldh) - ChapterProvider.viewWidth = w - ChapterProvider.viewHeight = h - ChapterProvider.upSize() + fun upVisibleRect() { visibleRect.set( ChapterProvider.paddingLeft.toFloat(), ChapterProvider.paddingTop.toFloat(), ChapterProvider.visibleRight.toFloat(), ChapterProvider.visibleBottom.toFloat() ) + } + + override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) { + super.onSizeChanged(w, h, oldw, oldh) + ChapterProvider.viewWidth = w + ChapterProvider.viewHeight = h + ChapterProvider.upSize() + upVisibleRect() textPage.format() } diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/ContentView.kt b/app/src/main/java/io/legado/app/ui/book/read/page/ContentView.kt index 98eff7aad..fb60c6361 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/ContentView.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/ContentView.kt @@ -52,12 +52,7 @@ class ContentView(context: Context) : FrameLayout(context) { ll_header.gone() page_panel.setPadding(0, context.statusBarHeight, 0, 0) } - content_text_view.setPadding( - paddingLeft.dp, - paddingTop.dp, - paddingRight.dp, - paddingBottom.dp - ) + content_text_view.upVisibleRect() ll_footer.setPadding( footerPaddingLeft.dp, footerPaddingTop.dp, diff --git a/app/src/main/java/io/legado/app/ui/book/search/SearchViewModel.kt b/app/src/main/java/io/legado/app/ui/book/search/SearchViewModel.kt index 1e780737e..33df6bde5 100644 --- a/app/src/main/java/io/legado/app/ui/book/search/SearchViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/book/search/SearchViewModel.kt @@ -141,6 +141,7 @@ class SearchViewModel(application: Application) : BaseViewModel(application) { } } } + searchBooks = copyDataS searchBookLiveData.postValue(copyDataS) } From 98b8847d241574ebe5dd5c7a45666f2f51766056 Mon Sep 17 00:00:00 2001 From: kunfei Date: Wed, 26 Feb 2020 23:06:54 +0800 Subject: [PATCH 21/72] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/io/legado/app/ui/book/read/page/ContentView.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/ContentView.kt b/app/src/main/java/io/legado/app/ui/book/read/page/ContentView.kt index fb60c6361..7bbc2adc5 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/ContentView.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/ContentView.kt @@ -52,13 +52,13 @@ class ContentView(context: Context) : FrameLayout(context) { ll_header.gone() page_panel.setPadding(0, context.statusBarHeight, 0, 0) } - content_text_view.upVisibleRect() ll_footer.setPadding( footerPaddingLeft.dp, footerPaddingTop.dp, footerPaddingRight.dp, footerPaddingBottom.dp ) + content_text_view.upVisibleRect() durConfig.textColor().let { tv_top_left.setTextColor(it) tv_top_right.setTextColor(it) From ba7d3fa14d2c9d68447df48745fef04c4fb337f0 Mon Sep 17 00:00:00 2001 From: kunfei Date: Wed, 26 Feb 2020 23:17:38 +0800 Subject: [PATCH 22/72] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/io/legado/app/ui/book/read/ReadBookActivity.kt | 2 -- app/src/main/java/io/legado/app/ui/book/read/page/PageView.kt | 1 + 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt b/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt index cf88a03dd..0f08df7c0 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt @@ -33,7 +33,6 @@ import io.legado.app.ui.book.info.BookInfoActivity import io.legado.app.ui.book.read.config.* import io.legado.app.ui.book.read.config.BgTextConfigDialog.Companion.BG_COLOR import io.legado.app.ui.book.read.config.BgTextConfigDialog.Companion.TEXT_COLOR -import io.legado.app.ui.book.read.page.ChapterProvider import io.legado.app.ui.book.read.page.ContentTextView import io.legado.app.ui.book.read.page.PageView import io.legado.app.ui.book.read.page.TextPageFactory @@ -656,7 +655,6 @@ class ReadBookActivity : VMBaseActivity(R.layout.activity_boo upSystemUiVisibility() page_view.upBg() page_view.upStyle() - ChapterProvider.upStyle() if (it) { ReadBook.loadContent() } else { diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/PageView.kt b/app/src/main/java/io/legado/app/ui/book/read/page/PageView.kt index d5a46d734..52acc8195 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/PageView.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/PageView.kt @@ -138,6 +138,7 @@ class PageView(context: Context, attrs: AttributeSet) : } fun upStyle() { + ChapterProvider.upStyle() curPage.upStyle() prevPage.upStyle() nextPage.upStyle() From aacdd2fefd82adb136486ab8a96290a98a1303b8 Mon Sep 17 00:00:00 2001 From: kunfei Date: Thu, 27 Feb 2020 08:09:14 +0800 Subject: [PATCH 23/72] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/assets/updateLog.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/src/main/assets/updateLog.md b/app/src/main/assets/updateLog.md index fdcc66d5d..d260fe346 100644 --- a/app/src/main/assets/updateLog.md +++ b/app/src/main/assets/updateLog.md @@ -2,6 +2,9 @@ * 旧版数据导入教程: * 先在旧版阅读(2.x)中进行备份,然后在新版阅读(3.x)【我的】->【备份与恢复】,选择【导入旧版本数据】。 +**2020/02/27** +* 修复bug,边距调节等一些bug + **2020/02/26** * 修复仿真翻页 * 功能添加: 选择默认字体时, 可选择字体默认字体(非衬线), 系统衬线字体, 系统等宽字体by hingbong From 864a7b4d09501dc351a070f8a7632d13c19e671c Mon Sep 17 00:00:00 2001 From: kunfei Date: Thu, 27 Feb 2020 10:26:34 +0800 Subject: [PATCH 24/72] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/legado/app/data/entities/SearchBook.kt | 10 +++------- .../java/io/legado/app/ui/book/search/DiffCallBack.kt | 6 +++--- .../java/io/legado/app/ui/book/search/SearchAdapter.kt | 4 ++-- 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/io/legado/app/data/entities/SearchBook.kt b/app/src/main/java/io/legado/app/data/entities/SearchBook.kt index edd6f6e56..27f666547 100644 --- a/app/src/main/java/io/legado/app/data/entities/SearchBook.kt +++ b/app/src/main/java/io/legado/app/data/entities/SearchBook.kt @@ -78,16 +78,12 @@ data class SearchBook( variable = GSON.toJson(variableMap) } - @Ignore + @delegate:Ignore @IgnoredOnParcel - var origins: LinkedHashSet? = null - private set + val origins: LinkedHashSet by lazy { linkedSetOf(origin) } fun addOrigin(origin: String) { - if (origins == null) { - origins = linkedSetOf(this.origin) - } - origins?.add(origin) + origins.add(origin) } fun getDisplayLastChapterTitle(): String { diff --git a/app/src/main/java/io/legado/app/ui/book/search/DiffCallBack.kt b/app/src/main/java/io/legado/app/ui/book/search/DiffCallBack.kt index 5dc166987..2bba67405 100644 --- a/app/src/main/java/io/legado/app/ui/book/search/DiffCallBack.kt +++ b/app/src/main/java/io/legado/app/ui/book/search/DiffCallBack.kt @@ -30,7 +30,7 @@ class DiffCallBack(private val oldItems: List, private val newItems: override fun areContentsTheSame(oldItemPosition: Int, newItemPosition: Int): Boolean { val oldItem = oldItems[oldItemPosition] val newItem = newItems[newItemPosition] - if (oldItem.origins?.size != newItem.origins?.size) { + if (oldItem.origins.size != newItem.origins.size) { return false } if (oldItem.coverUrl != newItem.coverUrl) { @@ -58,8 +58,8 @@ class DiffCallBack(private val oldItems: List, private val newItems: if (oldItem.author != newItem.author) { payload.putString("author", newItem.author) } - if (oldItem.origins?.size != newItem.origins?.size) { - payload.putInt("origins", newItem.origins?.size ?: 1) + if (oldItem.origins.size != newItem.origins.size) { + payload.putInt("origins", newItem.origins.size) } if (oldItem.coverUrl != newItem.coverUrl) { payload.putString("group", newItem.coverUrl) diff --git a/app/src/main/java/io/legado/app/ui/book/search/SearchAdapter.kt b/app/src/main/java/io/legado/app/ui/book/search/SearchAdapter.kt index fbdcb99cf..38d1154d6 100644 --- a/app/src/main/java/io/legado/app/ui/book/search/SearchAdapter.kt +++ b/app/src/main/java/io/legado/app/ui/book/search/SearchAdapter.kt @@ -40,7 +40,7 @@ class SearchAdapter(context: Context, val callBack: CallBack) : with(itemView) { tv_name.text = searchBook.name tv_author.text = context.getString(R.string.author_show, searchBook.author) - bv_originCount.setBadgeCount(searchBook.origins?.size ?: 1) + bv_originCount.setBadgeCount(searchBook.origins.size) upLasted(itemView, searchBook.latestChapterTitle) tv_introduce.text = context.getString(R.string.intro_show, searchBook.intro) upKind(itemView, searchBook.getKindList()) @@ -56,7 +56,7 @@ class SearchAdapter(context: Context, val callBack: CallBack) : "name" -> tv_name.text = searchBook.name "author" -> tv_author.text = context.getString(R.string.author_show, searchBook.author) - "originCount" -> bv_originCount.setBadgeCount(searchBook.origins?.size ?: 1) + "originCount" -> bv_originCount.setBadgeCount(searchBook.origins.size) "lasted" -> upLasted(itemView, searchBook.latestChapterTitle) "introduce" -> tv_introduce.text = context.getString(R.string.intro_show, searchBook.intro) From 7fae9506fd452ddca462272a1b093b91c4e75bad Mon Sep 17 00:00:00 2001 From: kunfei Date: Thu, 27 Feb 2020 15:32:35 +0800 Subject: [PATCH 25/72] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/ui/book/read/page/ChapterProvider.kt | 2 +- .../legado/app/ui/book/search/DiffCallBack.kt | 8 +++--- .../app/ui/book/search/SearchAdapter.kt | 6 ++--- .../app/ui/book/search/SearchViewModel.kt | 26 ++++++++++++++++++- 4 files changed, 33 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/ChapterProvider.kt b/app/src/main/java/io/legado/app/ui/book/read/page/ChapterProvider.kt index 4b133a001..dabf7caa3 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/ChapterProvider.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/ChapterProvider.kt @@ -79,7 +79,7 @@ object ChapterProvider { durY = joinBody(text, durY, textPages, pageLines, pageLengths, stringBuilder) } } - textPages.last().height = durY + textPages.last().height = durY + 20.dp textPages.last().text = stringBuilder.toString() if (pageLines.size < textPages.size) { pageLines.add(textPages.last().textLines.size) diff --git a/app/src/main/java/io/legado/app/ui/book/search/DiffCallBack.kt b/app/src/main/java/io/legado/app/ui/book/search/DiffCallBack.kt index 2bba67405..07a3b16c5 100644 --- a/app/src/main/java/io/legado/app/ui/book/search/DiffCallBack.kt +++ b/app/src/main/java/io/legado/app/ui/book/search/DiffCallBack.kt @@ -62,16 +62,16 @@ class DiffCallBack(private val oldItems: List, private val newItems: payload.putInt("origins", newItem.origins.size) } if (oldItem.coverUrl != newItem.coverUrl) { - payload.putString("group", newItem.coverUrl) + payload.putString("cover", newItem.coverUrl) } if (oldItem.kind != newItem.kind) { - payload.putString("enabled", newItem.kind) + payload.putString("kind", newItem.kind) } if (oldItem.latestChapterTitle != newItem.latestChapterTitle) { - payload.putString("enabled", newItem.latestChapterTitle) + payload.putString("last", newItem.latestChapterTitle) } if (oldItem.intro != newItem.intro) { - payload.putString("enabled", newItem.intro) + payload.putString("intro", newItem.intro) } return payload } diff --git a/app/src/main/java/io/legado/app/ui/book/search/SearchAdapter.kt b/app/src/main/java/io/legado/app/ui/book/search/SearchAdapter.kt index 38d1154d6..a96244113 100644 --- a/app/src/main/java/io/legado/app/ui/book/search/SearchAdapter.kt +++ b/app/src/main/java/io/legado/app/ui/book/search/SearchAdapter.kt @@ -56,9 +56,9 @@ class SearchAdapter(context: Context, val callBack: CallBack) : "name" -> tv_name.text = searchBook.name "author" -> tv_author.text = context.getString(R.string.author_show, searchBook.author) - "originCount" -> bv_originCount.setBadgeCount(searchBook.origins.size) - "lasted" -> upLasted(itemView, searchBook.latestChapterTitle) - "introduce" -> tv_introduce.text = + "origins" -> bv_originCount.setBadgeCount(searchBook.origins.size) + "last" -> upLasted(itemView, searchBook.latestChapterTitle) + "intro" -> tv_introduce.text = context.getString(R.string.intro_show, searchBook.intro) "kind" -> upKind(itemView, searchBook.getKindList()) "cover" -> iv_cover.load( diff --git a/app/src/main/java/io/legado/app/ui/book/search/SearchViewModel.kt b/app/src/main/java/io/legado/app/ui/book/search/SearchViewModel.kt index 33df6bde5..f56ad21d6 100644 --- a/app/src/main/java/io/legado/app/ui/book/search/SearchViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/book/search/SearchViewModel.kt @@ -141,7 +141,31 @@ class SearchViewModel(application: Application) : BaseViewModel(application) { } } } - + searchBooks.sortWith(Comparator { o1, o2 -> + if (o1.name == searchKey && o2.name != searchKey) { + 1 + } else if (o1.name != searchKey && o2.name == searchKey) { + -1 + } else if (o1.author == searchKey && o2.author != searchKey) { + 1 + } else if (o1.author != searchKey && o2.author == searchKey) { + -1 + } else if (o1.name == o2.name) { + when { + o1.origins.size > o2.origins.size -> { + 1 + } + o1.origins.size < o2.origins.size -> { + -1 + } + else -> { + 0 + } + } + } else { + 0 + } + }) searchBooks = copyDataS searchBookLiveData.postValue(copyDataS) } From 5727d11946b0ac177a7feee63966d109aecd3eee Mon Sep 17 00:00:00 2001 From: kunfei Date: Thu, 27 Feb 2020 15:52:09 +0800 Subject: [PATCH 26/72] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/io/legado/app/ui/book/search/SearchViewModel.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/search/SearchViewModel.kt b/app/src/main/java/io/legado/app/ui/book/search/SearchViewModel.kt index f56ad21d6..47671626d 100644 --- a/app/src/main/java/io/legado/app/ui/book/search/SearchViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/book/search/SearchViewModel.kt @@ -85,8 +85,8 @@ class SearchViewModel(application: Application) : BaseViewModel(application) { private fun precisionSearch(searchBooks: List) { val books = arrayListOf() searchBooks.forEach { searchBook -> - if (searchBook.name.equals(searchKey, true) - || searchBook.author.equals(searchKey, true) + if (searchBook.name.contains(searchKey, true) + || searchBook.author.contains(searchKey, true) ) books.add(searchBook) } App.db.searchBookDao().insert(*books.toTypedArray()) From 00065900485958ab0b20ac7b9e412d519fe8a9d2 Mon Sep 17 00:00:00 2001 From: kunfei Date: Thu, 27 Feb 2020 15:54:59 +0800 Subject: [PATCH 27/72] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/legado/app/ui/changesource/ChangeSourceViewModel.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/io/legado/app/ui/changesource/ChangeSourceViewModel.kt b/app/src/main/java/io/legado/app/ui/changesource/ChangeSourceViewModel.kt index 13b145a1e..1a683427f 100644 --- a/app/src/main/java/io/legado/app/ui/changesource/ChangeSourceViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/changesource/ChangeSourceViewModel.kt @@ -58,7 +58,7 @@ class ChangeSourceViewModel(application: Application) : BaseViewModel(applicatio App.db.searchBookDao().insert(searchBook) if (screenKey.isEmpty()) { searchBooks.add(searchBook) - } else if (searchBook.originName.contains(screenKey)) { + } else if (searchBook.name.contains(screenKey)) { searchBooks.add(searchBook) } upAdapter() From 02d42edaf7f7a506e804322985e49201858695e6 Mon Sep 17 00:00:00 2001 From: kunfei Date: Thu, 27 Feb 2020 15:59:18 +0800 Subject: [PATCH 28/72] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/assets/updateLog.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/src/main/assets/updateLog.md b/app/src/main/assets/updateLog.md index d260fe346..730c5320f 100644 --- a/app/src/main/assets/updateLog.md +++ b/app/src/main/assets/updateLog.md @@ -3,7 +3,8 @@ * 先在旧版阅读(2.x)中进行备份,然后在新版阅读(3.x)【我的】->【备份与恢复】,选择【导入旧版本数据】。 **2020/02/27** -* 修复bug,边距调节等一些bug +* 修复bug,边距调节,换源等一些bug,记不清了 +* 改了下包名,好上架应用市场 **2020/02/26** * 修复仿真翻页 From f876dbce2089cc234abb42407d52bf88df9986bc Mon Sep 17 00:00:00 2001 From: kunfei Date: Thu, 27 Feb 2020 16:57:17 +0800 Subject: [PATCH 29/72] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/ui/widget/font/FontSelectDialog.kt | 39 ++++++++----------- 1 file changed, 17 insertions(+), 22 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/widget/font/FontSelectDialog.kt b/app/src/main/java/io/legado/app/ui/widget/font/FontSelectDialog.kt index 0e2f21213..6732bf985 100644 --- a/app/src/main/java/io/legado/app/ui/widget/font/FontSelectDialog.kt +++ b/app/src/main/java/io/legado/app/ui/widget/font/FontSelectDialog.kt @@ -89,17 +89,14 @@ class FontSelectDialog : BaseDialogFragment(), override fun onMenuItemClick(item: MenuItem?): Boolean { when (item?.itemId) { R.id.menu_default -> { - val cb = (parentFragment as? CallBack) ?: (activity as? CallBack) - cb?.let { - val requireContext = requireContext() - requireContext.alert(titleResource = R.string.system_typeface) { - items(requireContext.resources.getStringArray(R.array.system_typefaces).toList()) { _, i -> - AppConfig.systemTypefaces = i - onDefaultFontChange(it) - } - }.show() - } - dismiss() + val requireContext = requireContext() + requireContext.alert(titleResource = R.string.system_typeface) { + items(requireContext.resources.getStringArray(R.array.system_typefaces).toList()) { _, i -> + AppConfig.systemTypefaces = i + onDefaultFontChange() + dismiss() + } + }.show() } R.id.menu_other -> { openFolder() @@ -212,12 +209,9 @@ class FontSelectDialog : BaseDialogFragment(), launch(IO) { file.copyTo(FileUtils.createFileIfNotExist(fontFolder, file.name), true) .absolutePath.let { path -> - val cb = (parentFragment as? CallBack) ?: (activity as? CallBack) - cb?.let { - if (it.curFontPath != path) { - withContext(Main) { - it.selectFile(path) - } + if (callBack?.curFontPath != path) { + withContext(Main) { + callBack?.selectFile(path) } } } @@ -226,9 +220,7 @@ class FontSelectDialog : BaseDialogFragment(), } override fun curFilePath(): String { - return (parentFragment as? CallBack)?.curFontPath - ?: (activity as? CallBack)?.curFontPath - ?: "" + return callBack?.curFontPath ?: "" } override fun onFilePicked(requestCode: Int, currentPath: String) { @@ -263,14 +255,17 @@ class FontSelectDialog : BaseDialogFragment(), } } - private fun onDefaultFontChange(callBack: CallBack) { + private fun onDefaultFontChange() { if (curFilePath() == "") { postEvent(EventBus.UP_CONFIG, true) } else { - callBack.selectFile("") + callBack?.selectFile("") } } + private val callBack: CallBack? + get() = (parentFragment as? CallBack) ?: (activity as? CallBack) + interface CallBack { fun selectFile(path: String) val curFontPath: String From 85f9fe59f684703b78a1c3294c9d777d0742a26e Mon Sep 17 00:00:00 2001 From: kunfei Date: Thu, 27 Feb 2020 16:59:49 +0800 Subject: [PATCH 30/72] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/legado/app/ui/widget/font/FontAdapter.kt | 4 ++-- .../io/legado/app/ui/widget/font/FontSelectDialog.kt | 10 ++++------ 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/widget/font/FontAdapter.kt b/app/src/main/java/io/legado/app/ui/widget/font/FontAdapter.kt index f7c73030a..f2724abcd 100644 --- a/app/src/main/java/io/legado/app/ui/widget/font/FontAdapter.kt +++ b/app/src/main/java/io/legado/app/ui/widget/font/FontAdapter.kt @@ -20,7 +20,7 @@ class FontAdapter(context: Context, val callBack: CallBack) : tv_font.typeface = typeface tv_font.text = item.name this.onClick { callBack.onClick(item) } - if (item.name == callBack.curFilePath().substringAfterLast(File.separator)) { + if (item.name == callBack.curFilePath.substringAfterLast(File.separator)) { iv_checked.visible() } else { iv_checked.invisible() @@ -38,6 +38,6 @@ class FontAdapter(context: Context, val callBack: CallBack) : interface CallBack { fun onClick(file: File) - fun curFilePath(): String + val curFilePath: String } } \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/ui/widget/font/FontSelectDialog.kt b/app/src/main/java/io/legado/app/ui/widget/font/FontSelectDialog.kt index 6732bf985..f72484338 100644 --- a/app/src/main/java/io/legado/app/ui/widget/font/FontSelectDialog.kt +++ b/app/src/main/java/io/legado/app/ui/widget/font/FontSelectDialog.kt @@ -209,7 +209,7 @@ class FontSelectDialog : BaseDialogFragment(), launch(IO) { file.copyTo(FileUtils.createFileIfNotExist(fontFolder, file.name), true) .absolutePath.let { path -> - if (callBack?.curFontPath != path) { + if (curFilePath != path) { withContext(Main) { callBack?.selectFile(path) } @@ -219,10 +219,6 @@ class FontSelectDialog : BaseDialogFragment(), } } - override fun curFilePath(): String { - return callBack?.curFontPath ?: "" - } - override fun onFilePicked(requestCode: Int, currentPath: String) { when (requestCode) { fontFolderRequestCode -> { @@ -256,13 +252,15 @@ class FontSelectDialog : BaseDialogFragment(), } private fun onDefaultFontChange() { - if (curFilePath() == "") { + if (curFilePath == "") { postEvent(EventBus.UP_CONFIG, true) } else { callBack?.selectFile("") } } + override val curFilePath: String get() = callBack?.curFontPath ?: "" + private val callBack: CallBack? get() = (parentFragment as? CallBack) ?: (activity as? CallBack) From 8a76129ce1de2129a45f40e772224232e34e01d9 Mon Sep 17 00:00:00 2001 From: kunfei Date: Thu, 27 Feb 2020 17:09:59 +0800 Subject: [PATCH 31/72] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/assets/updateLog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/app/src/main/assets/updateLog.md b/app/src/main/assets/updateLog.md index 730c5320f..4e003f418 100644 --- a/app/src/main/assets/updateLog.md +++ b/app/src/main/assets/updateLog.md @@ -4,6 +4,7 @@ **2020/02/27** * 修复bug,边距调节,换源等一些bug,记不清了 +* 修复字体选择问题 * 改了下包名,好上架应用市场 **2020/02/26** From 6b73533992826933ecc11ea527c2cce3e42247ef Mon Sep 17 00:00:00 2001 From: kunfei Date: Thu, 27 Feb 2020 17:10:56 +0800 Subject: [PATCH 32/72] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/assets/updateLog.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/assets/updateLog.md b/app/src/main/assets/updateLog.md index 4e003f418..8e1d73878 100644 --- a/app/src/main/assets/updateLog.md +++ b/app/src/main/assets/updateLog.md @@ -4,7 +4,7 @@ **2020/02/27** * 修复bug,边距调节,换源等一些bug,记不清了 -* 修复字体选择问题 +* 修复默认字体问题 * 改了下包名,好上架应用市场 **2020/02/26** From c1bcea6964b5b1f603f855da45f98e250d1d5b17 Mon Sep 17 00:00:00 2001 From: kunfei Date: Thu, 27 Feb 2020 17:32:59 +0800 Subject: [PATCH 33/72] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../legado/app/ui/config/BackupRestoreUi.kt | 37 +++++++++++++------ 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/config/BackupRestoreUi.kt b/app/src/main/java/io/legado/app/ui/config/BackupRestoreUi.kt index ddc41afce..f314b5f1b 100644 --- a/app/src/main/java/io/legado/app/ui/config/BackupRestoreUi.kt +++ b/app/src/main/java/io/legado/app/ui/config/BackupRestoreUi.kt @@ -49,21 +49,30 @@ object BackupRestoreUi { selectBackupFolder(fragment, backupSelectRequestCode) } } else { - backupUsePermission(fragment) + backupUsePermission(fragment, requestCode = backupSelectRequestCode) } } } - private fun backupUsePermission(fragment: Fragment, path: String = Backup.legadoPath) { + private fun backupUsePermission( + fragment: Fragment, + path: String = Backup.legadoPath, + requestCode: Int = selectFolderRequestCode + ) { PermissionsCompat.Builder(fragment) .addPermissions(*Permissions.Group.STORAGE) .rationale(R.string.tip_perm_request_storage) .onGranted { - Coroutine.async { - AppConfig.backupPath = Backup.legadoPath - Backup.backup(fragment.requireContext(), path) - }.onSuccess { - fragment.toast(R.string.backup_success) + when (requestCode) { + selectFolderRequestCode -> AppConfig.backupPath = Backup.legadoPath + else -> { + Coroutine.async { + AppConfig.backupPath = Backup.legadoPath + Backup.backup(fragment.requireContext(), path) + }.onSuccess { + fragment.toast(R.string.backup_success) + } + } } } .request() @@ -74,7 +83,7 @@ object BackupRestoreUi { titleResource = R.string.select_folder items(fragment.resources.getStringArray(R.array.select_folder).toList()) { _, index -> when (index) { - 0 -> backupUsePermission(fragment) + 0 -> backupUsePermission(fragment, requestCode = requestCode) 1 -> { try { val intent = Intent(Intent.ACTION_OPEN_DOCUMENT_TREE) @@ -231,6 +240,9 @@ object BackupRestoreUi { App.INSTANCE.toast(R.string.restore_success) } } + selectFolderRequestCode -> { + AppConfig.backupPath = currentPath + } } } @@ -240,7 +252,8 @@ object BackupRestoreUi { data?.data?.let { uri -> App.INSTANCE.contentResolver.takePersistableUriPermission( uri, - Intent.FLAG_GRANT_READ_URI_PERMISSION or Intent.FLAG_GRANT_WRITE_URI_PERMISSION + Intent.FLAG_GRANT_READ_URI_PERMISSION + or Intent.FLAG_GRANT_WRITE_URI_PERMISSION ) AppConfig.backupPath = uri.toString() Coroutine.async { @@ -254,7 +267,8 @@ object BackupRestoreUi { data?.data?.let { uri -> App.INSTANCE.contentResolver.takePersistableUriPermission( uri, - Intent.FLAG_GRANT_READ_URI_PERMISSION or Intent.FLAG_GRANT_WRITE_URI_PERMISSION + Intent.FLAG_GRANT_READ_URI_PERMISSION + or Intent.FLAG_GRANT_WRITE_URI_PERMISSION ) AppConfig.backupPath = uri.toString() Coroutine.async { @@ -268,7 +282,8 @@ object BackupRestoreUi { data?.data?.let { uri -> App.INSTANCE.contentResolver.takePersistableUriPermission( uri, - Intent.FLAG_GRANT_READ_URI_PERMISSION or Intent.FLAG_GRANT_WRITE_URI_PERMISSION + Intent.FLAG_GRANT_READ_URI_PERMISSION + or Intent.FLAG_GRANT_WRITE_URI_PERMISSION ) AppConfig.backupPath = uri.toString() } From 4dd307ab22e8491471407fca5630d48e273c087e Mon Sep 17 00:00:00 2001 From: kunfei Date: Thu, 27 Feb 2020 17:42:35 +0800 Subject: [PATCH 34/72] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/legado/app/service/HttpReadAloudService.kt | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/io/legado/app/service/HttpReadAloudService.kt b/app/src/main/java/io/legado/app/service/HttpReadAloudService.kt index 2cf46831c..c30180391 100644 --- a/app/src/main/java/io/legado/app/service/HttpReadAloudService.kt +++ b/app/src/main/java/io/legado/app/service/HttpReadAloudService.kt @@ -5,16 +5,14 @@ import android.media.MediaPlayer import io.legado.app.constant.EventBus import io.legado.app.help.AppConfig import io.legado.app.help.IntentHelp +import io.legado.app.help.coroutine.Coroutine import io.legado.app.help.http.HttpHelper import io.legado.app.help.http.api.HttpPostApi import io.legado.app.service.help.ReadBook import io.legado.app.utils.FileUtils import io.legado.app.utils.LogUtils import io.legado.app.utils.postEvent -import kotlinx.coroutines.Dispatchers.IO -import kotlinx.coroutines.Job import kotlinx.coroutines.isActive -import kotlinx.coroutines.launch import java.io.File import java.io.FileDescriptor import java.io.FileInputStream @@ -27,7 +25,7 @@ class HttpReadAloudService : BaseReadAloudService(), private val mediaPlayer = MediaPlayer() private lateinit var ttsFolder: String - private var job: Job? = null + private var task: Coroutine<*>? = null private var playingIndex = -1 override fun onCreate() { @@ -40,13 +38,13 @@ class HttpReadAloudService : BaseReadAloudService(), override fun onDestroy() { super.onDestroy() - job?.cancel() + task?.cancel() mediaPlayer.release() } override fun newReadAloud(dataKey: String?, play: Boolean) { mediaPlayer.reset() - job?.cancel() + task?.cancel() playingIndex = -1 super.newReadAloud(dataKey, play) } @@ -64,7 +62,7 @@ class HttpReadAloudService : BaseReadAloudService(), } private fun downloadAudio() { - job = launch(IO) { + task = execute { FileUtils.deleteFile(ttsFolder) for (index in 0 until contentList.size) { if (isActive) { @@ -150,7 +148,7 @@ class HttpReadAloudService : BaseReadAloudService(), * 更新朗读速度 */ override fun upSpeechRate(reset: Boolean) { - job?.cancel() + task?.cancel() mediaPlayer.stop() playingIndex = -1 downloadAudio() From a7661f191c3abaa521f7fa9cf2aa6d569ae7f749 Mon Sep 17 00:00:00 2001 From: kunfei Date: Thu, 27 Feb 2020 18:45:59 +0800 Subject: [PATCH 35/72] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/io/legado/app/service/HttpReadAloudService.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/io/legado/app/service/HttpReadAloudService.kt b/app/src/main/java/io/legado/app/service/HttpReadAloudService.kt index c30180391..9b4b56ebe 100644 --- a/app/src/main/java/io/legado/app/service/HttpReadAloudService.kt +++ b/app/src/main/java/io/legado/app/service/HttpReadAloudService.kt @@ -13,6 +13,7 @@ import io.legado.app.utils.FileUtils import io.legado.app.utils.LogUtils import io.legado.app.utils.postEvent import kotlinx.coroutines.isActive +import org.jetbrains.anko.toast import java.io.File import java.io.FileDescriptor import java.io.FileInputStream @@ -44,7 +45,6 @@ class HttpReadAloudService : BaseReadAloudService(), override fun newReadAloud(dataKey: String?, play: Boolean) { mediaPlayer.reset() - task?.cancel() playingIndex = -1 super.newReadAloud(dataKey, play) } @@ -62,6 +62,7 @@ class HttpReadAloudService : BaseReadAloudService(), } private fun downloadAudio() { + task?.cancel() task = execute { FileUtils.deleteFile(ttsFolder) for (index in 0 until contentList.size) { @@ -83,6 +84,8 @@ class HttpReadAloudService : BaseReadAloudService(), break } } + }.onError { + toast("下载朗读文件出错:${it.localizedMessage}") } } From 1871fed127b570e7803dc39659fa308beb19336f Mon Sep 17 00:00:00 2001 From: kunfei Date: Thu, 27 Feb 2020 19:44:51 +0800 Subject: [PATCH 36/72] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/legado/app/ui/book/read/page/ChapterProvider.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/ChapterProvider.kt b/app/src/main/java/io/legado/app/ui/book/read/page/ChapterProvider.kt index dabf7caa3..a0ab804c1 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/ChapterProvider.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/ChapterProvider.kt @@ -146,7 +146,7 @@ object ChapterProvider { title.substring(layout.getLineStart(lineIndex), layout.getLineEnd(lineIndex)) stringBuilder.append(words) textLine.text = words - val desiredWidth = layout.getLineMax(lineIndex) + val desiredWidth = layout.getLineWidth(lineIndex) if (lineIndex != layout.lineCount - 1) { val gapCount: Int = words.length - 1 val d = (visibleWidth - desiredWidth) / gapCount @@ -168,7 +168,7 @@ object ChapterProvider { textLine.text = "$words\n" stringBuilder.append("\n") var x = if (ReadBookConfig.titleCenter) - (visibleWidth - layout.getLineMax(lineIndex)) / 2 + (visibleWidth - layout.getLineWidth(lineIndex)) / 2 else 0f for (i in words.indices) { val char = words[i].toString() @@ -229,7 +229,7 @@ object ChapterProvider { text.substring(layout.getLineStart(lineIndex), layout.getLineEnd(lineIndex)) stringBuilder.append(words) textLine.text = words - val desiredWidth = layout.getLineMax(lineIndex) + val desiredWidth = layout.getLineWidth(lineIndex) if (lineIndex == 0 && layout.lineCount > 1) { //第一行 var x = 0f From 20486e7852d62c9f0d1d3bc1e40574ef72a23de0 Mon Sep 17 00:00:00 2001 From: kunfei Date: Thu, 27 Feb 2020 20:55:29 +0800 Subject: [PATCH 37/72] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/service/CheckSourceService.kt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/src/main/java/io/legado/app/service/CheckSourceService.kt b/app/src/main/java/io/legado/app/service/CheckSourceService.kt index 18f704a6e..67874f9e4 100644 --- a/app/src/main/java/io/legado/app/service/CheckSourceService.kt +++ b/app/src/main/java/io/legado/app/service/CheckSourceService.kt @@ -14,6 +14,7 @@ import io.legado.app.model.WebBook import io.legado.app.ui.book.source.manage.BookSourceActivity import kotlinx.coroutines.Dispatchers.IO import kotlinx.coroutines.asCoroutineDispatcher +import org.jetbrains.anko.toast import java.util.concurrent.Executors class CheckSourceService : BaseService() { @@ -68,6 +69,8 @@ class CheckSourceService : BaseService() { } } } + }.onError { + toast("校验书源出错:${it.localizedMessage}") } task?.invokeOnCompletion { From 6cc2e8b140747264a9335c87c50fdaaae1930902 Mon Sep 17 00:00:00 2001 From: kunfei Date: Thu, 27 Feb 2020 23:08:22 +0800 Subject: [PATCH 38/72] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/ui/book/read/page/ChapterProvider.kt | 172 +++++++++--------- .../ui/book/read/page/entities/TextChar.kt | 4 +- .../ui/book/read/page/entities/TextLine.kt | 8 +- .../io/legado/app/utils/StringExtensions.kt | 12 +- 4 files changed, 103 insertions(+), 93 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/ChapterProvider.kt b/app/src/main/java/io/legado/app/ui/book/read/page/ChapterProvider.kt index a0ab804c1..4a9d5bb71 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/ChapterProvider.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/ChapterProvider.kt @@ -12,7 +12,6 @@ import io.legado.app.help.AppConfig import io.legado.app.help.BookHelp import io.legado.app.help.ReadBookConfig import io.legado.app.ui.book.read.page.entities.TextChapter -import io.legado.app.ui.book.read.page.entities.TextChar import io.legado.app.ui.book.read.page.entities.TextLine import io.legado.app.ui.book.read.page.entities.TextPage import io.legado.app.utils.dp @@ -148,40 +147,13 @@ object ChapterProvider { textLine.text = words val desiredWidth = layout.getLineWidth(lineIndex) if (lineIndex != layout.lineCount - 1) { - val gapCount: Int = words.length - 1 - val d = (visibleWidth - desiredWidth) / gapCount - var x = 0f - for (i in words.indices) { - val char = words[i].toString() - val cw = StaticLayout.getDesiredWidth(char, titlePaint) - val x1 = if (i != words.lastIndex) (x + cw + d) else (x + cw) - val textChar = TextChar( - charData = char, - start = paddingLeft + x, - end = paddingLeft + x1 - ) - textLine.textChars.add(textChar) - x = x1 - } + addCharsToLineMiddle(textLine, words, titlePaint, desiredWidth, 0f) } else { //最后一行 - textLine.text = "$words\n" - stringBuilder.append("\n") - var x = if (ReadBookConfig.titleCenter) + val x = if (ReadBookConfig.titleCenter) (visibleWidth - layout.getLineWidth(lineIndex)) / 2 else 0f - for (i in words.indices) { - val char = words[i].toString() - val cw = StaticLayout.getDesiredWidth(char, titlePaint) - val x1 = x + cw - val textChar = TextChar( - charData = char, - start = paddingLeft + x, - end = paddingLeft + x1 - ) - textLine.textChars.add(textChar) - x = x1 - } + addCharsToLineLast(textLine, words, stringBuilder, titlePaint, x) } } durY += paragraphSpacing @@ -225,80 +197,102 @@ object ChapterProvider { textLine.lineBase = (paddingTop + durY - (layout.getLineBottom(lineIndex) - layout.getLineBaseline(lineIndex))).toFloat() textLine.lineBottom = textLine.lineBase + contentPaint.fontMetrics.descent - var words = + val words = text.substring(layout.getLineStart(lineIndex), layout.getLineEnd(lineIndex)) stringBuilder.append(words) textLine.text = words val desiredWidth = layout.getLineWidth(lineIndex) if (lineIndex == 0 && layout.lineCount > 1) { //第一行 - var x = 0f - val icw = StaticLayout.getDesiredWidth(bodyIndent, contentPaint) / bodyIndent.length - for (i in 0..bodyIndent.lastIndex) { - val x1 = x + icw - val textChar = TextChar( - charData = bodyIndent[i].toString(), - start = paddingLeft + x, - end = paddingLeft + x1 - ) - textLine.textChars.add(textChar) - x = x1 - } - words = words.replaceFirst(bodyIndent, "") - val gapCount: Int = words.length - 1 - val d = (visibleWidth - desiredWidth) / gapCount - for (i in words.indices) { - val char = words[i].toString() - val cw = StaticLayout.getDesiredWidth(char, contentPaint) - val x1 = if (i != words.lastIndex) x + cw + d else x + cw - val textChar1 = TextChar( - charData = char, - start = paddingLeft + x, - end = paddingLeft + x1 - ) - textLine.textChars.add(textChar1) - x = x1 - } + addCharsToLineFirst(textLine, words, contentPaint, desiredWidth) } else if (lineIndex == layout.lineCount - 1) { //最后一行 - stringBuilder.append("\n") - textLine.text = "$words\n" - var x = 0f - for (i in words.indices) { - val char = words[i].toString() - val cw = StaticLayout.getDesiredWidth(char, contentPaint) - val x1 = x + cw - val textChar = TextChar( - charData = char, - start = paddingLeft + x, - end = paddingLeft + x1 - ) - textLine.textChars.add(textChar) - x = x1 - } + addCharsToLineLast(textLine, words, stringBuilder, contentPaint, 0f) } else { //中间行 - val gapCount: Int = words.length - 1 - val d = (visibleWidth - desiredWidth) / gapCount - var x = 0f - for (i in words.indices) { - val char = words[i].toString() - val cw = StaticLayout.getDesiredWidth(char, contentPaint) - val x1 = if (i != words.lastIndex) x + cw + d else x + cw - val textChar = TextChar( - charData = char, - start = paddingLeft + x, - end = paddingLeft + x1 - ) - textLine.textChars.add(textChar) - x = x1 - } + addCharsToLineMiddle(textLine, words, contentPaint, desiredWidth, 0f) } } durY += paragraphSpacing return durY } + /** + * 有缩进,两端对齐 + */ + private fun addCharsToLineFirst( + textLine: TextLine, + words: String, + textPaint: TextPaint, + desiredWidth: Float + ) { + var x = 0f + val icw = StaticLayout.getDesiredWidth(bodyIndent, textPaint) / bodyIndent.length + for (i in 0..bodyIndent.lastIndex) { + val x1 = x + icw + textLine.addTextChar( + charData = bodyIndent[i].toString(), + start = paddingLeft + x, + end = paddingLeft + x1 + ) + x = x1 + } + val words1 = words.replaceFirst(bodyIndent, "") + addCharsToLineMiddle(textLine, words1, textPaint, desiredWidth, x) + } + + /** + * 无缩进,两端对齐 + */ + private fun addCharsToLineMiddle( + textLine: TextLine, + words: String, + textPaint: TextPaint, + desiredWidth: Float, + startX: Float + ) { + val gapCount: Int = words.length - 1 + val d = (visibleWidth - desiredWidth) / gapCount + var x = startX + for (i in words.indices) { + val char = words[i] + val cw = StaticLayout.getDesiredWidth(char.toString(), textPaint) + val x1 = if (i != words.lastIndex) (x + cw + d) else (x + cw) + textLine.addTextChar( + charData = char.toString(), + start = paddingLeft + x, + end = paddingLeft + x1 + ) + x = x1 + } + } + + /** + * 最后一行,自然排列 + */ + private fun addCharsToLineLast( + textLine: TextLine, + words: String, + stringBuilder: StringBuilder, + textPaint: TextPaint, + startX: Float + ) { + stringBuilder.append("\n") + textLine.text = "$words\n" + var x = startX + for (i in words.indices) { + val char = words[i].toString() + val cw = StaticLayout.getDesiredWidth(char, textPaint) + val x1 = x + cw + textLine.addTextChar( + charData = char, + start = paddingLeft + x, + end = paddingLeft + x1 + ) + x = x1 + } + } + /** * 更新样式 diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/entities/TextChar.kt b/app/src/main/java/io/legado/app/ui/book/read/page/entities/TextChar.kt index 6fed2fe97..642fc0dc6 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/entities/TextChar.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/entities/TextChar.kt @@ -2,7 +2,7 @@ package io.legado.app.ui.book.read.page.entities data class TextChar( val charData: String, - var selected: Boolean = false, val start: Float, - val end: Float + val end: Float, + var selected: Boolean = false ) \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/entities/TextLine.kt b/app/src/main/java/io/legado/app/ui/book/read/page/entities/TextLine.kt index 26fb31e90..547ad085d 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/entities/TextLine.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/entities/TextLine.kt @@ -8,4 +8,10 @@ data class TextLine( var lineBottom: Float = 0f, val isTitle: Boolean = false, var isReadAloud: Boolean = false -) \ No newline at end of file +) { + + fun addTextChar(charData: String, start: Float, end: Float) { + textChars.add(TextChar(charData, start = start, end = end)) + } + +} diff --git a/app/src/main/java/io/legado/app/utils/StringExtensions.kt b/app/src/main/java/io/legado/app/utils/StringExtensions.kt index 63954162e..3f4f40ee2 100644 --- a/app/src/main/java/io/legado/app/utils/StringExtensions.kt +++ b/app/src/main/java/io/legado/app/utils/StringExtensions.kt @@ -48,4 +48,14 @@ fun String.splitNotBlank(regex: Regex, limit: Int = 0): Array = run { this.split(regex, limit).map { it.trim() }.filterNot { it.isBlank() }.toTypedArray() } - +fun Char?.isHAN(): Boolean { + this ?: return false + val ub: Character.UnicodeBlock = Character.UnicodeBlock.of(this) ?: return false + return ub === Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS + || ub === Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS_EXTENSION_A + || ub === Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS_EXTENSION_B + || ub === Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS_EXTENSION_C + || ub === Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS_EXTENSION_D + || ub === Character.UnicodeBlock.CJK_COMPATIBILITY_IDEOGRAPHS + || ub === Character.UnicodeBlock.CJK_COMPATIBILITY_IDEOGRAPHS_SUPPLEMENT +} From e1c8c7c8e22da5c275864cd667faa259a6521519 Mon Sep 17 00:00:00 2001 From: hingbong Date: Thu, 27 Feb 2020 23:24:28 +0800 Subject: [PATCH 39/72] =?UTF-8?q?=E9=98=85=E8=AF=BB=E7=95=8C=E9=9D=A2?= =?UTF-8?q?=E5=B7=A6=E4=B8=8B=E8=A7=92=E7=AB=A0=E8=8A=82=E5=90=8D=E7=BB=9F?= =?UTF-8?q?=E4=B8=80=E7=AE=80=E4=BD=93/=E7=B9=81=E4=BD=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle | 2 +- .../java/io/legado/app/ui/book/read/page/ContentView.kt | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index d6f63988d..1b0c7d4b0 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -140,7 +140,7 @@ dependencies { implementation 'com.jeremyliao:live-event-bus-x:1.4.5' //协程 - def coroutines_version = '1.2.2' + def coroutines_version = '1.3.3' implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version" implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutines_version" diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/ContentView.kt b/app/src/main/java/io/legado/app/ui/book/read/page/ContentView.kt index 7bbc2adc5..7f1dcec1c 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/ContentView.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/ContentView.kt @@ -5,8 +5,10 @@ import android.content.Context import android.graphics.drawable.Drawable import android.view.MotionEvent import android.widget.FrameLayout +import com.github.houbb.opencc4j.core.impl.ZhConvertBootstrap import io.legado.app.R import io.legado.app.constant.AppConst.TIME_FORMAT +import io.legado.app.help.AppConfig import io.legado.app.help.ReadBookConfig import io.legado.app.ui.book.read.page.entities.TextPage import io.legado.app.utils.* @@ -90,7 +92,11 @@ class ContentView(context: Context) : FrameLayout(context) { } fun setContent(textPage: TextPage) { - tv_bottom_left.text = textPage.title + tv_bottom_left.text = when (AppConfig.chineseConverterType) { + 1 -> ZhConvertBootstrap.newInstance().toSimple(textPage.title) + 2 -> ZhConvertBootstrap.newInstance().toTraditional(textPage.title) + else -> textPage.title + } setPageIndex(textPage.index, textPage.pageSize) content_text_view.resetPageOffset() content_text_view.setContent(textPage) From b15928026c271cf78f61df96fb22adc1020361b0 Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 28 Feb 2020 09:04:25 +0800 Subject: [PATCH 40/72] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/ui/book/read/page/ChapterProvider.kt | 18 ++++++++++++++++++ .../app/ui/book/read/page/entities/TextChar.kt | 4 ++-- .../app/ui/book/read/page/entities/TextLine.kt | 11 +++++++++++ 3 files changed, 31 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/ChapterProvider.kt b/app/src/main/java/io/legado/app/ui/book/read/page/ChapterProvider.kt index 4a9d5bb71..2c3996fd8 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/ChapterProvider.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/ChapterProvider.kt @@ -265,6 +265,7 @@ object ChapterProvider { ) x = x1 } + exceed(textLine, words) } /** @@ -291,8 +292,25 @@ object ChapterProvider { ) x = x1 } + exceed(textLine, words) } + /** + * 超出边界处理 + */ + private fun exceed(textLine: TextLine, words: String) { + val endX = textLine.textChars.last().end + if (endX > visibleRight) { + val cc = (endX - visibleRight) / words.length + for (i in 0..words.lastIndex) { + textLine.getTextCharReverseAt(i).let { + val py = cc * (words.length - i) + it.start = it.start - py + it.end = it.end - py + } + } + } + } /** * 更新样式 diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/entities/TextChar.kt b/app/src/main/java/io/legado/app/ui/book/read/page/entities/TextChar.kt index 642fc0dc6..72798a9ea 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/entities/TextChar.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/entities/TextChar.kt @@ -2,7 +2,7 @@ package io.legado.app.ui.book.read.page.entities data class TextChar( val charData: String, - val start: Float, - val end: Float, + var start: Float, + var end: Float, var selected: Boolean = false ) \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/entities/TextLine.kt b/app/src/main/java/io/legado/app/ui/book/read/page/entities/TextLine.kt index 547ad085d..a9c84fb68 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/entities/TextLine.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/entities/TextLine.kt @@ -14,4 +14,15 @@ data class TextLine( textChars.add(TextChar(charData, start = start, end = end)) } + fun getTextCharAt(index: Int): TextChar { + return textChars[index] + } + + fun getTextCharReverseAt(index: Int): TextChar { + return textChars[textChars.lastIndex - index] + } + + fun getTextCharsCount(): Int { + return textChars.size + } } From 8f5545931da8a6cb3a4dbfdcebf7f655deeb1e45 Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 28 Feb 2020 09:53:48 +0800 Subject: [PATCH 41/72] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/assets/updateLog.md | 4 ++ .../app/ui/widget/image/CircleImageView.kt | 40 +++++++------------ .../res/layout/dialog_read_book_style.xml | 5 +++ 3 files changed, 23 insertions(+), 26 deletions(-) diff --git a/app/src/main/assets/updateLog.md b/app/src/main/assets/updateLog.md index 8e1d73878..7bf8ec04a 100644 --- a/app/src/main/assets/updateLog.md +++ b/app/src/main/assets/updateLog.md @@ -2,6 +2,10 @@ * 旧版数据导入教程: * 先在旧版阅读(2.x)中进行备份,然后在新版阅读(3.x)【我的】->【备份与恢复】,选择【导入旧版本数据】。 +**2020/02/28** +* 解决阅读界面部分字体超出范围的问题 +* + **2020/02/27** * 修复bug,边距调节,换源等一些bug,记不清了 * 修复默认字体问题 diff --git a/app/src/main/java/io/legado/app/ui/widget/image/CircleImageView.kt b/app/src/main/java/io/legado/app/ui/widget/image/CircleImageView.kt index 253c1bef3..7f14686e8 100644 --- a/app/src/main/java/io/legado/app/ui/widget/image/CircleImageView.kt +++ b/app/src/main/java/io/legado/app/ui/widget/image/CircleImageView.kt @@ -24,7 +24,11 @@ import io.legado.app.utils.sp import kotlin.math.min import kotlin.math.pow -class CircleImageView : AppCompatImageView { +class CircleImageView(context: Context, attrs: AttributeSet) : + AppCompatImageView( + context, + attrs + ) { private val mDrawableRect = RectF() private val mBorderRect = RectF() @@ -59,10 +63,9 @@ class CircleImageView : AppCompatImageView { private var mBorderOverlay: Boolean = false var isDisableCircularTransformation: Boolean = false set(disableCircularTransformation) { - if (isDisableCircularTransformation == disableCircularTransformation) { + if (field == disableCircularTransformation) { return } - field = disableCircularTransformation initializeBitmap() } @@ -85,7 +88,6 @@ class CircleImageView : AppCompatImageView { if (circleBackgroundColor == mCircleBackgroundColor) { return } - mCircleBackgroundColor = circleBackgroundColor mCircleBackgroundPaint.color = circleBackgroundColor invalidate() @@ -117,23 +119,14 @@ class CircleImageView : AppCompatImageView { private var textColor = context.getCompatColor(R.color.tv_text_default) - constructor(context: Context) : super(context) { - init() - } - - @JvmOverloads - constructor(context: Context, attrs: AttributeSet, defStyle: Int = 0) : super( - context, - attrs, - defStyle - ) { - - val a = context.obtainStyledAttributes(attrs, R.styleable.CircleImageView, defStyle, 0) - - mBorderWidth = a.getDimensionPixelSize( - R.styleable.CircleImageView_civ_border_width, - DEFAULT_BORDER_WIDTH - ) + init { + super.setScaleType(SCALE_TYPE) + val a = context.obtainStyledAttributes(attrs, R.styleable.CircleImageView) + mBorderWidth = + a.getDimensionPixelSize( + R.styleable.CircleImageView_civ_border_width, + DEFAULT_BORDER_WIDTH + ) mBorderColor = a.getColor(R.styleable.CircleImageView_civ_border_color, DEFAULT_BORDER_COLOR) mBorderOverlay = @@ -152,11 +145,6 @@ class CircleImageView : AppCompatImageView { } a.recycle() - init() - } - - private fun init() { - super.setScaleType(SCALE_TYPE) mReady = true if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { diff --git a/app/src/main/res/layout/dialog_read_book_style.xml b/app/src/main/res/layout/dialog_read_book_style.xml index 358d68063..2e6c05061 100644 --- a/app/src/main/res/layout/dialog_read_book_style.xml +++ b/app/src/main/res/layout/dialog_read_book_style.xml @@ -269,6 +269,7 @@ android:id="@+id/bg0" android:layout_width="48dp" android:layout_height="48dp" + android:src="@drawable/image_cover_default" app:civ_border_color="@color/tv_text_default" app:civ_border_width="1dp" app:text="@string/text" @@ -281,6 +282,7 @@ android:id="@+id/bg1" android:layout_width="48dp" android:layout_height="48dp" + android:src="@drawable/image_cover_default" app:civ_border_color="@color/tv_text_default" app:civ_border_width="1dp" app:text="@string/text" @@ -293,6 +295,7 @@ android:id="@+id/bg2" android:layout_width="48dp" android:layout_height="48dp" + android:src="@drawable/image_cover_default" app:civ_border_color="@color/tv_text_default" app:civ_border_width="1dp" app:text="@string/text" @@ -305,6 +308,7 @@ android:id="@+id/bg3" android:layout_width="48dp" android:layout_height="48dp" + android:src="@drawable/image_cover_default" app:civ_border_color="@color/tv_text_default" app:civ_border_width="1dp" app:text="@string/text" @@ -317,6 +321,7 @@ android:id="@+id/bg4" android:layout_width="48dp" android:layout_height="48dp" + android:src="@drawable/image_cover_default" app:civ_border_color="@color/tv_text_default" app:civ_border_width="1dp" app:text="@string/text" From 8152b4e87976f4e8a5979ab9037b458dc2f4ff24 Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 28 Feb 2020 10:01:28 +0800 Subject: [PATCH 42/72] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/AndroidManifest.xml | 14 ++++++++++++-- .../ui/rss/source/manage/RssSourceActivity.kt | 17 +++++++++++++++++ 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index a8ebd70da..563605c91 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -142,7 +142,6 @@ - @@ -152,7 +151,18 @@ - + + + + + + + + + + diff --git a/app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceActivity.kt b/app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceActivity.kt index 517290130..22277476e 100644 --- a/app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceActivity.kt +++ b/app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceActivity.kt @@ -57,6 +57,7 @@ class RssSourceActivity : VMBaseActivity(R.layout.activity_r private var groupMenu: SubMenu? = null override fun onActivityCreated(savedInstanceState: Bundle?) { + initUriScheme() initRecyclerView() initSearchView() initLiveDataGroup() @@ -102,6 +103,22 @@ class RssSourceActivity : VMBaseActivity(R.layout.activity_r return true } + private fun initUriScheme() { + intent.data?.let { + when (it.path) { + "/importonline" -> it.getQueryParameter("src")?.let { url -> + Snackbar.make(title_bar, R.string.importing, Snackbar.LENGTH_INDEFINITE).show() + viewModel.importSource(url) { msg -> + title_bar.snackbar(msg) + } + } + else -> { + toast("格式不对") + } + } + } + } + private fun initRecyclerView() { ATH.applyEdgeEffectColor(recycler_view) recycler_view.layoutManager = LinearLayoutManager(this) From 98b75d547bdfeb9a98b6380316955bcc0073ae39 Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 28 Feb 2020 10:28:16 +0800 Subject: [PATCH 43/72] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/assets/updateLog.md | 3 ++- .../app/ui/book/read/page/ContentTextView.kt | 24 ++++++++++++------- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/app/src/main/assets/updateLog.md b/app/src/main/assets/updateLog.md index 7bf8ec04a..3a564b3fa 100644 --- a/app/src/main/assets/updateLog.md +++ b/app/src/main/assets/updateLog.md @@ -4,7 +4,8 @@ **2020/02/28** * 解决阅读界面部分字体超出范围的问题 -* +* 修复背景切换有时空白的bug +* 修复滚动翻页问题 **2020/02/27** * 修复bug,边距调节,换源等一些bug,记不清了 diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/ContentTextView.kt b/app/src/main/java/io/legado/app/ui/book/read/page/ContentTextView.kt index 35f43c811..1bd474c89 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/ContentTextView.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/ContentTextView.kt @@ -164,15 +164,23 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at pageOffset += offset if (pageOffset > 0) { - pageFactory.moveToPrev() - textPage = pageFactory.currentPage - pageOffset -= textPage.height - upView?.invoke(textPage) + if (!pageFactory.hasPrev()) { + pageOffset = 0f + } else { + pageFactory.moveToPrev() + textPage = pageFactory.currentPage + pageOffset -= textPage.height + upView?.invoke(textPage) + } } else if (pageOffset < -textPage.height) { - pageOffset += textPage.height - pageFactory.moveToNext() - textPage = pageFactory.currentPage - upView?.invoke(textPage) + if (!pageFactory.hasNext()) { + pageOffset = -textPage.height.toFloat() + } else { + pageOffset += textPage.height + pageFactory.moveToNext() + textPage = pageFactory.currentPage + upView?.invoke(textPage) + } } invalidate() } From ae3581d29cd3738733b94c67708290f49e98ae53 Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 28 Feb 2020 11:17:49 +0800 Subject: [PATCH 44/72] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/io/legado/app/base/BaseDialogFragment.kt | 9 +++++++++ .../io/legado/app/ui/widget/font/FontSelectDialog.kt | 4 +++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/io/legado/app/base/BaseDialogFragment.kt b/app/src/main/java/io/legado/app/base/BaseDialogFragment.kt index 8bb119625..e893e34c4 100644 --- a/app/src/main/java/io/legado/app/base/BaseDialogFragment.kt +++ b/app/src/main/java/io/legado/app/base/BaseDialogFragment.kt @@ -2,6 +2,7 @@ package io.legado.app.base import android.os.Bundle import androidx.fragment.app.DialogFragment +import io.legado.app.help.coroutine.Coroutine import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Job @@ -21,4 +22,12 @@ abstract class BaseDialogFragment : DialogFragment(), CoroutineScope { super.onDestroy() job.cancel() } + + fun execute( + scope: CoroutineScope = this, + context: CoroutineContext = Dispatchers.IO, + block: suspend CoroutineScope.() -> T + ): Coroutine { + return Coroutine.async(scope, context) { block() } + } } \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/ui/widget/font/FontSelectDialog.kt b/app/src/main/java/io/legado/app/ui/widget/font/FontSelectDialog.kt index f72484338..87d87e8d6 100644 --- a/app/src/main/java/io/legado/app/ui/widget/font/FontSelectDialog.kt +++ b/app/src/main/java/io/legado/app/ui/widget/font/FontSelectDialog.kt @@ -147,7 +147,7 @@ class FontSelectDialog : BaseDialogFragment(), @SuppressLint("DefaultLocale") private fun getFontFiles(doc: DocumentFile) { - launch(IO) { + execute { val docItems = DocumentUtils.listFiles(App.INSTANCE, doc.uri) fontCacheFolder.listFiles()?.forEach { fontFile -> var contain = false @@ -182,6 +182,8 @@ class FontSelectDialog : BaseDialogFragment(), } catch (e: Exception) { toast(e.localizedMessage ?: "") } + }.onError { + toast("getFontFiles:${it.localizedMessage}") } } From dee067557e91825e2378492414d5ee4a21a5526b Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 28 Feb 2020 11:34:10 +0800 Subject: [PATCH 45/72] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/help/ReadBookConfig.kt | 4 ++-- .../io/legado/app/ui/book/read/config/ReadStyleDialog.kt | 8 +------- app/src/main/java/io/legado/app/utils/BitmapUtils.kt | 7 ++++++- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/io/legado/app/help/ReadBookConfig.kt b/app/src/main/java/io/legado/app/help/ReadBookConfig.kt index 3b05df869..63b59278f 100644 --- a/app/src/main/java/io/legado/app/help/ReadBookConfig.kt +++ b/app/src/main/java/io/legado/app/help/ReadBookConfig.kt @@ -215,7 +215,7 @@ object ReadBookConfig { class Config( private var bgStr: String = "#EEEEEE",//白天背景 private var bgStrNight: String = "#000000",//夜间背景 - private var bgType: Int = 0,//白天背景类型 + private var bgType: Int = 0,//白天背景类型 0:颜色, 1:assets图片, 2其它图片 private var bgTypeNight: Int = 0,//夜间背景类型 private var darkStatusIcon: Boolean = true,//白天是否暗色状态栏 private var darkStatusIconNight: Boolean = false,//晚上是否暗色状态栏 @@ -299,7 +299,7 @@ object ReadBookConfig { 1 -> { BitmapDrawable( resources, - BitmapUtils.decodeBitmap( + BitmapUtils.decodeAssetsBitmap( App.INSTANCE, "bg" + File.separator + bgStr(), width, diff --git a/app/src/main/java/io/legado/app/ui/book/read/config/ReadStyleDialog.kt b/app/src/main/java/io/legado/app/ui/book/read/config/ReadStyleDialog.kt index c78466569..b7a0a330b 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/config/ReadStyleDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/config/ReadStyleDialog.kt @@ -12,7 +12,6 @@ import io.legado.app.R import io.legado.app.constant.EventBus import io.legado.app.constant.PreferKey import io.legado.app.help.BookHelp -import io.legado.app.help.ImageLoader import io.legado.app.help.ReadBookConfig import io.legado.app.lib.dialogs.selector import io.legado.app.lib.theme.accentColor @@ -219,12 +218,7 @@ class ReadStyleDialog : DialogFragment(), FontSelectDialog.CallBack { 4 -> bg4 else -> bg0 } - ReadBookConfig.getConfig(i).apply { - when (bgType()) { - 2 -> ImageLoader.load(requireContext(), bgStr()).centerCrop().into(iv) - else -> iv.setImageDrawable(bgDrawable(100, 150)) - } - } + iv.setImageDrawable(ReadBookConfig.getConfig(i).bgDrawable(100, 150)) } } diff --git a/app/src/main/java/io/legado/app/utils/BitmapUtils.kt b/app/src/main/java/io/legado/app/utils/BitmapUtils.kt index 14212f442..371be8122 100644 --- a/app/src/main/java/io/legado/app/utils/BitmapUtils.kt +++ b/app/src/main/java/io/legado/app/utils/BitmapUtils.kt @@ -121,7 +121,12 @@ object BitmapUtils { * @throws IOException */ @Throws(IOException::class) - fun decodeBitmap(context: Context, fileNameInAssets: String, width: Int, height: Int): Bitmap? { + fun decodeAssetsBitmap( + context: Context, + fileNameInAssets: String, + width: Int, + height: Int + ): Bitmap? { var inputStream = context.assets.open(fileNameInAssets) val op = BitmapFactory.Options() From 034978da883aa471c189127ef00298709f38b260 Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 28 Feb 2020 12:36:37 +0800 Subject: [PATCH 46/72] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/ui/rss/read/ReadRssActivity.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/app/src/main/java/io/legado/app/ui/rss/read/ReadRssActivity.kt b/app/src/main/java/io/legado/app/ui/rss/read/ReadRssActivity.kt index ebaf05233..bb5700967 100644 --- a/app/src/main/java/io/legado/app/ui/rss/read/ReadRssActivity.kt +++ b/app/src/main/java/io/legado/app/ui/rss/read/ReadRssActivity.kt @@ -66,6 +66,7 @@ class ReadRssActivity : VMBaseActivity(R.layout.activity_rss_r webView.settings.apply { mixedContentMode = WebSettings.MIXED_CONTENT_ALWAYS_ALLOW domStorageEnabled = true + allowContentAccess = true } } From b6ed0f44e344cae089febd82fb1b0adb19e3c6ce Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 28 Feb 2020 13:55:15 +0800 Subject: [PATCH 47/72] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../legado/app/ui/rss/read/ReadRssActivity.kt | 18 +++++++++++++++++- .../io/legado/app/utils/ContextExtensions.kt | 6 +++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/rss/read/ReadRssActivity.kt b/app/src/main/java/io/legado/app/ui/rss/read/ReadRssActivity.kt index bb5700967..255505178 100644 --- a/app/src/main/java/io/legado/app/ui/rss/read/ReadRssActivity.kt +++ b/app/src/main/java/io/legado/app/ui/rss/read/ReadRssActivity.kt @@ -5,7 +5,9 @@ import android.os.Bundle import android.view.KeyEvent import android.view.Menu import android.view.MenuItem +import android.webkit.WebResourceRequest import android.webkit.WebSettings +import android.webkit.WebView import android.webkit.WebViewClient import androidx.lifecycle.Observer import io.legado.app.R @@ -14,6 +16,7 @@ import io.legado.app.lib.theme.DrawableUtils import io.legado.app.lib.theme.primaryTextColor import io.legado.app.utils.NetworkUtils import io.legado.app.utils.getViewModel +import io.legado.app.utils.openUrl import kotlinx.android.synthetic.main.activity_rss_read.* import kotlinx.coroutines.launch import org.apache.commons.text.StringEscapeUtils @@ -62,7 +65,20 @@ class ReadRssActivity : VMBaseActivity(R.layout.activity_rss_r } private fun initWebView() { - webView.webViewClient = WebViewClient() + webView.webViewClient = object : WebViewClient() { + override fun shouldOverrideUrlLoading( + view: WebView?, + request: WebResourceRequest? + ): Boolean { + if (request?.url?.scheme == "http" || request?.url?.scheme == "https") { + return false + } + request?.url?.let { + openUrl(it) + } + return true + } + } webView.settings.apply { mixedContentMode = WebSettings.MIXED_CONTENT_ALWAYS_ALLOW domStorageEnabled = true diff --git a/app/src/main/java/io/legado/app/utils/ContextExtensions.kt b/app/src/main/java/io/legado/app/utils/ContextExtensions.kt index 2f05fa014..febb0989a 100644 --- a/app/src/main/java/io/legado/app/utils/ContextExtensions.kt +++ b/app/src/main/java/io/legado/app/utils/ContextExtensions.kt @@ -149,8 +149,12 @@ val Context.sysBattery: Int } fun Context.openUrl(url: String) { + openUrl(Uri.parse(url)) +} + +fun Context.openUrl(uri: Uri) { val intent = Intent(Intent.ACTION_VIEW) - intent.data = Uri.parse(url) + intent.data = uri if (intent.resolveActivity(packageManager) != null) { try { startActivity(intent) From 2f89fb2524e4c73b3e2de77bfa9c4871c54b2d60 Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 28 Feb 2020 13:56:38 +0800 Subject: [PATCH 48/72] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/assets/updateLog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/app/src/main/assets/updateLog.md b/app/src/main/assets/updateLog.md index 3a564b3fa..6401e565f 100644 --- a/app/src/main/assets/updateLog.md +++ b/app/src/main/assets/updateLog.md @@ -6,6 +6,7 @@ * 解决阅读界面部分字体超出范围的问题 * 修复背景切换有时空白的bug * 修复滚动翻页问题 +* 添加书源一键导入 **2020/02/27** * 修复bug,边距调节,换源等一些bug,记不清了 From 373d062cd4501ab158a92e571a9df73e260c5f75 Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 28 Feb 2020 14:11:52 +0800 Subject: [PATCH 49/72] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/AndroidManifest.xml | 33 ++++++++++++++----- .../app/ui/replacerule/ReplaceRuleActivity.kt | 17 ++++++++++ 2 files changed, 41 insertions(+), 9 deletions(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 563605c91..ba4789e2c 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -123,9 +123,6 @@ - @@ -135,8 +132,8 @@ - - + + @@ -147,10 +144,7 @@ android:scheme="yuedu" /> - - - - + @@ -163,6 +157,27 @@ android:scheme="yuedu" /> + + + + + + + + + + + + + + + + + diff --git a/app/src/main/java/io/legado/app/ui/replacerule/ReplaceRuleActivity.kt b/app/src/main/java/io/legado/app/ui/replacerule/ReplaceRuleActivity.kt index 331c87a5d..5044e2667 100644 --- a/app/src/main/java/io/legado/app/ui/replacerule/ReplaceRuleActivity.kt +++ b/app/src/main/java/io/legado/app/ui/replacerule/ReplaceRuleActivity.kt @@ -55,6 +55,7 @@ class ReplaceRuleActivity : VMBaseActivity(R.layout.activi private var dataInit = false override fun onActivityCreated(savedInstanceState: Bundle?) { + initUriScheme() initRecyclerView() initSearchView() initSelectActionView() @@ -73,6 +74,22 @@ class ReplaceRuleActivity : VMBaseActivity(R.layout.activi return super.onPrepareOptionsMenu(menu) } + private fun initUriScheme() { + intent.data?.let { + when (it.path) { + "/importonline" -> it.getQueryParameter("src")?.let { url -> + Snackbar.make(title_bar, R.string.importing, Snackbar.LENGTH_INDEFINITE).show() + viewModel.importSource(url) { msg -> + title_bar.snackbar(msg) + } + } + else -> { + toast("格式不对") + } + } + } + } + private fun initRecyclerView() { ATH.applyEdgeEffectColor(recycler_view) recycler_view.layoutManager = LinearLayoutManager(this) From 51c0ac8f1b88e71598632410f88365ee5dc42c67 Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 28 Feb 2020 14:12:34 +0800 Subject: [PATCH 50/72] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/AndroidManifest.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index ba4789e2c..e4bc75603 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -132,7 +132,6 @@ - From a17cd1fb7b58b10ecd5c93b5b4fcfc8e7a5a7d13 Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 28 Feb 2020 14:46:34 +0800 Subject: [PATCH 51/72] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/io/legado/app/ui/book/read/ReadBookActivity.kt | 2 +- .../java/io/legado/app/ui/book/read/page/ContentTextView.kt | 1 + .../main/java/io/legado/app/ui/book/read/page/PageView.kt | 5 ----- .../io/legado/app/ui/book/read/page/delegate/PageDelegate.kt | 4 ---- 4 files changed, 2 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt b/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt index 0f08df7c0..48bdd6cf6 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt @@ -691,7 +691,7 @@ class ReadBookActivity : VMBaseActivity(R.layout.activity_boo upScreenTimeOut() } observeEvent(PreferKey.textSelectAble) { - page_view.upSelectAble(it) + page_view.curPage.upSelectAble(it) } } diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/ContentTextView.kt b/app/src/main/java/io/legado/app/ui/book/read/page/ContentTextView.kt index 1bd474c89..d17e55a67 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/ContentTextView.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/ContentTextView.kt @@ -197,6 +197,7 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at y: Float, select: (relativePage: Int, lineIndex: Int, charIndex: Int) -> Unit ) { + if (!selectAble) return if (!visibleRect.contains(x, y)) return var relativeOffset = relativeOffset(0) for ((lineIndex, textLine) in textPage.textLines.withIndex()) { diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/PageView.kt b/app/src/main/java/io/legado/app/ui/book/read/page/PageView.kt index 52acc8195..1482d309a 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/PageView.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/PageView.kt @@ -132,11 +132,6 @@ class PageView(context: Context, attrs: AttributeSet) : } } - fun upSelectAble(selectAble: Boolean) { - pageDelegate?.upSelectAble(selectAble) - curPage.upSelectAble(selectAble) - } - fun upStyle() { ChapterProvider.upStyle() curPage.upStyle() diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/delegate/PageDelegate.kt b/app/src/main/java/io/legado/app/ui/book/read/page/delegate/PageDelegate.kt index c710367c7..2b26714c4 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/delegate/PageDelegate.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/delegate/PageDelegate.kt @@ -101,10 +101,6 @@ abstract class PageDelegate(protected val pageView: PageView) : onScroll() } - fun upSelectAble(selectAble: Boolean) { - detector.setIsLongpressEnabled(selectAble) - } - open fun fling( startX: Int, startY: Int, velocityX: Int, velocityY: Int, minX: Int, maxX: Int, minY: Int, maxY: Int From c380d1e7e7f621d136960048eef9ac8e12095b33 Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 28 Feb 2020 15:12:45 +0800 Subject: [PATCH 52/72] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/App.kt | 7 ++++++- app/src/main/java/io/legado/app/utils/ContextExtensions.kt | 3 +++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/io/legado/app/App.kt b/app/src/main/java/io/legado/app/App.kt index 7310dcef8..24ebd1270 100644 --- a/app/src/main/java/io/legado/app/App.kt +++ b/app/src/main/java/io/legado/app/App.kt @@ -5,6 +5,7 @@ import android.app.Application import android.app.NotificationChannel import android.app.NotificationManager import android.content.Context +import android.content.res.Configuration import android.os.Build import android.os.Bundle import androidx.annotation.RequiresApi @@ -62,6 +63,11 @@ class App : Application() { registerActivityLife() } + override fun onConfigurationChanged(newConfig: Configuration) { + super.onConfigurationChanged(newConfig) + initNightMode() + } + /** * 更新主题 */ @@ -91,7 +97,6 @@ class App : Application() { ) .apply() } -// ChapterProvider.upReadAloudSpan() } fun applyDayNight() { diff --git a/app/src/main/java/io/legado/app/utils/ContextExtensions.kt b/app/src/main/java/io/legado/app/utils/ContextExtensions.kt index febb0989a..3436c9d94 100644 --- a/app/src/main/java/io/legado/app/utils/ContextExtensions.kt +++ b/app/src/main/java/io/legado/app/utils/ContextExtensions.kt @@ -133,6 +133,9 @@ fun Context.sendToClip(text: String) { } } +/** + * 系统是否暗色主题 + */ fun Context.sysIsDarkMode(): Boolean { val mode = resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK return mode == Configuration.UI_MODE_NIGHT_YES From 9e4fd23fb6431b95cf00028751428cab1dfc6ddc Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 28 Feb 2020 15:17:40 +0800 Subject: [PATCH 53/72] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/help/ReadBookConfig.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/io/legado/app/help/ReadBookConfig.kt b/app/src/main/java/io/legado/app/help/ReadBookConfig.kt index 63b59278f..57ccd5f14 100644 --- a/app/src/main/java/io/legado/app/help/ReadBookConfig.kt +++ b/app/src/main/java/io/legado/app/help/ReadBookConfig.kt @@ -34,7 +34,7 @@ object ReadBookConfig { var shareLayout = App.INSTANCE.getPrefBoolean(PreferKey.shareLayout) set(value) { field = value - App.INSTANCE.putPrefBoolean(PreferKey.shareLayout) + App.INSTANCE.putPrefBoolean(PreferKey.shareLayout, value) } var pageAnim = App.INSTANCE.getPrefInt(PreferKey.pageAnim) set(value) { From ffb8ed4b66bf57e743a3ab09b6b02be6f78d1b1e Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 28 Feb 2020 15:27:08 +0800 Subject: [PATCH 54/72] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/help/storage/Restore.kt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/src/main/java/io/legado/app/help/storage/Restore.kt b/app/src/main/java/io/legado/app/help/storage/Restore.kt index 9fd939f74..dd48d6472 100644 --- a/app/src/main/java/io/legado/app/help/storage/Restore.kt +++ b/app/src/main/java/io/legado/app/help/storage/Restore.kt @@ -12,6 +12,8 @@ import io.legado.app.constant.PreferKey import io.legado.app.data.entities.* import io.legado.app.help.LauncherIconHelp import io.legado.app.help.ReadBookConfig +import io.legado.app.service.help.ReadBook +import io.legado.app.ui.book.read.page.ChapterProvider import io.legado.app.utils.* import kotlinx.coroutines.Dispatchers.IO import kotlinx.coroutines.withContext @@ -113,6 +115,8 @@ object Restore { hideStatusBar = App.INSTANCE.getPrefBoolean(PreferKey.hideStatusBar) hideNavigationBar = App.INSTANCE.getPrefBoolean(PreferKey.hideNavigationBar) } + ChapterProvider.upStyle() + ReadBook.loadContent() } LauncherIconHelp.changeIcon(App.INSTANCE.getPrefString(PreferKey.launcherIcon)) } From ecd221930a7850a434ebc38b248978e6cbfdfcac Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 28 Feb 2020 15:31:53 +0800 Subject: [PATCH 55/72] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/App.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/io/legado/app/App.kt b/app/src/main/java/io/legado/app/App.kt index 24ebd1270..996f449d7 100644 --- a/app/src/main/java/io/legado/app/App.kt +++ b/app/src/main/java/io/legado/app/App.kt @@ -65,7 +65,9 @@ class App : Application() { override fun onConfigurationChanged(newConfig: Configuration) { super.onConfigurationChanged(newConfig) - initNightMode() + when (newConfig.uiMode and Configuration.UI_MODE_NIGHT_MASK) { + Configuration.UI_MODE_NIGHT_YES, Configuration.UI_MODE_NIGHT_NO -> initNightMode() + } } /** From eb1af6df3b48d548a2fd74e037cfb10655da9d02 Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 28 Feb 2020 15:34:17 +0800 Subject: [PATCH 56/72] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/App.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/io/legado/app/App.kt b/app/src/main/java/io/legado/app/App.kt index 996f449d7..cf0f4cf43 100644 --- a/app/src/main/java/io/legado/app/App.kt +++ b/app/src/main/java/io/legado/app/App.kt @@ -66,7 +66,7 @@ class App : Application() { override fun onConfigurationChanged(newConfig: Configuration) { super.onConfigurationChanged(newConfig) when (newConfig.uiMode and Configuration.UI_MODE_NIGHT_MASK) { - Configuration.UI_MODE_NIGHT_YES, Configuration.UI_MODE_NIGHT_NO -> initNightMode() + Configuration.UI_MODE_NIGHT_YES, Configuration.UI_MODE_NIGHT_NO -> applyDayNight() } } From acc9b0738e21d4d828e636c190d06f44c02466c0 Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 28 Feb 2020 16:12:38 +0800 Subject: [PATCH 57/72] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/assets/updateLog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/app/src/main/assets/updateLog.md b/app/src/main/assets/updateLog.md index 6401e565f..3e30d56af 100644 --- a/app/src/main/assets/updateLog.md +++ b/app/src/main/assets/updateLog.md @@ -7,6 +7,7 @@ * 修复背景切换有时空白的bug * 修复滚动翻页问题 * 添加书源一键导入 +* 修复主题模式跟随系统 **2020/02/27** * 修复bug,边距调节,换源等一些bug,记不清了 From 46081225e93de05e7114e8b0e48ea5a0d9529e4c Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 28 Feb 2020 17:10:24 +0800 Subject: [PATCH 58/72] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../legado/app/ui/widget/prefs/IconListPreference.kt | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/widget/prefs/IconListPreference.kt b/app/src/main/java/io/legado/app/ui/widget/prefs/IconListPreference.kt index ff3fa801c..b295e5ad3 100644 --- a/app/src/main/java/io/legado/app/ui/widget/prefs/IconListPreference.kt +++ b/app/src/main/java/io/legado/app/ui/widget/prefs/IconListPreference.kt @@ -167,8 +167,14 @@ class IconListPreference(context: Context, attrs: AttributeSet) : ListPreference dialogIconNames?.let { val resId = context.resources .getIdentifier(it[index].toString(), "mipmap", context.packageName) - val d = context.getCompatDrawable(resId) - icon.setImageDrawable(d) + val d = try { + context.getCompatDrawable(resId) + } catch (e: Exception) { + null + } + d?.let { + icon.setImageDrawable(d) + } } label.isChecked = item.toString() == dialogValue onClick { From e49ff9567724b23c37125fc68f7535d59b9a5233 Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 28 Feb 2020 17:28:50 +0800 Subject: [PATCH 59/72] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/io/legado/app/ui/qrcode/QrCodeActivity.kt | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/qrcode/QrCodeActivity.kt b/app/src/main/java/io/legado/app/ui/qrcode/QrCodeActivity.kt index bfd4d23a1..6ea1d85bd 100644 --- a/app/src/main/java/io/legado/app/ui/qrcode/QrCodeActivity.kt +++ b/app/src/main/java/io/legado/app/ui/qrcode/QrCodeActivity.kt @@ -2,6 +2,7 @@ package io.legado.app.ui.qrcode import android.app.Activity import android.content.Intent +import android.graphics.BitmapFactory import android.os.Bundle import android.view.Menu import android.view.MenuItem @@ -11,7 +12,7 @@ import io.legado.app.R import io.legado.app.base.BaseActivity import io.legado.app.help.permission.Permissions import io.legado.app.help.permission.PermissionsCompat -import io.legado.app.utils.RealPathUtil +import io.legado.app.utils.readBytes import kotlinx.android.synthetic.main.activity_qrcode_capture.* import kotlinx.android.synthetic.main.view_title_bar.* import org.jetbrains.anko.toast @@ -98,9 +99,11 @@ class QrCodeActivity : BaseActivity(R.layout.activity_qrcode_capture), QRCodeVie zxingview.startSpotAndShowRect() // 显示扫描框,并开始识别 if (resultCode == Activity.RESULT_OK && requestCode == requestQrImage) { - val picturePath = RealPathUtil.getPath(this, it) // 本来就用到 QRCodeView 时可直接调 QRCodeView 的方法,走通用的回调 - zxingview.decodeQRCode(picturePath) + it.readBytes(this)?.let { bytes -> + val bitmap = BitmapFactory.decodeByteArray(bytes, 0, bytes.size) + zxingview.decodeQRCode(bitmap) + } } } } From f9c1183580307f582f3557c874e178cd3971d2da Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 28 Feb 2020 19:24:16 +0800 Subject: [PATCH 60/72] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../legado/app/service/CheckSourceService.kt | 25 +++++++++---------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/app/src/main/java/io/legado/app/service/CheckSourceService.kt b/app/src/main/java/io/legado/app/service/CheckSourceService.kt index 67874f9e4..d94b3a6d1 100644 --- a/app/src/main/java/io/legado/app/service/CheckSourceService.kt +++ b/app/src/main/java/io/legado/app/service/CheckSourceService.kt @@ -21,8 +21,8 @@ class CheckSourceService : BaseService() { private var searchPool = Executors.newFixedThreadPool(AppConfig.threadCount).asCoroutineDispatcher() private var task: Coroutine<*>? = null - private var idsCount = 0 - private val unCheckIds = LinkedHashSet() + private val allIds = LinkedHashSet() + private val checkedIds = LinkedHashSet() override fun onCreate() { super.onCreate() @@ -47,12 +47,12 @@ class CheckSourceService : BaseService() { private fun check(ids: List) { task?.cancel() - unCheckIds.clear() - idsCount = ids.size - unCheckIds.addAll(ids) - updateNotification(0, getString(R.string.progress_show, 0, idsCount)) - task = execute { - unCheckIds.forEach { sourceUrl -> + allIds.clear() + checkedIds.clear() + allIds.addAll(ids) + updateNotification(0, getString(R.string.progress_show, 0, allIds.size)) + task = execute(context = searchPool) { + allIds.forEach { sourceUrl -> App.db.bookSourceDao().getBookSource(sourceUrl)?.let { source -> val webBook = WebBook(source) webBook.searchBook("我的", scope = this, context = searchPool) @@ -60,11 +60,10 @@ class CheckSourceService : BaseService() { source.addGroup("失效") App.db.bookSourceDao().update(source) }.onFinally { - unCheckIds.remove(sourceUrl) - val checkedCount = idsCount - unCheckIds.size + checkedIds.add(sourceUrl) updateNotification( - checkedCount, - getString(R.string.progress_show, checkedCount, idsCount) + checkedIds.size, + getString(R.string.progress_show, checkedIds.size, allIds.size) ) } } @@ -95,7 +94,7 @@ class CheckSourceService : BaseService() { getString(R.string.cancel), IntentHelp.servicePendingIntent(this, IntentAction.stop) ) - builder.setProgress(idsCount, state, false) + builder.setProgress(allIds.size, state, false) builder.setVisibility(NotificationCompat.VISIBILITY_PUBLIC) val notification = builder.build() startForeground(112202, notification) From d7017bd39a948c589b2341a5c777a8577bc55d9f Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 28 Feb 2020 19:29:22 +0800 Subject: [PATCH 61/72] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/assets/updateLog.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/src/main/assets/updateLog.md b/app/src/main/assets/updateLog.md index 3e30d56af..9bf7bcd87 100644 --- a/app/src/main/assets/updateLog.md +++ b/app/src/main/assets/updateLog.md @@ -2,12 +2,15 @@ * 旧版数据导入教程: * 先在旧版阅读(2.x)中进行备份,然后在新版阅读(3.x)【我的】->【备份与恢复】,选择【导入旧版本数据】。 +**2020/02/29** +* 添加书源一键导入 +* 修复主题模式跟随系统 +* 修复书源校验 + **2020/02/28** * 解决阅读界面部分字体超出范围的问题 * 修复背景切换有时空白的bug * 修复滚动翻页问题 -* 添加书源一键导入 -* 修复主题模式跟随系统 **2020/02/27** * 修复bug,边距调节,换源等一些bug,记不清了 From 531baaccb3f927938b85b10c9a00e49ce3cfcadd Mon Sep 17 00:00:00 2001 From: fisher Date: Fri, 28 Feb 2020 20:44:35 +0800 Subject: [PATCH 62/72] fixed classical novel type --- app/src/main/assets/txtTocRule.json | 126 +++++++++++++++------------- 1 file changed, 66 insertions(+), 60 deletions(-) diff --git a/app/src/main/assets/txtTocRule.json b/app/src/main/assets/txtTocRule.json index 4e93e04d7..1304059d0 100644 --- a/app/src/main/assets/txtTocRule.json +++ b/app/src/main/assets/txtTocRule.json @@ -1,62 +1,68 @@ [ - { - "enable": true, - "name": "数字 分隔符 标题名称", - "rule": "^[ \\t]{0,4}\\d{1,5}[\\,\\., 、\\-].{1,30}$", - "serialNumber": 0 - }, - { - "enable": true, - "name": "目录", - "rule": "^[ \\t]{0,4}(?:(?:内容|文章)?简介|前言|序章|楔子|正文(?!完)|[Cc]hapter|[Ss]ection|终章|后记|尾声|番外|第?\\s{0,4}[\\d零一二两三四五六七八九十百千万壹贰叁肆伍陆柒捌玖拾佰仟]+?\\s{0,4}(?:章|节(?!课)|卷|集(?![合和])|部(?!分)|篇(?!张))).{0,30}$", - "serialNumber": 1 - }, - { - "enable": false, - "name": "目录(不匹配行前空白)", - "rule": "^(?<=\\s)(?:(?:内容|文章)?简介|前言|序章|楔子|正文(?!完)|[Cc]hapter|[Ss]ection|终章|后记|尾声|番外|第?\\s{0,4}[\\d零一二两三四五六七八九十百千万壹贰叁肆伍陆柒捌玖拾佰仟]+?\\s{0,4}(?:章|节(?!课)|卷|集(?![合和])|部(?!分)|篇(?!张))).{0,30}$", - "serialNumber": 2 - }, - { - "enable": false, - "name": "目录(去简介)", - "rule": "^(?<=\\s)(?:前言|序章|楔子|正文(?!完)|[Cc]hapter|[Ss]ection|终章|后记|尾声|番外|第?\\s{0,4}[\\d零一二两三四五六七八九十百千万壹贰叁肆伍陆柒捌玖拾佰仟]+?\\s{0,4}(?:章|节(?!课)|卷|集(?![合和])|部(?!分)|篇(?!张))).{0,30}$", - "serialNumber": 3 - }, - { - "enable": false, - "name": "目录(古典小说备用)", - "rule": "^[ \\t]{0,4}(?:前言|序章|楔子|正文(?!完)|[Cc]hapter|[Ss]ection|终章|后记|尾声|番外|第?\\s{0,4}[\\d零一二两三四五六七八九十百千万壹贰叁肆伍陆柒捌玖拾佰仟]+?\\s{0,4}(?:章|节(?!课)|卷|集(?![合和])|部(?!分)|场(?![和合比电是])|篇(?!张))).{0,30}$", - "serialNumber": 4 - }, - { - "enable": true, - "name": "Chapter/Section/Part 序号 标题", - "rule": "^[ \\t]{0,4}(?:[Cc]hapter|[Ss]ection|[Pp]art)\\s{0,4}\\d{1,4}.{0,30}$", - "serialNumber": 5 - }, - { - "enable": true, - "name": "正文 标题/序号", - "rule": "^[ \\t]{0,4}正文\\s{1,4}.{0,20}$", - "serialNumber": 6 - }, - { - "enable": true, - "name": "特殊符号 序号 标题", - "rule": "^[ \\t]{0,4}[〈〖〔【][第卷][\\d零一二两三四五六七八九十百千万壹贰叁肆伍陆柒捌玖拾佰仟]{1,10}[章节][\\.:: \f\t].{0,30}$", - "serialNumber": 7 - }, - { - "enable": true, - "name": "特殊符号 标题", - "rule": "^[ \\t]{0,4}[〈〖〔【☆★].{1,30}[】〕〗〉]?\\s{0,4}$", - "serialNumber": 8 - }, - { - "enable":false, - "name": "特殊符号 标题(不匹配空白字符)", - "rule": "(?<=\\s)[〈〖〔【☆★].{1,30}[】〕〗〉]?\\s{0,4}$", - "serialNumber": 9 - } + { + "enable": true, + "name": "目录", + "rule": "^[ \\t]{0,4}(?:(?:内容|文章)?简介|文案|前言|序章|楔子|正文(?!完)|终章|后记|尾声|番外|第?\\s{0,4}[\\d零一二两三四五六七八九十百千万壹贰叁肆伍陆柒捌玖拾佰仟]+?\\s{0,4}(?:章|节(?!课)|卷|集(?![合和])|部(?!分)|篇(?!张))).{0,30}$", + "serialNumber": 0 + }, + { + "enable": false, + "name": "目录(不匹配行前空白)", + "rule": "^(?<=\\s)(?:(?:内容|文章)?简介|文案|前言|序章|楔子|正文(?!完)|终章|后记|尾声|番外|第?\\s{0,4}[\\d零一二两三四五六七八九十百千万壹贰叁肆伍陆柒捌玖拾佰仟]+?\\s{0,4}(?:章|节(?!课)|卷|集(?![合和])|部(?!分)|篇(?!张))).{0,30}$", + "serialNumber": 1 + }, + { + "enable": false, + "name": "目录(去简介)", + "rule": "^(?<=\\s)(?:前言|序章|楔子|正文(?!完)|终章|后记|尾声|番外|第?\\s{0,4}[\\d零一二两三四五六七八九十百千万壹贰叁肆伍陆柒捌玖拾佰仟]+?\\s{0,4}(?:章|节(?!课)|卷|集(?![合和])|部(?!分)|篇(?!张))).{0,30}$", + "serialNumber": 2 + }, + { + "enable": false, + "name": "目录(古典、轻小说备用)", + "rule": "^[ \\t]{0,4}(?:前言|序章|楔子|正文(?!完)|终章|后记|尾声|番外|第?\\s{0,4}[\\d零一二两三四五六七八九十百千万壹贰叁肆伍陆柒捌玖拾佰仟]+?\\s{0,4}(?:章|节(?!课)|卷|集(?![合和])|部(?!分)|回(?![合来事去])|场(?![和合比电是])|篇(?!张))).{0,30}$", + "serialNumber": 3 + }, + { + "enable": true, + "name": "数字 分隔符 标题名称", + "rule": "^[ \\t]{0,4}\\d{1,5}[\\,\\., 、\\-].{1,30}$", + "serialNumber": 4 + }, + { + "enable": true, + "name": "正文 标题/序号", + "rule": "^[ \\t]{0,4}正文\\s{1,4}.{0,20}$", + "serialNumber": 5 + }, + { + "enable": true, + "name": "Chapter/Section/Part 序号 标题", + "rule": "^[ \\t]{0,4}(?:[Cc]hapter|[Ss]ection|[Pp]art)\\s{0,4}\\d{1,4}.{0,30}$", + "serialNumber": 6 + }, + { + "enable": true, + "name": "特殊符号 序号 标题", + "rule": "^[ \\t]{0,4}[〈〖〔【][第卷][\\d零一二两三四五六七八九十百千万壹贰叁肆伍陆柒捌玖拾佰仟]{1,10}[章节][\\.:: \f\t].{0,30}$", + "serialNumber": 7 + }, + { + "enable": true, + "name": "特殊符号 标题", + "rule": "^[ \\t]{0,4}[\\[〈「『〖〔《(【\\(☆★].{1,30}[\\)】)》〕〗』」〉\\]]?\\s{0,4}$", + "serialNumber": 8 + }, + { + "enable":false, + "name": "特殊符号 标题(不匹配空白字符)", + "rule": "^(?<=\\s)[\\[〈「『〖〔《(【\\(☆★].{1,30}[\\)】)》〕〗』」〉\\]]?\\s{0,4}$", + "serialNumber": 9 + }, + { + "enable":false, + "name": "顶格标题", + "rule": "^\\S.{1,20}$", + "serialNumber": 10 + } ] From 39bac049d6d7297bfcc51be9478db312c4f8b3c6 Mon Sep 17 00:00:00 2001 From: fisher Date: Fri, 28 Feb 2020 21:03:47 +0800 Subject: [PATCH 63/72] fixed error text --- app/src/main/res/values/arrays.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml index ff1fc875c..bdcdf57eb 100644 --- a/app/src/main/res/values/arrays.xml +++ b/app/src/main/res/values/arrays.xml @@ -155,6 +155,6 @@ 系统默认字体 系统衬线字体 - 系统等宽等宽 + 系统等宽字体 \ No newline at end of file From 7ce3e670bd294ad525badd923dbe8e588eec75ed Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 28 Feb 2020 22:07:04 +0800 Subject: [PATCH 64/72] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/legado/app/constant/PreferKey.kt | 1 + .../ui/book/read/config/ReadStyleDialog.kt | 25 ++--- .../ui/main/bookshelf/BookshelfFragment.kt | 46 ++++++-- .../io/legado/app/utils/ViewExtensions.kt | 24 ++++ .../res/layout/dialog_bookshelf_config.xml | 105 ++++++++++++++++++ .../main/res/layout/dialog_number_picker.xml | 3 +- app/src/main/res/values/arrays.xml | 20 ---- app/src/main/res/values/strings.xml | 19 ++-- 8 files changed, 186 insertions(+), 57 deletions(-) create mode 100644 app/src/main/res/layout/dialog_bookshelf_config.xml diff --git a/app/src/main/java/io/legado/app/constant/PreferKey.kt b/app/src/main/java/io/legado/app/constant/PreferKey.kt index 6be087f05..225154a97 100644 --- a/app/src/main/java/io/legado/app/constant/PreferKey.kt +++ b/app/src/main/java/io/legado/app/constant/PreferKey.kt @@ -16,6 +16,7 @@ object PreferKey { const val nextKey = "nextKeyCode" const val showRss = "showRss" const val bookshelfLayout = "bookshelfLayout" + const val bookshelfSort = "bookshelfSort" const val recordLog = "recordLog" const val processText = "process_text" const val cleanCache = "cleanCache" diff --git a/app/src/main/java/io/legado/app/ui/book/read/config/ReadStyleDialog.kt b/app/src/main/java/io/legado/app/ui/book/read/config/ReadStyleDialog.kt index b7a0a330b..a6482caed 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/config/ReadStyleDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/config/ReadStyleDialog.kt @@ -19,6 +19,7 @@ import io.legado.app.lib.theme.primaryColor import io.legado.app.ui.book.read.Help import io.legado.app.ui.book.read.ReadBookActivity import io.legado.app.ui.widget.font.FontSelectDialog +import io.legado.app.utils.getIndexById import io.legado.app.utils.getPrefString import io.legado.app.utils.postEvent import io.legado.app.utils.putPrefString @@ -30,6 +31,8 @@ import org.jetbrains.anko.sdk27.listeners.onLongClick class ReadStyleDialog : DialogFragment(), FontSelectDialog.CallBack { + val callBack = activity as? ReadBookActivity + override fun onStart() { super.onStart() val dm = DisplayMetrics() @@ -120,11 +123,8 @@ class ReadStyleDialog : DialogFragment(), FontSelectDialog.CallBack { } } tv_padding.onClick { - val activity = activity dismiss() - if (activity is ReadBookActivity) { - activity.showPaddingConfig() - } + callBack?.showPaddingConfig() } dsb_text_size.onChanged = { ReadBookConfig.textSize = it + 5 @@ -143,15 +143,9 @@ class ReadStyleDialog : DialogFragment(), FontSelectDialog.CallBack { postEvent(EventBus.UP_CONFIG, true) } rg_page_anim.onCheckedChange { _, checkedId -> - for (i in 0 until rg_page_anim.childCount) { - if (checkedId == rg_page_anim[i].id) { - ReadBookConfig.pageAnim = i - val activity = activity - if (activity is ReadBookActivity) { - activity.page_view.upPageAnim() - } - break - } + rg_page_anim.getIndexById(checkedId).let { + ReadBookConfig.pageAnim = it + callBack?.page_view?.upPageAnim() } } cb_share_layout.onCheckedChangeListener = { checkBox, isChecked -> @@ -186,10 +180,7 @@ class ReadStyleDialog : DialogFragment(), FontSelectDialog.CallBack { private fun showBgTextConfig(index: Int): Boolean { dismiss() changeBg(index) - val activity = activity - if (activity is ReadBookActivity) { - activity.showBgTextConfig() - } + callBack?.showBgTextConfig() return true } diff --git a/app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfFragment.kt b/app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfFragment.kt index 16b7b286f..cd4d40a72 100644 --- a/app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfFragment.kt +++ b/app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfFragment.kt @@ -2,6 +2,7 @@ package io.legado.app.ui.main.bookshelf import android.annotation.SuppressLint import android.os.Bundle +import android.view.LayoutInflater import android.view.Menu import android.view.MenuItem import android.view.View @@ -17,7 +18,10 @@ import io.legado.app.constant.AppConst import io.legado.app.constant.EventBus import io.legado.app.constant.PreferKey import io.legado.app.data.entities.BookGroup -import io.legado.app.lib.dialogs.* +import io.legado.app.lib.dialogs.alert +import io.legado.app.lib.dialogs.customView +import io.legado.app.lib.dialogs.noButton +import io.legado.app.lib.dialogs.okButton import io.legado.app.lib.theme.ATH import io.legado.app.lib.theme.accentColor import io.legado.app.ui.book.arrange.ArrangeBookActivity @@ -27,6 +31,7 @@ import io.legado.app.ui.download.DownloadActivity import io.legado.app.ui.importbook.ImportBookActivity import io.legado.app.ui.widget.text.AutoCompleteTextView import io.legado.app.utils.* +import kotlinx.android.synthetic.main.dialog_bookshelf_config.view.* import kotlinx.android.synthetic.main.dialog_edit_text.view.* import kotlinx.android.synthetic.main.fragment_bookshelf.* import kotlinx.android.synthetic.main.view_tab_layout.* @@ -61,7 +66,7 @@ class BookshelfFragment : VMBaseFragment(R.layout.fragment_b super.onCompatOptionsItemSelected(item) when (item.itemId) { R.id.menu_search -> startActivity() - R.id.menu_bookshelf_layout -> selectBookshelfLayout() + R.id.menu_bookshelf_layout -> configBookshelf() R.id.menu_group_manage -> GroupManageDialog() .show(childFragmentManager, "groupManageDialog") R.id.menu_add_local -> startActivity() @@ -145,14 +150,35 @@ class BookshelfFragment : VMBaseFragment(R.layout.fragment_b } } - private fun selectBookshelfLayout() { - selector( - title = "选择书架布局", - items = resources.getStringArray(R.array.bookshelf_layout).toList() - ) { _, index -> - putPrefInt(PreferKey.bookshelfLayout, index) - activity?.recreate() - } + @SuppressLint("InflateParams") + private fun configBookshelf() { + requireContext().alert(titleResource = R.string.bookshelf_layout) { + val bookshelfLayout = getPrefInt(PreferKey.bookshelfLayout) + val bookshelfSort = getPrefInt(PreferKey.bookshelfSort) + val root = LayoutInflater.from(requireContext()) + .inflate(R.layout.dialog_bookshelf_config, null).apply { + rg_layout.checkByIndex(bookshelfLayout) + rg_sort.checkByIndex(bookshelfSort) + } + customView = root + okButton { + root.apply { + var changed = false + if (bookshelfLayout != rg_layout.getCheckedIndex()) { + putPrefInt(PreferKey.bookshelfLayout, rg_layout.getCheckedIndex()) + changed = true + } + if (bookshelfSort != rg_sort.getCheckedIndex()) { + putPrefInt(PreferKey.bookshelfLayout, rg_sort.getCheckedIndex()) + changed = true + } + if (changed) { + activity?.recreate() + } + } + } + noButton() + }.show().applyTint() } @SuppressLint("InflateParams") diff --git a/app/src/main/java/io/legado/app/utils/ViewExtensions.kt b/app/src/main/java/io/legado/app/utils/ViewExtensions.kt index 8eb3cb1f6..b8a457325 100644 --- a/app/src/main/java/io/legado/app/utils/ViewExtensions.kt +++ b/app/src/main/java/io/legado/app/utils/ViewExtensions.kt @@ -7,8 +7,10 @@ import android.os.Build import android.view.View import android.view.View.* import android.view.inputmethod.InputMethodManager +import android.widget.RadioGroup import android.widget.SeekBar import androidx.appcompat.app.AppCompatActivity +import androidx.core.view.get import io.legado.app.App @@ -69,4 +71,26 @@ fun View.screenshot(): Bitmap? { fun SeekBar.progressAdd(int: Int) { progress += int +} + +fun RadioGroup.getIndexById(id: Int): Int { + for (i in 0 until this.childCount) { + if (id == get(i).id) { + return i + } + } + return 0 +} + +fun RadioGroup.getCheckedIndex(): Int { + for (i in 0 until this.childCount) { + if (checkedRadioButtonId == get(i).id) { + return i + } + } + return 0 +} + +fun RadioGroup.checkByIndex(index: Int) { + check(get(index).id) } \ No newline at end of file diff --git a/app/src/main/res/layout/dialog_bookshelf_config.xml b/app/src/main/res/layout/dialog_bookshelf_config.xml new file mode 100644 index 000000000..944913f4c --- /dev/null +++ b/app/src/main/res/layout/dialog_bookshelf_config.xml @@ -0,0 +1,105 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/dialog_number_picker.xml b/app/src/main/res/layout/dialog_number_picker.xml index 5a471be84..f54fd0a00 100644 --- a/app/src/main/res/layout/dialog_number_picker.xml +++ b/app/src/main/res/layout/dialog_number_picker.xml @@ -7,6 +7,7 @@ android:id="@+id/number_picker" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_gravity="center" /> + android:layout_gravity="center" + android:scrollbars="none" /> \ No newline at end of file diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml index ff1fc875c..f46e94565 100644 --- a/app/src/main/res/values/arrays.xml +++ b/app/src/main/res/values/arrays.xml @@ -35,14 +35,6 @@ 9 - - @string/layout_list - @string/layout_grid3 - @string/layout_grid4 - @string/layout_grid5 - @string/layout_grid6 - - @string/indent_0 @string/indent_1 @@ -111,18 +103,6 @@ @string/screen_sensor - - @string/bookshelf_px_0 - @string/bookshelf_px_1 - @string/bookshelf_px_2 - - - - 0 - 1 - 2 - - diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 8da65e500..7e9540a2f 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -47,12 +47,13 @@ 书架还空着,先去添加吧! 搜索 下载 - 列表视图 - 网格视图三列 - 网格视图四列 - 网格视图五列 - 网格视图六列 + 列表 + 网格三列 + 网格四列 + 网格五列 + 网格六列 书架布局 + 视图 书城 添加本地 书源 @@ -226,11 +227,11 @@ 来源:%s 本地导入 网络导入 - 书架排序 检查更新间隔 - 按阅读时间排序 - 按更新时间排序 - 手动排序 + 按阅读时间 + 按更新时间 + 按书名 + 手动排序 阅读方式 删除所选 是否确认删除? From abb7a82859bb372802dbf7eee56839774a87a745 Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 28 Feb 2020 22:21:57 +0800 Subject: [PATCH 65/72] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/ui/main/bookshelf/BookshelfFragment.kt | 2 +- .../app/ui/main/bookshelf/books/BooksFragment.kt | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfFragment.kt b/app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfFragment.kt index cd4d40a72..f49cf2ea6 100644 --- a/app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfFragment.kt +++ b/app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfFragment.kt @@ -169,7 +169,7 @@ class BookshelfFragment : VMBaseFragment(R.layout.fragment_b changed = true } if (bookshelfSort != rg_sort.getCheckedIndex()) { - putPrefInt(PreferKey.bookshelfLayout, rg_sort.getCheckedIndex()) + putPrefInt(PreferKey.bookshelfSort, rg_sort.getCheckedIndex()) changed = true } if (changed) { diff --git a/app/src/main/java/io/legado/app/ui/main/bookshelf/books/BooksFragment.kt b/app/src/main/java/io/legado/app/ui/main/bookshelf/books/BooksFragment.kt index 1a462a294..49cadb56c 100644 --- a/app/src/main/java/io/legado/app/ui/main/bookshelf/books/BooksFragment.kt +++ b/app/src/main/java/io/legado/app/ui/main/bookshelf/books/BooksFragment.kt @@ -103,10 +103,16 @@ class BooksFragment : BaseFragment(R.layout.fragment_books), -3 -> App.db.bookDao().observeAudio() else -> App.db.bookDao().observeByGroup(groupId) } - bookshelfLiveData?.observe(this, Observer { + bookshelfLiveData?.observe(this, Observer { list -> + val books = when (getPrefInt(PreferKey.bookshelfSort)) { + 1 -> list.sortedByDescending { it.latestChapterTime } + 2 -> list.sortedBy { it.name } + 3 -> list.sortedBy { it.order } + else -> list.sortedByDescending { it.durChapterTime } + } val diffResult = DiffUtil - .calculateDiff(BooksDiffCallBack(ArrayList(booksAdapter.getItems()), it)) - booksAdapter.setItems(it, diffResult) + .calculateDiff(BooksDiffCallBack(ArrayList(booksAdapter.getItems()), books)) + booksAdapter.setItems(books, diffResult) }) } From 3683c5fdf6ccee51bc34428817f64387826b0da3 Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 28 Feb 2020 22:22:33 +0800 Subject: [PATCH 66/72] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/assets/updateLog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/app/src/main/assets/updateLog.md b/app/src/main/assets/updateLog.md index 9bf7bcd87..dea42f86d 100644 --- a/app/src/main/assets/updateLog.md +++ b/app/src/main/assets/updateLog.md @@ -6,6 +6,7 @@ * 添加书源一键导入 * 修复主题模式跟随系统 * 修复书源校验 +* 添加书架排序 **2020/02/28** * 解决阅读界面部分字体超出范围的问题 From 99cb6ec8fee46f239348d14babd13037d965007c Mon Sep 17 00:00:00 2001 From: Celeter Date: Fri, 28 Feb 2020 23:56:58 +0800 Subject: [PATCH 67/72] =?UTF-8?q?=E4=BF=AE=E6=94=B9UA=EF=BC=8C=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E6=97=A7=E4=B9=A6=E6=BA=90=E8=BD=AC=E6=8D=A2=E7=9A=84?= =?UTF-8?q?bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/io/legado/app/constant/AppConst.kt | 2 +- .../java/io/legado/app/help/storage/OldRule.kt | 16 +++++++++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/io/legado/app/constant/AppConst.kt b/app/src/main/java/io/legado/app/constant/AppConst.kt index 3a5b42efe..96cc7567f 100644 --- a/app/src/main/java/io/legado/app/constant/AppConst.kt +++ b/app/src/main/java/io/legado/app/constant/AppConst.kt @@ -22,7 +22,7 @@ object AppConst { const val UA_NAME = "User-Agent" val userAgent: String by lazy { - "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.142 Safari/537.36" + "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.88 Safari/537.36" } val SCRIPT_ENGINE: ScriptEngine by lazy { diff --git a/app/src/main/java/io/legado/app/help/storage/OldRule.kt b/app/src/main/java/io/legado/app/help/storage/OldRule.kt index c8036e559..7696bb383 100644 --- a/app/src/main/java/io/legado/app/help/storage/OldRule.kt +++ b/app/src/main/java/io/legado/app/help/storage/OldRule.kt @@ -100,15 +100,22 @@ object OldRule { if (oldRule.isNullOrBlank()) return null var newRule = oldRule var reverse = false + var allinone = false if (oldRule.startsWith("-")) { reverse = true newRule = oldRule.substring(1) } + if (newRule.startsWith("+")) { + allinone = true + newRule = newRule.substring(1) + } if (!newRule.startsWith("@CSS:", true) && !newRule.startsWith("@XPath:", true) && !newRule.startsWith("//") && !newRule.startsWith("##") && - !newRule.startsWith(":") + !newRule.startsWith(":") && + !newRule.contains("@js:",true) && + !newRule.contains("",true) ) { if (newRule.contains("#") && !newRule.contains("##")) { newRule = oldRule.replace("#", "##") @@ -134,8 +141,11 @@ object OldRule { newRule = newRule.replace("&", "&&") } } + if (allinone) { + newRule = "+" + newRule + } if (reverse) { - newRule += "-" + newRule = "-" + newRule } return newRule } @@ -145,7 +155,7 @@ object OldRule { if (!oldUrls.contains("\n") && !oldUrls.contains("&&")) return toNewUrl(oldUrls) - val urls = oldUrls.split("(&&|\n)+".toRegex()) + val urls = oldUrls.split("(&&|\r?\n)+".toRegex()) return urls.map { toNewUrl(it)?.replace("\n\\s*".toRegex(), "") }.joinToString("\n") From 0f81f874c4b60854e385bc1c49741feab8c95f60 Mon Sep 17 00:00:00 2001 From: kunfei Date: Sat, 29 Feb 2020 09:08:23 +0800 Subject: [PATCH 68/72] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/constant/PreferKey.kt | 1 + .../io/legado/app/ui/book/read/config/ReadStyleDialog.kt | 2 +- app/src/main/res/values/strings.xml | 2 +- app/src/main/res/xml/pref_config_read.xml | 6 ++++++ 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/io/legado/app/constant/PreferKey.kt b/app/src/main/java/io/legado/app/constant/PreferKey.kt index 225154a97..72d8c6b15 100644 --- a/app/src/main/java/io/legado/app/constant/PreferKey.kt +++ b/app/src/main/java/io/legado/app/constant/PreferKey.kt @@ -5,6 +5,7 @@ object PreferKey { const val themeMode = "themeMode" const val downloadPath = "downloadPath" const val hideStatusBar = "hideStatusBar" + const val clickTurnPage = "clickTurnPage" const val clickAllNext = "clickAllNext" const val hideNavigationBar = "hideNavigationBar" const val precisionSearch = "precisionSearch" diff --git a/app/src/main/java/io/legado/app/ui/book/read/config/ReadStyleDialog.kt b/app/src/main/java/io/legado/app/ui/book/read/config/ReadStyleDialog.kt index a6482caed..40c3c9e94 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/config/ReadStyleDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/config/ReadStyleDialog.kt @@ -31,7 +31,7 @@ import org.jetbrains.anko.sdk27.listeners.onLongClick class ReadStyleDialog : DialogFragment(), FontSelectDialog.CallBack { - val callBack = activity as? ReadBookActivity + val callBack get() = activity as? ReadBookActivity override fun onStart() { super.onStart() diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 7e9540a2f..3f54ea194 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -193,7 +193,7 @@ 封面 音量键翻页 - 点击翻页 + 点击翻页 点击总是翻下一页 翻页动画 屏幕超时 diff --git a/app/src/main/res/xml/pref_config_read.xml b/app/src/main/res/xml/pref_config_read.xml index 37b089a09..785646c60 100644 --- a/app/src/main/res/xml/pref_config_read.xml +++ b/app/src/main/res/xml/pref_config_read.xml @@ -28,6 +28,12 @@ android:key="volumeKeyPage" app:iconSpaceReserved="false" /> + + Date: Sat, 29 Feb 2020 09:27:27 +0800 Subject: [PATCH 69/72] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/legado/app/help/ReadBookConfig.kt | 1 + .../page/delegate/HorizontalPageDelegate.kt | 15 +++++++++++++++ .../ui/book/read/page/delegate/PageDelegate.kt | 18 ++++++++---------- .../read/page/delegate/ScrollPageDelegate.kt | 8 ++++++++ app/src/main/res/xml/pref_config_read.xml | 2 +- 5 files changed, 33 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/io/legado/app/help/ReadBookConfig.kt b/app/src/main/java/io/legado/app/help/ReadBookConfig.kt index 57ccd5f14..229d5d7e6 100644 --- a/app/src/main/java/io/legado/app/help/ReadBookConfig.kt +++ b/app/src/main/java/io/legado/app/help/ReadBookConfig.kt @@ -43,6 +43,7 @@ object ReadBookConfig { App.INSTANCE.putPrefInt(PreferKey.pageAnim, value) } var isScroll = pageAnim == 3 + val clickTurnPage get() = App.INSTANCE.getPrefBoolean(PreferKey.clickTurnPage, true) var bg: Drawable? = null init { diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/delegate/HorizontalPageDelegate.kt b/app/src/main/java/io/legado/app/ui/book/read/page/delegate/HorizontalPageDelegate.kt index 586b3d88e..700728b14 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/delegate/HorizontalPageDelegate.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/delegate/HorizontalPageDelegate.kt @@ -52,4 +52,19 @@ abstract class HorizontalPageDelegate(pageView: PageView) : PageDelegate(pageVie } } + override fun nextPageByAnim() { + if (!hasNext()) return + setDirection(Direction.NEXT) + setBitmap() + setTouchPoint(viewWidth.toFloat(), 0f) + onAnimStart() + } + + override fun prevPageByAnim() { + if (!hasPrev()) return + setDirection(Direction.PREV) + setBitmap() + setTouchPoint(0f, 0f) + onAnimStart() + } } \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/delegate/PageDelegate.kt b/app/src/main/java/io/legado/app/ui/book/read/page/delegate/PageDelegate.kt index 2b26714c4..9736f13c3 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/delegate/PageDelegate.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/delegate/PageDelegate.kt @@ -12,6 +12,7 @@ import android.widget.Scroller import androidx.annotation.CallSuper import com.google.android.material.snackbar.Snackbar import io.legado.app.help.AppConfig +import io.legado.app.help.ReadBookConfig import io.legado.app.ui.book.read.page.ContentView import io.legado.app.ui.book.read.page.PageView import io.legado.app.utils.screenshot @@ -193,6 +194,10 @@ abstract class PageDelegate(protected val pageView: PageView) : open fun onScroll() {}//移动contentView, slidePage + abstract fun nextPageByAnim() + + abstract fun prevPageByAnim() + @CallSuper open fun setDirection(direction: Direction) { mDirection = direction @@ -260,21 +265,14 @@ abstract class PageDelegate(protected val pageView: PageView) : if (centerRectF.contains(x, y)) { pageView.callBack.clickCenter() setTouchPoint(x, y) - } else { + } else if (ReadBookConfig.clickTurnPage) { if (x > viewWidth / 2 || AppConfig.clickAllNext ) { - //设置动画方向 - if (!hasNext()) return true - setDirection(Direction.NEXT) - setBitmap() + nextPageByAnim() } else { - if (!hasPrev()) return true - setDirection(Direction.PREV) - setBitmap() + prevPageByAnim() } - setTouchPoint(x, y) - onAnimStart() } return true } diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/delegate/ScrollPageDelegate.kt b/app/src/main/java/io/legado/app/ui/book/read/page/delegate/ScrollPageDelegate.kt index d90ee8649..368a9ad8a 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/delegate/ScrollPageDelegate.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/delegate/ScrollPageDelegate.kt @@ -58,4 +58,12 @@ class ScrollPageDelegate(pageView: PageView) : PageDelegate(pageView) { super.onDestroy() mVelocity.recycle() } + + override fun nextPageByAnim() { + + } + + override fun prevPageByAnim() { + + } } \ No newline at end of file diff --git a/app/src/main/res/xml/pref_config_read.xml b/app/src/main/res/xml/pref_config_read.xml index 785646c60..a19a8ba4c 100644 --- a/app/src/main/res/xml/pref_config_read.xml +++ b/app/src/main/res/xml/pref_config_read.xml @@ -29,7 +29,7 @@ app:iconSpaceReserved="false" /> From 53168c02b09729cda42a87fe25a25ae656039dd3 Mon Sep 17 00:00:00 2001 From: kunfei Date: Sat, 29 Feb 2020 09:42:05 +0800 Subject: [PATCH 70/72] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../legado/app/ui/book/read/page/PageView.kt | 4 +-- .../book/read/page/delegate/PageDelegate.kt | 28 ------------------- 2 files changed, 2 insertions(+), 30 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/PageView.kt b/app/src/main/java/io/legado/app/ui/book/read/page/PageView.kt index 1482d309a..c6839b214 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/PageView.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/PageView.kt @@ -120,7 +120,7 @@ class PageView(context: Context, attrs: AttributeSet) : if (noAnim) { fillPage(PageDelegate.Direction.PREV) } else { - pageDelegate?.start(PageDelegate.Direction.PREV) + pageDelegate?.prevPageByAnim() } } @@ -128,7 +128,7 @@ class PageView(context: Context, attrs: AttributeSet) : if (noAnim) { fillPage(PageDelegate.Direction.NEXT) } else { - pageDelegate?.start(PageDelegate.Direction.NEXT) + pageDelegate?.nextPageByAnim() } } diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/delegate/PageDelegate.kt b/app/src/main/java/io/legado/app/ui/book/read/page/delegate/PageDelegate.kt index 9736f13c3..76b40fb78 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/delegate/PageDelegate.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/delegate/PageDelegate.kt @@ -158,34 +158,6 @@ abstract class PageDelegate(protected val pageView: PageView) : } } - fun start(direction: Direction) { - if (isStarted) return - if (direction === Direction.NEXT) { - val x = viewWidth.toFloat() - val y = viewHeight.toFloat() - //初始化动画 - setStartPoint(x, y, false) - //设置点击点 - setTouchPoint(x, y, false) - //设置方向 - if (!hasNext()) { - return - } - } else { - val x = 0.toFloat() - val y = viewHeight.toFloat() - //初始化动画 - setStartPoint(x, y, false) - //设置点击点 - setTouchPoint(x, y, false) - //设置方向方向 - if (!hasPrev()) { - return - } - } - onAnimStart() - } - open fun onAnimStart() {}//scroller start open fun onDraw(canvas: Canvas) {}//绘制 From 13cd5a0861bbd2af3da1196c07a4025a27f854bd Mon Sep 17 00:00:00 2001 From: kunfei Date: Sat, 29 Feb 2020 09:43:26 +0800 Subject: [PATCH 71/72] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/assets/updateLog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/app/src/main/assets/updateLog.md b/app/src/main/assets/updateLog.md index dea42f86d..c2c457bf5 100644 --- a/app/src/main/assets/updateLog.md +++ b/app/src/main/assets/updateLog.md @@ -7,6 +7,7 @@ * 修复主题模式跟随系统 * 修复书源校验 * 添加书架排序 +* 添加点击翻页开关 **2020/02/28** * 解决阅读界面部分字体超出范围的问题 From 6cc7452c4cfe41d92914b1edc39f5f9de2c98cf2 Mon Sep 17 00:00:00 2001 From: kunfei Date: Sat, 29 Feb 2020 10:00:22 +0800 Subject: [PATCH 72/72] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/assets/updateLog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/app/src/main/assets/updateLog.md b/app/src/main/assets/updateLog.md index c2c457bf5..aabd6c581 100644 --- a/app/src/main/assets/updateLog.md +++ b/app/src/main/assets/updateLog.md @@ -8,6 +8,7 @@ * 修复书源校验 * 添加书架排序 * 添加点击翻页开关 +* 修复共用布局没有记住配置的bug **2020/02/28** * 解决阅读界面部分字体超出范围的问题