From 6a0542f5addf1a7ada7017a8b73535bfb219b525 Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 6 Mar 2020 21:01:30 +0800 Subject: [PATCH 001/359] =?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 | 4 + .../ui/book/read/config/ReadStyleDialog.kt | 30 +- .../app/ui/book/read/config/ReadTypeDialog.kt | 85 +++ .../main/res/drawable/ic_type_default_1.xml | 12 + .../main/res/drawable/ic_type_default_2.xml | 15 + .../main/res/drawable/ic_type_default_3.xml | 18 + .../res/layout/dialog_read_book_style.xml | 497 ++++++++++-------- app/src/main/res/layout/dialog_read_type.xml | 36 ++ app/src/main/res/values/strings.xml | 4 + 9 files changed, 447 insertions(+), 254 deletions(-) create mode 100644 app/src/main/java/io/legado/app/ui/book/read/config/ReadTypeDialog.kt create mode 100644 app/src/main/res/drawable/ic_type_default_1.xml create mode 100644 app/src/main/res/drawable/ic_type_default_2.xml create mode 100644 app/src/main/res/drawable/ic_type_default_3.xml create mode 100644 app/src/main/res/layout/dialog_read_type.xml 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 de1f1d728..e85a0db31 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 @@ -152,6 +152,10 @@ class ReadBookActivity : VMBaseActivity(R.layout.activity_boo PaddingConfigDialog().show(supportFragmentManager, "paddingConfig") } + fun showTypeConfig() { + ReadTypeDialog().show(supportFragmentManager, "readTypeDialog") + } + fun showBgTextConfig() { BgTextConfigDialog().show(supportFragmentManager, "bgTextConfig") } 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 4a5d435cf..71604dfb8 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 @@ -75,14 +75,6 @@ class ReadStyleDialog : DialogFragment(), FontSelectDialog.CallBack { private fun initView() { root_view.setBackgroundColor(requireContext().bottomBackground) - dsb_text_size.valueFormat = { - (it + 5).toString() - } - dsb_text_letter_spacing.valueFormat = { - ((it - 50) / 100f).toString() - } - dsb_line_size.valueFormat = { ((it - 10) / 10f).toString() } - dsb_paragraph_spacing.valueFormat = { (it / 10f).toString() } } private fun initData() { @@ -131,21 +123,9 @@ class ReadStyleDialog : DialogFragment(), FontSelectDialog.CallBack { dismiss() callBack?.showPaddingConfig() } - dsb_text_size.onChanged = { - ReadBookConfig.textSize = it + 10 - postEvent(EventBus.UP_CONFIG, true) - } - dsb_text_letter_spacing.onChanged = { - ReadBookConfig.letterSpacing = (it - 50) / 100f - postEvent(EventBus.UP_CONFIG, true) - } - dsb_line_size.onChanged = { - ReadBookConfig.lineSpacingExtra = it - postEvent(EventBus.UP_CONFIG, true) - } - dsb_paragraph_spacing.onChanged = { - ReadBookConfig.paragraphSpacing = it - postEvent(EventBus.UP_CONFIG, true) + tv_type.onClick { + dismiss() + callBack?.showTypeConfig() } rg_page_anim.onCheckedChange { _, checkedId -> rg_page_anim.getIndexById(checkedId).let { @@ -193,10 +173,6 @@ class ReadStyleDialog : DialogFragment(), FontSelectDialog.CallBack { ReadBookConfig.let { tv_title_mode.text = titleModes.getOrElse(it.titleMode) { titleModes[0] } tv_text_bold.isSelected = it.textBold - dsb_text_size.progress = it.textSize - 5 - dsb_text_letter_spacing.progress = (it.letterSpacing * 100).toInt() + 50 - dsb_line_size.progress = it.lineSpacingExtra - dsb_paragraph_spacing.progress = it.paragraphSpacing } } diff --git a/app/src/main/java/io/legado/app/ui/book/read/config/ReadTypeDialog.kt b/app/src/main/java/io/legado/app/ui/book/read/config/ReadTypeDialog.kt new file mode 100644 index 000000000..8ac81d53d --- /dev/null +++ b/app/src/main/java/io/legado/app/ui/book/read/config/ReadTypeDialog.kt @@ -0,0 +1,85 @@ +package io.legado.app.ui.book.read.config + +import android.os.Bundle +import android.util.DisplayMetrics +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import io.legado.app.R +import io.legado.app.base.BaseDialogFragment +import io.legado.app.constant.EventBus +import io.legado.app.help.ReadBookConfig +import io.legado.app.ui.book.read.Help +import io.legado.app.utils.postEvent +import kotlinx.android.synthetic.main.dialog_read_type.* + +class ReadTypeDialog : BaseDialogFragment() { + + override fun onStart() { + super.onStart() + val dm = DisplayMetrics() + activity?.let { + Help.upSystemUiVisibility(it) + it.windowManager?.defaultDisplay?.getMetrics(dm) + } + dialog?.window?.let { + val attr = it.attributes + attr.dimAmount = 0.0f + it.attributes = attr + it.setLayout((dm.widthPixels * 0.9).toInt(), ViewGroup.LayoutParams.WRAP_CONTENT) + } + } + + override fun onCreateView( + inflater: LayoutInflater, + container: ViewGroup?, + savedInstanceState: Bundle? + ): View? { + return inflater.inflate(R.layout.dialog_read_type, container) + } + + override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) { + initView() + initViewEvent() + upStyle() + } + + private fun initView() { + dsb_text_size.valueFormat = { + (it + 5).toString() + } + dsb_text_letter_spacing.valueFormat = { + ((it - 50) / 100f).toString() + } + dsb_line_size.valueFormat = { ((it - 10) / 10f).toString() } + dsb_paragraph_spacing.valueFormat = { (it / 10f).toString() } + } + + private fun initViewEvent() { + dsb_text_size.onChanged = { + ReadBookConfig.textSize = it + 10 + postEvent(EventBus.UP_CONFIG, true) + } + dsb_text_letter_spacing.onChanged = { + ReadBookConfig.letterSpacing = (it - 50) / 100f + postEvent(EventBus.UP_CONFIG, true) + } + dsb_line_size.onChanged = { + ReadBookConfig.lineSpacingExtra = it + postEvent(EventBus.UP_CONFIG, true) + } + dsb_paragraph_spacing.onChanged = { + ReadBookConfig.paragraphSpacing = it + postEvent(EventBus.UP_CONFIG, true) + } + } + + private fun upStyle() { + ReadBookConfig.let { + dsb_text_size.progress = it.textSize - 5 + dsb_text_letter_spacing.progress = (it.letterSpacing * 100).toInt() + 50 + dsb_line_size.progress = it.lineSpacingExtra + dsb_paragraph_spacing.progress = it.paragraphSpacing + } + } +} \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_type_default_1.xml b/app/src/main/res/drawable/ic_type_default_1.xml new file mode 100644 index 000000000..14d903eee --- /dev/null +++ b/app/src/main/res/drawable/ic_type_default_1.xml @@ -0,0 +1,12 @@ + + + + diff --git a/app/src/main/res/drawable/ic_type_default_2.xml b/app/src/main/res/drawable/ic_type_default_2.xml new file mode 100644 index 000000000..a0c29bc99 --- /dev/null +++ b/app/src/main/res/drawable/ic_type_default_2.xml @@ -0,0 +1,15 @@ + + + + + diff --git a/app/src/main/res/drawable/ic_type_default_3.xml b/app/src/main/res/drawable/ic_type_default_3.xml new file mode 100644 index 000000000..feb07717f --- /dev/null +++ b/app/src/main/res/drawable/ic_type_default_3.xml @@ -0,0 +1,18 @@ + + + + + + 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 f2d8a1810..764fd63b4 100644 --- a/app/src/main/res/layout/dialog_read_book_style.xml +++ b/app/src/main/res/layout/dialog_read_book_style.xml @@ -1,7 +1,6 @@ - - - - - - - - - - - - - - + android:orientation="horizontal" + android:gravity="center_vertical"> - + - + + + + + + + - + + + + + + + + + + + + + + + android:paddingTop="6dp" + android:paddingBottom="6dp" + android:gravity="center_vertical"> + + + + + + + + + + + + + + + + + + + + + + + + + android:background="@color/btn_bg_press" /> + android:text="@string/page_anim" /> + android:gravity="center"> + android:background="@color/btn_bg_press" /> - - - + android:orientation="horizontal" + android:gravity="center_vertical"> - + + + + + + + + - - - - - - - - - - - - \ No newline at end of file + android:orientation="horizontal" + android:gravity="center_vertical"> + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/dialog_read_type.xml b/app/src/main/res/layout/dialog_read_type.xml new file mode 100644 index 000000000..8bf2ebecd --- /dev/null +++ b/app/src/main/res/layout/dialog_read_type.xml @@ -0,0 +1,36 @@ + + + + + + + + + + + + \ 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 309f2bec2..368df1c1d 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -234,6 +234,7 @@ 按书名 手动排序 阅读方式 + 排版 删除所选 是否确认删除? 默认字体 @@ -630,4 +631,7 @@ 其它朗读设置 系统内置字体样式 是否删除源文件 + 预设一 + 预设二 + 预设三 From 40d9a372085043882697d65dd4f9d66a718e4e84 Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 6 Mar 2020 21:04:04 +0800 Subject: [PATCH 002/359] =?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/dialog_read_type.xml | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/app/src/main/res/layout/dialog_read_type.xml b/app/src/main/res/layout/dialog_read_type.xml index 8bf2ebecd..c27a65f2d 100644 --- a/app/src/main/res/layout/dialog_read_type.xml +++ b/app/src/main/res/layout/dialog_read_type.xml @@ -2,6 +2,7 @@ + android:paddingRight="10dp" + app:max="45" + app:title="@string/text_size" /> + android:paddingRight="10dp" + app:max="100" + app:title="@string/text_letter_spacing" /> + android:paddingRight="10dp" + app:max="20" + app:title="@string/line_size" /> + android:paddingRight="10dp" + app:max="20" + app:title="@string/paragraph_size" /> \ No newline at end of file From 3dcfe335263e1755c29adfde774e3ee637cb0472 Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 6 Mar 2020 21:06:04 +0800 Subject: [PATCH 003/359] =?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/read/config/ReadTypeDialog.kt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/src/main/java/io/legado/app/ui/book/read/config/ReadTypeDialog.kt b/app/src/main/java/io/legado/app/ui/book/read/config/ReadTypeDialog.kt index 8ac81d53d..6594efc18 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/config/ReadTypeDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/config/ReadTypeDialog.kt @@ -1,5 +1,6 @@ package io.legado.app.ui.book.read.config +import android.content.DialogInterface import android.os.Bundle import android.util.DisplayMetrics import android.view.LayoutInflater @@ -38,6 +39,11 @@ class ReadTypeDialog : BaseDialogFragment() { return inflater.inflate(R.layout.dialog_read_type, container) } + override fun onDismiss(dialog: DialogInterface) { + super.onDismiss(dialog) + ReadBookConfig.save() + } + override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) { initView() initViewEvent() From 938147107d884a79b0c3ca133a7387e58a94ddda Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 6 Mar 2020 21:07:09 +0800 Subject: [PATCH 004/359] =?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/read/config/PaddingConfigDialog.kt | 5 +++-- .../io/legado/app/ui/book/read/config/ReadStyleDialog.kt | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/read/config/PaddingConfigDialog.kt b/app/src/main/java/io/legado/app/ui/book/read/config/PaddingConfigDialog.kt index 6ce9dfc03..a19789fd3 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/config/PaddingConfigDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/config/PaddingConfigDialog.kt @@ -1,5 +1,6 @@ package io.legado.app.ui.book.read.config +import android.content.DialogInterface import android.os.Bundle import android.util.DisplayMetrics import android.view.LayoutInflater @@ -47,8 +48,8 @@ class PaddingConfigDialog : DialogFragment() { initView() } - override fun onDestroy() { - super.onDestroy() + override fun onDismiss(dialog: DialogInterface) { + super.onDismiss(dialog) ReadBookConfig.save() } 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 71604dfb8..81485083e 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 @@ -1,5 +1,6 @@ package io.legado.app.ui.book.read.config +import android.content.DialogInterface import android.os.Bundle import android.util.DisplayMetrics import android.view.Gravity @@ -68,8 +69,8 @@ class ReadStyleDialog : DialogFragment(), FontSelectDialog.CallBack { initViewEvent() } - override fun onDestroy() { - super.onDestroy() + override fun onDismiss(dialog: DialogInterface) { + super.onDismiss(dialog) ReadBookConfig.save() } From fb87f2fffbca60b140c35d5152f3e25144e851b3 Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 6 Mar 2020 21:09:36 +0800 Subject: [PATCH 005/359] =?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/config/ReadTypeDialog.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/io/legado/app/ui/book/read/config/ReadTypeDialog.kt b/app/src/main/java/io/legado/app/ui/book/read/config/ReadTypeDialog.kt index 6594efc18..c5247a455 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/config/ReadTypeDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/config/ReadTypeDialog.kt @@ -63,7 +63,7 @@ class ReadTypeDialog : BaseDialogFragment() { private fun initViewEvent() { dsb_text_size.onChanged = { - ReadBookConfig.textSize = it + 10 + ReadBookConfig.textSize = it + 5 postEvent(EventBus.UP_CONFIG, true) } dsb_text_letter_spacing.onChanged = { From 8c6b0992e83dbc54d358f2918555596b2e4e13b7 Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 6 Mar 2020 21:16:26 +0800 Subject: [PATCH 006/359] =?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/config/ReadStyleDialog.kt | 12 +++++ .../res/layout/dialog_read_book_style.xml | 50 +++++++++++++++---- 2 files changed, 52 insertions(+), 10 deletions(-) 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 81485083e..e66a0d52c 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 @@ -141,6 +141,18 @@ class ReadStyleDialog : DialogFragment(), FontSelectDialog.CallBack { postEvent(EventBus.UP_CONFIG, true) } } + iv_default1.onClick { + ReadBookConfig.lineSpacingExtra = 15 + postEvent(EventBus.UP_CONFIG, true) + } + iv_default2.onClick { + ReadBookConfig.lineSpacingExtra = 11 + postEvent(EventBus.UP_CONFIG, true) + } + iv_default3.onClick { + ReadBookConfig.lineSpacingExtra = 10 + postEvent(EventBus.UP_CONFIG, true) + } bg0.onClick { changeBg(0) } bg0.onLongClick { showBgTextConfig(0) } bg1.onClick { changeBg(1) } 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 764fd63b4..b11e6e9df 100644 --- a/app/src/main/res/layout/dialog_read_book_style.xml +++ b/app/src/main/res/layout/dialog_read_book_style.xml @@ -23,7 +23,10 @@ android:id="@+id/tv_title_mode" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:padding="6dp" + android:paddingLeft="6dp" + android:paddingRight="6dp" + android:paddingTop="4dp" + android:paddingBottom="4dp" android:text="@string/title_center" android:gravity="center" android:textSize="14sp" /> @@ -37,7 +40,10 @@ android:id="@+id/tv_text_bold" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:padding="6dp" + android:paddingLeft="6dp" + android:paddingRight="6dp" + android:paddingTop="4dp" + android:paddingBottom="4dp" android:text="@string/text_bold" android:gravity="center" android:textSize="14sp" /> @@ -51,7 +57,10 @@ android:id="@+id/tv_text_font" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:padding="6dp" + android:paddingLeft="6dp" + android:paddingRight="6dp" + android:paddingTop="4dp" + android:paddingBottom="4dp" android:text="@string/text_font" android:gravity="center" android:textSize="14sp" /> @@ -65,7 +74,10 @@ android:id="@+id/tv_text_indent" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:padding="6dp" + android:paddingLeft="6dp" + android:paddingRight="6dp" + android:paddingTop="4dp" + android:paddingBottom="4dp" android:text="@string/text_indent" android:gravity="center" android:textSize="14sp" /> @@ -79,7 +91,10 @@ android:id="@+id/chinese_converter" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:padding="6dp" + android:paddingLeft="6dp" + android:paddingRight="6dp" + android:paddingTop="4dp" + android:paddingBottom="4dp" android:gravity="center" android:textSize="14sp" /> @@ -103,9 +118,12 @@ android:layout_weight="0.5" /> @@ -115,9 +133,12 @@ android:layout_weight="1" /> @@ -127,9 +148,12 @@ android:layout_weight="1" /> @@ -142,7 +166,10 @@ android:id="@+id/tv_type" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:padding="6dp" + android:paddingLeft="6dp" + android:paddingRight="6dp" + android:paddingTop="4dp" + android:paddingBottom="4dp" android:text="@string/compose_type" android:gravity="center" android:textSize="14sp" /> @@ -156,7 +183,10 @@ android:id="@+id/tv_padding" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:padding="6dp" + android:paddingLeft="6dp" + android:paddingRight="6dp" + android:paddingTop="4dp" + android:paddingBottom="4dp" android:text="@string/padding" android:gravity="center" android:textSize="14sp" /> From 51457e25cfd9593b7b8db01490931c2040c5d1a5 Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 6 Mar 2020 21:19:36 +0800 Subject: [PATCH 007/359] =?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/config/ReadStyleDialog.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 e66a0d52c..cb4c11325 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 @@ -142,11 +142,11 @@ class ReadStyleDialog : DialogFragment(), FontSelectDialog.CallBack { } } iv_default1.onClick { - ReadBookConfig.lineSpacingExtra = 15 + ReadBookConfig.lineSpacingExtra = 16 postEvent(EventBus.UP_CONFIG, true) } iv_default2.onClick { - ReadBookConfig.lineSpacingExtra = 11 + ReadBookConfig.lineSpacingExtra = 13 postEvent(EventBus.UP_CONFIG, true) } iv_default3.onClick { From c99355e50439880d276255f3658ced613faec8b0 Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 6 Mar 2020 21:22:31 +0800 Subject: [PATCH 008/359] =?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/config/ReadStyleDialog.kt | 3 +++ 1 file changed, 3 insertions(+) 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 cb4c11325..3c2bbb78a 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 @@ -143,14 +143,17 @@ class ReadStyleDialog : DialogFragment(), FontSelectDialog.CallBack { } iv_default1.onClick { ReadBookConfig.lineSpacingExtra = 16 + ReadBookConfig.paragraphSpacing = 6 postEvent(EventBus.UP_CONFIG, true) } iv_default2.onClick { ReadBookConfig.lineSpacingExtra = 13 + ReadBookConfig.paragraphSpacing = 3 postEvent(EventBus.UP_CONFIG, true) } iv_default3.onClick { ReadBookConfig.lineSpacingExtra = 10 + ReadBookConfig.paragraphSpacing = 0 postEvent(EventBus.UP_CONFIG, true) } bg0.onClick { changeBg(0) } From 39ed24d4dccc6cefde2be8bd86a94df336f0d5c1 Mon Sep 17 00:00:00 2001 From: kunfei Date: Sat, 7 Mar 2020 10:50:27 +0800 Subject: [PATCH 009/359] =?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 | 4 - .../ui/book/read/config/ReadStyleDialog.kt | 85 ++++++++----- .../app/ui/book/read/config/ReadTypeDialog.kt | 91 -------------- .../main/res/drawable/ic_type_default_1.xml | 12 -- .../main/res/drawable/ic_type_default_2.xml | 15 --- .../main/res/drawable/ic_type_default_3.xml | 18 --- .../res/layout/dialog_read_book_style.xml | 117 ++++++------------ app/src/main/res/layout/dialog_read_type.xml | 45 ------- .../main/res/layout/dialog_title_config.xml | 51 ++++++++ app/src/main/res/values/arrays.xml | 6 - app/src/main/res/values/strings.xml | 5 +- 11 files changed, 151 insertions(+), 298 deletions(-) delete mode 100644 app/src/main/java/io/legado/app/ui/book/read/config/ReadTypeDialog.kt delete mode 100644 app/src/main/res/drawable/ic_type_default_1.xml delete mode 100644 app/src/main/res/drawable/ic_type_default_2.xml delete mode 100644 app/src/main/res/drawable/ic_type_default_3.xml delete mode 100644 app/src/main/res/layout/dialog_read_type.xml create mode 100644 app/src/main/res/layout/dialog_title_config.xml 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 e85a0db31..de1f1d728 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 @@ -152,10 +152,6 @@ class ReadBookActivity : VMBaseActivity(R.layout.activity_boo PaddingConfigDialog().show(supportFragmentManager, "paddingConfig") } - fun showTypeConfig() { - ReadTypeDialog().show(supportFragmentManager, "readTypeDialog") - } - fun showBgTextConfig() { BgTextConfigDialog().show(supportFragmentManager, "bgTextConfig") } 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 3c2bbb78a..9ba703ab1 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 @@ -1,5 +1,6 @@ package io.legado.app.ui.book.read.config +import android.annotation.SuppressLint import android.content.DialogInterface import android.os.Bundle import android.util.DisplayMetrics @@ -13,6 +14,7 @@ import io.legado.app.R import io.legado.app.constant.EventBus import io.legado.app.constant.PreferKey import io.legado.app.help.ReadBookConfig +import io.legado.app.lib.dialogs.alert import io.legado.app.lib.dialogs.selector import io.legado.app.lib.theme.accentColor import io.legado.app.lib.theme.bottomBackground @@ -20,12 +22,10 @@ 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 +import io.legado.app.utils.* import kotlinx.android.synthetic.main.activity_book_read.* import kotlinx.android.synthetic.main.dialog_read_book_style.* +import kotlinx.android.synthetic.main.dialog_title_config.view.* import org.jetbrains.anko.sdk27.listeners.onCheckedChange import org.jetbrains.anko.sdk27.listeners.onClick import org.jetbrains.anko.sdk27.listeners.onLongClick @@ -33,7 +33,6 @@ import org.jetbrains.anko.sdk27.listeners.onLongClick class ReadStyleDialog : DialogFragment(), FontSelectDialog.CallBack { val callBack get() = activity as? ReadBookActivity - lateinit var titleModes: Array override fun onStart() { super.onStart() @@ -63,7 +62,6 @@ class ReadStyleDialog : DialogFragment(), FontSelectDialog.CallBack { override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) - titleModes = requireContext().resources.getStringArray(R.array.title_mode) initView() initData() initViewEvent() @@ -76,6 +74,14 @@ class ReadStyleDialog : DialogFragment(), FontSelectDialog.CallBack { private fun initView() { root_view.setBackgroundColor(requireContext().bottomBackground) + dsb_text_size.valueFormat = { + (it + 5).toString() + } + dsb_text_letter_spacing.valueFormat = { + ((it - 50) / 100f).toString() + } + dsb_line_size.valueFormat = { ((it - 10) / 10f).toString() } + dsb_paragraph_spacing.valueFormat = { (it / 10f).toString() } } private fun initData() { @@ -95,11 +101,7 @@ class ReadStyleDialog : DialogFragment(), FontSelectDialog.CallBack { postEvent(EventBus.UP_CONFIG, true) } tv_title_mode.onClick { - requireContext().selector("标题模式", titleModes.toList()) { _, index -> - ReadBookConfig.titleMode = index - tv_title_mode.text = titleModes[index] - postEvent(EventBus.UP_CONFIG, true) - } + showTitleConfig() } tv_text_bold.onClick { ReadBookConfig.apply { @@ -124,15 +126,9 @@ class ReadStyleDialog : DialogFragment(), FontSelectDialog.CallBack { dismiss() callBack?.showPaddingConfig() } - tv_type.onClick { - dismiss() - callBack?.showTypeConfig() - } rg_page_anim.onCheckedChange { _, checkedId -> - rg_page_anim.getIndexById(checkedId).let { - ReadBookConfig.pageAnim = it - callBack?.page_view?.upPageAnim() - } + ReadBookConfig.pageAnim = rg_page_anim.getIndexById(checkedId) + callBack?.page_view?.upPageAnim() } cb_share_layout.onCheckedChangeListener = { checkBox, isChecked -> if (checkBox.isPressed) { @@ -141,19 +137,20 @@ class ReadStyleDialog : DialogFragment(), FontSelectDialog.CallBack { postEvent(EventBus.UP_CONFIG, true) } } - iv_default1.onClick { - ReadBookConfig.lineSpacingExtra = 16 - ReadBookConfig.paragraphSpacing = 6 + dsb_text_size.onChanged = { + ReadBookConfig.textSize = it + 5 + postEvent(EventBus.UP_CONFIG, true) + } + dsb_text_letter_spacing.onChanged = { + ReadBookConfig.letterSpacing = (it - 50) / 100f postEvent(EventBus.UP_CONFIG, true) } - iv_default2.onClick { - ReadBookConfig.lineSpacingExtra = 13 - ReadBookConfig.paragraphSpacing = 3 + dsb_line_size.onChanged = { + ReadBookConfig.lineSpacingExtra = it postEvent(EventBus.UP_CONFIG, true) } - iv_default3.onClick { - ReadBookConfig.lineSpacingExtra = 10 - ReadBookConfig.paragraphSpacing = 0 + dsb_paragraph_spacing.onChanged = { + ReadBookConfig.paragraphSpacing = it postEvent(EventBus.UP_CONFIG, true) } bg0.onClick { changeBg(0) } @@ -168,6 +165,33 @@ class ReadStyleDialog : DialogFragment(), FontSelectDialog.CallBack { bg4.onLongClick { showBgTextConfig(4) } } + @SuppressLint("InflateParams") + private fun showTitleConfig() { + requireContext().alert(R.string.title) { + val rootView = LayoutInflater.from(requireContext()) + .inflate(R.layout.dialog_title_config, null).apply { + ReadBookConfig.apply { + rg_title_mode.checkByIndex(titleMode) + dsb_title_top.progress = titleTopSpacing + dsb_title_bottom.progress = titleBottomSpacing + rg_title_mode.onCheckedChange { _, checkedId -> + titleMode = rg_title_mode.getIndexById(checkedId) + postEvent(EventBus.UP_CONFIG, true) + } + dsb_title_top.onChanged = { + titleTopSpacing = it + postEvent(EventBus.UP_CONFIG, true) + } + dsb_title_bottom.onChanged = { + titleBottomSpacing = it + postEvent(EventBus.UP_CONFIG, true) + } + } + } + customView = rootView + }.show() + } + private fun changeBg(index: Int) { if (ReadBookConfig.styleSelect != index) { ReadBookConfig.styleSelect = index @@ -187,8 +211,11 @@ class ReadStyleDialog : DialogFragment(), FontSelectDialog.CallBack { private fun upStyle() { ReadBookConfig.let { - tv_title_mode.text = titleModes.getOrElse(it.titleMode) { titleModes[0] } tv_text_bold.isSelected = it.textBold + dsb_text_size.progress = it.textSize - 5 + dsb_text_letter_spacing.progress = (it.letterSpacing * 100).toInt() + 50 + dsb_line_size.progress = it.lineSpacingExtra + dsb_paragraph_spacing.progress = it.paragraphSpacing } } diff --git a/app/src/main/java/io/legado/app/ui/book/read/config/ReadTypeDialog.kt b/app/src/main/java/io/legado/app/ui/book/read/config/ReadTypeDialog.kt deleted file mode 100644 index c5247a455..000000000 --- a/app/src/main/java/io/legado/app/ui/book/read/config/ReadTypeDialog.kt +++ /dev/null @@ -1,91 +0,0 @@ -package io.legado.app.ui.book.read.config - -import android.content.DialogInterface -import android.os.Bundle -import android.util.DisplayMetrics -import android.view.LayoutInflater -import android.view.View -import android.view.ViewGroup -import io.legado.app.R -import io.legado.app.base.BaseDialogFragment -import io.legado.app.constant.EventBus -import io.legado.app.help.ReadBookConfig -import io.legado.app.ui.book.read.Help -import io.legado.app.utils.postEvent -import kotlinx.android.synthetic.main.dialog_read_type.* - -class ReadTypeDialog : BaseDialogFragment() { - - override fun onStart() { - super.onStart() - val dm = DisplayMetrics() - activity?.let { - Help.upSystemUiVisibility(it) - it.windowManager?.defaultDisplay?.getMetrics(dm) - } - dialog?.window?.let { - val attr = it.attributes - attr.dimAmount = 0.0f - it.attributes = attr - it.setLayout((dm.widthPixels * 0.9).toInt(), ViewGroup.LayoutParams.WRAP_CONTENT) - } - } - - override fun onCreateView( - inflater: LayoutInflater, - container: ViewGroup?, - savedInstanceState: Bundle? - ): View? { - return inflater.inflate(R.layout.dialog_read_type, container) - } - - override fun onDismiss(dialog: DialogInterface) { - super.onDismiss(dialog) - ReadBookConfig.save() - } - - override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) { - initView() - initViewEvent() - upStyle() - } - - private fun initView() { - dsb_text_size.valueFormat = { - (it + 5).toString() - } - dsb_text_letter_spacing.valueFormat = { - ((it - 50) / 100f).toString() - } - dsb_line_size.valueFormat = { ((it - 10) / 10f).toString() } - dsb_paragraph_spacing.valueFormat = { (it / 10f).toString() } - } - - private fun initViewEvent() { - dsb_text_size.onChanged = { - ReadBookConfig.textSize = it + 5 - postEvent(EventBus.UP_CONFIG, true) - } - dsb_text_letter_spacing.onChanged = { - ReadBookConfig.letterSpacing = (it - 50) / 100f - postEvent(EventBus.UP_CONFIG, true) - } - dsb_line_size.onChanged = { - ReadBookConfig.lineSpacingExtra = it - postEvent(EventBus.UP_CONFIG, true) - } - dsb_paragraph_spacing.onChanged = { - ReadBookConfig.paragraphSpacing = it - postEvent(EventBus.UP_CONFIG, true) - } - } - - private fun upStyle() { - ReadBookConfig.let { - dsb_text_size.progress = it.textSize - 5 - dsb_text_letter_spacing.progress = (it.letterSpacing * 100).toInt() + 50 - dsb_line_size.progress = it.lineSpacingExtra - dsb_paragraph_spacing.progress = it.paragraphSpacing - } - } -} \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_type_default_1.xml b/app/src/main/res/drawable/ic_type_default_1.xml deleted file mode 100644 index 14d903eee..000000000 --- a/app/src/main/res/drawable/ic_type_default_1.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - diff --git a/app/src/main/res/drawable/ic_type_default_2.xml b/app/src/main/res/drawable/ic_type_default_2.xml deleted file mode 100644 index a0c29bc99..000000000 --- a/app/src/main/res/drawable/ic_type_default_2.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - diff --git a/app/src/main/res/drawable/ic_type_default_3.xml b/app/src/main/res/drawable/ic_type_default_3.xml deleted file mode 100644 index feb07717f..000000000 --- a/app/src/main/res/drawable/ic_type_default_3.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - 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 b11e6e9df..da110908f 100644 --- a/app/src/main/res/layout/dialog_read_book_style.xml +++ b/app/src/main/res/layout/dialog_read_book_style.xml @@ -27,7 +27,7 @@ android:paddingRight="6dp" android:paddingTop="4dp" android:paddingBottom="4dp" - android:text="@string/title_center" + android:text="@string/title" android:gravity="center" android:textSize="14sp" /> @@ -98,82 +98,6 @@ android:gravity="center" android:textSize="14sp" /> - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + diff --git a/app/src/main/res/layout/dialog_read_type.xml b/app/src/main/res/layout/dialog_read_type.xml deleted file mode 100644 index c27a65f2d..000000000 --- a/app/src/main/res/layout/dialog_read_type.xml +++ /dev/null @@ -1,45 +0,0 @@ - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/dialog_title_config.xml b/app/src/main/res/layout/dialog_title_config.xml new file mode 100644 index 000000000..4a2d35cd8 --- /dev/null +++ b/app/src/main/res/layout/dialog_title_config.xml @@ -0,0 +1,51 @@ + + + + + + + + + + + + + + + + + \ 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 15deecdec..104febad6 100644 --- a/app/src/main/res/values/arrays.xml +++ b/app/src/main/res/values/arrays.xml @@ -93,10 +93,4 @@ 系统等宽字体 - - 标题靠左 - 标题居中 - 标题隐藏 - - \ 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 368df1c1d..9bf3a423a 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -620,7 +620,6 @@ 文本选择结束位置 文本选择开始位置 共用布局 - 标题居中 浏览器 导入默认规则 名称 @@ -634,4 +633,8 @@ 预设一 预设二 预设三 + 标题 + 靠左 + 居中 + 隐藏 From df38b79abe8e80642988124a28634cc36b00fafb Mon Sep 17 00:00:00 2001 From: kunfei Date: Sat, 7 Mar 2020 11:03:26 +0800 Subject: [PATCH 010/359] =?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/ChapterProvider.kt | 10 ++++++++-- app/src/main/res/layout/dialog_title_config.xml | 2 ++ app/src/main/res/layout/view_book_page.xml | 12 ++++++++---- 3 files changed, 18 insertions(+), 6 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 3366c019d..927ef210f 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 @@ -28,6 +28,8 @@ object ChapterProvider { var visibleBottom = 0 private var lineSpacingExtra = 0 private var paragraphSpacing = 0 + private var titleTopSpacing = 0 + private var titleBottomSpacing = 0 var typeface: Typeface = Typeface.SANS_SERIF var titlePaint = TextPaint() var contentPaint = TextPaint() @@ -97,7 +99,7 @@ object ChapterProvider { stringBuilder: StringBuilder, isTitle: Boolean ): Float { - var durY = y + var durY = if (isTitle) y + titleTopSpacing else y val textPaint = if (isTitle) titlePaint else contentPaint val layout = StaticLayout( text, textPaint, visibleWidth, @@ -140,6 +142,9 @@ object ChapterProvider { textPages.last().textLines.add(textLine) textLine.upTopBottom(durY, textPaint) durY += textPaint.textHeight * lineSpacingExtra / 10f + if (isTitle) { + durY += titleBottomSpacing + } textPages.last().height = durY } durY += textPaint.textHeight * paragraphSpacing / 10f @@ -273,7 +278,8 @@ object ChapterProvider { paragraphSpacing = ReadBookConfig.paragraphSpacing titlePaint.textSize = (ReadBookConfig.textSize + 2).sp.toFloat() contentPaint.textSize = ReadBookConfig.textSize.sp.toFloat() - + titleTopSpacing = ReadBookConfig.titleTopSpacing.dp + titleBottomSpacing = ReadBookConfig.titleBottomSpacing.dp upSize() } diff --git a/app/src/main/res/layout/dialog_title_config.xml b/app/src/main/res/layout/dialog_title_config.xml index 4a2d35cd8..93e14f89c 100644 --- a/app/src/main/res/layout/dialog_title_config.xml +++ b/app/src/main/res/layout/dialog_title_config.xml @@ -39,6 +39,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:padding="3dp" + app:max="100" app:title="上间距" /> \ 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 81c9e09d4..bba89c8fb 100644 --- a/app/src/main/res/layout/view_book_page.xml +++ b/app/src/main/res/layout/view_book_page.xml @@ -16,12 +16,14 @@ android:id="@+id/tv_top_left" android:layout_width="0dp" android:layout_height="wrap_content" - android:layout_weight="1" /> + android:layout_weight="1" + android:textSize="12sp" /> + android:layout_height="wrap_content" + android:textSize="12sp" /> @@ -56,12 +58,14 @@ android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" - android:singleLine="true" /> + android:singleLine="true" + android:textSize="12sp" /> + android:layout_height="wrap_content" + android:textSize="12sp" /> From 56fdbd4d2089b7f9179ba8c6fe07a1a62adc0c02 Mon Sep 17 00:00:00 2001 From: kunfei Date: Sat, 7 Mar 2020 11:04:22 +0800 Subject: [PATCH 011/359] =?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 7ace22ee4..ecb6b1371 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/07** +* 添加标题上下间距调整 + **2020/03/06** * 添加隐藏标题 * 行距段距改成倍距,根据字体大小变化 From 98135941e65034c607a5882c10f9e41e9546d9ca Mon Sep 17 00:00:00 2001 From: kunfei Date: Sat, 7 Mar 2020 11:32:19 +0800 Subject: [PATCH 012/359] =?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/LabelsBar.kt | 2 +- .../app/ui/widget/text/AccentBgTextView.kt | 12 ++++++------ .../app/ui/widget/text/StrokeTextView.kt | 18 ++++++++++++++++-- .../main/res/layout/dialog_read_book_style.xml | 18 ++++++++++++------ app/src/main/res/values/attrs.xml | 4 ++++ 5 files changed, 39 insertions(+), 15 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/widget/LabelsBar.kt b/app/src/main/java/io/legado/app/ui/widget/LabelsBar.kt index 2d830ca55..a2f354772 100644 --- a/app/src/main/java/io/legado/app/ui/widget/LabelsBar.kt +++ b/app/src/main/java/io/legado/app/ui/widget/LabelsBar.kt @@ -38,7 +38,7 @@ class LabelsBar(context: Context, attrs: AttributeSet?) : LinearLayout(context, val tv = if (unUsedViews.isEmpty()) { AccentBgTextView(context, null).apply { setPadding(3.dp, 0, 3.dp, 0) - setRadios(2) + setRadius(2) val lp = LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT) lp.setMargins(0, 0, 2.dp, 0) layoutParams = lp diff --git a/app/src/main/java/io/legado/app/ui/widget/text/AccentBgTextView.kt b/app/src/main/java/io/legado/app/ui/widget/text/AccentBgTextView.kt index 6f48e81af..b2dcc2578 100644 --- a/app/src/main/java/io/legado/app/ui/widget/text/AccentBgTextView.kt +++ b/app/src/main/java/io/legado/app/ui/widget/text/AccentBgTextView.kt @@ -14,31 +14,31 @@ import io.legado.app.utils.getCompatColor class AccentBgTextView(context: Context, attrs: AttributeSet?) : AppCompatTextView(context, attrs) { - private var radios = 0 + private var radius = 0 init { val typedArray = context.obtainStyledAttributes(attrs, R.styleable.AccentBgTextView) - radios = typedArray.getDimensionPixelOffset(R.styleable.AccentBgTextView_radius, radios) + radius = typedArray.getDimensionPixelOffset(R.styleable.AccentBgTextView_radius, radius) typedArray.recycle() upBackground() setTextColor(Color.WHITE) } - fun setRadios(radio: Int) { - this.radios = radio.dp + fun setRadius(radius: Int) { + this.radius = radius.dp upBackground() } private fun upBackground() { background = if (isInEditMode) { Selector.shapeBuild() - .setCornerRadius(radios) + .setCornerRadius(radius) .setDefaultBgColor(context.getCompatColor(R.color.colorAccent)) .setPressedBgColor(ColorUtils.darkenColor(context.getCompatColor(R.color.colorAccent))) .create() } else { Selector.shapeBuild() - .setCornerRadius(radios) + .setCornerRadius(radius) .setDefaultBgColor(ThemeStore.accentColor(context)) .setPressedBgColor(ColorUtils.darkenColor(ThemeStore.accentColor(context))) .create() diff --git a/app/src/main/java/io/legado/app/ui/widget/text/StrokeTextView.kt b/app/src/main/java/io/legado/app/ui/widget/text/StrokeTextView.kt index df4da33ea..3fa0544d3 100644 --- a/app/src/main/java/io/legado/app/ui/widget/text/StrokeTextView.kt +++ b/app/src/main/java/io/legado/app/ui/widget/text/StrokeTextView.kt @@ -12,10 +12,24 @@ import io.legado.app.utils.getCompatColor open class StrokeTextView(context: Context, attrs: AttributeSet?) : AppCompatTextView(context, attrs) { + private var radius = 1.dp + init { + val typedArray = context.obtainStyledAttributes(attrs, R.styleable.StrokeTextView) + radius = typedArray.getDimensionPixelOffset(R.styleable.StrokeTextView_radius, radius) + typedArray.recycle() + upBackground() + } + + fun setRadius(radius: Int) { + this.radius = radius.dp + upBackground() + } + + private fun upBackground() { if (isInEditMode) { background = Selector.shapeBuild() - .setCornerRadius(1.dp) + .setCornerRadius(radius) .setStrokeWidth(1.dp) .setDisabledStrokeColor(context.getCompatColor(R.color.md_grey_500)) .setDefaultStrokeColor(context.getCompatColor(R.color.tv_text_secondary)) @@ -31,7 +45,7 @@ open class StrokeTextView(context: Context, attrs: AttributeSet?) : ) } else { background = Selector.shapeBuild() - .setCornerRadius(1.dp) + .setCornerRadius(radius) .setStrokeWidth(1.dp) .setDisabledStrokeColor(context.getCompatColor(R.color.md_grey_500)) .setDefaultStrokeColor(ThemeStore.textColorSecondary(context)) 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 da110908f..4adff8b72 100644 --- a/app/src/main/res/layout/dialog_read_book_style.xml +++ b/app/src/main/res/layout/dialog_read_book_style.xml @@ -29,7 +29,8 @@ android:paddingBottom="4dp" android:text="@string/title" android:gravity="center" - android:textSize="14sp" /> + android:textSize="14sp" + app:radius="3dp" /> + android:textSize="14sp" + app:radius="3dp" /> + android:textSize="14sp" + app:radius="3dp" /> + android:textSize="14sp" + app:radius="3dp" /> + android:textSize="14sp" + app:radius="3dp" /> + android:textSize="14sp" + app:radius="3dp" /> + + + + From 95664913698c1a008db9987852d0c41393c08f33 Mon Sep 17 00:00:00 2001 From: kunfei Date: Sat, 7 Mar 2020 11:39:40 +0800 Subject: [PATCH 013/359] =?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/info/BookInfoActivity.kt | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) 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 621a41fa9..769b47b21 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 @@ -86,8 +86,13 @@ class BookInfoActivity : } } R.id.menu_can_update -> { - viewModel.bookData.value?.let { - it.canUpdate = !it.canUpdate + if (viewModel.inBookshelf) { + viewModel.bookData.value?.let { + it.canUpdate = !it.canUpdate + viewModel.saveBook() + } + } else { + toast(R.string.after_add_bookshelf) } } } From 067269000765b73f3fda3d5bad2c271fe5c2960f Mon Sep 17 00:00:00 2001 From: kunfei Date: Sat, 7 Mar 2020 11:46:59 +0800 Subject: [PATCH 014/359] =?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/BookContent.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 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 14ea49b25..568615aa1 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 @@ -39,7 +39,7 @@ object BookContent { var contentData = analyzeContent( book, baseUrl, body, contentRule, bookChapter, bookSource ) - content.append(contentData.content.replace(bookChapter.title, "")) + content.append(contentData.content.replace(bookChapter.title, "")).append("\n") if (contentData.nextUrl.size == 1) { var nextUrl = contentData.nextUrl[0] val nextChapterUrl = if (!nextChapterUrlF.isNullOrEmpty()) @@ -64,7 +64,7 @@ object BookContent { ) nextUrl = if (contentData.nextUrl.isNotEmpty()) contentData.nextUrl[0] else "" - content.append(contentData.content) + content.append(contentData.content).append("\n") } } Debug.log(bookSource.bookSourceUrl, "◇本章总页数:${nextUrlList.size}") @@ -91,7 +91,7 @@ object BookContent { } } for (item in contentDataList) { - content.append(item.content) + content.append(item.content).append("\n") } } From 348a571eeb02d45dc198453a4042964cff5f0be1 Mon Sep 17 00:00:00 2001 From: kunfei Date: Sat, 7 Mar 2020 12:05:13 +0800 Subject: [PATCH 015/359] =?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/dialog_title_config.xml | 7 +++++++ app/src/main/res/menu/arrange_book_sel.xml | 8 ++++++++ app/src/main/res/menu/book_source_sel.xml | 5 ----- app/src/main/res/values/strings.xml | 1 + 4 files changed, 16 insertions(+), 5 deletions(-) diff --git a/app/src/main/res/layout/dialog_title_config.xml b/app/src/main/res/layout/dialog_title_config.xml index 93e14f89c..ff05802a4 100644 --- a/app/src/main/res/layout/dialog_title_config.xml +++ b/app/src/main/res/layout/dialog_title_config.xml @@ -34,6 +34,13 @@ android:text="@string/title_hide" /> + + + + + + diff --git a/app/src/main/res/menu/book_source_sel.xml b/app/src/main/res/menu/book_source_sel.xml index dff64669a..456bf4645 100644 --- a/app/src/main/res/menu/book_source_sel.xml +++ b/app/src/main/res/menu/book_source_sel.xml @@ -22,11 +22,6 @@ android:title="@string/disable_explore" app:showAsAction="never" /> - - 朗读时音量键翻页 Tip边距跟随边距调整 允许更新 + 禁止更新 反选 搜索书名、作者 书名、作者、URL From ed4b77b3132849909e830155f65967d8e2821b6e Mon Sep 17 00:00:00 2001 From: kunfei Date: Sat, 7 Mar 2020 12:06:50 +0800 Subject: [PATCH 016/359] =?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/menu/rss_source_sel.xml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/app/src/main/res/menu/rss_source_sel.xml b/app/src/main/res/menu/rss_source_sel.xml index 360f456b5..48797b9e6 100644 --- a/app/src/main/res/menu/rss_source_sel.xml +++ b/app/src/main/res/menu/rss_source_sel.xml @@ -12,11 +12,6 @@ android:title="@string/disable_selection" app:showAsAction="never" /> - - Date: Sat, 7 Mar 2020 12:13:26 +0800 Subject: [PATCH 017/359] =?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 | 4 ++++ .../legado/app/ui/book/arrange/ArrangeBookViewModel.kt | 9 +++++++++ 2 files changed, 13 insertions(+) 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 c0907f002..bc73aed3d 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 @@ -147,6 +147,10 @@ class ArrangeBookActivity : VMBaseActivity(R.layout.activi okButton { viewModel.deleteBook(*adapter.selectedBooks.toTypedArray()) } noButton { } }.show().applyTint() + R.id.menu_update_enable -> + viewModel.upCanUpdate(adapter.selectedBooks.toTypedArray(), true) + R.id.menu_update_disable -> + viewModel.upCanUpdate(adapter.selectedBooks.toTypedArray(), true) } return false } diff --git a/app/src/main/java/io/legado/app/ui/book/arrange/ArrangeBookViewModel.kt b/app/src/main/java/io/legado/app/ui/book/arrange/ArrangeBookViewModel.kt index 4f4972de9..82ec712d2 100644 --- a/app/src/main/java/io/legado/app/ui/book/arrange/ArrangeBookViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/book/arrange/ArrangeBookViewModel.kt @@ -8,6 +8,15 @@ import io.legado.app.data.entities.Book class ArrangeBookViewModel(application: Application) : BaseViewModel(application) { + fun upCanUpdate(books: Array, canUpdate: Boolean) { + execute { + books.forEach { + it.canUpdate = canUpdate + } + App.db.bookDao().update(*books) + } + } + fun updateBook(vararg book: Book) { execute { App.db.bookDao().update(*book) From af06cb384e37ec035e63e0e9e8efa797c3c2f420 Mon Sep 17 00:00:00 2001 From: kunfei Date: Sat, 7 Mar 2020 13:13:57 +0800 Subject: [PATCH 018/359] =?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 +++++++++ app/src/main/res/menu/arrange_book_sel.xml | 8 ++++++-- app/src/main/res/values/strings.xml | 1 + 3 files changed, 16 insertions(+), 2 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 bc73aed3d..00ee621e4 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 @@ -32,6 +32,7 @@ class ArrangeBookActivity : VMBaseActivity(R.layout.activi get() = getViewModel(ArrangeBookViewModel::class.java) override val groupList: ArrayList = arrayListOf() private val groupRequestCode = 22 + private val addToGroupRequestCode = 34 private lateinit var adapter: ArrangeBookAdapter private var groupLiveData: LiveData>? = null private var booksLiveData: LiveData>? = null @@ -151,6 +152,7 @@ class ArrangeBookActivity : VMBaseActivity(R.layout.activi viewModel.upCanUpdate(adapter.selectedBooks.toTypedArray(), true) R.id.menu_update_disable -> viewModel.upCanUpdate(adapter.selectedBooks.toTypedArray(), true) + R.id.menu_add_to_group -> selectGroup(0, addToGroupRequestCode) } return false } @@ -182,6 +184,13 @@ class ArrangeBookActivity : VMBaseActivity(R.layout.activi viewModel.updateBook(it.copy(group = groupId)) } } + addToGroupRequestCode -> { + val books = arrayListOf() + adapter.selectedBooks.forEach { + books.add(it.copy(group = it.group or groupId)) + } + viewModel.updateBook(*books.toTypedArray()) + } } } diff --git a/app/src/main/res/menu/arrange_book_sel.xml b/app/src/main/res/menu/arrange_book_sel.xml index a4a3dc50d..880569d40 100644 --- a/app/src/main/res/menu/arrange_book_sel.xml +++ b/app/src/main/res/menu/arrange_book_sel.xml @@ -1,6 +1,10 @@ + + @@ -10,7 +14,7 @@ android:title="@string/disable_update" /> + android:id="@+id/menu_add_to_group" + android:title="@string/add_to_group" /> \ 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 61e09e2a7..9c055c8d5 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -638,4 +638,5 @@ 靠左 居中 隐藏 + 加入分组 From 4cb126f7b9536e6795396b2fa3440f7b3a79ac85 Mon Sep 17 00:00:00 2001 From: kunfei Date: Sat, 7 Mar 2020 13:22:54 +0800 Subject: [PATCH 019/359] =?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 | 6 +++++- .../java/io/legado/app/ui/book/read/page/ChapterProvider.kt | 4 ++-- 2 files changed, 7 insertions(+), 3 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 77dc45e9a..090cf8ad9 100644 --- a/app/src/main/java/io/legado/app/help/ReadBookConfig.kt +++ b/app/src/main/java/io/legado/app/help/ReadBookConfig.kt @@ -169,7 +169,10 @@ object ReadBookConfig { get() = if (shareLayout) shareConfig.titleMode else durConfig.titleMode set(value) = if (shareLayout) shareConfig.titleMode = value else durConfig.titleMode = value - + var titleSize: Int + get() = if (shareLayout) shareConfig.titleSize else durConfig.titleSize + set(value) = + if (shareLayout) shareConfig.titleSize = value else durConfig.titleSize = value var titleTopSpacing: Int get() = if (shareLayout) shareConfig.titleTopSpacing else durConfig.titleTopSpacing set(value) = @@ -271,6 +274,7 @@ object ReadBookConfig { var lineSpacingExtra: Int = 12,//行间距 var paragraphSpacing: Int = 12,//段距 var titleMode: Int = 0,//标题居中 + var titleSize: Int = 0, var titleTopSpacing: Int = 0, var titleBottomSpacing: Int = 0, var paddingBottom: Int = 6, 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 927ef210f..11c5eb6a4 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 @@ -267,17 +267,17 @@ object ChapterProvider { titlePaint.color = ReadBookConfig.durConfig.textColor() titlePaint.letterSpacing = ReadBookConfig.letterSpacing titlePaint.typeface = Typeface.create(typeface, Typeface.BOLD) + titlePaint.textSize = (ReadBookConfig.textSize + ReadBookConfig.titleSize).sp.toFloat() //正文 contentPaint.isAntiAlias = true contentPaint.color = ReadBookConfig.durConfig.textColor() contentPaint.letterSpacing = ReadBookConfig.letterSpacing val bold = if (ReadBookConfig.textBold) Typeface.BOLD else Typeface.NORMAL contentPaint.typeface = Typeface.create(typeface, bold) + contentPaint.textSize = ReadBookConfig.textSize.sp.toFloat() //间距 lineSpacingExtra = ReadBookConfig.lineSpacingExtra paragraphSpacing = ReadBookConfig.paragraphSpacing - titlePaint.textSize = (ReadBookConfig.textSize + 2).sp.toFloat() - contentPaint.textSize = ReadBookConfig.textSize.sp.toFloat() titleTopSpacing = ReadBookConfig.titleTopSpacing.dp titleBottomSpacing = ReadBookConfig.titleBottomSpacing.dp upSize() From bc24f16257ed29c675d5aeedba151491f769cd0e Mon Sep 17 00:00:00 2001 From: kunfei Date: Sat, 7 Mar 2020 13:27:24 +0800 Subject: [PATCH 020/359] =?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 11c5eb6a4..c00dc2ba3 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 @@ -267,7 +267,7 @@ object ChapterProvider { titlePaint.color = ReadBookConfig.durConfig.textColor() titlePaint.letterSpacing = ReadBookConfig.letterSpacing titlePaint.typeface = Typeface.create(typeface, Typeface.BOLD) - titlePaint.textSize = (ReadBookConfig.textSize + ReadBookConfig.titleSize).sp.toFloat() + titlePaint.textSize = with(ReadBookConfig) { textSize + titleSize }.sp.toFloat() //正文 contentPaint.isAntiAlias = true contentPaint.color = ReadBookConfig.durConfig.textColor() From 4f1737cd122909fac284e7270a5d4267667a28f9 Mon Sep 17 00:00:00 2001 From: kunfei Date: Sat, 7 Mar 2020 13:29:55 +0800 Subject: [PATCH 021/359] =?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/read/config/ReadStyleDialog.kt | 5 +++++ app/src/main/res/layout/dialog_title_config.xml | 1 + 2 files changed, 6 insertions(+) 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 9ba703ab1..ece020ffa 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 @@ -172,12 +172,17 @@ class ReadStyleDialog : DialogFragment(), FontSelectDialog.CallBack { .inflate(R.layout.dialog_title_config, null).apply { ReadBookConfig.apply { rg_title_mode.checkByIndex(titleMode) + dsb_title_size.progress = titleSize dsb_title_top.progress = titleTopSpacing dsb_title_bottom.progress = titleBottomSpacing rg_title_mode.onCheckedChange { _, checkedId -> titleMode = rg_title_mode.getIndexById(checkedId) postEvent(EventBus.UP_CONFIG, true) } + dsb_title_size.onChanged = { + titleSize = it + postEvent(EventBus.UP_CONFIG, true) + } dsb_title_top.onChanged = { titleTopSpacing = it postEvent(EventBus.UP_CONFIG, true) diff --git a/app/src/main/res/layout/dialog_title_config.xml b/app/src/main/res/layout/dialog_title_config.xml index ff05802a4..9480c1602 100644 --- a/app/src/main/res/layout/dialog_title_config.xml +++ b/app/src/main/res/layout/dialog_title_config.xml @@ -35,6 +35,7 @@ Date: Sat, 7 Mar 2020 13:40:19 +0800 Subject: [PATCH 022/359] =?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/src/main/java/io/legado/app/data/dao/SearchBookDao.kt | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/src/main/assets/updateLog.md b/app/src/main/assets/updateLog.md index ecb6b1371..51355715a 100644 --- a/app/src/main/assets/updateLog.md +++ b/app/src/main/assets/updateLog.md @@ -4,6 +4,9 @@ **2020/03/07** * 添加标题上下间距调整 +* 添加标题大小调整 +* 书籍整理添加批量启用禁用更新 +* 换源禁用书源不显示 **2020/03/06** * 添加隐藏标题 diff --git a/app/src/main/java/io/legado/app/data/dao/SearchBookDao.kt b/app/src/main/java/io/legado/app/data/dao/SearchBookDao.kt index 779cfd1e2..a5dd26718 100644 --- a/app/src/main/java/io/legado/app/data/dao/SearchBookDao.kt +++ b/app/src/main/java/io/legado/app/data/dao/SearchBookDao.kt @@ -27,7 +27,7 @@ interface SearchBookDao { select t1.name, t1.author, t1.origin, t1.originName, t1.coverUrl, t1.bookUrl, t1.type, t1.time, t1.intro, t1.kind, t1.latestChapterTitle, t1.tocUrl, t1.variable, t1.wordCount, t2.customOrder as originOrder from searchBooks as t1 inner join book_sources as t2 on t1.origin = t2.bookSourceUrl - where t1.name = :name and t1.author = :author + where t1.name = :name and t1.author = :author and t2.enabled = 1 order by t2.customOrder """ ) @@ -38,7 +38,7 @@ interface SearchBookDao { select t1.name, t1.author, t1.origin, t1.originName, t1.coverUrl, t1.bookUrl, t1.type, t1.time, t1.intro, t1.kind, t1.latestChapterTitle, t1.tocUrl, t1.variable, t1.wordCount, t2.customOrder as originOrder from searchBooks as t1 inner join book_sources as t2 on t1.origin = t2.bookSourceUrl - where t1.name = :name and t1.author = :author and originName like '%'||:key||'%' + where t1.name = :name and t1.author = :author and originName like '%'||:key||'%' and t2.enabled = 1 order by t2.customOrder """ ) From 6b9265c056e13a507e0e1d0e4be3afa45deeb5c8 Mon Sep 17 00:00:00 2001 From: kunfei Date: Sat, 7 Mar 2020 13:41:01 +0800 Subject: [PATCH 023/359] =?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/data/dao/SearchBookDao.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/io/legado/app/data/dao/SearchBookDao.kt b/app/src/main/java/io/legado/app/data/dao/SearchBookDao.kt index a5dd26718..c02450091 100644 --- a/app/src/main/java/io/legado/app/data/dao/SearchBookDao.kt +++ b/app/src/main/java/io/legado/app/data/dao/SearchBookDao.kt @@ -49,7 +49,7 @@ interface SearchBookDao { select t1.name, t1.author, t1.origin, t1.originName, t1.coverUrl, t1.bookUrl, t1.type, t1.time, t1.intro, t1.kind, t1.latestChapterTitle, t1.tocUrl, t1.variable, t1.wordCount, t2.customOrder as originOrder from searchBooks as t1 inner join book_sources as t2 on t1.origin = t2.bookSourceUrl - where t1.name = :name and t1.author = :author and t1.coverUrl is not null and t1.coverUrl <> '' + where t1.name = :name and t1.author = :author and t1.coverUrl is not null and t1.coverUrl <> '' and t2.enabled = 1 order by t2.customOrder """ ) From 89178d8532bb315caeef4823112e2ffb021d491e Mon Sep 17 00:00:00 2001 From: kunfei Date: Sat, 7 Mar 2020 14:03:41 +0800 Subject: [PATCH 024/359] =?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/item_search.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/src/main/res/layout/item_search.xml b/app/src/main/res/layout/item_search.xml index 78e5a44da..3fbae7ac0 100644 --- a/app/src/main/res/layout/item_search.xml +++ b/app/src/main/res/layout/item_search.xml @@ -7,8 +7,8 @@ Date: Sat, 7 Mar 2020 14:08:48 +0800 Subject: [PATCH 025/359] =?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/item_search.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/res/layout/item_search.xml b/app/src/main/res/layout/item_search.xml index 3fbae7ac0..65e518c60 100644 --- a/app/src/main/res/layout/item_search.xml +++ b/app/src/main/res/layout/item_search.xml @@ -43,7 +43,7 @@ android:layout_width="0dp" android:layout_height="0dp" android:orientation="vertical" - android:layout_marginTop="6dp" + android:layout_marginTop="3dp" app:layout_constraintBottom_toBottomOf="@id/iv_cover" app:layout_constraintLeft_toLeftOf="@+id/tv_name" app:layout_constraintRight_toRightOf="@id/tv_name" @@ -78,7 +78,7 @@ Date: Sat, 7 Mar 2020 14:46:05 +0800 Subject: [PATCH 026/359] =?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/ReadBookConfig.kt | 11 +++++------ 1 file changed, 5 insertions(+), 6 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 090cf8ad9..b1a17905f 100644 --- a/app/src/main/java/io/legado/app/help/ReadBookConfig.kt +++ b/app/src/main/java/io/legado/app/help/ReadBookConfig.kt @@ -70,12 +70,11 @@ object ReadBookConfig { val dm = resources.displayMetrics val width = dm.widthPixels val height = dm.heightPixels - bg = durConfig.bgDrawable(width, height) - bg?.let { - if (it is BitmapDrawable) { - bgMeanColor = BitmapUtils.getMeanColor(it.bitmap) - } else if (it is ColorDrawable) { - bgMeanColor = it.color + bg = durConfig.bgDrawable(width, height).apply { + if (this is BitmapDrawable) { + bgMeanColor = BitmapUtils.getMeanColor(bitmap) + } else if (this is ColorDrawable) { + bgMeanColor = color } } } From 5cdcde05281b30e93755eb562f7a0631c15c55b4 Mon Sep 17 00:00:00 2001 From: kunfei Date: Sat, 7 Mar 2020 14:50:33 +0800 Subject: [PATCH 027/359] =?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/config/ReadStyleDialog.kt | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) 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 ece020ffa..95b7d81e9 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 @@ -224,12 +224,12 @@ class ReadStyleDialog : DialogFragment(), FontSelectDialog.CallBack { } } - private fun setBg() { - bg0.setTextColor(ReadBookConfig.getConfig(0).textColor()) - bg1.setTextColor(ReadBookConfig.getConfig(1).textColor()) - bg2.setTextColor(ReadBookConfig.getConfig(2).textColor()) - bg3.setTextColor(ReadBookConfig.getConfig(3).textColor()) - bg4.setTextColor(ReadBookConfig.getConfig(4).textColor()) + private fun setBg() = ReadBookConfig.apply { + bg0.setTextColor(getConfig(0).textColor()) + bg1.setTextColor(getConfig(1).textColor()) + bg2.setTextColor(getConfig(2).textColor()) + bg3.setTextColor(getConfig(3).textColor()) + bg4.setTextColor(getConfig(4).textColor()) for (i in 0..4) { val iv = when (i) { 1 -> bg1 @@ -238,22 +238,22 @@ class ReadStyleDialog : DialogFragment(), FontSelectDialog.CallBack { 4 -> bg4 else -> bg0 } - iv.setImageDrawable(ReadBookConfig.getConfig(i).bgDrawable(100, 150)) + iv.setImageDrawable(getConfig(i).bgDrawable(100, 150)) } } - private fun upBg() { - bg0.borderColor = requireContext().primaryColor - bg1.borderColor = requireContext().primaryColor - bg2.borderColor = requireContext().primaryColor - bg3.borderColor = requireContext().primaryColor - bg4.borderColor = requireContext().primaryColor + private fun upBg() = requireContext().apply { + bg0.borderColor = primaryColor + bg1.borderColor = primaryColor + bg2.borderColor = primaryColor + bg3.borderColor = primaryColor + bg4.borderColor = primaryColor when (ReadBookConfig.styleSelect) { - 1 -> bg1.borderColor = requireContext().accentColor - 2 -> bg2.borderColor = requireContext().accentColor - 3 -> bg3.borderColor = requireContext().accentColor - 4 -> bg4.borderColor = requireContext().accentColor - else -> bg0.borderColor = requireContext().accentColor + 1 -> bg1.borderColor = accentColor + 2 -> bg2.borderColor = accentColor + 3 -> bg3.borderColor = accentColor + 4 -> bg4.borderColor = accentColor + else -> bg0.borderColor = accentColor } } From dda8ac997f62defa1fe7dd51288cd8c1c9b4bfca Mon Sep 17 00:00:00 2001 From: kunfei Date: Sat, 7 Mar 2020 14:52:20 +0800 Subject: [PATCH 028/359] =?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/config/ReadStyleDialog.kt | 42 +++++++++---------- 1 file changed, 20 insertions(+), 22 deletions(-) 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 95b7d81e9..68a1d11aa 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 @@ -166,31 +166,29 @@ class ReadStyleDialog : DialogFragment(), FontSelectDialog.CallBack { } @SuppressLint("InflateParams") - private fun showTitleConfig() { + private fun showTitleConfig() = ReadBookConfig.apply { requireContext().alert(R.string.title) { val rootView = LayoutInflater.from(requireContext()) .inflate(R.layout.dialog_title_config, null).apply { - ReadBookConfig.apply { - rg_title_mode.checkByIndex(titleMode) - dsb_title_size.progress = titleSize - dsb_title_top.progress = titleTopSpacing - dsb_title_bottom.progress = titleBottomSpacing - rg_title_mode.onCheckedChange { _, checkedId -> - titleMode = rg_title_mode.getIndexById(checkedId) - postEvent(EventBus.UP_CONFIG, true) - } - dsb_title_size.onChanged = { - titleSize = it - postEvent(EventBus.UP_CONFIG, true) - } - dsb_title_top.onChanged = { - titleTopSpacing = it - postEvent(EventBus.UP_CONFIG, true) - } - dsb_title_bottom.onChanged = { - titleBottomSpacing = it - postEvent(EventBus.UP_CONFIG, true) - } + rg_title_mode.checkByIndex(titleMode) + dsb_title_size.progress = titleSize + dsb_title_top.progress = titleTopSpacing + dsb_title_bottom.progress = titleBottomSpacing + rg_title_mode.onCheckedChange { _, checkedId -> + titleMode = rg_title_mode.getIndexById(checkedId) + postEvent(EventBus.UP_CONFIG, true) + } + dsb_title_size.onChanged = { + titleSize = it + postEvent(EventBus.UP_CONFIG, true) + } + dsb_title_top.onChanged = { + titleTopSpacing = it + postEvent(EventBus.UP_CONFIG, true) + } + dsb_title_bottom.onChanged = { + titleBottomSpacing = it + postEvent(EventBus.UP_CONFIG, true) } } customView = rootView From 10a338609db16e6ebbd2c79fceb100b3c1469618 Mon Sep 17 00:00:00 2001 From: kunfei Date: Sat, 7 Mar 2020 15:05:20 +0800 Subject: [PATCH 029/359] =?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 | 2 -- 1 file changed, 2 deletions(-) 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 22f5e7f3d..a9533a966 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 @@ -2,7 +2,6 @@ package io.legado.app.ui.config import android.content.SharedPreferences import android.os.Bundle -import android.os.Handler import android.view.View import androidx.preference.Preference import androidx.preference.PreferenceFragmentCompat @@ -177,7 +176,6 @@ class ThemeConfigFragment : PreferenceFragmentCompat(), SharedPreferences.OnShar private fun recreateActivities() { postEvent(EventBus.RECREATE, "") - Handler().postDelayed({ activity?.recreate() }, 100L) } } \ No newline at end of file From ae5823abe33f4557c0773d734d1cea5b6599513e Mon Sep 17 00:00:00 2001 From: kunfei Date: Sat, 7 Mar 2020 15:16:16 +0800 Subject: [PATCH 030/359] =?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/config/ThemeConfigFragment.kt | 6 ++++-- app/src/main/java/io/legado/app/utils/EventBusKt.kt | 4 ++++ 2 files changed, 8 insertions(+), 2 deletions(-) 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 a9533a966..99d7d1e54 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 @@ -169,8 +169,10 @@ class ThemeConfigFragment : PreferenceFragmentCompat(), SharedPreferences.OnShar private fun upTheme(isNightTheme: Boolean) { if (AppConfig.isNightTheme == isNightTheme) { - App.INSTANCE.applyTheme() - recreateActivities() + listView.post { + App.INSTANCE.applyTheme() + recreateActivities() + } } } diff --git a/app/src/main/java/io/legado/app/utils/EventBusKt.kt b/app/src/main/java/io/legado/app/utils/EventBusKt.kt index 6731e06d6..0d9473a3c 100644 --- a/app/src/main/java/io/legado/app/utils/EventBusKt.kt +++ b/app/src/main/java/io/legado/app/utils/EventBusKt.kt @@ -14,6 +14,10 @@ inline fun postEvent(tag: String, event: EVENT) { LiveEventBus.get(tag).post(event) } +inline fun postEventDelay(tag: String, event: EVENT, delay: Long) { + LiveEventBus.get(tag).postDelay(event, delay) +} + inline fun AppCompatActivity.observeEvent( vararg tags: String, noinline observer: (EVENT) -> Unit From 657f9181bf1e32b8eb036fe4b4961265d4ea512e Mon Sep 17 00:00:00 2001 From: kunfei Date: Sat, 7 Mar 2020 16:27:23 +0800 Subject: [PATCH 031/359] =?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 | 4 +--- 1 file changed, 1 insertion(+), 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 c00dc2ba3..81e483c75 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 @@ -142,11 +142,9 @@ object ChapterProvider { textPages.last().textLines.add(textLine) textLine.upTopBottom(durY, textPaint) durY += textPaint.textHeight * lineSpacingExtra / 10f - if (isTitle) { - durY += titleBottomSpacing - } textPages.last().height = durY } + if (isTitle) durY += titleBottomSpacing durY += textPaint.textHeight * paragraphSpacing / 10f return durY } From f4fe3206f76e2c20fa65138ab94a24f1505c5400 Mon Sep 17 00:00:00 2001 From: kunfei Date: Sat, 7 Mar 2020 17:16:33 +0800 Subject: [PATCH 032/359] =?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/text/MultilineTextView.kt | 27 +++++++++++++++++++ app/src/main/res/layout/item_search.xml | 2 +- 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 app/src/main/java/io/legado/app/ui/widget/text/MultilineTextView.kt diff --git a/app/src/main/java/io/legado/app/ui/widget/text/MultilineTextView.kt b/app/src/main/java/io/legado/app/ui/widget/text/MultilineTextView.kt new file mode 100644 index 000000000..c0ccd86da --- /dev/null +++ b/app/src/main/java/io/legado/app/ui/widget/text/MultilineTextView.kt @@ -0,0 +1,27 @@ +package io.legado.app.ui.widget.text + +import android.content.Context +import android.graphics.Canvas +import android.util.AttributeSet +import androidx.appcompat.widget.AppCompatTextView + +class MultilineTextView(context: Context?, attrs: AttributeSet?) : + AppCompatTextView(context, attrs) { + + private var calculatedLines = false + + override fun onDraw(canvas: Canvas?) { + if (!calculatedLines) { + calculateLines(); + calculatedLines = true; + } + super.onDraw(canvas) + } + + private fun calculateLines() { + val mHeight = measuredHeight + val lHeight = lineHeight + val lines = mHeight / lHeight + setLines(lines) + } +} \ No newline at end of file diff --git a/app/src/main/res/layout/item_search.xml b/app/src/main/res/layout/item_search.xml index 65e518c60..2942b5db5 100644 --- a/app/src/main/res/layout/item_search.xml +++ b/app/src/main/res/layout/item_search.xml @@ -75,7 +75,7 @@ android:textColor="@color/tv_text_default" android:textSize="12sp" /> - Date: Sat, 7 Mar 2020 17:18:51 +0800 Subject: [PATCH 033/359] =?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 51355715a..02af30af8 100644 --- a/app/src/main/assets/updateLog.md +++ b/app/src/main/assets/updateLog.md @@ -7,6 +7,7 @@ * 添加标题大小调整 * 书籍整理添加批量启用禁用更新 * 换源禁用书源不显示 +* 修复搜索界面简介最下面显示半行文字 **2020/03/06** * 添加隐藏标题 From 9e5e4938922b4a2c5f58435935a96ef0ebc0876f Mon Sep 17 00:00:00 2001 From: kunfei Date: Sat, 7 Mar 2020 17:40:57 +0800 Subject: [PATCH 034/359] =?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/text/MultilineTextView.kt | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/widget/text/MultilineTextView.kt b/app/src/main/java/io/legado/app/ui/widget/text/MultilineTextView.kt index c0ccd86da..839ca59bd 100644 --- a/app/src/main/java/io/legado/app/ui/widget/text/MultilineTextView.kt +++ b/app/src/main/java/io/legado/app/ui/widget/text/MultilineTextView.kt @@ -8,13 +8,8 @@ import androidx.appcompat.widget.AppCompatTextView class MultilineTextView(context: Context?, attrs: AttributeSet?) : AppCompatTextView(context, attrs) { - private var calculatedLines = false - override fun onDraw(canvas: Canvas?) { - if (!calculatedLines) { - calculateLines(); - calculatedLines = true; - } + calculateLines() super.onDraw(canvas) } From d789561913214f3b25646d26a57433e9f2888739 Mon Sep 17 00:00:00 2001 From: kunfei Date: Sat, 7 Mar 2020 17:43:58 +0800 Subject: [PATCH 035/359] =?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 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 00ee621e4..4819e6384 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 @@ -151,7 +151,7 @@ class ArrangeBookActivity : VMBaseActivity(R.layout.activi R.id.menu_update_enable -> viewModel.upCanUpdate(adapter.selectedBooks.toTypedArray(), true) R.id.menu_update_disable -> - viewModel.upCanUpdate(adapter.selectedBooks.toTypedArray(), true) + viewModel.upCanUpdate(adapter.selectedBooks.toTypedArray(), false) R.id.menu_add_to_group -> selectGroup(0, addToGroupRequestCode) } return false From aad32764b646396227a4a9788b69e50398ce36e4 Mon Sep 17 00:00:00 2001 From: kunfei Date: Sat, 7 Mar 2020 17:44:48 +0800 Subject: [PATCH 036/359] =?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 deletion(-) 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 4819e6384..619aebdc4 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 @@ -103,7 +103,6 @@ class ArrangeBookActivity : VMBaseActivity(R.layout.activi else -> App.db.bookDao().observeByGroup(groupId) } booksLiveData?.observe(this, Observer { - adapter.selectedBooks.clear() adapter.setItems(it) upSelectCount() }) From c01e70c6a1f930b995c08bfa569d51f30c2f44f8 Mon Sep 17 00:00:00 2001 From: kunfei Date: Sat, 7 Mar 2020 17:55:19 +0800 Subject: [PATCH 037/359] =?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/arrange/ArrangeBookActivity.kt | 16 ++++++---------- .../app/ui/book/arrange/ArrangeBookAdapter.kt | 12 +++++++++++- 2 files changed, 17 insertions(+), 11 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 619aebdc4..f03cc1df5 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 @@ -115,25 +115,21 @@ class ArrangeBookActivity : VMBaseActivity(R.layout.activi R.id.menu_all -> { title_bar.subtitle = item.title groupId = -1 - adapter.selectedBooks.clear() initBookData() } R.id.menu_local -> { title_bar.subtitle = item.title groupId = -2 - adapter.selectedBooks.clear() initBookData() } R.id.menu_audio -> { title_bar.subtitle = item.title groupId = -3 - adapter.selectedBooks.clear() initBookData() } else -> if (item.groupId == R.id.menu_group) { title_bar.subtitle = item.title groupId = item.itemId - adapter.selectedBooks.clear() initBookData() } } @@ -144,13 +140,13 @@ class ArrangeBookActivity : VMBaseActivity(R.layout.activi when (item?.itemId) { R.id.menu_del_selection -> alert(titleResource = R.string.draw, messageResource = R.string.sure_del) { - okButton { viewModel.deleteBook(*adapter.selectedBooks.toTypedArray()) } + okButton { viewModel.deleteBook(*adapter.selectedBooks()) } noButton { } }.show().applyTint() R.id.menu_update_enable -> - viewModel.upCanUpdate(adapter.selectedBooks.toTypedArray(), true) + viewModel.upCanUpdate(adapter.selectedBooks(), true) R.id.menu_update_disable -> - viewModel.upCanUpdate(adapter.selectedBooks.toTypedArray(), false) + viewModel.upCanUpdate(adapter.selectedBooks(), false) R.id.menu_add_to_group -> selectGroup(0, addToGroupRequestCode) } return false @@ -173,7 +169,7 @@ class ArrangeBookActivity : VMBaseActivity(R.layout.activi when (requestCode) { groupRequestCode -> { val books = arrayListOf() - adapter.selectedBooks.forEach { + adapter.selectedBooks().forEach { books.add(it.copy(group = groupId)) } viewModel.updateBook(*books.toTypedArray()) @@ -185,7 +181,7 @@ class ArrangeBookActivity : VMBaseActivity(R.layout.activi } addToGroupRequestCode -> { val books = arrayListOf() - adapter.selectedBooks.forEach { + adapter.selectedBooks().forEach { books.add(it.copy(group = it.group or groupId)) } viewModel.updateBook(*books.toTypedArray()) @@ -194,7 +190,7 @@ class ArrangeBookActivity : VMBaseActivity(R.layout.activi } override fun upSelectCount() { - select_action_bar.upCountView(adapter.selectedBooks.size, adapter.getItems().size) + select_action_bar.upCountView(adapter.selectedBooks().size, adapter.getItems().size) } override fun deleteBook(book: Book) { diff --git a/app/src/main/java/io/legado/app/ui/book/arrange/ArrangeBookAdapter.kt b/app/src/main/java/io/legado/app/ui/book/arrange/ArrangeBookAdapter.kt index 66eff5706..96fe1344e 100644 --- a/app/src/main/java/io/legado/app/ui/book/arrange/ArrangeBookAdapter.kt +++ b/app/src/main/java/io/legado/app/ui/book/arrange/ArrangeBookAdapter.kt @@ -13,7 +13,7 @@ import org.jetbrains.anko.sdk27.listeners.onClick class ArrangeBookAdapter(context: Context, val callBack: CallBack) : SimpleRecyclerAdapter(context, R.layout.item_arrange_book) { val groupRequestCode = 12 - val selectedBooks: HashSet = hashSetOf() + private val selectedBooks: HashSet = hashSetOf() var actionItem: Book? = null fun selectAll(selectAll: Boolean) { @@ -40,6 +40,16 @@ class ArrangeBookAdapter(context: Context, val callBack: CallBack) : callBack.upSelectCount() } + fun selectedBooks(): Array { + val books = arrayListOf() + selectedBooks.forEach { + if (getItems().contains(it)) { + books.add(it) + } + } + return books.toTypedArray() + } + override fun convert(holder: ItemViewHolder, item: Book, payloads: MutableList) { with(holder.itemView) { tv_name.text = if (item.author.isEmpty()) { From 7c96fd84cf93c04ce4a06170b59c1c0a0cf63b55 Mon Sep 17 00:00:00 2001 From: kunfei Date: Sat, 7 Mar 2020 18:08:01 +0800 Subject: [PATCH 038/359] =?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/SearchActivity.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/search/SearchActivity.kt b/app/src/main/java/io/legado/app/ui/book/search/SearchActivity.kt index a41fcd656..195a1c5e5 100644 --- a/app/src/main/java/io/legado/app/ui/book/search/SearchActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/search/SearchActivity.kt @@ -11,6 +11,7 @@ import androidx.lifecycle.Observer import androidx.recyclerview.widget.DiffUtil import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView +import com.google.android.flexbox.FlexboxLayoutManager import io.legado.app.App import io.legado.app.R import io.legado.app.base.VMBaseActivity @@ -133,11 +134,10 @@ class SearchActivity : VMBaseActivity(R.layout.activity_book_se ATH.applyEdgeEffectColor(rv_bookshelf_search) ATH.applyEdgeEffectColor(rv_history_key) bookAdapter = BookAdapter(this, this) - rv_bookshelf_search.layoutManager = - LinearLayoutManager(this, RecyclerView.HORIZONTAL, false) + rv_bookshelf_search.layoutManager = FlexboxLayoutManager(this) rv_bookshelf_search.adapter = bookAdapter historyKeyAdapter = HistoryKeyAdapter(this, this) - rv_history_key.layoutManager = LinearLayoutManager(this, RecyclerView.HORIZONTAL, false) + rv_history_key.layoutManager = FlexboxLayoutManager(this) rv_history_key.adapter = historyKeyAdapter adapter = SearchAdapter(this, this) recycler_view.layoutManager = LinearLayoutManager(this) From 1827288eca333aca1487062dcbce3680288e0a7d Mon Sep 17 00:00:00 2001 From: kunfei Date: Sat, 7 Mar 2020 18:08:32 +0800 Subject: [PATCH 039/359] =?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 02af30af8..524a248bf 100644 --- a/app/src/main/assets/updateLog.md +++ b/app/src/main/assets/updateLog.md @@ -8,6 +8,7 @@ * 书籍整理添加批量启用禁用更新 * 换源禁用书源不显示 * 修复搜索界面简介最下面显示半行文字 +* 搜索历史改为多行 **2020/03/06** * 添加隐藏标题 From d50682e34081f49845ad2850f1cdc8869eb7699d Mon Sep 17 00:00:00 2001 From: kunfei Date: Sat, 7 Mar 2020 19:12:18 +0800 Subject: [PATCH 040/359] =?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/search/SearchActivity.kt | 17 ++++++++++------- .../ui/book/source/manage/BookSourceActivity.kt | 8 +++++--- .../app/ui/main/explore/ExploreFragment.kt | 10 ++++++---- .../ui/rss/source/manage/RssSourceActivity.kt | 9 ++++++--- app/src/main/res/layout/item_search.xml | 1 + 5 files changed, 28 insertions(+), 17 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/search/SearchActivity.kt b/app/src/main/java/io/legado/app/ui/book/search/SearchActivity.kt index 195a1c5e5..c86f96dba 100644 --- a/app/src/main/java/io/legado/app/ui/book/search/SearchActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/search/SearchActivity.kt @@ -32,6 +32,7 @@ import kotlinx.coroutines.launch import kotlinx.coroutines.withContext import org.jetbrains.anko.sdk27.listeners.onClick import org.jetbrains.anko.startActivity +import java.text.Collator class SearchActivity : VMBaseActivity(R.layout.activity_book_search), @@ -50,7 +51,7 @@ class SearchActivity : VMBaseActivity(R.layout.activity_book_se private var bookData: LiveData>? = null private var menu: Menu? = null private var precisionSearchMenuItem: MenuItem? = null - private var groups = hashSetOf() + private var groups = linkedSetOf() private var refreshTime = System.currentTimeMillis() override fun onActivityCreated(savedInstanceState: Bundle?) { @@ -229,12 +230,13 @@ class SearchActivity : VMBaseActivity(R.layout.activity_book_se if (selectedGroup == "") { item?.isChecked = true } - groups.map { - item = menu?.add(R.id.source_group, Menu.NONE, Menu.NONE, it) - if (it == selectedGroup) { - item?.isChecked = true + groups.sortedWith(Collator.getInstance(java.util.Locale.CHINESE)) + .map { + item = menu?.add(R.id.source_group, Menu.NONE, Menu.NONE, it) + if (it == selectedGroup) { + item?.isChecked = true + } } - } menu?.setGroupCheckable(R.id.source_group, true, true) } @@ -266,7 +268,8 @@ class SearchActivity : VMBaseActivity(R.layout.activity_book_se } else { App.db.searchKeywordDao().liveDataSearch(key) } - historyData?.observe(this, Observer { historyKeyAdapter.setItems(it) + historyData?.observe(this, Observer { + historyKeyAdapter.setItems(it) if (it.isEmpty()) { tv_clear_history.invisible() } else { diff --git a/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt b/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt index 31b1c2028..eba5950f4 100644 --- a/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt @@ -40,6 +40,7 @@ import org.jetbrains.anko.startActivity import org.jetbrains.anko.startActivityForResult import org.jetbrains.anko.toast import java.io.File +import java.text.Collator class BookSourceActivity : VMBaseActivity(R.layout.activity_book_source), PopupMenu.OnMenuItemClickListener, @@ -197,9 +198,10 @@ class BookSourceActivity : VMBaseActivity(R.layout.activity private fun upGroupMenu() { groupMenu?.removeGroup(R.id.source_group) - groups.map { - groupMenu?.add(R.id.source_group, Menu.NONE, Menu.NONE, it) - } + groups.sortedWith(Collator.getInstance(java.util.Locale.CHINESE)) + .map { + groupMenu?.add(R.id.source_group, Menu.NONE, Menu.NONE, it) + } } @SuppressLint("InflateParams") diff --git a/app/src/main/java/io/legado/app/ui/main/explore/ExploreFragment.kt b/app/src/main/java/io/legado/app/ui/main/explore/ExploreFragment.kt index f4257732c..c8f93fc64 100644 --- a/app/src/main/java/io/legado/app/ui/main/explore/ExploreFragment.kt +++ b/app/src/main/java/io/legado/app/ui/main/explore/ExploreFragment.kt @@ -17,14 +17,15 @@ import io.legado.app.base.VMBaseFragment import io.legado.app.data.entities.BookSource import io.legado.app.lib.theme.ATH import io.legado.app.lib.theme.primaryTextColor -import io.legado.app.ui.book.source.edit.BookSourceEditActivity import io.legado.app.ui.book.explore.ExploreShowActivity +import io.legado.app.ui.book.source.edit.BookSourceEditActivity import io.legado.app.utils.getViewModel import io.legado.app.utils.splitNotBlank import io.legado.app.utils.startActivity import kotlinx.android.synthetic.main.fragment_find_book.* import kotlinx.android.synthetic.main.view_search.* import kotlinx.android.synthetic.main.view_title_bar.* +import java.text.Collator class ExploreFragment : VMBaseFragment(R.layout.fragment_find_book), @@ -119,9 +120,10 @@ class ExploreFragment : VMBaseFragment(R.layout.fragment_find_ private fun upGroupsMenu() { groupsMenu?.let { subMenu -> subMenu.removeGroup(R.id.menu_group_text) - groups.forEach { - subMenu.add(R.id.menu_group_text, Menu.NONE, Menu.NONE, it) - } + groups.sortedWith(Collator.getInstance(java.util.Locale.CHINESE)) + .forEach { + subMenu.add(R.id.menu_group_text, Menu.NONE, Menu.NONE, it) + } } } 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 35934e4d6..c60ddaa39 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 @@ -39,6 +39,8 @@ import org.jetbrains.anko.startActivity import org.jetbrains.anko.startActivityForResult import org.jetbrains.anko.toast import java.io.File +import java.text.Collator +import java.util.* class RssSourceActivity : VMBaseActivity(R.layout.activity_rss_source), @@ -190,9 +192,10 @@ class RssSourceActivity : VMBaseActivity(R.layout.activity_r private fun upGroupMenu() { groupMenu?.removeGroup(R.id.source_group) - groups.map { - groupMenu?.add(R.id.source_group, Menu.NONE, Menu.NONE, it) - } + groups.sortedWith(Collator.getInstance(java.util.Locale.CHINESE)) + .map { + groupMenu?.add(R.id.source_group, Menu.NONE, Menu.NONE, it) + } } private fun initLiveDataSource(key: String? = null) { diff --git a/app/src/main/res/layout/item_search.xml b/app/src/main/res/layout/item_search.xml index 2942b5db5..421082d13 100644 --- a/app/src/main/res/layout/item_search.xml +++ b/app/src/main/res/layout/item_search.xml @@ -35,6 +35,7 @@ android:singleLine="true" android:text="@string/app_name" android:textColor="@color/tv_text_default" + android:textSize="16sp" app:layout_constraintEnd_toStartOf="@id/bv_originCount" app:layout_constraintStart_toEndOf="@+id/iv_cover" app:layout_constraintTop_toTopOf="parent" /> From 203f492fa375ef8e5382b9a33bee3526728de20e Mon Sep 17 00:00:00 2001 From: kunfei Date: Sat, 7 Mar 2020 19:23:50 +0800 Subject: [PATCH 041/359] =?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 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/build.gradle b/app/build.gradle index 3c8a18f6c..037194e73 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -167,7 +167,7 @@ dependencies { implementation 'org.nanohttpd:nanohttpd-websocket:2.3.1' //二维码 - implementation 'cn.bingoogolapple:bga-qrcode-zxing:1.3.6' + implementation 'cn.bingoogolapple:bga-qrcode-zxing:1.3.7' //颜色选择 implementation 'com.jaredrummler:colorpicker:1.1.0' From 8ee3932dca4334cb03149f3cf97b52f1275cfe22 Mon Sep 17 00:00:00 2001 From: kunfei Date: Sat, 7 Mar 2020 19:28:58 +0800 Subject: [PATCH 042/359] =?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/books/BooksFragment.kt | 16 ---------------- 1 file changed, 16 deletions(-) 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 5d922cae9..43375288e 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 @@ -7,7 +7,6 @@ import androidx.lifecycle.Observer import androidx.recyclerview.widget.DiffUtil import androidx.recyclerview.widget.GridLayoutManager import androidx.recyclerview.widget.LinearLayoutManager -import androidx.recyclerview.widget.RecyclerView import io.legado.app.App import io.legado.app.R import io.legado.app.base.BaseFragment @@ -75,21 +74,6 @@ class BooksFragment : BaseFragment(R.layout.fragment_books), booksAdapter = BooksAdapterGrid(requireContext(),this) } rv_bookshelf.adapter = booksAdapter - booksAdapter.registerAdapterDataObserver(object : RecyclerView.AdapterDataObserver() { - override fun onItemRangeInserted(positionStart: Int, itemCount: Int) { - super.onItemRangeInserted(positionStart, itemCount) - if (positionStart == 0) { - rv_bookshelf.scrollToPosition(0) - } - } - - override fun onItemRangeMoved(fromPosition: Int, toPosition: Int, itemCount: Int) { - super.onItemRangeMoved(fromPosition, toPosition, itemCount) - if (toPosition == 0) { - rv_bookshelf.scrollToPosition(0) - } - } - }) } private fun upRecyclerData() { From b03675c53b5962e4afd9302eb607a86baaf11c32 Mon Sep 17 00:00:00 2001 From: kunfei Date: Sat, 7 Mar 2020 19:50:55 +0800 Subject: [PATCH 043/359] =?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/SearchActivity.kt | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/search/SearchActivity.kt b/app/src/main/java/io/legado/app/ui/book/search/SearchActivity.kt index c86f96dba..2d1054859 100644 --- a/app/src/main/java/io/legado/app/ui/book/search/SearchActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/search/SearchActivity.kt @@ -283,15 +283,10 @@ class SearchActivity : VMBaseActivity(R.layout.activity_book_se */ @Synchronized private fun upSearchItems(items: List, isMandatoryUpdate: Boolean) { - if (!isMandatoryUpdate && System.currentTimeMillis() - refreshTime < 500) { - return - } - refreshTime = System.currentTimeMillis() - try { + if (isMandatoryUpdate || System.currentTimeMillis() - refreshTime > 500) { + refreshTime = System.currentTimeMillis() val diffResult = DiffUtil.calculateDiff(DiffCallBack(adapter.getItems(), items)) adapter.setItems(items, diffResult) - } catch (e: Exception) { - e.printStackTrace() } } From fb881c5951cad577254375369e907c2896cfcc69 Mon Sep 17 00:00:00 2001 From: kunfei Date: Sat, 7 Mar 2020 21:34:56 +0800 Subject: [PATCH 044/359] =?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/AppConst.kt | 8 ++- .../java/io/legado/app/help/JsExtensions.kt | 4 +- .../app/ui/book/download/DownloadActivity.kt | 2 +- .../app/ui/book/local/ImportBookAdapter.kt | 2 +- .../app/ui/book/read/page/ContentView.kt | 4 +- .../book/source/manage/BookSourceActivity.kt | 7 ++- .../legado/app/ui/filechooser/FilePicker.kt | 24 ++++++--- .../app/ui/replacerule/ReplaceRuleActivity.kt | 7 ++- .../legado/app/ui/rss/read/ReadRssActivity.kt | 54 ++++++++++++++++++- .../app/ui/rss/read/ReadRssViewModel.kt | 35 ++++++++++++ .../ui/rss/source/manage/RssSourceActivity.kt | 7 ++- app/src/main/res/values/strings.xml | 2 + 12 files changed, 137 insertions(+), 19 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 96cc7567f..fb197b3bb 100644 --- a/app/src/main/java/io/legado/app/constant/AppConst.kt +++ b/app/src/main/java/io/legado/app/constant/AppConst.kt @@ -29,14 +29,18 @@ object AppConst { ScriptEngineManager().getEngineByName("rhino") } - val TIME_FORMAT: SimpleDateFormat by lazy { + val timeFormat: SimpleDateFormat by lazy { SimpleDateFormat("HH:mm") } - val DATE_FORMAT: SimpleDateFormat by lazy { + val dateFormat: SimpleDateFormat by lazy { SimpleDateFormat("yyyy/MM/dd HH:mm") } + val fileNameFormat: SimpleDateFormat by lazy { + SimpleDateFormat("yy-MM-dd-HH-mm-ss") + } + val keyboardToolChars: List by lazy { arrayListOf( "@", "&", "|", "%", "/", ":", "[", "]", "{", "}", "<", ">", "\\", "$", "#", "!", ".", diff --git a/app/src/main/java/io/legado/app/help/JsExtensions.kt b/app/src/main/java/io/legado/app/help/JsExtensions.kt index 7cfd763a1..493ede9c3 100644 --- a/app/src/main/java/io/legado/app/help/JsExtensions.kt +++ b/app/src/main/java/io/legado/app/help/JsExtensions.kt @@ -2,7 +2,7 @@ package io.legado.app.help import android.util.Base64 import androidx.annotation.Keep -import io.legado.app.constant.AppConst.DATE_FORMAT +import io.legado.app.constant.AppConst.dateFormat import io.legado.app.model.analyzeRule.AnalyzeUrl import io.legado.app.utils.EncoderUtils import io.legado.app.utils.MD5Utils @@ -50,6 +50,6 @@ interface JsExtensions { } fun timeFormat(time: Long): String { - return DATE_FORMAT.format(Date(time)) + return dateFormat.format(Date(time)) } } diff --git a/app/src/main/java/io/legado/app/ui/book/download/DownloadActivity.kt b/app/src/main/java/io/legado/app/ui/book/download/DownloadActivity.kt index f731806a7..fec1ed537 100644 --- a/app/src/main/java/io/legado/app/ui/book/download/DownloadActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/download/DownloadActivity.kt @@ -127,7 +127,7 @@ class DownloadActivity : VMBaseActivity(R.layout.activity_dow FilePicker.selectFolder(this, exportRequestCode) { val path = ACache.get(this@DownloadActivity).getAsString(exportBookPathKey) if (path.isNullOrEmpty()) { - toast("没有默认路径") + toast(R.string.no_default_path) } else { startExport(path) } diff --git a/app/src/main/java/io/legado/app/ui/book/local/ImportBookAdapter.kt b/app/src/main/java/io/legado/app/ui/book/local/ImportBookAdapter.kt index acc3b7265..153356754 100644 --- a/app/src/main/java/io/legado/app/ui/book/local/ImportBookAdapter.kt +++ b/app/src/main/java/io/legado/app/ui/book/local/ImportBookAdapter.kt @@ -87,7 +87,7 @@ class ImportBookAdapter(context: Context, val callBack: CallBack) : ll_brief.visible() tv_tag.text = item.name.substringAfterLast(".") tv_size.text = StringUtils.toSize(item.size) - tv_date.text = AppConst.DATE_FORMAT.format(item.date) + tv_date.text = AppConst.dateFormat.format(item.date) cb_select.isChecked = selectedUris.contains(item.uri.toString()) } tv_name.text = item.name 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 8e0bf1d55..bcec98b1d 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 @@ -7,7 +7,7 @@ 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.constant.AppConst.timeFormat import io.legado.app.help.AppConfig import io.legado.app.help.ReadBookConfig import io.legado.app.ui.book.read.page.entities.TextPage @@ -85,7 +85,7 @@ class ContentView(context: Context) : FrameLayout(context) { } fun upTime() { - tv_top_left.text = TIME_FORMAT.format(Date(System.currentTimeMillis())) + tv_top_left.text = timeFormat.format(Date(System.currentTimeMillis())) } fun upBattery(battery: Int) { diff --git a/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt b/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt index eba5950f4..385088640 100644 --- a/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt @@ -85,7 +85,12 @@ class BookSourceActivity : VMBaseActivity(R.layout.activity R.id.menu_group_manage -> GroupManageDialog().show(supportFragmentManager, "groupManage") R.id.menu_import_source_local -> FilePicker - .selectFile(this, importRequestCode, "text/*", arrayOf("txt", "json")) + .selectFile( + this, + importRequestCode, + type = "text/*", + allowExtensions = arrayOf("txt", "json") + ) R.id.menu_import_source_onLine -> showImportDialog() } if (item.groupId == R.id.source_group) { diff --git a/app/src/main/java/io/legado/app/ui/filechooser/FilePicker.kt b/app/src/main/java/io/legado/app/ui/filechooser/FilePicker.kt index 9260fc8bd..8f5549709 100644 --- a/app/src/main/java/io/legado/app/ui/filechooser/FilePicker.kt +++ b/app/src/main/java/io/legado/app/ui/filechooser/FilePicker.kt @@ -14,8 +14,13 @@ import org.jetbrains.anko.toast @Suppress("unused") object FilePicker { - fun selectFolder(activity: AppCompatActivity, requestCode: Int, default: (() -> Unit)? = null) { - activity.alert(titleResource = R.string.select_folder) { + fun selectFolder( + activity: AppCompatActivity, + requestCode: Int, + title: String = activity.getString(R.string.select_folder), + default: (() -> Unit)? = null + ) { + activity.alert(title = title) { val selectList = activity.resources.getStringArray(R.array.select_folder).toMutableList() default ?: let { @@ -45,9 +50,14 @@ object FilePicker { }.show() } - fun selectFolder(fragment: Fragment, requestCode: Int, default: (() -> Unit)? = null) { + fun selectFolder( + fragment: Fragment, + requestCode: Int, + title: String = fragment.getString(R.string.select_folder), + default: (() -> Unit)? = null + ) { fragment.requireContext() - .alert(titleResource = R.string.select_folder) { + .alert(title = title) { val selectList = fragment.resources.getStringArray(R.array.select_folder).toMutableList() default ?: let { @@ -80,11 +90,12 @@ object FilePicker { fun selectFile( activity: BaseActivity, requestCode: Int, + title: String = activity.getString(R.string.select_file), type: String, allowExtensions: Array?, default: (() -> Unit)? = null ) { - activity.alert(titleResource = R.string.select_file) { + activity.alert(title = title) { val selectList = activity.resources.getStringArray(R.array.select_folder).toMutableList() default ?: let { @@ -119,12 +130,13 @@ object FilePicker { fun selectFile( fragment: Fragment, requestCode: Int, + title: String = fragment.getString(R.string.select_file), type: String, allowExtensions: Array, default: (() -> Unit)? = null ) { fragment.requireContext() - .alert(titleResource = R.string.select_file) { + .alert(title = title) { val selectList = fragment.resources.getStringArray(R.array.select_folder).toMutableList() default ?: let { 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 16ffee4a1..fd0a591b6 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 @@ -180,7 +180,12 @@ class ReplaceRuleActivity : VMBaseActivity(R.layout.activi R.id.menu_del_selection -> viewModel.delSelection(adapter.getSelection()) R.id.menu_import_source_onLine -> showImportDialog() R.id.menu_import_source_local -> FilePicker - .selectFile(this, importRequestCode, "text/*", arrayOf("txt", "json")) + .selectFile( + this, + importRequestCode, + type = "text/*", + allowExtensions = arrayOf("txt", "json") + ) } return super.onCompatOptionsItemSelected(item) } 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 1764a1f32..bf3b67f5f 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 @@ -1,6 +1,7 @@ package io.legado.app.ui.rss.read import android.annotation.SuppressLint +import android.content.Intent import android.os.Bundle import android.view.KeyEvent import android.view.Menu @@ -14,6 +15,9 @@ import io.legado.app.R import io.legado.app.base.VMBaseActivity import io.legado.app.lib.theme.DrawableUtils import io.legado.app.lib.theme.primaryTextColor +import io.legado.app.ui.filechooser.FileChooserDialog +import io.legado.app.ui.filechooser.FilePicker +import io.legado.app.utils.ACache import io.legado.app.utils.NetworkUtils import io.legado.app.utils.getViewModel import io.legado.app.utils.openUrl @@ -21,17 +25,22 @@ 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.jetbrains.anko.toast import org.jsoup.Jsoup import org.jsoup.safety.Whitelist + class ReadRssActivity : VMBaseActivity(R.layout.activity_rss_read), + FileChooserDialog.CallBack, ReadRssViewModel.CallBack { override val viewModel: ReadRssViewModel get() = getViewModel(ReadRssViewModel::class.java) - + private val savePathRequestCode = 132 + private val imagePathKey = "" private var starMenuItem: MenuItem? = null private var ttsMenuItem: MenuItem? = null + var webPic: String? = null override fun onActivityCreated(savedInstanceState: Bundle?) { viewModel.callBack = this @@ -95,6 +104,30 @@ class ReadRssActivity : VMBaseActivity(R.layout.activity_rss_r domStorageEnabled = true allowContentAccess = true } + web_view.setOnLongClickListener { + val hitTestResult = web_view.hitTestResult + if (hitTestResult.type == WebView.HitTestResult.IMAGE_TYPE || + hitTestResult.type == WebView.HitTestResult.SRC_IMAGE_ANCHOR_TYPE + ) { + hitTestResult.extra?.let { + webPic = it + saveImage() + return@setOnLongClickListener true + } + } + return@setOnLongClickListener false + } + } + + private fun saveImage() { + FilePicker.selectFolder(this, savePathRequestCode, getString(R.string.save_image)) { + val path = ACache.get(this).getAsString(imagePathKey) + if (path.isNullOrEmpty()) { + toast(R.string.no_default_path) + } else { + viewModel.saveImage(webPic, path) + } + } } @SuppressLint("SetJavaScriptEnabled") @@ -113,7 +146,6 @@ class ReadRssActivity : VMBaseActivity(R.layout.activity_rss_r url )//不想用baseUrl进else } else { - //webView.loadData(html, "text/html;charset=utf-8", "utf-8")//经测试可以解决中文乱码 web_view.loadDataWithBaseURL( null, html, @@ -203,6 +235,24 @@ class ReadRssActivity : VMBaseActivity(R.layout.activity_rss_r } } + override fun onFilePicked(requestCode: Int, currentPath: String) { + when (requestCode) { + savePathRequestCode -> { + ACache.get(this).put(imagePathKey, currentPath) + viewModel.saveImage(webPic, currentPath) + } + } + } + + override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { + super.onActivityResult(requestCode, resultCode, data) + when (requestCode) { + savePathRequestCode -> data?.data?.let { + onFilePicked(requestCode, it.toString()) + } + } + } + override fun onDestroy() { super.onDestroy() web_view.destroy() diff --git a/app/src/main/java/io/legado/app/ui/rss/read/ReadRssViewModel.kt b/app/src/main/java/io/legado/app/ui/rss/read/ReadRssViewModel.kt index 17b66f41c..7cc96ef29 100644 --- a/app/src/main/java/io/legado/app/ui/rss/read/ReadRssViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/rss/read/ReadRssViewModel.kt @@ -2,19 +2,29 @@ package io.legado.app.ui.rss.read import android.app.Application import android.content.Intent +import android.net.Uri import android.speech.tts.TextToSpeech import android.speech.tts.UtteranceProgressListener +import android.util.Base64 +import androidx.documentfile.provider.DocumentFile import androidx.lifecycle.MutableLiveData import io.legado.app.App import io.legado.app.R import io.legado.app.base.BaseViewModel +import io.legado.app.constant.AppConst import io.legado.app.data.entities.RssArticle import io.legado.app.data.entities.RssSource import io.legado.app.model.Rss import io.legado.app.model.analyzeRule.AnalyzeUrl +import io.legado.app.utils.DocumentUtils +import io.legado.app.utils.FileUtils +import io.legado.app.utils.isContentPath +import io.legado.app.utils.writeBytes import kotlinx.coroutines.launch +import java.io.File import java.util.* + class ReadRssViewModel(application: Application) : BaseViewModel(application), TextToSpeech.OnInitListener { var callBack: CallBack? = null @@ -85,6 +95,31 @@ class ReadRssViewModel(application: Application) : BaseViewModel(application), } } + fun saveImage(webPic: String?, path: String) { + webPic ?: return + execute { + val fileName = "${AppConst.fileNameFormat.format(Date(System.currentTimeMillis()))}.jpg" + webData2bitmap(webPic).let { biteArray -> + if (path.isContentPath()) { + val uri = Uri.parse(path) + DocumentFile.fromTreeUri(context, uri)?.let { doc -> + DocumentUtils.createFileIfNotExist(doc, fileName) + ?.writeBytes(context, biteArray) + } + } else { + val file = FileUtils.createFileIfNotExist(File(path), fileName) + file.writeBytes(biteArray) + } + } + }.onError { + toast("保存图片失败:${it.localizedMessage}") + } + } + + private fun webData2bitmap(data: String): ByteArray { + return Base64.decode(data.split(",").toTypedArray()[1], Base64.DEFAULT) + } + fun clHtml(content: String): String { return if (content.contains(" - ``` + 订阅源的内容规则中存在`