From 39ed24d4dccc6cefde2be8bd86a94df336f0d5c1 Mon Sep 17 00:00:00 2001 From: kunfei Date: Sat, 7 Mar 2020 10:50:27 +0800 Subject: [PATCH 01/34] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../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 02/34] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../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 03/34] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/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 04/34] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../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 05/34] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/legado/app/ui/book/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 06/34] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../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 07/34] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/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 08/34] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/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 09/34] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../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 10/34] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../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 11/34] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/help/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 12/34] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/legado/app/ui/book/read/page/ChapterProvider.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/ChapterProvider.kt b/app/src/main/java/io/legado/app/ui/book/read/page/ChapterProvider.kt index 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 13/34] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../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 14/34] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 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 15/34] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/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 16/34] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/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 17/34] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/res/layout/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 18/34] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../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 19/34] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../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 20/34] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../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 21/34] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../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 22/34] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../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 23/34] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/legado/app/ui/book/read/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 24/34] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../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 25/34] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/assets/updateLog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/app/src/main/assets/updateLog.md b/app/src/main/assets/updateLog.md index 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 26/34] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../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 27/34] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../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 28/34] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/legado/app/ui/book/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 29/34] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../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 30/34] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../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 31/34] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/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 32/34] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../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 33/34] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 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 34/34] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../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() {