From 59cef5f5a71bb481f90f0eb7ce9d9aba590507a2 Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 21 Feb 2020 21:10:44 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/ui/book/read/page/ContentTextView.kt | 49 ++++++++++++++- .../app/ui/widget/checkbox/SmoothCheckBox.kt | 2 +- .../res/layout/dialog_read_book_style.xml | 59 +++++++++++++++---- app/src/main/res/values/strings.xml | 2 + 4 files changed, 99 insertions(+), 13 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/ContentTextView.kt b/app/src/main/java/io/legado/app/ui/book/read/page/ContentTextView.kt index 52176ac4d..cf47dfdef 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/ContentTextView.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/ContentTextView.kt @@ -114,11 +114,56 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at } fun selectStartMove(x: Float, y: Float) { - + textPage?.let { textPage -> + for ((lineIndex, textLine) in textPage.textLines.withIndex()) { + if (y > textLine.lineTop && y < textLine.lineBottom) { + for ((charIndex, textChar) in textLine.textChars.withIndex()) { + if (x > textChar.leftBottomPosition.x && x < textChar.rightTopPosition.x) { + textChar.selected = true + invalidate() + selectStartLine = lineIndex + selectStartChar = charIndex + selectEndLine = lineIndex + selectEndChar = charIndex + SelectPoint( + textChar.leftBottomPosition.x, + textChar.leftBottomPosition.y.toFloat(), + textChar.rightTopPosition.x, + textChar.leftBottomPosition.y.toFloat() + ) + break + } + } + break + } + } + } } fun selectEndMove(x: Float, y: Float) { - + textPage?.let { textPage -> + for ((lineIndex, textLine) in textPage.textLines.withIndex()) { + if (y > textLine.lineTop && y < textLine.lineBottom) { + for ((charIndex, textChar) in textLine.textChars.withIndex()) { + if (x > textChar.leftBottomPosition.x && x < textChar.rightTopPosition.x) { + textChar.selected = true + invalidate() + selectStartLine = lineIndex + selectStartChar = charIndex + selectEndLine = lineIndex + selectEndChar = charIndex + SelectPoint( + textChar.leftBottomPosition.x, + textChar.leftBottomPosition.y.toFloat(), + textChar.rightTopPosition.x, + textChar.leftBottomPosition.y.toFloat() + ) + } + } + break + } + } + } } } diff --git a/app/src/main/java/io/legado/app/ui/widget/checkbox/SmoothCheckBox.kt b/app/src/main/java/io/legado/app/ui/widget/checkbox/SmoothCheckBox.kt index 7179d8a38..09a095fad 100644 --- a/app/src/main/java/io/legado/app/ui/widget/checkbox/SmoothCheckBox.kt +++ b/app/src/main/java/io/legado/app/ui/widget/checkbox/SmoothCheckBox.kt @@ -45,7 +45,7 @@ class SmoothCheckBox @JvmOverloads constructor( init { val ta = context.obtainStyledAttributes(attrs, R.styleable.SmoothCheckBox) var tickColor = ThemeStore.accentColor(context) - mCheckedColor = context.getCompatColor(R.color.background_card) + mCheckedColor = context.getCompatColor(R.color.background_menu) mUnCheckedColor = context.getCompatColor(R.color.background_menu) mFloorColor = context.getCompatColor(R.color.transparent30) tickColor = ta.getColor(R.styleable.SmoothCheckBox_color_tick, tickColor) 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 2acc48750..358d68063 100644 --- a/app/src/main/res/layout/dialog_read_book_style.xml +++ b/app/src/main/res/layout/dialog_read_book_style.xml @@ -1,12 +1,27 @@ + + @@ -77,7 +92,6 @@ android:paddingBottom="3dp" android:gravity="center" android:textSize="14sp" - app:layout_constraintLeft_toRightOf="@+id/tv_padding" app:layout_constraintRight_toRightOf="parent" app:layout_constraintTop_toTopOf="parent" /> @@ -133,8 +147,8 @@ android:id="@+id/tv_page_anim" android:layout_width="match_parent" android:layout_height="wrap_content" - android:paddingStart="10dp" - android:paddingEnd="10dp" + android:paddingStart="6dp" + android:paddingEnd="6dp" android:text="@string/page_anim" app:layout_constraintTop_toBottomOf="@+id/vw_bg_fg" /> @@ -142,8 +156,8 @@ android:id="@+id/rg_page_anim" android:layout_width="match_parent" android:layout_height="wrap_content" - android:paddingLeft="16dp" - android:paddingRight="16dp" + android:paddingLeft="10dp" + android:paddingRight="10dp" android:orientation="horizontal" android:gravity="center" app:layout_constraintTop_toBottomOf="@id/tv_page_anim"> @@ -219,12 +233,37 @@ + app:layout_constraintTop_toBottomOf="@+id/vw_bg_fg1" + app:layout_constraintLeft_toLeftOf="parent" + app:layout_constraintRight_toLeftOf="@+id/tv_share_layout" /> + + + + 页角 文本选择结束位置 文本选择开始位置 + 共用布局 + 标题居中