From 48bfabcbeabf109cb4ea84abe754805056618618 Mon Sep 17 00:00:00 2001 From: kunfei Date: Mon, 9 Mar 2020 09:36:34 +0800 Subject: [PATCH 01/34] =?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/widget/BatteryView.kt | 61 ++++++++----------- app/src/main/res/layout/view_book_page.xml | 3 +- 2 files changed, 26 insertions(+), 38 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/widget/BatteryView.kt b/app/src/main/java/io/legado/app/ui/widget/BatteryView.kt index 60e781c93..1cae8e09d 100644 --- a/app/src/main/java/io/legado/app/ui/widget/BatteryView.kt +++ b/app/src/main/java/io/legado/app/ui/widget/BatteryView.kt @@ -1,67 +1,54 @@ package io.legado.app.ui.widget +import android.annotation.SuppressLint import android.content.Context import android.graphics.Canvas import android.graphics.Paint import android.graphics.Rect -import android.graphics.Typeface -import android.text.StaticLayout -import android.text.TextPaint import android.util.AttributeSet -import android.view.View import androidx.annotation.ColorInt +import androidx.appcompat.widget.AppCompatTextView import io.legado.app.R import io.legado.app.utils.dp import io.legado.app.utils.getCompatColor -import io.legado.app.utils.sp -class BatteryView(context: Context, attrs: AttributeSet?) : View(context, attrs) { - private var battery = 100 - private val textPaint = TextPaint() - private var batteryHeight: Int = 0 - private var batteryWidth: Int = 0 +class BatteryView(context: Context, attrs: AttributeSet?) : AppCompatTextView(context, attrs) { + private val batteryPaint = Paint() private val outFrame = Rect() private val polar = Rect() init { - textPaint.textSize = 10.sp.toFloat() - textPaint.strokeWidth = 1.dp.toFloat() - textPaint.isAntiAlias = true - textPaint.textAlign = Paint.Align.CENTER - textPaint.color = context.getCompatColor(R.color.tv_text_default) - textPaint.typeface = Typeface.createFromAsset(context.assets, "number.ttf") - batteryHeight = with(textPaint.fontMetrics) { descent - ascent + leading }.toInt() - batteryWidth = StaticLayout.getDesiredWidth("100", textPaint).toInt() + 10.dp - outFrame.set(1.dp, 1.dp, batteryWidth - 3.dp, batteryHeight - 1.dp) - polar.set(outFrame.right, batteryHeight / 3, batteryWidth, batteryHeight * 2 / 3) - } - - override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) { - super.onMeasure( - MeasureSpec.makeMeasureSpec(batteryWidth, MeasureSpec.EXACTLY), - MeasureSpec.makeMeasureSpec(batteryHeight, MeasureSpec.EXACTLY) - ) + setPadding(4.dp, 0, 6.dp, 0) + batteryPaint.strokeWidth = 1.dp.toFloat() + batteryPaint.isAntiAlias = true + batteryPaint.color = context.getCompatColor(R.color.tv_text_default) } fun setColor(@ColorInt color: Int) { - textPaint.color = color + setTextColor(color) + batteryPaint.color = color invalidate() } + @SuppressLint("SetTextI18n") fun setBattery(battery: Int) { - this.battery = battery - invalidate() + text = "$battery" } override fun onDraw(canvas: Canvas) { super.onDraw(canvas) - textPaint.style = Paint.Style.STROKE - canvas.drawRect(outFrame, textPaint) - textPaint.style = Paint.Style.FILL - canvas.drawRect(polar, textPaint) - val text = battery.toString() - val baseHeight = batteryHeight - textPaint.fontMetrics.descent - canvas.drawText(text, outFrame.right / 2.toFloat(), baseHeight, textPaint) + outFrame.set( + 1.dp, + layout.getLineTop(0) + 2.dp, + width - 3.dp, + layout.getLineBottom(0) - 2.dp + ) + val dj = (outFrame.bottom - outFrame.top) / 3 + polar.set(outFrame.right, outFrame.top + dj, width - 1.dp, outFrame.bottom - dj) + batteryPaint.style = Paint.Style.STROKE + canvas.drawRect(outFrame, batteryPaint) + batteryPaint.style = Paint.Style.FILL + canvas.drawRect(polar, batteryPaint) } } \ No newline at end of file diff --git a/app/src/main/res/layout/view_book_page.xml b/app/src/main/res/layout/view_book_page.xml index fc80e05f5..922819b1e 100644 --- a/app/src/main/res/layout/view_book_page.xml +++ b/app/src/main/res/layout/view_book_page.xml @@ -78,7 +78,8 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="3dp" - tools:ignore="RtlHardcoded,RtlSymmetry" /> + android:textSize="10sp" + tools:ignore="RtlHardcoded,RtlSymmetry,SmallSp" /> From 6a5d38131467504615a69f467107e80e61f76fde Mon Sep 17 00:00:00 2001 From: kunfei Date: Mon, 9 Mar 2020 09:41:20 +0800 Subject: [PATCH 02/34] =?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/widget/BatteryView.kt | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/widget/BatteryView.kt b/app/src/main/java/io/legado/app/ui/widget/BatteryView.kt index 1cae8e09d..a51e250f7 100644 --- a/app/src/main/java/io/legado/app/ui/widget/BatteryView.kt +++ b/app/src/main/java/io/legado/app/ui/widget/BatteryView.kt @@ -8,9 +8,7 @@ import android.graphics.Rect import android.util.AttributeSet import androidx.annotation.ColorInt import androidx.appcompat.widget.AppCompatTextView -import io.legado.app.R import io.legado.app.utils.dp -import io.legado.app.utils.getCompatColor class BatteryView(context: Context, attrs: AttributeSet?) : AppCompatTextView(context, attrs) { private val batteryPaint = Paint() @@ -21,7 +19,7 @@ class BatteryView(context: Context, attrs: AttributeSet?) : AppCompatTextView(co setPadding(4.dp, 0, 6.dp, 0) batteryPaint.strokeWidth = 1.dp.toFloat() batteryPaint.isAntiAlias = true - batteryPaint.color = context.getCompatColor(R.color.tv_text_default) + batteryPaint.color = paint.color } fun setColor(@ColorInt color: Int) { From 19e2fa92c92ef9ca4366a33b94288910676f8eef Mon Sep 17 00:00:00 2001 From: kunfei Date: Mon, 9 Mar 2020 09:42:33 +0800 Subject: [PATCH 03/34] =?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/widget/BatteryView.kt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/io/legado/app/ui/widget/BatteryView.kt b/app/src/main/java/io/legado/app/ui/widget/BatteryView.kt index a51e250f7..f11db64e8 100644 --- a/app/src/main/java/io/legado/app/ui/widget/BatteryView.kt +++ b/app/src/main/java/io/legado/app/ui/widget/BatteryView.kt @@ -42,7 +42,12 @@ class BatteryView(context: Context, attrs: AttributeSet?) : AppCompatTextView(co layout.getLineBottom(0) - 2.dp ) val dj = (outFrame.bottom - outFrame.top) / 3 - polar.set(outFrame.right, outFrame.top + dj, width - 1.dp, outFrame.bottom - dj) + polar.set( + outFrame.right, + outFrame.top + dj, + width - 1.dp, + outFrame.bottom - dj + ) batteryPaint.style = Paint.Style.STROKE canvas.drawRect(outFrame, batteryPaint) batteryPaint.style = Paint.Style.FILL From 554c388b52616a1add581ad4ab910805e928c534 Mon Sep 17 00:00:00 2001 From: kunfei Date: Mon, 9 Mar 2020 11:52:08 +0800 Subject: [PATCH 04/34] =?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 | 1 + .../app/ui/book/read/page/entities/TextPage.kt | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) 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 65121906c..b7cf7182e 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 @@ -75,6 +75,7 @@ object ChapterProvider { item.chapterIndex = bookChapter.index item.chapterSize = chapterSize item.title = bookChapter.title + item.upLinesPosition(visibleHeight) } return TextChapter( bookChapter.index, diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/entities/TextPage.kt b/app/src/main/java/io/legado/app/ui/book/read/page/entities/TextPage.kt index bfb8e822c..adb5f0ec9 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/entities/TextPage.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/entities/TextPage.kt @@ -18,6 +18,21 @@ data class TextPage( var height: Float = 0f ) { + fun upLinesPosition(visibleHeight: Int) { + if (textLines.size <= 1) return + if (visibleHeight - height > with(textLines.last()) { lineBottom - lineTop }) return + val surplus = (visibleHeight - textLines.last().lineBottom) + height += surplus + val tj = surplus / (textLines.size - 1) + if (tj == 0f) return + for (i in 1 until textLines.size) { + val line = textLines[i] + line.lineTop = line.lineTop + tj * i + line.lineBase = line.lineBase + tj * i + line.lineBottom = line.lineBottom + tj * i + } + } + @Suppress("DEPRECATION") fun format(): TextPage { if (textLines.isEmpty() && ChapterProvider.visibleWidth > 0) { @@ -101,4 +116,5 @@ data class TextPage( } return percent } + } From 1af48c398f6b53cf16e1d9d8478f0e5c34611357 Mon Sep 17 00:00:00 2001 From: yangyxd Date: Mon, 9 Mar 2020 11:52:35 +0800 Subject: [PATCH 05/34] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=B9=A6=E7=B1=8D?= =?UTF-8?q?=E8=AF=A6=E6=83=85=E9=A1=B5=E6=8E=92=E7=89=88,=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E6=A8=AA=E5=B1=8F=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/ui/book/info/BookInfoActivity.kt | 4 +- .../res/layout-land/activity_book_info.xml | 419 ++++++++++++++++++ .../main/res/layout/activity_book_info.xml | 196 +++++--- app/src/main/res/values/strings.xml | 4 +- 4 files changed, 551 insertions(+), 72 deletions(-) create mode 100644 app/src/main/res/layout-land/activity_book_info.xml diff --git a/app/src/main/java/io/legado/app/ui/book/info/BookInfoActivity.kt b/app/src/main/java/io/legado/app/ui/book/info/BookInfoActivity.kt index 769b47b21..42e56f206 100644 --- a/app/src/main/java/io/legado/app/ui/book/info/BookInfoActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/info/BookInfoActivity.kt @@ -207,7 +207,7 @@ class BookInfoActivity : ChangeSourceDialog.show(supportFragmentManager, it.name, it.author) } } - tv_toc.onClick { + tv_toc_view.onClick { if (!viewModel.inBookshelf) { viewModel.saveBook { viewModel.saveChapterList { @@ -218,7 +218,7 @@ class BookInfoActivity : openChapterList() } } - tv_group.onClick { + tv_change_group.onClick { viewModel.bookData.value?.let { GroupSelectDialog.show(supportFragmentManager, it.group) } diff --git a/app/src/main/res/layout-land/activity_book_info.xml b/app/src/main/res/layout-land/activity_book_info.xml new file mode 100644 index 000000000..27e0bec0d --- /dev/null +++ b/app/src/main/res/layout-land/activity_book_info.xml @@ -0,0 +1,419 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_book_info.xml b/app/src/main/res/layout/activity_book_info.xml index 8e58e34cb..568a4e60a 100644 --- a/app/src/main/res/layout/activity_book_info.xml +++ b/app/src/main/res/layout/activity_book_info.xml @@ -64,40 +64,6 @@ - - - - - - - - + + + + + + + + @@ -241,6 +241,94 @@ + + + + + + + + + + + + + + + + + + + + - - - - - - - + android:layout_height="8dp" + android:background="@color/background"> 添加书籍网址 背景 作者 - 作者:%s + 作者: %s 朗读停止 清除缓存 成功清理缓存 @@ -641,4 +641,6 @@ 加入分组 保存图片 没有默认路径 + 设置分组 + 查看目录 From 3cf9fb63449095b4c49c36783c16ee4c26bda827 Mon Sep 17 00:00:00 2001 From: kunfei Date: Mon, 9 Mar 2020 12:39:17 +0800 Subject: [PATCH 06/34] =?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/entities/TextPage.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/entities/TextPage.kt b/app/src/main/java/io/legado/app/ui/book/read/page/entities/TextPage.kt index adb5f0ec9..6c4e27073 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/entities/TextPage.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/entities/TextPage.kt @@ -22,9 +22,9 @@ data class TextPage( if (textLines.size <= 1) return if (visibleHeight - height > with(textLines.last()) { lineBottom - lineTop }) return val surplus = (visibleHeight - textLines.last().lineBottom) + if (surplus == 0f) return height += surplus val tj = surplus / (textLines.size - 1) - if (tj == 0f) return for (i in 1 until textLines.size) { val line = textLines[i] line.lineTop = line.lineTop + tj * i From 011acd3b7b792863215b58246cd83466ec4ccb50 Mon Sep 17 00:00:00 2001 From: kunfei Date: Mon, 9 Mar 2020 13:32:36 +0800 Subject: [PATCH 07/34] =?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 e1374809f..3503f19ef 100644 --- a/app/src/main/assets/updateLog.md +++ b/app/src/main/assets/updateLog.md @@ -2,6 +2,9 @@ * 旧版数据导入教程:先在旧版阅读(2.x)中进行备份,然后在新版阅读(3.x)【我的】->【备份与恢复】,选择【导入旧版本数据】。 * 请关注[开源阅读软件]()支持我,同时关注合作公众号[小说拾遗](),阅读公众号小编。 +**2020/03/09** +* 底部文字对齐 + **2020/03/08** * 订阅长按保存图片 * 订阅全屏播放 From 12e779c68c8d3185aaacbcdc16b6a852c3ba265b Mon Sep 17 00:00:00 2001 From: kunfei Date: Mon, 9 Mar 2020 13:48:59 +0800 Subject: [PATCH 08/34] =?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/book/read/page/ContentView.kt | 1 - 1 file changed, 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 a9a752303..4e820008e 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 @@ -109,7 +109,6 @@ class ContentView(context: Context) : FrameLayout(context) { fun setContent(textPage: TextPage) { setProgress(textPage) - content_text_view.resetPageOffset() content_text_view.setContent(textPage) } From 0325ce00e4598e84a5d6fcd259a76d9998ea6f16 Mon Sep 17 00:00:00 2001 From: kunfei Date: Mon, 9 Mar 2020 14:24:34 +0800 Subject: [PATCH 09/34] =?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 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 b7cf7182e..67101684e 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 @@ -50,7 +50,7 @@ object ChapterProvider { val pageLines = arrayListOf() val pageLengths = arrayListOf() val stringBuilder = StringBuilder() - val contents = content.split("\n") + val contents = content.splitNotBlank("\n") var durY = 0f textPages.add(TextPage()) for ((index, text) in contents.withIndex()) { From caffa332a765503efc1c16f6e2475959a7a13baa Mon Sep 17 00:00:00 2001 From: kunfei Date: Mon, 9 Mar 2020 14:40:19 +0800 Subject: [PATCH 10/34] =?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 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 67101684e..b7cf7182e 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 @@ -50,7 +50,7 @@ object ChapterProvider { val pageLines = arrayListOf() val pageLengths = arrayListOf() val stringBuilder = StringBuilder() - val contents = content.splitNotBlank("\n") + val contents = content.split("\n") var durY = 0f textPages.add(TextPage()) for ((index, text) in contents.withIndex()) { From d2dab7f43bc8856ecdd3137ac67c0f8644b09de5 Mon Sep 17 00:00:00 2001 From: kunfei Date: Mon, 9 Mar 2020 14:46:21 +0800 Subject: [PATCH 11/34] =?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/BookHelp.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/io/legado/app/help/BookHelp.kt b/app/src/main/java/io/legado/app/help/BookHelp.kt index 304df9997..b7b45baea 100644 --- a/app/src/main/java/io/legado/app/help/BookHelp.kt +++ b/app/src/main/java/io/legado/app/help/BookHelp.kt @@ -300,6 +300,8 @@ object BookHelp { 1 -> c = ZhConvertBootstrap.newInstance().toSimple(c) 2 -> c = ZhConvertBootstrap.newInstance().toTraditional(c) } - return c.replace("\\s*\\n+\\s*".toRegex(), "\n${ReadBookConfig.bodyIndent}") + return c + .replace("\\s*\\n+\\s*".toRegex(), "\n${ReadBookConfig.bodyIndent}") + .replace("[\\n\\s]+$".toRegex(), "") //移除尾部空行 } } \ No newline at end of file From 133e2945e8f0b3b72b125878162f3545db071f19 Mon Sep 17 00:00:00 2001 From: yangyxd Date: Mon, 9 Mar 2020 15:59:00 +0800 Subject: [PATCH 12/34] =?UTF-8?q?=E4=B8=BB=E9=A2=98=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=E4=B8=AD=E5=A2=9E=E5=8A=A0=E5=AF=BC=E8=88=AA=E6=A0=8F=E9=98=B4?= =?UTF-8?q?=E5=BD=B1=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/io/legado/app/help/AppConfig.kt | 5 +++++ .../java/io/legado/app/lib/theme/ATHUtils.kt | 12 ++++++++++ .../app/lib/theme/MaterialValueHelper.kt | 5 ++++- .../io/legado/app/lib/theme/ThemeStore.kt | 8 +++++++ .../app/lib/theme/ThemeStorePrefKeys.kt | 2 ++ .../app/ui/config/ThemeConfigFragment.kt | 22 +++++++++++++++++++ .../java/io/legado/app/ui/widget/TitleBar.kt | 9 ++++++++ .../ui/widget/number/NumberPickerDialog.kt | 11 ++++++++++ app/src/main/res/values/strings.xml | 3 +++ app/src/main/res/xml/pref_config_theme.xml | 7 ++++++ 10 files changed, 83 insertions(+), 1 deletion(-) 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 6eef2bfa0..7e9c05834 100644 --- a/app/src/main/java/io/legado/app/help/AppConfig.kt +++ b/app/src/main/java/io/legado/app/help/AppConfig.kt @@ -111,4 +111,9 @@ object AppConfig { App.INSTANCE.putPrefBoolean("bookGroupAudio", value) } + var elevation: Int + get() = App.INSTANCE.getPrefInt("elevation", -1) + set(value) { + App.INSTANCE.putPrefInt("elevation", value) + } } diff --git a/app/src/main/java/io/legado/app/lib/theme/ATHUtils.kt b/app/src/main/java/io/legado/app/lib/theme/ATHUtils.kt index 73e342713..ddd6fc816 100644 --- a/app/src/main/java/io/legado/app/lib/theme/ATHUtils.kt +++ b/app/src/main/java/io/legado/app/lib/theme/ATHUtils.kt @@ -19,4 +19,16 @@ object ATHUtils { a.recycle() } } + + @JvmOverloads + fun resolveFloat(context: Context, @AttrRes attr: Int, fallback: Float = 0.0f): Float { + val a = context.theme.obtainStyledAttributes(intArrayOf(attr)) + return try { + a.getFloat(0, fallback) + } catch (e: Exception) { + fallback + } finally { + a.recycle() + } + } } \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/lib/theme/MaterialValueHelper.kt b/app/src/main/java/io/legado/app/lib/theme/MaterialValueHelper.kt index fab853c6b..bc898d065 100644 --- a/app/src/main/java/io/legado/app/lib/theme/MaterialValueHelper.kt +++ b/app/src/main/java/io/legado/app/lib/theme/MaterialValueHelper.kt @@ -107,4 +107,7 @@ val Context.isDarkTheme: Boolean get() = ColorUtils.isColorLight(ThemeStore.primaryColor(this)) val Fragment.isDarkTheme: Boolean - get() = requireContext().isDarkTheme \ No newline at end of file + get() = requireContext().isDarkTheme + +val Context.elevation: Float + get() = ThemeStore.elevation(this) \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/lib/theme/ThemeStore.kt b/app/src/main/java/io/legado/app/lib/theme/ThemeStore.kt index 927fc2fb0..5b3997081 100644 --- a/app/src/main/java/io/legado/app/lib/theme/ThemeStore.kt +++ b/app/src/main/java/io/legado/app/lib/theme/ThemeStore.kt @@ -284,6 +284,14 @@ private constructor(private val mContext: Context) : ThemeStoreInterface { ) } + @CheckResult + fun elevation(context: Context): Float { + return prefs(context).getFloat( + ThemeStorePrefKeys.KEY_ELEVATION, + ATHUtils.resolveFloat(context, android.R.attr.elevation, context.resources.getDimension(R.dimen.design_appbar_elevation)) + ) + } + @CheckResult @ColorInt fun bottomBackground(context: Context): Int { diff --git a/app/src/main/java/io/legado/app/lib/theme/ThemeStorePrefKeys.kt b/app/src/main/java/io/legado/app/lib/theme/ThemeStorePrefKeys.kt index a2ab19d60..ca8e85fc1 100644 --- a/app/src/main/java/io/legado/app/lib/theme/ThemeStorePrefKeys.kt +++ b/app/src/main/java/io/legado/app/lib/theme/ThemeStorePrefKeys.kt @@ -27,4 +27,6 @@ object ThemeStorePrefKeys { const val KEY_APPLY_PRIMARYDARK_STATUSBAR = "apply_primarydark_statusbar" const val KEY_APPLY_PRIMARY_NAVBAR = "apply_primary_navbar" const val KEY_AUTO_GENERATE_PRIMARYDARK = "auto_generate_primarydark" + + const val KEY_ELEVATION = "elevation" } \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/ui/config/ThemeConfigFragment.kt b/app/src/main/java/io/legado/app/ui/config/ThemeConfigFragment.kt index 99d7d1e54..17a3bcfe1 100644 --- a/app/src/main/java/io/legado/app/ui/config/ThemeConfigFragment.kt +++ b/app/src/main/java/io/legado/app/ui/config/ThemeConfigFragment.kt @@ -16,6 +16,8 @@ import io.legado.app.lib.dialogs.noButton import io.legado.app.lib.dialogs.yesButton import io.legado.app.lib.theme.ATH import io.legado.app.lib.theme.ColorUtils +import io.legado.app.lib.theme.elevation +import io.legado.app.ui.widget.number.NumberPickerDialog import io.legado.app.utils.* @@ -25,6 +27,7 @@ class ThemeConfigFragment : PreferenceFragmentCompat(), SharedPreferences.OnShar override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) { addPreferencesFromResource(R.xml.pref_config_theme) + upPreferenceSummary("barElevation", AppConfig.elevation.toString()) } override fun onViewCreated(view: View, savedInstanceState: Bundle?) { @@ -145,6 +148,19 @@ class ThemeConfigFragment : PreferenceFragmentCompat(), SharedPreferences.OnShar recreateActivities() } }.show().applyTint() + "barElevation" -> NumberPickerDialog(requireContext()) + .setTitle(getString(R.string.bar_elevation)) + .setMaxValue(32) + .setMinValue(0) + .setValue(AppConfig.elevation) + .setCustomButton((R.string.btn_default_s)) { + AppConfig.elevation = App.INSTANCE.resources.getDimension(R.dimen.design_appbar_elevation).toInt() + recreateActivities() + } + .show { + AppConfig.elevation = it + recreateActivities() + } } return super.onPreferenceTreeClick(preference) } @@ -180,4 +196,10 @@ class ThemeConfigFragment : PreferenceFragmentCompat(), SharedPreferences.OnShar postEvent(EventBus.RECREATE, "") } + private fun upPreferenceSummary(preferenceKey: String, value: String?) { + val preference = findPreference(preferenceKey) ?: return + when (preferenceKey) { + "barElevation" -> preference.summary = getString(R.string.bar_elevation_s, value) + } + } } \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/ui/widget/TitleBar.kt b/app/src/main/java/io/legado/app/ui/widget/TitleBar.kt index d19c8929f..8df952849 100644 --- a/app/src/main/java/io/legado/app/ui/widget/TitleBar.kt +++ b/app/src/main/java/io/legado/app/ui/widget/TitleBar.kt @@ -10,6 +10,8 @@ import androidx.annotation.StyleRes import androidx.appcompat.widget.Toolbar import com.google.android.material.appbar.AppBarLayout import io.legado.app.R +import io.legado.app.help.AppConfig +import io.legado.app.lib.theme.elevation import io.legado.app.lib.theme.primaryColor import io.legado.app.utils.activity import io.legado.app.utils.navigationBarHeight @@ -140,6 +142,13 @@ class TitleBar(context: Context, attrs: AttributeSet?) : AppBarLayout(context, a } backgroundColor = context.primaryColor + // targetElevation = context.elevation + stateListAnimator = null + if (AppConfig.elevation < 0) { + elevation = context.elevation + } else { + elevation = AppConfig.elevation.toFloat() + } a.recycle() } diff --git a/app/src/main/java/io/legado/app/ui/widget/number/NumberPickerDialog.kt b/app/src/main/java/io/legado/app/ui/widget/number/NumberPickerDialog.kt index 17fe9ab53..3b4c8f5db 100644 --- a/app/src/main/java/io/legado/app/ui/widget/number/NumberPickerDialog.kt +++ b/app/src/main/java/io/legado/app/ui/widget/number/NumberPickerDialog.kt @@ -40,6 +40,17 @@ class NumberPickerDialog(context: Context) { return this } + fun setCustomButton(textId: Int, listener: (() -> Unit)?): NumberPickerDialog { + builder.setNeutralButton(textId) { _, _ -> + numberPicker?.let { + it.clearFocus() + it.hideSoftInput() + listener?.invoke() + } + } + return this; + } + fun show(callBack: ((value: Int) -> Unit)?) { builder.setPositiveButton(R.string.ok) { _, _ -> numberPicker?.let { diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 52c7b3b08..d082e75a0 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -643,4 +643,7 @@ 没有默认路径 设置分组 查看目录 + 导航栏阴影 + 当前阴影大小(elevation): %s + 默认 diff --git a/app/src/main/res/xml/pref_config_theme.xml b/app/src/main/res/xml/pref_config_theme.xml index fe0d24ca2..2f34e86ec 100644 --- a/app/src/main/res/xml/pref_config_theme.xml +++ b/app/src/main/res/xml/pref_config_theme.xml @@ -26,6 +26,13 @@ android:title="@string/navigation_bar_color_change" app:iconSpaceReserved="false" /> + + Date: Mon, 9 Mar 2020 18:48:41 +0800 Subject: [PATCH 13/34] =?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 3503f19ef..fe74ee832 100644 --- a/app/src/main/assets/updateLog.md +++ b/app/src/main/assets/updateLog.md @@ -4,6 +4,7 @@ **2020/03/09** * 底部文字对齐 +* 主题添加阴影调节 by yangyxd **2020/03/08** * 订阅长按保存图片 From 23a718a795ed8bad2320d771b34dc9fe473814d3 Mon Sep 17 00:00:00 2001 From: kunfei Date: Mon, 9 Mar 2020 19:41:34 +0800 Subject: [PATCH 14/34] =?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/TTSReadAloudService.kt | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/app/src/main/java/io/legado/app/service/TTSReadAloudService.kt b/app/src/main/java/io/legado/app/service/TTSReadAloudService.kt index 6fd32219d..e54900db7 100644 --- a/app/src/main/java/io/legado/app/service/TTSReadAloudService.kt +++ b/app/src/main/java/io/legado/app/service/TTSReadAloudService.kt @@ -175,9 +175,7 @@ class TTSReadAloudService : BaseReadAloudService(), TextToSpeech.OnInitListener } override fun onError(s: String) { - launch { - toast(s) - } + pauseReadAloud(true) } } From 5d7716ecef441faa4c7635dcfebbee48109bc592 Mon Sep 17 00:00:00 2001 From: kunfei Date: Mon, 9 Mar 2020 19:48:54 +0800 Subject: [PATCH 15/34] =?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/widget/TitleBar.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/widget/TitleBar.kt b/app/src/main/java/io/legado/app/ui/widget/TitleBar.kt index 8df952849..10cd4191f 100644 --- a/app/src/main/java/io/legado/app/ui/widget/TitleBar.kt +++ b/app/src/main/java/io/legado/app/ui/widget/TitleBar.kt @@ -144,10 +144,10 @@ class TitleBar(context: Context, attrs: AttributeSet?) : AppBarLayout(context, a backgroundColor = context.primaryColor // targetElevation = context.elevation stateListAnimator = null - if (AppConfig.elevation < 0) { - elevation = context.elevation + elevation = if (AppConfig.elevation < 0) { + context.elevation } else { - elevation = AppConfig.elevation.toFloat() + AppConfig.elevation.toFloat() } a.recycle() From cb568cbeb6aa8745a0bea91d53a0aa01f22865fe Mon Sep 17 00:00:00 2001 From: kunfei Date: Mon, 9 Mar 2020 19:49:35 +0800 Subject: [PATCH 16/34] =?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/widget/TitleBar.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/io/legado/app/ui/widget/TitleBar.kt b/app/src/main/java/io/legado/app/ui/widget/TitleBar.kt index 10cd4191f..663bb55a8 100644 --- a/app/src/main/java/io/legado/app/ui/widget/TitleBar.kt +++ b/app/src/main/java/io/legado/app/ui/widget/TitleBar.kt @@ -142,7 +142,7 @@ class TitleBar(context: Context, attrs: AttributeSet?) : AppBarLayout(context, a } backgroundColor = context.primaryColor - // targetElevation = context.elevation + stateListAnimator = null elevation = if (AppConfig.elevation < 0) { context.elevation From 37e399d8e49ad840970ed8d1d20e5eb22ae20ed8 Mon Sep 17 00:00:00 2001 From: fisher Date: Mon, 9 Mar 2020 20:28:36 +0800 Subject: [PATCH 17/34] update all rules --- app/src/main/assets/txtTocRule.json | 54 +++++++++++++++++++---------- 1 file changed, 36 insertions(+), 18 deletions(-) diff --git a/app/src/main/assets/txtTocRule.json b/app/src/main/assets/txtTocRule.json index fc5469653..cce871125 100644 --- a/app/src/main/assets/txtTocRule.json +++ b/app/src/main/assets/txtTocRule.json @@ -2,25 +2,25 @@ { "enable": true, "name": "目录", - "rule": "^[  \\t]{0,4}(?:(?:内容|文章)?简介|文案|前言|序章|楔子|正文(?!完)|终章|后记|尾声|番外|第?\\s{0,4}[\\d零一二两三四五六七八九十百千万壹贰叁肆伍陆柒捌玖拾佰仟]+?\\s{0,4}(?:章|节(?!课)|卷|集(?![合和])|部(?!分)|篇(?!张))).{0,30}$", + "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}$", + "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}$", + "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}$", + "rule": "^[  \\t]{0,4}(?:前言|序章|楔子|正文(?!完|结)|终章|后记|尾声|番外|第?\\s{0,4}[\\d零一二两三四五六七八九十百千万壹贰叁肆伍陆柒捌玖拾佰仟]+?\\s{0,4}(?:章|节(?!课)|卷|集(?![合和])|部(?!分)|回(?![合来事去])|场(?![和合比电是])|篇(?!张))).{0,30}$", "serialNumber": 3 }, { @@ -32,43 +32,61 @@ { "enable": true, "name": "正文 标题/序号", - "rule": "^[  \\t]{0,4}正文\\s{1,4}.{0,20}$", + "rule": "^[  \\t]{0,4}正文[  ]{1,4}.{0,20}$", "serialNumber": 5 }, { "enable": true, "name": "Chapter/Section/Part/Episode 序号 标题", - "rule": "^[  \\t]{0,4}(?:[Cc]hapter|[Ss]ection|[Pp]art|PART|[Ee]pisode)\\s{0,4}\\d{1,4}.{0,30}$", + "rule": "^[  \\t]{0,4}(?:[Cc]hapter|[Ss]ection|[Pp]art|PART|[Ee]pisode|(?:内容|文章)?简介|文案|前言|序章|楔子|正文(?!完|结)|终章|后记|尾声|番外)\\s{0,4}\\d{1,4}.{0,30}$", "serialNumber": 6 }, { - "enable": true, - "name": "特殊符号 序号 标题", - "rule": "^[  \\t]{0,4}[〈〖〔【][第卷][\\d零一二两三四五六七八九十百千万壹贰叁肆伍陆柒捌玖拾佰仟]{1,10}[章节][\\.:: \f\t].{0,30}$", + "enable": false, + "name": "Chapter(去简介)", + "rule": "^[  \\t]{0,4}(?:[Cc]hapter|[Ss]ection|[Pp]art|PART|[Ee]pisode)\\s{0,4}\\d{1,4}.{0,30}$", "serialNumber": 7 }, { "enable": true, - "name": "特殊符号 标题", - "rule": "^[  \\t]{0,4}[\\[〈「『〖〔《(【\\(☆★].{1,30}[\\)】)》〕〗』」〉\\]]?\\s{0,4}$", + "name": "特殊符号 序号 标题", + "rule": "(?<=[\\s ]{0,4}).{1,3}(?:第|卷|[Cc]hapter)[\\d零一二两三四五六七八九十百千万壹贰叁肆伍陆柒捌玖拾佰仟]{1,10}[章节]?[\\.:: \f\t].{0,20}$", "serialNumber": 8 }, { - "enable":false, - "name": "特殊符号 标题(不匹配空白字符)", - "rule": "^(?<= |\\s)[\\[〈「『〖〔《(【\\(☆★].{1,30}[\\)】)》〕〗』」〉\\]]?\\s{0,4}$", + "enable": false, + "name": "特殊符号 标题(成对)", + "rule": "(?<=[\\s ]{0,4})(?:[\\[〈「『〖〔《(【\\(].{1,30}[\\)】)》〕〗』」〉\\]]?|(?:内容|文章)?简介|文案|前言|序章|楔子|正文(?!完|结)|终章|后记|尾声|番外)[  ]{0,4}$", "serialNumber": 9 }, + { + "enable":true, + "name": "特殊符号 标题(单个)", + "rule": "(?<=[\\s ]{0,4})(?:[☆★✦✧].{1,30}|(?:内容|文章)?简介|文案|前言|序章|楔子|正文(?!完|结)|终章|后记|尾声|番外)[  ]{0,4}$", + "serialNumber": 10 + }, { "enable": true, "name": "章/卷 序号 标题", - "rule": "^[  \\t]{0,4}(?:(?:内容|文章)?简介|文案|前言|序章|楔子|正文(?!完)|终章|后记|尾声|番外|[卷章][\\d零一二两三四五六七八九十百千万壹贰叁肆伍陆柒捌玖拾佰仟]{1,8})\\s{0,4}.{0,30}$", - "serialNumber": 10 + "rule": "^[ \\t ]{0,4}(?:(?:内容|文章)?简介|文案|前言|序章|楔子|正文(?!完|结)|终章|后记|尾声|番外|[卷章][\\d零一二两三四五六七八九十百千万壹贰叁肆伍陆柒捌玖拾佰仟]{1,8})[  ]{0,4}.{0,30}$", + "serialNumber": 11 }, { "enable":false, "name": "顶格标题", "rule": "^\\S.{1,20}$", - "serialNumber": 11 + "serialNumber": 12 + }, + { + "enable":false, + "name": "双标题(前向)", + "rule": "(?m)(?<=[ \\t ]{0,4})第[\\d零一二两三四五六七八九十百千万壹贰叁肆伍陆柒捌玖拾佰仟]{1,8}章.{0,30}$(?=[\\s ]{0,8}第[\\d零一二两三四五六七八九十百千万壹贰叁肆伍陆柒捌玖拾佰仟]{1,8}章)", + "serialNumber": 13 + }, + { + "enable":false, + "name": "双标题(后向)", + "rule": "(?m)(?<=[ \\t ]{0,4}第[\\d零一二两三四五六七八九十百千万壹贰叁肆伍陆柒捌玖拾佰仟]{1,8}章.{0,30}$[\\s ]{0,8})第[\\d零一二两三四五六七八九十百千万壹贰叁肆伍陆柒捌玖拾佰仟]{1,8}章.{0,30}$", + "serialNumber": 14 } ] From e05a451314686b7d786ec1766dade79610c0acad Mon Sep 17 00:00:00 2001 From: kunfei Date: Mon, 9 Mar 2020 21:04:12 +0800 Subject: [PATCH 18/34] =?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 - .../main/java/io/legado/app/help/AppConfig.kt | 2 +- app/src/main/java/io/legado/app/help/BookHelp.kt | 4 ++-- .../legado/app/ui/config/OtherConfigFragment.kt | 16 ++++++++++------ .../io/legado/app/ui/welcome/WelcomeActivity.kt | 2 +- .../io/legado/app/utils/ContextExtensions.kt | 7 +++++++ 6 files changed, 21 insertions(+), 11 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 1ba9ba6cf..e14ec42f6 100644 --- a/app/src/main/java/io/legado/app/constant/PreferKey.kt +++ b/app/src/main/java/io/legado/app/constant/PreferKey.kt @@ -3,7 +3,6 @@ package io.legado.app.constant object PreferKey { const val versionCode = "versionCode" const val themeMode = "themeMode" - const val downloadPath = "downloadPath" const val hideStatusBar = "hideStatusBar" const val clickTurnPage = "clickTurnPage" const val clickAllNext = "clickAllNext" 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 7e9c05834..9d6f87d61 100644 --- a/app/src/main/java/io/legado/app/help/AppConfig.kt +++ b/app/src/main/java/io/legado/app/help/AppConfig.kt @@ -49,7 +49,7 @@ object AppConfig { } val autoRefreshBook: Boolean - get() = App.INSTANCE.getPrefBoolean(App.INSTANCE.getString(R.string.pk_auto_refresh)) + get() = App.INSTANCE.getPrefBoolean(R.string.pk_auto_refresh) var threadCount: Int get() = App.INSTANCE.getPrefInt(PreferKey.threadCount, 16) diff --git a/app/src/main/java/io/legado/app/help/BookHelp.kt b/app/src/main/java/io/legado/app/help/BookHelp.kt index b7b45baea..b6e3ec000 100644 --- a/app/src/main/java/io/legado/app/help/BookHelp.kt +++ b/app/src/main/java/io/legado/app/help/BookHelp.kt @@ -4,8 +4,8 @@ import android.net.Uri import androidx.documentfile.provider.DocumentFile import com.github.houbb.opencc4j.core.impl.ZhConvertBootstrap import io.legado.app.App +import io.legado.app.R import io.legado.app.constant.EventBus -import io.legado.app.constant.PreferKey import io.legado.app.data.entities.Book import io.legado.app.data.entities.BookChapter import io.legado.app.data.entities.ReplaceRule @@ -21,7 +21,7 @@ import kotlin.math.min object BookHelp { private const val cacheFolderName = "book_cache" val downloadPath: String - get() = App.INSTANCE.getPrefString(PreferKey.downloadPath) + get() = App.INSTANCE.getPrefString(R.string.pk_download_path) ?: App.INSTANCE.getExternalFilesDir(null)?.absolutePath ?: App.INSTANCE.cacheDir.absolutePath diff --git a/app/src/main/java/io/legado/app/ui/config/OtherConfigFragment.kt b/app/src/main/java/io/legado/app/ui/config/OtherConfigFragment.kt index 58caa351d..a010428fd 100644 --- a/app/src/main/java/io/legado/app/ui/config/OtherConfigFragment.kt +++ b/app/src/main/java/io/legado/app/ui/config/OtherConfigFragment.kt @@ -40,7 +40,7 @@ class OtherConfigFragment : PreferenceFragmentCompat(), override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) { putPrefBoolean(PreferKey.processText, isProcessTextEnabled()) addPreferencesFromResource(R.xml.pref_config_other) - upPreferenceSummary(PreferKey.downloadPath, BookHelp.downloadPath) + upPreferenceSummary(getString(R.string.pk_download_path), BookHelp.downloadPath) upPreferenceSummary(PreferKey.threadCount, AppConfig.threadCount.toString()) upPreferenceSummary(PreferKey.webPort, webPort.toString()) } @@ -74,7 +74,7 @@ class OtherConfigFragment : PreferenceFragmentCompat(), .show { putPrefInt(PreferKey.webPort, it) } - PreferKey.downloadPath -> selectDownloadPath() + getString(R.string.pk_download_path) -> selectDownloadPath() PreferKey.cleanCache -> { BookHelp.clearCache() toast(R.string.clear_cache_success) @@ -85,7 +85,7 @@ class OtherConfigFragment : PreferenceFragmentCompat(), override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences?, key: String?) { when (key) { - PreferKey.downloadPath -> { + getString(R.string.pk_download_path) -> { upPreferenceSummary(key, BookHelp.downloadPath) } PreferKey.threadCount -> upPreferenceSummary( @@ -141,13 +141,17 @@ class OtherConfigFragment : PreferenceFragmentCompat(), private fun selectDownloadPath() { FilePicker.selectFolder(this, requestCodeDownloadPath) { - removePref(PreferKey.downloadPath) + removePref(getString(R.string.pk_download_path)) } } + private fun putDownloadPath(path: String) { + putPrefString(getString(R.string.pk_download_path), path) + } + override fun onFilePicked(requestCode: Int, currentPath: String) { if (requestCode == requestCodeDownloadPath) { - putPrefString(PreferKey.downloadPath, currentPath) + putDownloadPath(currentPath) } } @@ -160,7 +164,7 @@ class OtherConfigFragment : PreferenceFragmentCompat(), uri, Intent.FLAG_GRANT_READ_URI_PERMISSION or Intent.FLAG_GRANT_WRITE_URI_PERMISSION ) - putPrefString(PreferKey.downloadPath, uri.toString()) + putDownloadPath(uri.toString()) } } } diff --git a/app/src/main/java/io/legado/app/ui/welcome/WelcomeActivity.kt b/app/src/main/java/io/legado/app/ui/welcome/WelcomeActivity.kt index 5c84aa679..46e1e446e 100644 --- a/app/src/main/java/io/legado/app/ui/welcome/WelcomeActivity.kt +++ b/app/src/main/java/io/legado/app/ui/welcome/WelcomeActivity.kt @@ -48,7 +48,7 @@ open class WelcomeActivity : BaseActivity(R.layout.activity_welcome) { private fun startMainActivity() { startActivity() - if (getPrefBoolean(getString(R.string.pk_default_read))) { + if (getPrefBoolean(R.string.pk_default_read)) { startActivity() } finish() 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 3436c9d94..bc3f6f9fa 100644 --- a/app/src/main/java/io/legado/app/utils/ContextExtensions.kt +++ b/app/src/main/java/io/legado/app/utils/ContextExtensions.kt @@ -12,6 +12,7 @@ import android.os.BatteryManager import android.provider.Settings import androidx.annotation.ColorRes import androidx.annotation.DrawableRes +import androidx.annotation.StringRes import androidx.core.content.ContextCompat import androidx.core.content.FileProvider import androidx.core.content.edit @@ -28,6 +29,9 @@ import java.io.FileOutputStream fun Context.getPrefBoolean(key: String, defValue: Boolean = false) = defaultSharedPreferences.getBoolean(key, defValue) +fun Context.getPrefBoolean(@StringRes keyId: Int, defValue: Boolean = false) = + defaultSharedPreferences.getBoolean(getString(keyId), defValue) + fun Context.putPrefBoolean(key: String, value: Boolean = false) = defaultSharedPreferences.edit { putBoolean(key, value) } @@ -46,6 +50,9 @@ fun Context.putPrefLong(key: String, value: Long) = fun Context.getPrefString(key: String, defValue: String? = null) = defaultSharedPreferences.getString(key, defValue) +fun Context.getPrefString(@StringRes keyId: Int, defValue: String? = null) = + defaultSharedPreferences.getString(getString(keyId), defValue) + fun Context.putPrefString(key: String, value: String) = defaultSharedPreferences.edit { putString(key, value) } From e9e483ac0ab4050f32cd8303e329ae5207e111cd Mon Sep 17 00:00:00 2001 From: fisher Date: Mon, 9 Mar 2020 21:25:05 +0800 Subject: [PATCH 19/34] added numerical format --- app/src/main/assets/txtTocRule.json | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/app/src/main/assets/txtTocRule.json b/app/src/main/assets/txtTocRule.json index cce871125..b4f6f5b28 100644 --- a/app/src/main/assets/txtTocRule.json +++ b/app/src/main/assets/txtTocRule.json @@ -23,70 +23,76 @@ "rule": "^[  \\t]{0,4}(?:前言|序章|楔子|正文(?!完|结)|终章|后记|尾声|番外|第?\\s{0,4}[\\d零一二两三四五六七八九十百千万壹贰叁肆伍陆柒捌玖拾佰仟]+?\\s{0,4}(?:章|节(?!课)|卷|集(?![合和])|部(?!分)|回(?![合来事去])|场(?![和合比电是])|篇(?!张))).{0,30}$", "serialNumber": 3 }, + { + "enable": false, + "name": "数字(纯数字标题)", + "rule": "^\\d+$", + "serialNumber": 4 + }, { "enable": true, "name": "数字 分隔符 标题名称", "rule": "^[  \\t]{0,4}\\d{1,5}[\\,\\., 、\\-].{1,30}$", - "serialNumber": 4 + "serialNumber": 5 }, { "enable": true, "name": "正文 标题/序号", "rule": "^[  \\t]{0,4}正文[  ]{1,4}.{0,20}$", - "serialNumber": 5 + "serialNumber": 6 }, { "enable": true, "name": "Chapter/Section/Part/Episode 序号 标题", "rule": "^[  \\t]{0,4}(?:[Cc]hapter|[Ss]ection|[Pp]art|PART|[Ee]pisode|(?:内容|文章)?简介|文案|前言|序章|楔子|正文(?!完|结)|终章|后记|尾声|番外)\\s{0,4}\\d{1,4}.{0,30}$", - "serialNumber": 6 + "serialNumber": 7 }, { "enable": false, "name": "Chapter(去简介)", "rule": "^[  \\t]{0,4}(?:[Cc]hapter|[Ss]ection|[Pp]art|PART|[Ee]pisode)\\s{0,4}\\d{1,4}.{0,30}$", - "serialNumber": 7 + "serialNumber": 8 }, { "enable": true, "name": "特殊符号 序号 标题", "rule": "(?<=[\\s ]{0,4}).{1,3}(?:第|卷|[Cc]hapter)[\\d零一二两三四五六七八九十百千万壹贰叁肆伍陆柒捌玖拾佰仟]{1,10}[章节]?[\\.:: \f\t].{0,20}$", - "serialNumber": 8 + "serialNumber": 9 }, { "enable": false, "name": "特殊符号 标题(成对)", "rule": "(?<=[\\s ]{0,4})(?:[\\[〈「『〖〔《(【\\(].{1,30}[\\)】)》〕〗』」〉\\]]?|(?:内容|文章)?简介|文案|前言|序章|楔子|正文(?!完|结)|终章|后记|尾声|番外)[  ]{0,4}$", - "serialNumber": 9 + "serialNumber": 10 }, { "enable":true, "name": "特殊符号 标题(单个)", "rule": "(?<=[\\s ]{0,4})(?:[☆★✦✧].{1,30}|(?:内容|文章)?简介|文案|前言|序章|楔子|正文(?!完|结)|终章|后记|尾声|番外)[  ]{0,4}$", - "serialNumber": 10 + "serialNumber": 11 }, { "enable": true, "name": "章/卷 序号 标题", "rule": "^[ \\t ]{0,4}(?:(?:内容|文章)?简介|文案|前言|序章|楔子|正文(?!完|结)|终章|后记|尾声|番外|[卷章][\\d零一二两三四五六七八九十百千万壹贰叁肆伍陆柒捌玖拾佰仟]{1,8})[  ]{0,4}.{0,30}$", - "serialNumber": 11 + "serialNumber": 12 }, { "enable":false, "name": "顶格标题", "rule": "^\\S.{1,20}$", - "serialNumber": 12 + "serialNumber": 13 }, { "enable":false, "name": "双标题(前向)", "rule": "(?m)(?<=[ \\t ]{0,4})第[\\d零一二两三四五六七八九十百千万壹贰叁肆伍陆柒捌玖拾佰仟]{1,8}章.{0,30}$(?=[\\s ]{0,8}第[\\d零一二两三四五六七八九十百千万壹贰叁肆伍陆柒捌玖拾佰仟]{1,8}章)", - "serialNumber": 13 + "serialNumber": 14 }, { "enable":false, "name": "双标题(后向)", "rule": "(?m)(?<=[ \\t ]{0,4}第[\\d零一二两三四五六七八九十百千万壹贰叁肆伍陆柒捌玖拾佰仟]{1,8}章.{0,30}$[\\s ]{0,8})第[\\d零一二两三四五六七八九十百千万壹贰叁肆伍陆柒捌玖拾佰仟]{1,8}章.{0,30}$", - "serialNumber": 14 + "serialNumber": 15 } ] From 7f1add2b31493bf8002938b7ec94e6426cc2f5bd Mon Sep 17 00:00:00 2001 From: kunfei Date: Mon, 9 Mar 2020 21:29:07 +0800 Subject: [PATCH 20/34] =?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/AppConfig.kt | 3 +++ .../java/io/legado/app/ui/config/OtherConfigFragment.kt | 7 +++++++ app/src/main/res/values/arrays.xml | 2 +- app/src/main/res/values/pref_key_value.xml | 2 +- app/src/main/res/xml/pref_config_other.xml | 8 ++++++++ 5 files changed, 20 insertions(+), 2 deletions(-) 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 9d6f87d61..4b768b9e7 100644 --- a/app/src/main/java/io/legado/app/help/AppConfig.kt +++ b/app/src/main/java/io/legado/app/help/AppConfig.kt @@ -32,6 +32,9 @@ object AppConfig { App.INSTANCE.putPrefBoolean("transparentStatusBar", value) } + val requestedDirection: String? + get() = App.INSTANCE.getPrefString(R.string.pk_requested_direction) + var backupPath: String? get() = App.INSTANCE.getPrefString(PreferKey.backupPath) set(value) { diff --git a/app/src/main/java/io/legado/app/ui/config/OtherConfigFragment.kt b/app/src/main/java/io/legado/app/ui/config/OtherConfigFragment.kt index a010428fd..c6633461a 100644 --- a/app/src/main/java/io/legado/app/ui/config/OtherConfigFragment.kt +++ b/app/src/main/java/io/legado/app/ui/config/OtherConfigFragment.kt @@ -43,6 +43,10 @@ class OtherConfigFragment : PreferenceFragmentCompat(), upPreferenceSummary(getString(R.string.pk_download_path), BookHelp.downloadPath) upPreferenceSummary(PreferKey.threadCount, AppConfig.threadCount.toString()) upPreferenceSummary(PreferKey.webPort, webPort.toString()) + upPreferenceSummary( + getString(R.string.pk_requested_direction), + AppConfig.requestedDirection + ) } override fun onViewCreated(view: View, savedInstanceState: Bundle?) { @@ -103,6 +107,9 @@ class OtherConfigFragment : PreferenceFragmentCompat(), setProcessTextEnable(it.getBoolean(key, true)) } PreferKey.showRss -> postEvent(EventBus.SHOW_RSS, "unused") + getString(R.string.pk_requested_direction) -> { + upPreferenceSummary(key, AppConfig.requestedDirection) + } } } diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml index 104febad6..a53546e7f 100644 --- a/app/src/main/res/values/arrays.xml +++ b/app/src/main/res/values/arrays.xml @@ -67,7 +67,7 @@ @string/app_folder_picker - + @string/screen_unspecified @string/screen_portrait @string/screen_landscape diff --git a/app/src/main/res/values/pref_key_value.xml b/app/src/main/res/values/pref_key_value.xml index 7bcded4da..0c535ad67 100644 --- a/app/src/main/res/values/pref_key_value.xml +++ b/app/src/main/res/values/pref_key_value.xml @@ -1,7 +1,7 @@ auto_refresh - list_screen_direction + list_screen_direction full_screen threads_num user_agent diff --git a/app/src/main/res/xml/pref_config_other.xml b/app/src/main/res/xml/pref_config_other.xml index b049bcf22..bc241370e 100644 --- a/app/src/main/res/xml/pref_config_other.xml +++ b/app/src/main/res/xml/pref_config_other.xml @@ -6,6 +6,14 @@ android:title="@string/main_activity" app:iconSpaceReserved="false"> + + Date: Mon, 9 Mar 2020 21:58:39 +0800 Subject: [PATCH 21/34] =?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/res/values/array_values.xml | 6 ++++++ app/src/main/res/xml/pref_config_other.xml | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/app/src/main/res/values/array_values.xml b/app/src/main/res/values/array_values.xml index 2aa918837..c517c46ce 100644 --- a/app/src/main/res/values/array_values.xml +++ b/app/src/main/res/values/array_values.xml @@ -38,5 +38,11 @@ 9 + + 0 + 1 + 2 + 3 + \ No newline at end of file diff --git a/app/src/main/res/xml/pref_config_other.xml b/app/src/main/res/xml/pref_config_other.xml index bc241370e..6bf712292 100644 --- a/app/src/main/res/xml/pref_config_other.xml +++ b/app/src/main/res/xml/pref_config_other.xml @@ -8,10 +8,10 @@ Date: Mon, 9 Mar 2020 22:20:33 +0800 Subject: [PATCH 22/34] =?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 + .../main/java/io/legado/app/ui/book/read/Help.kt | 13 +++++++++++++ .../io/legado/app/ui/book/read/ReadBookActivity.kt | 5 +++++ .../app/ui/book/read/config/MoreConfigDialog.kt | 5 +++++ .../io/legado/app/ui/config/OtherConfigFragment.kt | 7 ------- app/src/main/res/xml/pref_config_other.xml | 8 -------- app/src/main/res/xml/pref_config_read.xml | 8 ++++++++ 7 files changed, 32 insertions(+), 15 deletions(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 67af4688e..543c13f6c 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -185,6 +185,7 @@ android:launchMode="singleTop" /> requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED + "1" -> requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT + "2" -> requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE + "3" -> requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR + } + } + + /** * 返回NavigationBar是否存在 * 该方法需要在View完全被绘制出来之后调用,否则判断不了 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 2ca4555a3..3696ccbab 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 @@ -88,6 +88,11 @@ class ReadBookActivity : VMBaseActivity(R.layout.activity_boo override val pageFactory: TextPageFactory get() = page_view.pageFactory override val headerHeight: Int get() = page_view.curPage.headerHeight + override fun onCreate(savedInstanceState: Bundle?) { + Help.setOrientation(this) + super.onCreate(savedInstanceState) + } + override fun onActivityCreated(savedInstanceState: Bundle?) { Help.upLayoutInDisplayCutoutMode(window) initView() diff --git a/app/src/main/java/io/legado/app/ui/book/read/config/MoreConfigDialog.kt b/app/src/main/java/io/legado/app/ui/book/read/config/MoreConfigDialog.kt index 6f472f270..a23725143 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/config/MoreConfigDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/config/MoreConfigDialog.kt @@ -104,6 +104,11 @@ class MoreConfigDialog : DialogFragment() { } PreferKey.keepLight -> postEvent(key, true) PreferKey.textSelectAble -> postEvent(key, getPrefBoolean(key)) + getString(R.string.pk_requested_direction) -> { + activity?.let { + Help.setOrientation(it) + } + } } } diff --git a/app/src/main/java/io/legado/app/ui/config/OtherConfigFragment.kt b/app/src/main/java/io/legado/app/ui/config/OtherConfigFragment.kt index c6633461a..a010428fd 100644 --- a/app/src/main/java/io/legado/app/ui/config/OtherConfigFragment.kt +++ b/app/src/main/java/io/legado/app/ui/config/OtherConfigFragment.kt @@ -43,10 +43,6 @@ class OtherConfigFragment : PreferenceFragmentCompat(), upPreferenceSummary(getString(R.string.pk_download_path), BookHelp.downloadPath) upPreferenceSummary(PreferKey.threadCount, AppConfig.threadCount.toString()) upPreferenceSummary(PreferKey.webPort, webPort.toString()) - upPreferenceSummary( - getString(R.string.pk_requested_direction), - AppConfig.requestedDirection - ) } override fun onViewCreated(view: View, savedInstanceState: Bundle?) { @@ -107,9 +103,6 @@ class OtherConfigFragment : PreferenceFragmentCompat(), setProcessTextEnable(it.getBoolean(key, true)) } PreferKey.showRss -> postEvent(EventBus.SHOW_RSS, "unused") - getString(R.string.pk_requested_direction) -> { - upPreferenceSummary(key, AppConfig.requestedDirection) - } } } diff --git a/app/src/main/res/xml/pref_config_other.xml b/app/src/main/res/xml/pref_config_other.xml index 6bf712292..b049bcf22 100644 --- a/app/src/main/res/xml/pref_config_other.xml +++ b/app/src/main/res/xml/pref_config_other.xml @@ -6,14 +6,6 @@ android:title="@string/main_activity" app:iconSpaceReserved="false"> - - + + Date: Mon, 9 Mar 2020 22:37:17 +0800 Subject: [PATCH 23/34] =?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/ReadBookActivity.kt | 6 ++++++ 1 file changed, 6 insertions(+) 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 3696ccbab..3ac7715e6 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 @@ -3,6 +3,7 @@ package io.legado.app.ui.book.read import android.annotation.SuppressLint import android.app.Activity import android.content.Intent +import android.content.res.Configuration import android.net.Uri import android.os.Bundle import android.os.Handler @@ -111,6 +112,11 @@ class ReadBookActivity : VMBaseActivity(R.layout.activity_boo upSystemUiVisibility() } + override fun onConfigurationChanged(newConfig: Configuration) { + super.onConfigurationChanged(newConfig) + ReadBook.loadContent() + } + override fun onResume() { super.onResume() upSystemUiVisibility() From ef3049c8d3f22022f186018c3856b287e9741b91 Mon Sep 17 00:00:00 2001 From: kunfei Date: Mon, 9 Mar 2020 22:54:35 +0800 Subject: [PATCH 24/34] =?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/ReadBookActivity.kt | 8 ++++---- .../io/legado/app/ui/book/read/page/PageView.kt | 16 ++++++---------- .../ui/book/read/page/delegate/PageDelegate.kt | 13 +++++++++---- 3 files changed, 19 insertions(+), 18 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 3ac7715e6..ffdcfcbfc 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 @@ -349,7 +349,8 @@ class ReadBookActivity : VMBaseActivity(R.layout.activity_boo @SuppressLint("ClickableViewAccessibility") override fun onTouch(v: View, event: MotionEvent): Boolean { when (event.action) { - MotionEvent.ACTION_MOVE, MotionEvent.ACTION_UP -> { + MotionEvent.ACTION_DOWN -> textActionMenu?.dismiss() + MotionEvent.ACTION_MOVE -> { when (v.id) { R.id.cursor_left -> page_view.curPage.selectStartMove( event.rawX + cursor_left.width, @@ -361,6 +362,7 @@ class ReadBookActivity : VMBaseActivity(R.layout.activity_boo ) } } + MotionEvent.ACTION_UP -> showTextActionMenu() } return true } @@ -372,7 +374,6 @@ class ReadBookActivity : VMBaseActivity(R.layout.activity_boo cursor_left.x = x - cursor_left.width cursor_left.y = y cursor_left.visible(true) - showTextActionMenu() } /** @@ -382,7 +383,6 @@ class ReadBookActivity : VMBaseActivity(R.layout.activity_boo cursor_right.x = x cursor_right.y = y cursor_right.visible(true) - showTextActionMenu() } /** @@ -397,7 +397,7 @@ class ReadBookActivity : VMBaseActivity(R.layout.activity_boo /** * 显示文本操作菜单 */ - private fun showTextActionMenu() { + override fun showTextActionMenu() { textActionMenu ?: let { textActionMenu = TextActionMenu(this, this) } 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 dbde99c7e..1b7b71b07 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 @@ -16,25 +16,20 @@ class PageView(context: Context, attrs: AttributeSet) : FrameLayout(context, attrs), DataSource { - var callBack: CallBack - var pageFactory: TextPageFactory + val callBack: CallBack get() = activity as CallBack + var pageFactory: TextPageFactory = TextPageFactory(this) var pageDelegate: PageDelegate? = null - var prevPage: ContentView - var curPage: ContentView - var nextPage: ContentView + var prevPage: ContentView = ContentView(context) + var curPage: ContentView = ContentView(context) + var nextPage: ContentView = ContentView(context) init { - callBack = activity as CallBack - nextPage = ContentView(context) addView(nextPage) - curPage = ContentView(context) addView(curPage) - prevPage = ContentView(context) addView(prevPage) upBg() setWillNotDraw(false) - pageFactory = TextPageFactory(this) upPageAnim() } @@ -170,5 +165,6 @@ class PageView(context: Context, attrs: AttributeSet) : val isInitFinish: Boolean fun clickCenter() fun screenOffTimerStart() + fun showTextActionMenu() } } 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 4173ffb09..d83f60edb 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 @@ -200,11 +200,16 @@ abstract class PageDelegate(protected val pageView: PageView) : //GestureDetector.onFling小幅移动不会触发,所以要自己判断 when (event.action) { MotionEvent.ACTION_UP, - MotionEvent.ACTION_CANCEL -> if (isMoved) { - if (selectedOnDown) { - selectedOnDown = false + MotionEvent.ACTION_CANCEL -> { + if (isTextSelected) { + pageView.callBack.showTextActionMenu() + } + if (isMoved) { + if (selectedOnDown) { + selectedOnDown = false + } + if (!noNext) onAnimStart() } - if (!noNext) onAnimStart() } } } From e4865324b19e5a49564cf189c09d0efc5605f885 Mon Sep 17 00:00:00 2001 From: fisher Date: Tue, 10 Mar 2020 00:35:02 +0800 Subject: [PATCH 25/34] update rules --- app/src/main/assets/txtTocRule.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/assets/txtTocRule.json b/app/src/main/assets/txtTocRule.json index b4f6f5b28..ececb6800 100644 --- a/app/src/main/assets/txtTocRule.json +++ b/app/src/main/assets/txtTocRule.json @@ -26,7 +26,7 @@ { "enable": false, "name": "数字(纯数字标题)", - "rule": "^\\d+$", + "rule": "(?<=[ \\s])\\d+[  \\t]{0,4}$", "serialNumber": 4 }, { From ce7142222cdd4cee1cd9283d15cc652c5cabf9a5 Mon Sep 17 00:00:00 2001 From: kunfei Date: Tue, 10 Mar 2020 09:10:35 +0800 Subject: [PATCH 26/34] =?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/model/localBook/LocalBook.kt | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/io/legado/app/model/localBook/LocalBook.kt b/app/src/main/java/io/legado/app/model/localBook/LocalBook.kt index 9a893b8a3..fc94613d8 100644 --- a/app/src/main/java/io/legado/app/model/localBook/LocalBook.kt +++ b/app/src/main/java/io/legado/app/model/localBook/LocalBook.kt @@ -4,6 +4,7 @@ import android.net.Uri import androidx.documentfile.provider.DocumentFile import io.legado.app.App import io.legado.app.data.entities.Book +import io.legado.app.help.BookHelp import io.legado.app.utils.FileUtils @@ -12,8 +13,17 @@ object LocalBook { fun importFile(doc: DocumentFile) { doc.name?.let { fileName -> val str = fileName.substringBeforeLast(".") - var name = str.substringBefore("作者") - val author = str.substringAfter("作者", "") + val authorIndex = str.indexOf("作者") + var name: String + var author: String + if (authorIndex == -1) { + name = str + author = "" + } else { + name = str.substring(0, authorIndex) + author = str.substring(authorIndex) + author = BookHelp.formatAuthor(author) + } val smhStart = name.indexOf("《") val smhEnd = name.indexOf("》") if (smhStart != -1 && smhEnd != -1) { From ec362af975810c7452a7000fcc12a9f3a7f3be23 Mon Sep 17 00:00:00 2001 From: kunfei Date: Tue, 10 Mar 2020 10:34:47 +0800 Subject: [PATCH 27/34] =?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/ReadBookActivity.kt | 18 +++---- .../app/ui/book/read/page/ContentTextView.kt | 53 ++++++++++++++----- .../main/res/layout/activity_book_read.xml | 6 +++ 3 files changed, 56 insertions(+), 21 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 ffdcfcbfc..c6294c290 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 @@ -370,10 +370,12 @@ class ReadBookActivity : VMBaseActivity(R.layout.activity_boo /** * 更新文字选择开始位置 */ - override fun upSelectedStart(x: Float, y: Float) { + override fun upSelectedStart(x: Float, y: Float, top: Float) { cursor_left.x = x - cursor_left.width cursor_left.y = y cursor_left.visible(true) + text_menu_position.x = x + text_menu_position.y = top } /** @@ -399,17 +401,15 @@ class ReadBookActivity : VMBaseActivity(R.layout.activity_boo */ override fun showTextActionMenu() { textActionMenu ?: let { - textActionMenu = TextActionMenu(this, this) - } - val x = cursor_left.x.toInt() + cursor_left.width - val y = if (cursor_left.y - statusBarHeight > ReadBookConfig.textSize.dp * 1.5 + 20.dp) { - (page_view.height - cursor_left.y + ReadBookConfig.textSize.dp * 1.5).toInt() - } else { - (page_view.height - cursor_left.y - cursor_left.height - 40.dp).toInt() + textActionMenu = TextActionMenu(this, this).apply { + contentView.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED) + } } textActionMenu?.let { popup -> + val x = text_menu_position.x.toInt() + val y = text_menu_position.y.toInt() - popup.contentView.measuredHeight if (!popup.isShowing) { - popup.showAtLocation(cursor_left, Gravity.BOTTOM or Gravity.START, x, y) + popup.showAtLocation(text_menu_position, Gravity.TOP or Gravity.START, x, y) } else { popup.update(x, y, WRAP_CONTENT, WRAP_CONTENT) } 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 44baa68f6..53f03462f 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 @@ -31,6 +31,7 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at private val selectStart = arrayOf(0, 0, 0) private val selectEnd = arrayOf(0, 0, 0) private var textPage: TextPage = TextPage() + //滚动参数 private val pageFactory: TextPageFactory get() = callBack.pageFactory private val maxScrollOffset = 100f @@ -210,7 +211,11 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at selectEnd[0] = 0 selectEnd[1] = lineIndex selectEnd[2] = charIndex - upSelectedStart(textChar.start, textLine.lineBottom + relativeOffset) + upSelectedStart( + textChar.start, + textLine.lineBottom + relativeOffset, + textLine.lineTop + relativeOffset + ) upSelectedEnd(textChar.end, textLine.lineBottom + relativeOffset) select(0, lineIndex, charIndex) return @@ -236,7 +241,11 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at selectEnd[0] = 1 selectEnd[1] = lineIndex selectEnd[2] = charIndex - upSelectedStart(textChar.start, textLine.lineBottom + relativeOffset) + upSelectedStart( + textChar.start, + textLine.lineBottom + relativeOffset, + textLine.lineTop + relativeOffset + ) upSelectedEnd(textChar.end, textLine.lineBottom + relativeOffset) select(1, lineIndex, charIndex) return @@ -259,7 +268,11 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at selectEnd[0] = 2 selectEnd[1] = lineIndex selectEnd[2] = charIndex - upSelectedStart(textChar.start, textLine.lineBottom + relativeOffset) + upSelectedStart( + textChar.start, + textLine.lineBottom + relativeOffset, + textLine.lineTop + relativeOffset + ) upSelectedEnd(textChar.end, textLine.lineBottom + relativeOffset) select(2, lineIndex, charIndex) return @@ -287,7 +300,11 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at selectStart[0] = 0 selectStart[1] = lineIndex selectStart[2] = charIndex - upSelectedStart(textChar.start, textLine.lineBottom + relativeOffset) + upSelectedStart( + textChar.start, + textLine.lineBottom + relativeOffset, + textLine.lineTop + relativeOffset + ) upSelectChars() } return @@ -311,7 +328,11 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at selectStart[0] = 1 selectStart[1] = lineIndex selectStart[2] = charIndex - upSelectedStart(textChar.start, textLine.lineBottom + relativeOffset) + upSelectedStart( + textChar.start, + textLine.lineBottom + relativeOffset, + textLine.lineTop + relativeOffset + ) upSelectChars() } return @@ -333,7 +354,11 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at selectStart[0] = 2 selectStart[1] = lineIndex selectStart[2] = charIndex - upSelectedStart(textChar.start, textLine.lineBottom + relativeOffset) + upSelectedStart( + textChar.start, + textLine.lineBottom + relativeOffset, + textLine.lineTop + relativeOffset + ) upSelectChars() } return @@ -427,7 +452,11 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at selectStart[2] = charIndex val textLine = relativePage(relativePage).textLines[lineIndex] val textChar = textLine.textChars[charIndex] - upSelectedStart(textChar.start, textLine.lineBottom + relativeOffset(relativePage)) + upSelectedStart( + textChar.start, + textLine.lineBottom + relativeOffset(relativePage), + textLine.lineTop + ) upSelectChars() } @@ -475,12 +504,12 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at invalidate() } - private fun upSelectedStart(x: Float, y: Float) { - callBack.upSelectedStart(x, y + callBack.headerHeight) + private fun upSelectedStart(x: Float, y: Float, top: Float) = callBack.apply { + upSelectedStart(x, y + headerHeight, top + headerHeight) } - private fun upSelectedEnd(x: Float, y: Float) { - callBack.upSelectedEnd(x, y + callBack.headerHeight) + private fun upSelectedEnd(x: Float, y: Float) = callBack.apply { + upSelectedEnd(x, y + headerHeight) } fun cancelSelect() { @@ -580,7 +609,7 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at } interface CallBack { - fun upSelectedStart(x: Float, y: Float) + fun upSelectedStart(x: Float, y: Float, top: Float) fun upSelectedEnd(x: Float, y: Float) fun onCancelSelect() val headerHeight: Int diff --git a/app/src/main/res/layout/activity_book_read.xml b/app/src/main/res/layout/activity_book_read.xml index 35d8d5f45..3fc498716 100644 --- a/app/src/main/res/layout/activity_book_read.xml +++ b/app/src/main/res/layout/activity_book_read.xml @@ -9,6 +9,12 @@ android:layout_width="match_parent" android:layout_height="match_parent" /> + + Date: Tue, 10 Mar 2020 10:51:52 +0800 Subject: [PATCH 28/34] =?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/ReadBookActivity.kt | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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 c6294c290..43c6ef541 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 @@ -406,8 +406,15 @@ class ReadBookActivity : VMBaseActivity(R.layout.activity_boo } } textActionMenu?.let { popup -> + val popupHeight = popup.contentView.measuredHeight val x = text_menu_position.x.toInt() - val y = text_menu_position.y.toInt() - popup.contentView.measuredHeight + var y = text_menu_position.y.toInt() - popupHeight + if (y < statusBarHeight) { + y = (cursor_left.y + cursor_left.height).toInt() + } + if (cursor_right.y > y && cursor_right.y < y + popupHeight) { + y = (cursor_right.y + cursor_right.height).toInt() + } if (!popup.isShowing) { popup.showAtLocation(text_menu_position, Gravity.TOP or Gravity.START, x, y) } else { From 853d970642013f66128b2d9b87bd1f84382e6e4b Mon Sep 17 00:00:00 2001 From: kunfei Date: Tue, 10 Mar 2020 10:58:08 +0800 Subject: [PATCH 29/34] =?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/TextActionMenu.kt | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) 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 7e90c7ad1..9d7046f6e 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 @@ -151,15 +151,16 @@ class TextActionMenu(private val context: Context, private val callBack: CallBac */ @RequiresApi(Build.VERSION_CODES.M) private fun onInitializeMenu(menu: Menu) { - // Start with a menu Item order value that is high enough - // so that your "PROCESS_TEXT" menu items appear after the - // standard selection menu items like Cut, Copy, Paste. - var menuItemOrder = 100 - for (resolveInfo in getSupportedActivities()) { - menu.add( - Menu.NONE, Menu.NONE, - menuItemOrder++, resolveInfo.loadLabel(context.packageManager) - ).intent = createProcessTextIntentForResolveInfo(resolveInfo) + try { + var menuItemOrder = 100 + for (resolveInfo in getSupportedActivities()) { + menu.add( + Menu.NONE, Menu.NONE, + menuItemOrder++, resolveInfo.loadLabel(context.packageManager) + ).intent = createProcessTextIntentForResolveInfo(resolveInfo) + } + } catch (e: Exception) { + context.toast("获取文字操作菜单出错:${e.localizedMessage}") } } From 664813061ec231a7d021fd881a96a6c3b52b5efb Mon Sep 17 00:00:00 2001 From: kunfei Date: Tue, 10 Mar 2020 11:01:50 +0800 Subject: [PATCH 30/34] =?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 fe74ee832..7cfdcfb4c 100644 --- a/app/src/main/assets/updateLog.md +++ b/app/src/main/assets/updateLog.md @@ -2,6 +2,10 @@ * 旧版数据导入教程:先在旧版阅读(2.x)中进行备份,然后在新版阅读(3.x)【我的】->【备份与恢复】,选择【导入旧版本数据】。 * 请关注[开源阅读软件]()支持我,同时关注合作公众号[小说拾遗](),阅读公众号小编。 +**2020/03/10** +* 优化文字选择菜单弹出位置 +* 添加屏幕方向控制 + **2020/03/09** * 底部文字对齐 * 主题添加阴影调节 by yangyxd From 838bc6f034b8a4b752f1f2ffad3121a305732866 Mon Sep 17 00:00:00 2001 From: kunfei Date: Tue, 10 Mar 2020 11:04:42 +0800 Subject: [PATCH 31/34] =?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/res/layout/popup_action_menu.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/res/layout/popup_action_menu.xml b/app/src/main/res/layout/popup_action_menu.xml index c6b9067d7..98cceb33c 100644 --- a/app/src/main/res/layout/popup_action_menu.xml +++ b/app/src/main/res/layout/popup_action_menu.xml @@ -16,7 +16,7 @@ android:id="@+id/iv_menu_more" android:layout_width="24dp" android:layout_height="24dp" - android:background="?attr/selectableItemBackground" + android:background="?attr/selectableItemBackgroundBorderless" android:src="@drawable/ic_more_vert" android:tint="@color/tv_text_default" android:visibility="gone" From 339ab4c2705bfa89a1eb20f8fb64f58ce0684cbb Mon Sep 17 00:00:00 2001 From: kunfei Date: Tue, 10 Mar 2020 11:46:16 +0800 Subject: [PATCH 32/34] =?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 | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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 43c6ef541..3de366ec3 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 @@ -14,6 +14,7 @@ import androidx.core.view.isVisible import androidx.core.view.size import androidx.lifecycle.Observer import com.jaredrummler.android.colorpicker.ColorPickerDialogListener +import io.legado.app.BuildConfig import io.legado.app.R import io.legado.app.base.VMBaseActivity import io.legado.app.constant.EventBus @@ -681,7 +682,9 @@ class ReadBookActivity : VMBaseActivity(R.layout.activity_boo mHandler.removeCallbacks(keepScreenRunnable) textActionMenu?.dismiss() page_view.onDestroy() - SyncBookProgress.uploadBookProgress() + if (!BuildConfig.DEBUG) { + SyncBookProgress.uploadBookProgress() + } } override fun observeLiveBus() { From bc06effc6a1bc5805ef46fb002b3c4f4ccc571c4 Mon Sep 17 00:00:00 2001 From: kunfei Date: Tue, 10 Mar 2020 13:10:33 +0800 Subject: [PATCH 33/34] =?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/config/ThemeConfigFragment.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/io/legado/app/ui/config/ThemeConfigFragment.kt b/app/src/main/java/io/legado/app/ui/config/ThemeConfigFragment.kt index 17a3bcfe1..5eb887f31 100644 --- a/app/src/main/java/io/legado/app/ui/config/ThemeConfigFragment.kt +++ b/app/src/main/java/io/legado/app/ui/config/ThemeConfigFragment.kt @@ -1,6 +1,7 @@ package io.legado.app.ui.config import android.content.SharedPreferences +import android.os.Build import android.os.Bundle import android.view.View import androidx.preference.Preference @@ -16,7 +17,6 @@ import io.legado.app.lib.dialogs.noButton import io.legado.app.lib.dialogs.yesButton import io.legado.app.lib.theme.ATH import io.legado.app.lib.theme.ColorUtils -import io.legado.app.lib.theme.elevation import io.legado.app.ui.widget.number.NumberPickerDialog import io.legado.app.utils.* @@ -27,6 +27,9 @@ class ThemeConfigFragment : PreferenceFragmentCompat(), SharedPreferences.OnShar override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) { addPreferencesFromResource(R.xml.pref_config_theme) + if (Build.VERSION.SDK_INT < 26) { + preferenceScreen.removePreference(findPreference(PreferKey.launcherIcon)) + } upPreferenceSummary("barElevation", AppConfig.elevation.toString()) } From f6d010923b0047c63b45136316050a2ffbbd1032 Mon Sep 17 00:00:00 2001 From: kunfei Date: Tue, 10 Mar 2020 13:13:33 +0800 Subject: [PATCH 34/34] =?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/config/ThemeConfigFragment.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/io/legado/app/ui/config/ThemeConfigFragment.kt b/app/src/main/java/io/legado/app/ui/config/ThemeConfigFragment.kt index 5eb887f31..da2672841 100644 --- a/app/src/main/java/io/legado/app/ui/config/ThemeConfigFragment.kt +++ b/app/src/main/java/io/legado/app/ui/config/ThemeConfigFragment.kt @@ -18,6 +18,7 @@ import io.legado.app.lib.dialogs.yesButton import io.legado.app.lib.theme.ATH import io.legado.app.lib.theme.ColorUtils import io.legado.app.ui.widget.number.NumberPickerDialog +import io.legado.app.ui.widget.prefs.IconListPreference import io.legado.app.utils.* @@ -28,7 +29,9 @@ class ThemeConfigFragment : PreferenceFragmentCompat(), SharedPreferences.OnShar override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) { addPreferencesFromResource(R.xml.pref_config_theme) if (Build.VERSION.SDK_INT < 26) { - preferenceScreen.removePreference(findPreference(PreferKey.launcherIcon)) + findPreference(PreferKey.launcherIcon)?.let { + preferenceScreen.removePreference(it) + } } upPreferenceSummary("barElevation", AppConfig.elevation.toString()) }