feat: 优化代码

pull/103/head
kunfei 5 years ago
parent 9dc8983585
commit 6f2b8d59b0
  1. 4
      app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt
  2. 4
      app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfFragment.kt
  3. 4
      app/src/main/java/io/legado/app/ui/replacerule/ReplaceRuleActivity.kt
  4. 4
      app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceActivity.kt
  5. 8
      app/src/main/java/io/legado/app/ui/widget/text/AccentBgTextView.kt
  6. 4
      app/src/main/java/io/legado/app/ui/widget/text/AccentStrokeTextView.kt
  7. 4
      app/src/main/java/io/legado/app/ui/widget/text/AutoCompleteTextView.kt
  8. 2
      app/src/main/java/io/legado/app/ui/widget/text/BadgeView.kt
  9. 18
      app/src/main/res/layout/activity_book_info.xml
  10. 2
      app/src/main/res/layout/dialog_edit_text.xml
  11. 4
      app/src/main/res/layout/item_bookshelf_grid.xml
  12. 2
      app/src/main/res/layout/item_bookshelf_list.xml
  13. 4
      app/src/main/res/layout/item_import_book.xml
  14. 14
      app/src/main/res/layout/item_search.xml
  15. 4
      app/src/main/res/layout/view_select_action_bar.xml
  16. 4
      app/src/main/res/values/attrs.xml

@ -25,12 +25,12 @@ import io.legado.app.help.permission.PermissionsCompat
import io.legado.app.lib.dialogs.*
import io.legado.app.lib.theme.ATH
import io.legado.app.lib.theme.primaryTextColor
import io.legado.app.lib.theme.view.ATEAutoCompleteTextView
import io.legado.app.service.help.CheckSource
import io.legado.app.ui.book.source.edit.BookSourceEditActivity
import io.legado.app.ui.filechooser.FileChooserDialog
import io.legado.app.ui.qrcode.QrCodeActivity
import io.legado.app.ui.widget.SelectActionBar
import io.legado.app.ui.widget.text.AutoCompleteTextView
import io.legado.app.utils.*
import kotlinx.android.synthetic.main.activity_book_source.*
import kotlinx.android.synthetic.main.dialog_edit_text.view.*
@ -208,7 +208,7 @@ class BookSourceActivity : VMBaseActivity<BookSourceViewModel>(R.layout.activity
?.splitNotBlank(",")
?.toMutableList() ?: mutableListOf()
alert(titleResource = R.string.import_book_source_on_line) {
var editText: ATEAutoCompleteTextView? = null
var editText: AutoCompleteTextView? = null
customView {
layoutInflater.inflate(R.layout.dialog_edit_text, null).apply {
editText = edit_view

@ -20,12 +20,12 @@ import io.legado.app.data.entities.BookGroup
import io.legado.app.lib.dialogs.*
import io.legado.app.lib.theme.ATH
import io.legado.app.lib.theme.accentColor
import io.legado.app.lib.theme.view.ATEAutoCompleteTextView
import io.legado.app.ui.book.arrange.ArrangeBookActivity
import io.legado.app.ui.book.group.GroupManageDialog
import io.legado.app.ui.book.search.SearchActivity
import io.legado.app.ui.download.DownloadActivity
import io.legado.app.ui.importbook.ImportBookActivity
import io.legado.app.ui.widget.text.AutoCompleteTextView
import io.legado.app.utils.*
import kotlinx.android.synthetic.main.dialog_edit_text.view.*
import kotlinx.android.synthetic.main.fragment_bookshelf.*
@ -159,7 +159,7 @@ class BookshelfFragment : VMBaseFragment<BookshelfViewModel>(R.layout.fragment_b
private fun addBookByUrl() {
requireContext()
.alert(titleResource = R.string.add_book_url) {
var editText: ATEAutoCompleteTextView? = null
var editText: AutoCompleteTextView? = null
customView {
layoutInflater.inflate(R.layout.dialog_edit_text, null).apply {
editText = edit_view

@ -25,10 +25,10 @@ import io.legado.app.help.permission.PermissionsCompat
import io.legado.app.lib.dialogs.*
import io.legado.app.lib.theme.ATH
import io.legado.app.lib.theme.primaryTextColor
import io.legado.app.lib.theme.view.ATEAutoCompleteTextView
import io.legado.app.ui.filechooser.FileChooserDialog
import io.legado.app.ui.replacerule.edit.ReplaceEditDialog
import io.legado.app.ui.widget.SelectActionBar
import io.legado.app.ui.widget.text.AutoCompleteTextView
import io.legado.app.utils.*
import kotlinx.android.synthetic.main.activity_replace_rule.*
import kotlinx.android.synthetic.main.dialog_edit_text.view.*
@ -189,7 +189,7 @@ class ReplaceRuleActivity : VMBaseActivity<ReplaceRuleViewModel>(R.layout.activi
?.splitNotBlank(",")
?.toMutableList() ?: mutableListOf()
alert(titleResource = R.string.import_replace_rule_on_line) {
var editText: ATEAutoCompleteTextView? = null
var editText: AutoCompleteTextView? = null
customView {
layoutInflater.inflate(R.layout.dialog_edit_text, null).apply {
editText = edit_view

@ -25,11 +25,11 @@ import io.legado.app.help.permission.PermissionsCompat
import io.legado.app.lib.dialogs.*
import io.legado.app.lib.theme.ATH
import io.legado.app.lib.theme.primaryTextColor
import io.legado.app.lib.theme.view.ATEAutoCompleteTextView
import io.legado.app.ui.filechooser.FileChooserDialog
import io.legado.app.ui.qrcode.QrCodeActivity
import io.legado.app.ui.rss.source.edit.RssSourceEditActivity
import io.legado.app.ui.widget.SelectActionBar
import io.legado.app.ui.widget.text.AutoCompleteTextView
import io.legado.app.utils.*
import kotlinx.android.synthetic.main.activity_rss_source.*
import kotlinx.android.synthetic.main.dialog_edit_text.view.*
@ -204,7 +204,7 @@ class RssSourceActivity : VMBaseActivity<RssSourceViewModel>(R.layout.activity_r
?.splitNotBlank(",")
?.toMutableList() ?: mutableListOf()
alert(titleResource = R.string.import_book_source_on_line) {
var editText: ATEAutoCompleteTextView? = null
var editText: AutoCompleteTextView? = null
customView {
layoutInflater.inflate(R.layout.dialog_edit_text, null).apply {
editText = edit_view

@ -1,4 +1,4 @@
package io.legado.app.lib.theme.view
package io.legado.app.ui.widget.text
import android.content.Context
import android.graphics.Color
@ -9,13 +9,13 @@ import io.legado.app.lib.theme.ColorUtils
import io.legado.app.lib.theme.Selector
import io.legado.app.lib.theme.ThemeStore
class ATEAccentBgTextView(context: Context, attrs: AttributeSet) :
class AccentBgTextView(context: Context, attrs: AttributeSet) :
AppCompatTextView(context, attrs) {
init {
val typedArray = context.obtainStyledAttributes(attrs, R.styleable.ATEAccentBgTextView)
val typedArray = context.obtainStyledAttributes(attrs, R.styleable.AccentBgTextView)
val radios =
typedArray.getDimensionPixelOffset(R.styleable.ATEAccentBgTextView_abt_radius, 0)
typedArray.getDimensionPixelOffset(R.styleable.AccentBgTextView_bg_radius, 0)
typedArray.recycle()
background = Selector.shapeBuild()
.setCornerRadius(radios)

@ -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
@ -9,7 +9,7 @@ import io.legado.app.lib.theme.ThemeStore
import io.legado.app.utils.dp
import io.legado.app.utils.getCompatColor
class ATEAccentStrokeTextView(context: Context, attrs: AttributeSet) :
class AccentStrokeTextView(context: Context, attrs: AttributeSet) :
AppCompatTextView(context, attrs) {
init {

@ -1,4 +1,4 @@
package io.legado.app.lib.theme.view
package io.legado.app.ui.widget.text
import android.annotation.SuppressLint
import android.content.Context
@ -17,7 +17,7 @@ import kotlinx.android.synthetic.main.item_1line_text_and_del.view.*
import org.jetbrains.anko.sdk27.listeners.onClick
class ATEAutoCompleteTextView : AppCompatAutoCompleteTextView {
class AutoCompleteTextView : AppCompatAutoCompleteTextView {
constructor(context: Context) : super(context)

@ -1,4 +1,4 @@
package io.legado.app.ui.widget
package io.legado.app.ui.widget.text
import android.content.Context
import android.graphics.Color

@ -87,7 +87,7 @@
android:textColor="@color/md_white_1000"
tools:ignore="NestedWeights" />
<io.legado.app.lib.theme.view.ATEAccentBgTextView
<io.legado.app.ui.widget.text.AccentBgTextView
android:id="@+id/tv_change_source"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
@ -96,7 +96,7 @@
android:paddingRight="5dp"
android:text="@string/change_origin"
android:textSize="16sp"
app:abt_radius="2dp" />
app:bg_radius="2dp" />
</LinearLayout>
@ -108,7 +108,7 @@
android:orientation="horizontal"
android:visibility="gone">
<io.legado.app.lib.theme.view.ATEAccentBgTextView
<io.legado.app.ui.widget.text.AccentBgTextView
android:id="@+id/tv_kind"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
@ -118,9 +118,9 @@
android:singleLine="true"
android:text="@string/app_name"
android:textSize="14sp"
app:abt_radius="2dp" />
app:bg_radius="2dp" />
<io.legado.app.lib.theme.view.ATEAccentBgTextView
<io.legado.app.ui.widget.text.AccentBgTextView
android:id="@+id/tv_kind_1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
@ -129,9 +129,9 @@
android:singleLine="true"
android:text="@string/app_name"
android:textSize="14sp"
app:abt_radius="2dp" />
app:bg_radius="2dp" />
<io.legado.app.lib.theme.view.ATEAccentBgTextView
<io.legado.app.ui.widget.text.AccentBgTextView
android:id="@+id/tv_kind_2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
@ -141,7 +141,7 @@
android:singleLine="true"
android:text="@string/app_name"
android:textSize="14sp"
app:abt_radius="2dp" />
app:bg_radius="2dp" />
</LinearLayout>
@ -253,7 +253,7 @@
android:textColor="@color/tv_text_default"
android:textSize="15sp" />
<io.legado.app.lib.theme.view.ATEAccentBgTextView
<io.legado.app.ui.widget.text.AccentBgTextView
android:id="@+id/tv_read"
android:layout_width="0dp"
android:layout_height="match_parent"

@ -7,7 +7,7 @@
android:layout_marginBottom="48dp"
android:overScrollMode="ifContentScrolls">
<io.legado.app.lib.theme.view.ATEAutoCompleteTextView
<io.legado.app.ui.widget.text.AutoCompleteTextView
android:id="@+id/edit_view"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"

@ -29,7 +29,7 @@
app:layout_constraintRight_toRightOf="@id/iv_cover"
app:layout_constraintTop_toTopOf="@id/iv_cover">
<io.legado.app.ui.widget.BadgeView
<io.legado.app.ui.widget.text.BadgeView
android:id="@+id/bv_unread"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
@ -48,7 +48,7 @@
tools:ignore="RtlHardcoded" />
</FrameLayout>
<io.legado.app.ui.widget.BadgeView
<io.legado.app.ui.widget.text.BadgeView
android:id="@+id/bv_author"
android:layout_width="match_parent"
android:layout_height="wrap_content"

@ -33,7 +33,7 @@
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="@+id/iv_cover">
<io.legado.app.ui.widget.BadgeView
<io.legado.app.ui.widget.text.BadgeView
android:id="@+id/bv_unread"
android:layout_width="wrap_content"
android:layout_height="wrap_content"

@ -58,7 +58,7 @@
android:gravity="center_vertical"
android:orientation="horizontal">
<io.legado.app.lib.theme.view.ATEAccentBgTextView
<io.legado.app.ui.widget.text.AccentBgTextView
android:id="@+id/tv_tag"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
@ -68,7 +68,7 @@
android:text="TXT"
android:maxLines="1"
android:maxWidth="50dp"
app:abt_radius="2dp"
app:bg_radius="2dp"
tools:ignore="HardcodedText,RtlHardcoded" />
<TextView

@ -19,7 +19,7 @@
app:layout_constraintTop_toTopOf="parent"
tools:ignore="UnusedAttribute" />
<io.legado.app.ui.widget.BadgeView
<io.legado.app.ui.widget.text.BadgeView
android:id="@+id/bv_originCount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
@ -64,7 +64,7 @@
android:layout_height="wrap_content"
android:orientation="horizontal">
<io.legado.app.lib.theme.view.ATEAccentBgTextView
<io.legado.app.ui.widget.text.AccentBgTextView
android:id="@+id/tv_kind"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
@ -74,9 +74,9 @@
android:singleLine="true"
android:text="@string/app_name"
android:textSize="12sp"
app:abt_radius="2dp" />
app:bg_radius="2dp" />
<io.legado.app.lib.theme.view.ATEAccentBgTextView
<io.legado.app.ui.widget.text.AccentBgTextView
android:id="@+id/tv_kind_1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
@ -86,9 +86,9 @@
android:singleLine="true"
android:text="@string/app_name"
android:textSize="12sp"
app:abt_radius="2dp" />
app:bg_radius="2dp" />
<io.legado.app.lib.theme.view.ATEAccentBgTextView
<io.legado.app.ui.widget.text.AccentBgTextView
android:id="@+id/tv_kind_2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
@ -98,7 +98,7 @@
android:singleLine="true"
android:text="@string/app_name"
android:textSize="12sp"
app:abt_radius="2dp" />
app:bg_radius="2dp" />
</LinearLayout>

@ -20,7 +20,7 @@
android:text="@string/select_all_count"
android:textColor="@color/tv_text_default" />
<io.legado.app.lib.theme.view.ATEAccentStrokeTextView
<io.legado.app.ui.widget.text.AccentStrokeTextView
android:id="@+id/btn_revert_selection"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
@ -30,7 +30,7 @@
android:minWidth="80dp"
android:text="@string/revert_selection" />
<io.legado.app.lib.theme.view.ATEAccentStrokeTextView
<io.legado.app.ui.widget.text.AccentStrokeTextView
android:id="@+id/btn_select_action_main"
android:layout_width="wrap_content"
android:layout_height="wrap_content"

@ -144,8 +144,8 @@
</attr>
</declare-styleable>
<declare-styleable name="ATEAccentBgTextView">
<attr name="abt_radius" format="dimension" />
<declare-styleable name="AccentBgTextView">
<attr name="bg_radius" format="dimension" />
</declare-styleable>
<declare-styleable name="BadgeView">

Loading…
Cancel
Save