From 9a481af33dd45df40d2d589750a8a5c4eeef97b7 Mon Sep 17 00:00:00 2001 From: kunfei Date: Sat, 15 Feb 2020 20:05:40 +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/lib/theme/view/ATEStrokeTextView.kt | 31 ------------ .../app/lib/theme/view/ATETextInputLayout.kt | 15 ------ .../widget/text/PrimaryTextView.kt} | 4 +- .../widget/text/SecondaryTextView.kt} | 4 +- .../app/ui/widget/text/StrokeTextView.kt | 49 +++++++++++++++++++ .../app/ui/widget/text/TextInputLayout.kt | 18 +++++++ .../res/layout/activity_book_info_edit.xml | 22 ++++----- .../main/res/layout/activity_import_book.xml | 2 +- app/src/main/res/layout/dialog_page_key.xml | 8 +-- .../main/res/layout/dialog_read_bg_text.xml | 6 +-- .../res/layout/dialog_read_book_style.xml | 8 +-- .../main/res/layout/dialog_replace_edit.xml | 20 ++++---- app/src/main/res/layout/item_source_edit.xml | 4 +- 13 files changed, 106 insertions(+), 85 deletions(-) delete mode 100644 app/src/main/java/io/legado/app/lib/theme/view/ATEStrokeTextView.kt delete mode 100644 app/src/main/java/io/legado/app/lib/theme/view/ATETextInputLayout.kt rename app/src/main/java/io/legado/app/{lib/theme/view/ATEPrimaryTextView.kt => ui/widget/text/PrimaryTextView.kt} (75%) rename app/src/main/java/io/legado/app/{lib/theme/view/ATESecondaryTextView.kt => ui/widget/text/SecondaryTextView.kt} (75%) create mode 100644 app/src/main/java/io/legado/app/ui/widget/text/StrokeTextView.kt create mode 100644 app/src/main/java/io/legado/app/ui/widget/text/TextInputLayout.kt diff --git a/app/src/main/java/io/legado/app/lib/theme/view/ATEStrokeTextView.kt b/app/src/main/java/io/legado/app/lib/theme/view/ATEStrokeTextView.kt deleted file mode 100644 index d113321d9..000000000 --- a/app/src/main/java/io/legado/app/lib/theme/view/ATEStrokeTextView.kt +++ /dev/null @@ -1,31 +0,0 @@ -package io.legado.app.lib.theme.view - -import android.content.Context -import android.util.AttributeSet -import androidx.appcompat.widget.AppCompatTextView -import io.legado.app.R -import io.legado.app.lib.theme.Selector -import io.legado.app.lib.theme.ThemeStore -import io.legado.app.utils.dp -import io.legado.app.utils.getCompatColor - -class ATEStrokeTextView(context: Context, attrs: AttributeSet) : AppCompatTextView(context, attrs) { - - init { - background = Selector.shapeBuild() - .setCornerRadius(1.dp) - .setStrokeWidth(1.dp) - .setDisabledStrokeColor(context.getCompatColor(R.color.md_grey_500)) - .setDefaultStrokeColor(ThemeStore.textColorSecondary(context)) - .setSelectedStrokeColor(ThemeStore.accentColor(context)) - .setPressedBgColor(context.getCompatColor(R.color.transparent30)) - .create() - setTextColor( - Selector.colorBuild() - .setDefaultColor(ThemeStore.textColorSecondary(context)) - .setSelectedColor(ThemeStore.accentColor(context)) - .setDisabledColor(context.getCompatColor(R.color.md_grey_500)) - .create() - ) - } -} diff --git a/app/src/main/java/io/legado/app/lib/theme/view/ATETextInputLayout.kt b/app/src/main/java/io/legado/app/lib/theme/view/ATETextInputLayout.kt deleted file mode 100644 index 5444a309c..000000000 --- a/app/src/main/java/io/legado/app/lib/theme/view/ATETextInputLayout.kt +++ /dev/null @@ -1,15 +0,0 @@ -package io.legado.app.lib.theme.view - -import android.content.Context -import android.util.AttributeSet -import com.google.android.material.textfield.TextInputLayout -import io.legado.app.lib.theme.Selector -import io.legado.app.lib.theme.ThemeStore - -class ATETextInputLayout(context: Context, attrs: AttributeSet?) : TextInputLayout(context, attrs) { - - init { - defaultHintTextColor = Selector.colorBuild().setDefaultColor(ThemeStore.accentColor(context)).create() - } - -} diff --git a/app/src/main/java/io/legado/app/lib/theme/view/ATEPrimaryTextView.kt b/app/src/main/java/io/legado/app/ui/widget/text/PrimaryTextView.kt similarity index 75% rename from app/src/main/java/io/legado/app/lib/theme/view/ATEPrimaryTextView.kt rename to app/src/main/java/io/legado/app/ui/widget/text/PrimaryTextView.kt index b28a97305..2c2666e07 100644 --- a/app/src/main/java/io/legado/app/lib/theme/view/ATEPrimaryTextView.kt +++ b/app/src/main/java/io/legado/app/ui/widget/text/PrimaryTextView.kt @@ -1,4 +1,4 @@ -package io.legado.app.lib.theme.view +package io.legado.app.ui.widget.text import android.content.Context import android.util.AttributeSet @@ -8,7 +8,7 @@ import io.legado.app.lib.theme.ThemeStore /** * @author Aidan Follestad (afollestad) */ -class ATEPrimaryTextView(context: Context, attrs: AttributeSet) : +class PrimaryTextView(context: Context, attrs: AttributeSet) : AppCompatTextView(context, attrs) { init { diff --git a/app/src/main/java/io/legado/app/lib/theme/view/ATESecondaryTextView.kt b/app/src/main/java/io/legado/app/ui/widget/text/SecondaryTextView.kt similarity index 75% rename from app/src/main/java/io/legado/app/lib/theme/view/ATESecondaryTextView.kt rename to app/src/main/java/io/legado/app/ui/widget/text/SecondaryTextView.kt index 8031961d3..6d59af0e6 100644 --- a/app/src/main/java/io/legado/app/lib/theme/view/ATESecondaryTextView.kt +++ b/app/src/main/java/io/legado/app/ui/widget/text/SecondaryTextView.kt @@ -1,4 +1,4 @@ -package io.legado.app.lib.theme.view +package io.legado.app.ui.widget.text import android.content.Context import android.util.AttributeSet @@ -8,7 +8,7 @@ import io.legado.app.lib.theme.secondaryTextColor /** * @author Aidan Follestad (afollestad) */ -class ATESecondaryTextView(context: Context, attrs: AttributeSet) : +class SecondaryTextView(context: Context, attrs: AttributeSet) : AppCompatTextView(context, attrs) { init { 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 new file mode 100644 index 000000000..c899e1c42 --- /dev/null +++ b/app/src/main/java/io/legado/app/ui/widget/text/StrokeTextView.kt @@ -0,0 +1,49 @@ +package io.legado.app.ui.widget.text + +import android.content.Context +import android.util.AttributeSet +import androidx.appcompat.widget.AppCompatTextView +import io.legado.app.R +import io.legado.app.lib.theme.Selector +import io.legado.app.lib.theme.ThemeStore +import io.legado.app.utils.dp +import io.legado.app.utils.getCompatColor + +class StrokeTextView(context: Context, attrs: AttributeSet) : AppCompatTextView(context, attrs) { + + init { + if (isInEditMode) { + background = Selector.shapeBuild() + .setCornerRadius(1.dp) + .setStrokeWidth(1.dp) + .setDisabledStrokeColor(context.getCompatColor(R.color.md_grey_500)) + .setDefaultStrokeColor(context.getCompatColor(R.color.tv_text_secondary)) + .setSelectedStrokeColor(context.getCompatColor(R.color.colorAccent)) + .setPressedBgColor(context.getCompatColor(R.color.transparent30)) + .create() + setTextColor( + Selector.colorBuild() + .setDefaultColor(context.getCompatColor(R.color.tv_text_secondary)) + .setSelectedColor(context.getCompatColor(R.color.colorAccent)) + .setDisabledColor(context.getCompatColor(R.color.md_grey_500)) + .create() + ) + } else { + background = Selector.shapeBuild() + .setCornerRadius(1.dp) + .setStrokeWidth(1.dp) + .setDisabledStrokeColor(context.getCompatColor(R.color.md_grey_500)) + .setDefaultStrokeColor(ThemeStore.textColorSecondary(context)) + .setSelectedStrokeColor(ThemeStore.accentColor(context)) + .setPressedBgColor(context.getCompatColor(R.color.transparent30)) + .create() + setTextColor( + Selector.colorBuild() + .setDefaultColor(ThemeStore.textColorSecondary(context)) + .setSelectedColor(ThemeStore.accentColor(context)) + .setDisabledColor(context.getCompatColor(R.color.md_grey_500)) + .create() + ) + } + } +} diff --git a/app/src/main/java/io/legado/app/ui/widget/text/TextInputLayout.kt b/app/src/main/java/io/legado/app/ui/widget/text/TextInputLayout.kt new file mode 100644 index 000000000..015e848c3 --- /dev/null +++ b/app/src/main/java/io/legado/app/ui/widget/text/TextInputLayout.kt @@ -0,0 +1,18 @@ +package io.legado.app.ui.widget.text + +import android.content.Context +import android.util.AttributeSet +import com.google.android.material.textfield.TextInputLayout +import io.legado.app.lib.theme.Selector +import io.legado.app.lib.theme.ThemeStore + +class TextInputLayout(context: Context, attrs: AttributeSet?) : TextInputLayout(context, attrs) { + + init { + if (!isInEditMode) { + defaultHintTextColor = + Selector.colorBuild().setDefaultColor(ThemeStore.accentColor(context)).create() + } + } + +} diff --git a/app/src/main/res/layout/activity_book_info_edit.xml b/app/src/main/res/layout/activity_book_info_edit.xml index 170449767..0301bcfb6 100644 --- a/app/src/main/res/layout/activity_book_info_edit.xml +++ b/app/src/main/res/layout/activity_book_info_edit.xml @@ -42,7 +42,7 @@ android:orientation="vertical" android:padding="5dp"> - - + - - + - - + - - - - - + diff --git a/app/src/main/res/layout/activity_import_book.xml b/app/src/main/res/layout/activity_import_book.xml index e3473f202..092290eb2 100644 --- a/app/src/main/res/layout/activity_import_book.xml +++ b/app/src/main/res/layout/activity_import_book.xml @@ -34,7 +34,7 @@ android:focusable="true" tools:text="/" /> - - - + - - + - - - - - - - - - + - - + - - + - - + - - + diff --git a/app/src/main/res/layout/item_source_edit.xml b/app/src/main/res/layout/item_source_edit.xml index e68432c3e..d5db8fada 100644 --- a/app/src/main/res/layout/item_source_edit.xml +++ b/app/src/main/res/layout/item_source_edit.xml @@ -1,5 +1,5 @@ - - \ No newline at end of file + \ No newline at end of file