pull/34/head
kunfei 5 years ago
parent 8fb336671f
commit 4c72a094a5
  1. 2
      app/src/main/java/io/legado/app/lib/dialogs/AndroidDialogs.kt
  2. 27
      app/src/main/java/io/legado/app/lib/theme/view/ATEAutoCompleteTextView.kt
  3. 24
      app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt
  4. 9
      app/src/main/java/io/legado/app/ui/book/source/manage/GroupManageDialog.kt
  5. 5
      app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfFragment.kt
  6. 9
      app/src/main/java/io/legado/app/ui/replacerule/GroupManageDialog.kt
  7. 2
      app/src/main/res/layout/dialog_edit_text.xml

@ -57,7 +57,7 @@ fun Context.alert(
titleResource: Int? = null,
messageResource: Int? = null,
init: (AlertBuilder<DialogInterface>.() -> Unit)? = null
): AlertBuilder<DialogInterface> {
): AlertBuilder<AlertDialog> {
return AndroidAlertBuilder(this).apply {
if (titleResource != null) {
this.titleResource = titleResource

@ -2,36 +2,31 @@ package io.legado.app.lib.theme.view
import android.content.Context
import android.graphics.Rect
import android.os.Build
import android.util.AttributeSet
import android.view.KeyEvent
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ArrayAdapter
import androidx.appcompat.widget.AppCompatAutoCompleteTextView
import io.legado.app.R
import io.legado.app.lib.theme.Selector
import io.legado.app.lib.theme.ThemeStore
import io.legado.app.lib.theme.ATH
import io.legado.app.utils.gone
import io.legado.app.utils.visible
import kotlinx.android.synthetic.main.item_1line_text_and_del.view.*
import org.jetbrains.anko.sdk27.listeners.onClick
class ATEAutoCompleteTextView(context: Context, attrs: AttributeSet) :
AppCompatAutoCompleteTextView(context, attrs) {
class ATEAutoCompleteTextView : AppCompatAutoCompleteTextView {
constructor(context: Context) : super(context)
constructor(context: Context, attrs: AttributeSet) : super(context, attrs)
var delCallBack: DelCallBack? = null
var showDel: Boolean = false
init {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
backgroundTintList = Selector.colorBuild()
.setFocusedColor(ThemeStore.accentColor(context))
.setDefaultColor(ThemeStore.textColorPrimary(context))
.create()
}
ATH.applyAccentTint(this)
}
override fun enoughToFilter(): Boolean {
@ -41,11 +36,7 @@ class ATEAutoCompleteTextView(context: Context, attrs: AttributeSet) :
override fun onFocusChanged(focused: Boolean, direction: Int, previouslyFocusedRect: Rect?) {
super.onFocusChanged(focused, direction, previouslyFocusedRect)
performFiltering()
}
fun performFiltering() {
performFiltering(text, KeyEvent.KEYCODE_UNKNOWN)
showDropDown()
}
fun setFilterValues(values: List<String>, showDel: Boolean = false) {
@ -70,7 +61,7 @@ class ATEAutoCompleteTextView(context: Context, attrs: AttributeSet) :
getItem(position)?.let {
remove(it)
delCallBack?.delete(it)
performFiltering()
showDropDown()
}
}
return view

@ -19,14 +19,21 @@ import io.legado.app.base.VMBaseActivity
import io.legado.app.data.entities.BookSource
import io.legado.app.help.ItemTouchCallback
import io.legado.app.help.storage.Restore
import io.legado.app.lib.dialogs.alert
import io.legado.app.lib.dialogs.cancelButton
import io.legado.app.lib.dialogs.customView
import io.legado.app.lib.dialogs.okButton
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.CheckSourceService
import io.legado.app.ui.book.source.edit.SourceEditActivity
import io.legado.app.ui.qrcode.QrCodeActivity
import io.legado.app.utils.applyTint
import io.legado.app.utils.getViewModel
import io.legado.app.utils.splitNotBlank
import kotlinx.android.synthetic.main.activity_book_source.*
import kotlinx.android.synthetic.main.dialog_edit_text.view.*
import kotlinx.android.synthetic.main.view_search.*
import kotlinx.android.synthetic.main.view_title_bar.*
import org.jetbrains.anko.startActivity
@ -84,6 +91,7 @@ class BookSourceActivity : VMBaseActivity<BookSourceViewModel>(R.layout.activity
R.id.menu_del_selection -> viewModel.delSelection(adapter.getSelectionIds())
R.id.menu_check_book_source ->
startService<CheckSourceService>(Pair("data", adapter.getSelectionIds()))
R.id.menu_import_book_source_onLine -> showImportDialog()
}
if (item.groupId == R.id.source_group) {
search_view.setQuery(item.title, true)
@ -153,6 +161,22 @@ class BookSourceActivity : VMBaseActivity<BookSourceViewModel>(R.layout.activity
}
}
private fun showImportDialog() {
alert(titleResource = R.string.import_book_source_on_line) {
var editText: ATEAutoCompleteTextView? = null
customView {
layoutInflater.inflate(R.layout.dialog_edit_text, null).apply {
editText = edit_view
}
}
okButton {
editText?.text
}
cancelButton()
}.show().applyTint()
}
override fun onQueryTextChange(newText: String?): Boolean {
newText?.let {
initLiveDataBookSource(it)

@ -23,12 +23,11 @@ import io.legado.app.lib.dialogs.alert
import io.legado.app.lib.dialogs.customView
import io.legado.app.lib.dialogs.noButton
import io.legado.app.lib.dialogs.yesButton
import io.legado.app.lib.theme.ATH
import io.legado.app.utils.applyTint
import io.legado.app.utils.getViewModelOfActivity
import io.legado.app.utils.requestInputMethod
import io.legado.app.utils.splitNotBlank
import kotlinx.android.synthetic.main.dialog_edittext.view.*
import kotlinx.android.synthetic.main.dialog_edit_text.view.*
import kotlinx.android.synthetic.main.dialog_recycler_view.*
import kotlinx.android.synthetic.main.item_book_group.view.tv_group
import kotlinx.android.synthetic.main.item_group_manage.view.*
@ -91,9 +90,8 @@ class GroupManageDialog : DialogFragment(), Toolbar.OnMenuItemClickListener {
alert(title = getString(R.string.add_group)) {
var editText: EditText? = null
customView {
layoutInflater.inflate(R.layout.dialog_edittext, null).apply {
layoutInflater.inflate(R.layout.dialog_edit_text, null).apply {
editText = edit_view.apply {
ATH.applyAccentTint(this)
hint = "分组名称"
}
}
@ -114,9 +112,8 @@ class GroupManageDialog : DialogFragment(), Toolbar.OnMenuItemClickListener {
alert(title = getString(R.string.group_edit)) {
var editText: EditText? = null
customView {
layoutInflater.inflate(R.layout.dialog_edittext, null).apply {
layoutInflater.inflate(R.layout.dialog_edit_text, null).apply {
editText = edit_view.apply {
ATH.applyAccentTint(this)
hint = "分组名称"
setText(group)
}

@ -27,7 +27,7 @@ import io.legado.app.ui.book.read.ReadBookActivity
import io.legado.app.ui.book.search.SearchActivity
import io.legado.app.ui.bookshelf.BookshelfActivity
import io.legado.app.utils.*
import kotlinx.android.synthetic.main.dialog_edittext.view.*
import kotlinx.android.synthetic.main.dialog_edit_text.view.*
import kotlinx.android.synthetic.main.fragment_bookshelf.*
import kotlinx.android.synthetic.main.view_title_bar.*
import org.jetbrains.anko.startActivity
@ -135,9 +135,8 @@ class BookshelfFragment : VMBaseFragment<BookshelfViewModel>(R.layout.fragment_b
alert(title = "新建分组") {
var editText: EditText? = null
customView {
layoutInflater.inflate(R.layout.dialog_edittext, null).apply {
layoutInflater.inflate(R.layout.dialog_edit_text, null).apply {
editText = edit_view.apply {
ATH.applyAccentTint(this)
hint = "分组名称"
}
}

@ -23,12 +23,11 @@ import io.legado.app.lib.dialogs.alert
import io.legado.app.lib.dialogs.customView
import io.legado.app.lib.dialogs.noButton
import io.legado.app.lib.dialogs.yesButton
import io.legado.app.lib.theme.ATH
import io.legado.app.utils.applyTint
import io.legado.app.utils.getViewModelOfActivity
import io.legado.app.utils.requestInputMethod
import io.legado.app.utils.splitNotBlank
import kotlinx.android.synthetic.main.dialog_edittext.view.*
import kotlinx.android.synthetic.main.dialog_edit_text.view.*
import kotlinx.android.synthetic.main.dialog_recycler_view.*
import kotlinx.android.synthetic.main.item_book_group.view.tv_group
import kotlinx.android.synthetic.main.item_group_manage.view.*
@ -91,9 +90,8 @@ class GroupManageDialog : DialogFragment(), Toolbar.OnMenuItemClickListener {
alert(title = getString(R.string.add_group)) {
var editText: EditText? = null
customView {
layoutInflater.inflate(R.layout.dialog_edittext, null).apply {
layoutInflater.inflate(R.layout.dialog_edit_text, null).apply {
editText = edit_view.apply {
ATH.applyAccentTint(this)
hint = "分组名称"
}
}
@ -114,9 +112,8 @@ class GroupManageDialog : DialogFragment(), Toolbar.OnMenuItemClickListener {
alert(title = getString(R.string.group_edit)) {
var editText: EditText? = null
customView {
layoutInflater.inflate(R.layout.dialog_edittext, null).apply {
layoutInflater.inflate(R.layout.dialog_edit_text, null).apply {
editText = edit_view.apply {
ATH.applyAccentTint(this)
hint = "分组名称"
setText(group)
}

@ -7,7 +7,7 @@
android:layout_marginBottom="48dp"
android:overScrollMode="ifContentScrolls">
<androidx.appcompat.widget.AppCompatEditText
<io.legado.app.lib.theme.view.ATEAutoCompleteTextView
android:id="@+id/edit_view"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
Loading…
Cancel
Save