pull/517/head
gedoor 4 years ago
parent 3a55d1af75
commit 57fe65e354
  1. 12
      app/src/main/java/io/legado/app/ui/association/ImportBookSourceDialog.kt
  2. 12
      app/src/main/java/io/legado/app/ui/association/ImportRssSourceDialog.kt
  3. 28
      app/src/main/java/io/legado/app/ui/book/group/GroupManageDialog.kt
  4. 28
      app/src/main/java/io/legado/app/ui/book/group/GroupSelectDialog.kt
  5. 30
      app/src/main/java/io/legado/app/ui/book/read/ReadBookBaseActivity.kt
  6. 23
      app/src/main/java/io/legado/app/ui/book/read/config/BgTextConfigDialog.kt
  7. 60
      app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt
  8. 9
      app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfFragment.kt
  9. 19
      app/src/main/java/io/legado/app/ui/replace/ReplaceRuleActivity.kt
  10. 19
      app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceActivity.kt

@ -16,11 +16,11 @@ import io.legado.app.base.adapter.ItemViewHolder
import io.legado.app.base.adapter.SimpleRecyclerAdapter import io.legado.app.base.adapter.SimpleRecyclerAdapter
import io.legado.app.constant.PreferKey import io.legado.app.constant.PreferKey
import io.legado.app.data.entities.BookSource import io.legado.app.data.entities.BookSource
import io.legado.app.databinding.DialogEditTextBinding
import io.legado.app.databinding.DialogRecyclerViewBinding import io.legado.app.databinding.DialogRecyclerViewBinding
import io.legado.app.databinding.ItemSourceImportBinding import io.legado.app.databinding.ItemSourceImportBinding
import io.legado.app.help.AppConfig import io.legado.app.help.AppConfig
import io.legado.app.lib.dialogs.alert import io.legado.app.lib.dialogs.alert
import io.legado.app.ui.widget.text.AutoCompleteTextView
import io.legado.app.utils.getViewModelOfActivity import io.legado.app.utils.getViewModelOfActivity
import io.legado.app.utils.putPrefBoolean import io.legado.app.utils.putPrefBoolean
import io.legado.app.utils.viewbindingdelegate.viewBinding import io.legado.app.utils.viewbindingdelegate.viewBinding
@ -85,14 +85,10 @@ class ImportBookSourceDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickList
when (item.itemId) { when (item.itemId) {
R.id.menu_new_group -> { R.id.menu_new_group -> {
alert(R.string.diy_edit_source_group) { alert(R.string.diy_edit_source_group) {
var editText: AutoCompleteTextView? = null val alertBinding = DialogEditTextBinding.inflate(layoutInflater)
customView { customView = alertBinding.root
layoutInflater.inflate(R.layout.dialog_edit_text, null).apply {
editText = findViewById(R.id.edit_view)
}
}
okButton { okButton {
editText?.text?.toString()?.let { group -> alertBinding.editView.text?.toString()?.let { group ->
viewModel.groupName = group viewModel.groupName = group
item.title = getString(R.string.diy_edit_source_group_title, group) item.title = getString(R.string.diy_edit_source_group_title, group)
} }

@ -16,11 +16,11 @@ import io.legado.app.base.adapter.ItemViewHolder
import io.legado.app.base.adapter.SimpleRecyclerAdapter import io.legado.app.base.adapter.SimpleRecyclerAdapter
import io.legado.app.constant.PreferKey import io.legado.app.constant.PreferKey
import io.legado.app.data.entities.RssSource import io.legado.app.data.entities.RssSource
import io.legado.app.databinding.DialogEditTextBinding
import io.legado.app.databinding.DialogRecyclerViewBinding import io.legado.app.databinding.DialogRecyclerViewBinding
import io.legado.app.databinding.ItemSourceImportBinding import io.legado.app.databinding.ItemSourceImportBinding
import io.legado.app.help.AppConfig import io.legado.app.help.AppConfig
import io.legado.app.lib.dialogs.alert import io.legado.app.lib.dialogs.alert
import io.legado.app.ui.widget.text.AutoCompleteTextView
import io.legado.app.utils.getViewModelOfActivity import io.legado.app.utils.getViewModelOfActivity
import io.legado.app.utils.putPrefBoolean import io.legado.app.utils.putPrefBoolean
import io.legado.app.utils.viewbindingdelegate.viewBinding import io.legado.app.utils.viewbindingdelegate.viewBinding
@ -85,14 +85,10 @@ class ImportRssSourceDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListe
when (item.itemId) { when (item.itemId) {
R.id.menu_new_group -> { R.id.menu_new_group -> {
alert(R.string.diy_edit_source_group) { alert(R.string.diy_edit_source_group) {
var editText: AutoCompleteTextView? = null val alertBinding = DialogEditTextBinding.inflate(layoutInflater)
customView { customView = alertBinding.root
layoutInflater.inflate(R.layout.dialog_edit_text, null).apply {
editText = findViewById(R.id.edit_view)
}
}
okButton { okButton {
editText?.text?.toString()?.let { group -> alertBinding.editView.text?.toString()?.let { group ->
viewModel.groupName = group viewModel.groupName = group
item.title = getString(R.string.diy_edit_source_group_title, group) item.title = getString(R.string.diy_edit_source_group_title, group)
} }

@ -7,7 +7,6 @@ import android.view.LayoutInflater
import android.view.MenuItem import android.view.MenuItem
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.EditText
import androidx.appcompat.widget.Toolbar import androidx.appcompat.widget.Toolbar
import androidx.core.view.isGone import androidx.core.view.isGone
import androidx.recyclerview.widget.DiffUtil import androidx.recyclerview.widget.DiffUtil
@ -20,6 +19,7 @@ import io.legado.app.base.BaseDialogFragment
import io.legado.app.base.adapter.ItemViewHolder import io.legado.app.base.adapter.ItemViewHolder
import io.legado.app.base.adapter.SimpleRecyclerAdapter import io.legado.app.base.adapter.SimpleRecyclerAdapter
import io.legado.app.data.entities.BookGroup import io.legado.app.data.entities.BookGroup
import io.legado.app.databinding.DialogEditTextBinding
import io.legado.app.databinding.DialogRecyclerViewBinding import io.legado.app.databinding.DialogRecyclerViewBinding
import io.legado.app.databinding.ItemGroupManageBinding import io.legado.app.databinding.ItemGroupManageBinding
import io.legado.app.lib.dialogs.alert import io.legado.app.lib.dialogs.alert
@ -99,15 +99,12 @@ class GroupManageDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener
@SuppressLint("InflateParams") @SuppressLint("InflateParams")
private fun addGroup() { private fun addGroup() {
alert(title = getString(R.string.add_group)) { alert(title = getString(R.string.add_group)) {
var editText: EditText? = null val alertBinding = DialogEditTextBinding.inflate(layoutInflater).apply {
customView { editView.setHint(R.string.group_name)
layoutInflater.inflate(R.layout.dialog_edit_text, null).apply {
editText = findViewById(R.id.edit_view)
editText?.setHint(R.string.group_name)
}
} }
customView = alertBinding.root
yesButton { yesButton {
editText?.text?.toString()?.let { alertBinding.editView.text?.toString()?.let {
if (it.isNotBlank()) { if (it.isNotBlank()) {
viewModel.addGroup(it) viewModel.addGroup(it)
} }
@ -120,16 +117,15 @@ class GroupManageDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener
@SuppressLint("InflateParams") @SuppressLint("InflateParams")
private fun editGroup(bookGroup: BookGroup) { private fun editGroup(bookGroup: BookGroup) {
alert(title = getString(R.string.group_edit)) { alert(title = getString(R.string.group_edit)) {
var editText: EditText? = null val alertBinding = DialogEditTextBinding.inflate(layoutInflater).apply {
customView { editView.setHint(R.string.group_name)
layoutInflater.inflate(R.layout.dialog_edit_text, null).apply { editView.setText(bookGroup.groupName)
editText = findViewById(R.id.edit_view)
editText!!.setHint(R.string.group_name)
editText!!.setText(bookGroup.groupName)
}
} }
customView = alertBinding.root
yesButton { yesButton {
viewModel.upGroup(bookGroup.copy(groupName = editText?.text?.toString() ?: "")) alertBinding.editView.text?.toString()?.let {
viewModel.upGroup(bookGroup.copy(groupName = it))
}
} }
noButton() noButton()
}.show().requestInputMethod() }.show().requestInputMethod()

@ -7,7 +7,6 @@ import android.view.LayoutInflater
import android.view.MenuItem import android.view.MenuItem
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.EditText
import androidx.appcompat.widget.Toolbar import androidx.appcompat.widget.Toolbar
import androidx.fragment.app.FragmentManager import androidx.fragment.app.FragmentManager
import androidx.recyclerview.widget.ItemTouchHelper import androidx.recyclerview.widget.ItemTouchHelper
@ -20,6 +19,7 @@ import io.legado.app.base.adapter.ItemViewHolder
import io.legado.app.base.adapter.SimpleRecyclerAdapter import io.legado.app.base.adapter.SimpleRecyclerAdapter
import io.legado.app.data.entities.BookGroup import io.legado.app.data.entities.BookGroup
import io.legado.app.databinding.DialogBookGroupPickerBinding import io.legado.app.databinding.DialogBookGroupPickerBinding
import io.legado.app.databinding.DialogEditTextBinding
import io.legado.app.databinding.ItemGroupSelectBinding import io.legado.app.databinding.ItemGroupSelectBinding
import io.legado.app.lib.dialogs.alert import io.legado.app.lib.dialogs.alert
import io.legado.app.lib.theme.accentColor import io.legado.app.lib.theme.accentColor
@ -120,15 +120,12 @@ class GroupSelectDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener
@SuppressLint("InflateParams") @SuppressLint("InflateParams")
private fun addGroup() { private fun addGroup() {
alert(title = getString(R.string.add_group)) { alert(title = getString(R.string.add_group)) {
var editText: EditText? = null val alertBinding = DialogEditTextBinding.inflate(layoutInflater).apply {
customView { editView.setHint(R.string.group_name)
layoutInflater.inflate(R.layout.dialog_edit_text, null).apply {
editText = findViewById(R.id.edit_view)
editText!!.setHint(R.string.group_name)
}
} }
customView = alertBinding.root
yesButton { yesButton {
editText?.text?.toString()?.let { alertBinding.editView.text?.toString()?.let {
if (it.isNotBlank()) { if (it.isNotBlank()) {
viewModel.addGroup(it) viewModel.addGroup(it)
} }
@ -141,16 +138,15 @@ class GroupSelectDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener
@SuppressLint("InflateParams") @SuppressLint("InflateParams")
private fun editGroup(bookGroup: BookGroup) { private fun editGroup(bookGroup: BookGroup) {
alert(title = getString(R.string.group_edit)) { alert(title = getString(R.string.group_edit)) {
var editText: EditText? = null val alertBinding = DialogEditTextBinding.inflate(layoutInflater).apply {
customView { editView.setHint(R.string.group_name)
layoutInflater.inflate(R.layout.dialog_edit_text, null).apply { editView.setText(bookGroup.groupName)
editText = findViewById(R.id.edit_view)
editText!!.setHint(R.string.group_name)
editText!!.setText(bookGroup.groupName)
}
} }
customView = alertBinding.root
yesButton { yesButton {
viewModel.upGroup(bookGroup.copy(groupName = editText?.text?.toString() ?: "")) alertBinding.editView.text?.toString()?.let {
viewModel.upGroup(bookGroup.copy(groupName = it))
}
} }
noButton() noButton()
}.show().requestInputMethod() }.show().requestInputMethod()

@ -6,7 +6,6 @@ import android.graphics.Color
import android.os.Build import android.os.Build
import android.os.Bundle import android.os.Bundle
import android.view.* import android.view.*
import android.widget.EditText
import androidx.core.view.isVisible import androidx.core.view.isVisible
import io.legado.app.App import io.legado.app.App
import io.legado.app.R import io.legado.app.R
@ -15,6 +14,7 @@ import io.legado.app.constant.PreferKey
import io.legado.app.data.entities.Bookmark import io.legado.app.data.entities.Bookmark
import io.legado.app.databinding.ActivityBookReadBinding import io.legado.app.databinding.ActivityBookReadBinding
import io.legado.app.databinding.DialogDownloadChoiceBinding import io.legado.app.databinding.DialogDownloadChoiceBinding
import io.legado.app.databinding.DialogEditTextBinding
import io.legado.app.help.AppConfig import io.legado.app.help.AppConfig
import io.legado.app.help.LocalConfig import io.legado.app.help.LocalConfig
import io.legado.app.help.ReadBookConfig import io.legado.app.help.ReadBookConfig
@ -30,7 +30,6 @@ import io.legado.app.service.help.ReadBook
import io.legado.app.ui.book.read.config.BgTextConfigDialog import io.legado.app.ui.book.read.config.BgTextConfigDialog
import io.legado.app.ui.book.read.config.ClickActionConfigDialog import io.legado.app.ui.book.read.config.ClickActionConfigDialog
import io.legado.app.ui.book.read.config.PaddingConfigDialog import io.legado.app.ui.book.read.config.PaddingConfigDialog
import io.legado.app.ui.widget.text.AutoCompleteTextView
import io.legado.app.utils.getPrefString import io.legado.app.utils.getPrefString
import io.legado.app.utils.getViewModel import io.legado.app.utils.getViewModel
import io.legado.app.utils.requestInputMethod import io.legado.app.utils.requestInputMethod
@ -207,16 +206,13 @@ abstract class ReadBookBaseActivity :
val book = ReadBook.book ?: return val book = ReadBook.book ?: return
val textChapter = ReadBook.curTextChapter ?: return val textChapter = ReadBook.curTextChapter ?: return
alert(title = getString(R.string.bookmark_add)) { alert(title = getString(R.string.bookmark_add)) {
var editText: EditText? = null val alertBinding = DialogEditTextBinding.inflate(layoutInflater).apply {
message = book.name + "" + textChapter.title editView.setHint(R.string.note_content)
customView {
layoutInflater.inflate(R.layout.dialog_edit_text, null).apply {
editText = findViewById(R.id.edit_view)
editText!!.setHint(R.string.note_content)
}
} }
message = book.name + "" + textChapter.title
customView = alertBinding.root
yesButton { yesButton {
editText?.text?.toString()?.let { editContent -> alertBinding.editView.text?.toString()?.let { editContent ->
Coroutine.async { Coroutine.async {
val bookmark = Bookmark( val bookmark = Bookmark(
bookUrl = book.bookUrl, bookUrl = book.bookUrl,
@ -239,17 +235,13 @@ abstract class ReadBookBaseActivity :
val charsets = val charsets =
arrayListOf("UTF-8", "GB2312", "GBK", "Unicode", "UTF-16", "UTF-16LE", "ASCII") arrayListOf("UTF-8", "GB2312", "GBK", "Unicode", "UTF-16", "UTF-16LE", "ASCII")
alert(R.string.set_charset) { alert(R.string.set_charset) {
var editText: AutoCompleteTextView? = null val alertBinding = DialogEditTextBinding.inflate(layoutInflater).apply {
customView { editView.setFilterValues(charsets)
layoutInflater.inflate(R.layout.dialog_edit_text, null).apply { editView.setText(ReadBook.book?.charset)
editText = findViewById(R.id.edit_view)
editText?.setFilterValues(charsets)
editText?.setText(ReadBook.book?.charset)
}
} }
customView = alertBinding.root
okButton { okButton {
val text = editText?.text?.toString() alertBinding.editView.text?.toString()?.let {
text?.let {
ReadBook.setCharset(it) ReadBook.setCharset(it)
} }
} }

@ -13,6 +13,7 @@ import com.jaredrummler.android.colorpicker.ColorPickerDialog
import io.legado.app.R import io.legado.app.R
import io.legado.app.base.BaseDialogFragment import io.legado.app.base.BaseDialogFragment
import io.legado.app.constant.EventBus import io.legado.app.constant.EventBus
import io.legado.app.databinding.DialogEditTextBinding
import io.legado.app.databinding.DialogReadBgTextBinding import io.legado.app.databinding.DialogReadBgTextBinding
import io.legado.app.databinding.ItemBgImageBinding import io.legado.app.databinding.ItemBgImageBinding
import io.legado.app.help.ReadBookConfig import io.legado.app.help.ReadBookConfig
@ -26,7 +27,6 @@ import io.legado.app.lib.theme.getSecondaryTextColor
import io.legado.app.ui.book.read.ReadBookActivity import io.legado.app.ui.book.read.ReadBookActivity
import io.legado.app.ui.filepicker.FilePicker import io.legado.app.ui.filepicker.FilePicker
import io.legado.app.ui.filepicker.FilePickerDialog import io.legado.app.ui.filepicker.FilePickerDialog
import io.legado.app.ui.widget.text.AutoCompleteTextView
import io.legado.app.utils.* import io.legado.app.utils.*
import io.legado.app.utils.viewbindingdelegate.viewBinding import io.legado.app.utils.viewbindingdelegate.viewBinding
import org.jetbrains.anko.sdk27.listeners.onCheckedChange import org.jetbrains.anko.sdk27.listeners.onCheckedChange
@ -123,15 +123,12 @@ class BgTextConfigDialog : BaseDialogFragment(), FilePickerDialog.CallBack {
private fun initEvent() = with(ReadBookConfig.durConfig) { private fun initEvent() = with(ReadBookConfig.durConfig) {
binding.ivEdit.onClick { binding.ivEdit.onClick {
alert(R.string.style_name) { alert(R.string.style_name) {
var editText: AutoCompleteTextView? = null val alertBinding = DialogEditTextBinding.inflate(layoutInflater).apply {
customView { editView.setText(ReadBookConfig.durConfig.name)
layoutInflater.inflate(R.layout.dialog_edit_text, null).apply {
editText = findViewById(R.id.edit_view)
editText!!.setText(ReadBookConfig.durConfig.name)
}
} }
customView = alertBinding.root
okButton { okButton {
editText?.text?.toString()?.let { alertBinding.editView.text?.toString()?.let {
binding.tvName.text = it binding.tvName.text = it
ReadBookConfig.durConfig.name = it ReadBookConfig.durConfig.name = it
} }
@ -278,14 +275,10 @@ class BgTextConfigDialog : BaseDialogFragment(), FilePickerDialog.CallBack {
@SuppressLint("InflateParams") @SuppressLint("InflateParams")
private fun importNetConfigAlert() { private fun importNetConfigAlert() {
alert("输入地址") { alert("输入地址") {
var editText: AutoCompleteTextView? = null val alertBinding = DialogEditTextBinding.inflate(layoutInflater)
customView { customView = alertBinding.root
layoutInflater.inflate(R.layout.dialog_edit_text, null).apply {
editText = findViewById(R.id.edit_view)
}
}
okButton { okButton {
editText?.text?.toString()?.let { url -> alertBinding.editView.text?.toString()?.let { url ->
importNetConfig(url) importNetConfig(url)
} }
} }

@ -22,6 +22,7 @@ import io.legado.app.constant.AppPattern
import io.legado.app.constant.EventBus import io.legado.app.constant.EventBus
import io.legado.app.data.entities.BookSource import io.legado.app.data.entities.BookSource
import io.legado.app.databinding.ActivityBookSourceBinding import io.legado.app.databinding.ActivityBookSourceBinding
import io.legado.app.databinding.DialogEditTextBinding
import io.legado.app.help.IntentDataHelp import io.legado.app.help.IntentDataHelp
import io.legado.app.help.LocalConfig import io.legado.app.help.LocalConfig
import io.legado.app.lib.dialogs.alert import io.legado.app.lib.dialogs.alert
@ -38,7 +39,6 @@ import io.legado.app.ui.widget.dialog.TextDialog
import io.legado.app.ui.widget.recycler.DragSelectTouchHelper import io.legado.app.ui.widget.recycler.DragSelectTouchHelper
import io.legado.app.ui.widget.recycler.ItemTouchCallback import io.legado.app.ui.widget.recycler.ItemTouchCallback
import io.legado.app.ui.widget.recycler.VerticalDivider import io.legado.app.ui.widget.recycler.VerticalDivider
import io.legado.app.ui.widget.text.AutoCompleteTextView
import io.legado.app.utils.* import io.legado.app.utils.*
import org.jetbrains.anko.startActivity import org.jetbrains.anko.startActivity
import org.jetbrains.anko.startActivityForResult import org.jetbrains.anko.startActivityForResult
@ -279,15 +279,12 @@ class BookSourceActivity : VMBaseActivity<ActivityBookSourceBinding, BookSourceV
@SuppressLint("InflateParams") @SuppressLint("InflateParams")
private fun checkSource() { private fun checkSource() {
alert(titleResource = R.string.search_book_key) { alert(titleResource = R.string.search_book_key) {
var editText: AutoCompleteTextView? = null val alertBinding = DialogEditTextBinding.inflate(layoutInflater).apply {
customView { editView.setText(CheckSource.keyword)
layoutInflater.inflate(R.layout.dialog_edit_text, null).apply {
editText = findViewById(R.id.edit_view)
editText?.setText(CheckSource.keyword)
}
} }
customView = alertBinding.root
okButton { okButton {
editText?.text?.toString()?.let { alertBinding.editView.text?.toString()?.let {
if (it.isNotEmpty()) { if (it.isNotEmpty()) {
CheckSource.keyword = it CheckSource.keyword = it
} }
@ -301,17 +298,14 @@ class BookSourceActivity : VMBaseActivity<ActivityBookSourceBinding, BookSourceV
@SuppressLint("InflateParams") @SuppressLint("InflateParams")
private fun selectionAddToGroups() { private fun selectionAddToGroups() {
alert(titleResource = R.string.add_group) { alert(titleResource = R.string.add_group) {
var editText: AutoCompleteTextView? = null val alertBinding = DialogEditTextBinding.inflate(layoutInflater).apply {
customView { editView.setHint(R.string.group_name)
layoutInflater.inflate(R.layout.dialog_edit_text, null).apply { editView.setFilterValues(groups.toList())
editText = findViewById(R.id.edit_view) editView.dropDownHeight = 180.dp
editText?.setHint(R.string.group_name)
editText?.setFilterValues(groups.toList())
editText?.dropDownHeight = 180.dp
}
} }
customView = alertBinding.root
okButton { okButton {
editText?.text?.toString()?.let { alertBinding.editView.text?.toString()?.let {
if (it.isNotEmpty()) { if (it.isNotEmpty()) {
viewModel.selectionAddToGroups(adapter.getSelection(), it) viewModel.selectionAddToGroups(adapter.getSelection(), it)
} }
@ -324,17 +318,14 @@ class BookSourceActivity : VMBaseActivity<ActivityBookSourceBinding, BookSourceV
@SuppressLint("InflateParams") @SuppressLint("InflateParams")
private fun selectionRemoveFromGroups() { private fun selectionRemoveFromGroups() {
alert(titleResource = R.string.remove_group) { alert(titleResource = R.string.remove_group) {
var editText: AutoCompleteTextView? = null val alertBinding = DialogEditTextBinding.inflate(layoutInflater).apply {
customView { editView.setHint(R.string.group_name)
layoutInflater.inflate(R.layout.dialog_edit_text, null).apply { editView.setFilterValues(groups.toList())
editText = findViewById(R.id.edit_view) editView.dropDownHeight = 180.dp
editText?.setHint(R.string.group_name)
editText?.setFilterValues(groups.toList())
editText?.dropDownHeight = 180.dp
}
} }
customView = alertBinding.root
okButton { okButton {
editText?.text?.toString()?.let { alertBinding.editView.text?.toString()?.let {
if (it.isNotEmpty()) { if (it.isNotEmpty()) {
viewModel.selectionRemoveFromGroups(adapter.getSelection(), it) viewModel.selectionRemoveFromGroups(adapter.getSelection(), it)
} }
@ -360,19 +351,16 @@ class BookSourceActivity : VMBaseActivity<ActivityBookSourceBinding, BookSourceV
?.splitNotBlank(",") ?.splitNotBlank(",")
?.toMutableList() ?: mutableListOf() ?.toMutableList() ?: mutableListOf()
alert(titleResource = R.string.import_book_source_on_line) { alert(titleResource = R.string.import_book_source_on_line) {
var editText: AutoCompleteTextView? = null val alertBinding = DialogEditTextBinding.inflate(layoutInflater).apply {
customView { editView.setFilterValues(cacheUrls)
layoutInflater.inflate(R.layout.dialog_edit_text, null).apply { editView.delCallBack = {
editText = findViewById(R.id.edit_view) cacheUrls.remove(it)
editText?.setFilterValues(cacheUrls) aCache.put(importRecordKey, cacheUrls.joinToString(","))
editText?.delCallBack = {
cacheUrls.remove(it)
aCache.put(importRecordKey, cacheUrls.joinToString(","))
}
} }
} }
customView = alertBinding.root
okButton { okButton {
val text = editText?.text?.toString() val text = alertBinding.editView.text?.toString()
text?.let { text?.let {
if (!cacheUrls.contains(it)) { if (!cacheUrls.contains(it)) {
cacheUrls.add(0, it) cacheUrls.add(0, it)

@ -2,7 +2,10 @@ package io.legado.app.ui.main.bookshelf
import android.annotation.SuppressLint import android.annotation.SuppressLint
import android.os.Bundle import android.os.Bundle
import android.view.* import android.view.Menu
import android.view.MenuItem
import android.view.View
import android.view.ViewGroup
import androidx.appcompat.widget.SearchView import androidx.appcompat.widget.SearchView
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager import androidx.fragment.app.FragmentManager
@ -146,7 +149,7 @@ class BookshelfFragment : VMBaseFragment<BookshelfViewModel>(R.layout.fragment_b
val bookshelfLayout = getPrefInt(PreferKey.bookshelfLayout) val bookshelfLayout = getPrefInt(PreferKey.bookshelfLayout)
val bookshelfSort = getPrefInt(PreferKey.bookshelfSort) val bookshelfSort = getPrefInt(PreferKey.bookshelfSort)
val alertBinding = val alertBinding =
DialogBookshelfConfigBinding.inflate(LayoutInflater.from(requireContext())) DialogBookshelfConfigBinding.inflate(layoutInflater)
.apply { .apply {
rgLayout.checkByIndex(bookshelfLayout) rgLayout.checkByIndex(bookshelfLayout)
rgSort.checkByIndex(bookshelfSort) rgSort.checkByIndex(bookshelfSort)
@ -175,7 +178,7 @@ class BookshelfFragment : VMBaseFragment<BookshelfViewModel>(R.layout.fragment_b
@SuppressLint("InflateParams") @SuppressLint("InflateParams")
private fun addBookByUrl() { private fun addBookByUrl() {
alert(titleResource = R.string.add_book_url) { alert(titleResource = R.string.add_book_url) {
val alertBinding = DialogEditTextBinding.inflate(LayoutInflater.from(requireContext())) val alertBinding = DialogEditTextBinding.inflate(layoutInflater)
customView = alertBinding.root customView = alertBinding.root
okButton { okButton {
alertBinding.editView.text?.toString()?.let { alertBinding.editView.text?.toString()?.let {

@ -20,6 +20,7 @@ import io.legado.app.base.VMBaseActivity
import io.legado.app.constant.AppPattern import io.legado.app.constant.AppPattern
import io.legado.app.data.entities.ReplaceRule import io.legado.app.data.entities.ReplaceRule
import io.legado.app.databinding.ActivityReplaceRuleBinding import io.legado.app.databinding.ActivityReplaceRuleBinding
import io.legado.app.databinding.DialogEditTextBinding
import io.legado.app.help.IntentDataHelp import io.legado.app.help.IntentDataHelp
import io.legado.app.help.coroutine.Coroutine import io.legado.app.help.coroutine.Coroutine
import io.legado.app.lib.dialogs.alert import io.legado.app.lib.dialogs.alert
@ -34,7 +35,6 @@ import io.legado.app.ui.widget.SelectActionBar
import io.legado.app.ui.widget.recycler.DragSelectTouchHelper import io.legado.app.ui.widget.recycler.DragSelectTouchHelper
import io.legado.app.ui.widget.recycler.ItemTouchCallback import io.legado.app.ui.widget.recycler.ItemTouchCallback
import io.legado.app.ui.widget.recycler.VerticalDivider import io.legado.app.ui.widget.recycler.VerticalDivider
import io.legado.app.ui.widget.text.AutoCompleteTextView
import io.legado.app.utils.* import io.legado.app.utils.*
import org.jetbrains.anko.startActivity import org.jetbrains.anko.startActivity
import org.jetbrains.anko.toast import org.jetbrains.anko.toast
@ -214,19 +214,16 @@ class ReplaceRuleActivity : VMBaseActivity<ActivityReplaceRuleBinding, ReplaceRu
?.splitNotBlank(",") ?.splitNotBlank(",")
?.toMutableList() ?: mutableListOf() ?.toMutableList() ?: mutableListOf()
alert(titleResource = R.string.import_replace_rule_on_line) { alert(titleResource = R.string.import_replace_rule_on_line) {
var editText: AutoCompleteTextView? = null val alertBinding = DialogEditTextBinding.inflate(layoutInflater).apply {
customView { editView.setFilterValues(cacheUrls)
layoutInflater.inflate(R.layout.dialog_edit_text, null).apply { editView.delCallBack = {
editText = findViewById(R.id.edit_view) cacheUrls.remove(it)
editText?.setFilterValues(cacheUrls) aCache.put(importRecordKey, cacheUrls.joinToString(","))
editText?.delCallBack = {
cacheUrls.remove(it)
aCache.put(importRecordKey, cacheUrls.joinToString(","))
}
} }
} }
customView = alertBinding.root
okButton { okButton {
val text = editText?.text?.toString() val text = alertBinding.editView.text?.toString()
text?.let { text?.let {
if (!cacheUrls.contains(it)) { if (!cacheUrls.contains(it)) {
cacheUrls.add(0, it) cacheUrls.add(0, it)

@ -20,6 +20,7 @@ import io.legado.app.base.VMBaseActivity
import io.legado.app.constant.AppPattern import io.legado.app.constant.AppPattern
import io.legado.app.data.entities.RssSource import io.legado.app.data.entities.RssSource
import io.legado.app.databinding.ActivityRssSourceBinding import io.legado.app.databinding.ActivityRssSourceBinding
import io.legado.app.databinding.DialogEditTextBinding
import io.legado.app.help.IntentDataHelp import io.legado.app.help.IntentDataHelp
import io.legado.app.lib.dialogs.alert import io.legado.app.lib.dialogs.alert
import io.legado.app.lib.theme.ATH import io.legado.app.lib.theme.ATH
@ -33,7 +34,6 @@ import io.legado.app.ui.widget.SelectActionBar
import io.legado.app.ui.widget.recycler.DragSelectTouchHelper import io.legado.app.ui.widget.recycler.DragSelectTouchHelper
import io.legado.app.ui.widget.recycler.ItemTouchCallback import io.legado.app.ui.widget.recycler.ItemTouchCallback
import io.legado.app.ui.widget.recycler.VerticalDivider import io.legado.app.ui.widget.recycler.VerticalDivider
import io.legado.app.ui.widget.text.AutoCompleteTextView
import io.legado.app.utils.* import io.legado.app.utils.*
import org.jetbrains.anko.startActivity import org.jetbrains.anko.startActivity
import org.jetbrains.anko.startActivityForResult import org.jetbrains.anko.startActivityForResult
@ -228,19 +228,16 @@ class RssSourceActivity : VMBaseActivity<ActivityRssSourceBinding, RssSourceView
?.splitNotBlank(",") ?.splitNotBlank(",")
?.toMutableList() ?: mutableListOf() ?.toMutableList() ?: mutableListOf()
alert(titleResource = R.string.import_book_source_on_line) { alert(titleResource = R.string.import_book_source_on_line) {
var editText: AutoCompleteTextView? = null val alertBinding = DialogEditTextBinding.inflate(layoutInflater).apply {
customView { editView.setFilterValues(cacheUrls)
layoutInflater.inflate(R.layout.dialog_edit_text, null).apply { editView.delCallBack = {
editText = findViewById(R.id.edit_view) cacheUrls.remove(it)
editText?.setFilterValues(cacheUrls) aCache.put(importRecordKey, cacheUrls.joinToString(","))
editText?.delCallBack = {
cacheUrls.remove(it)
aCache.put(importRecordKey, cacheUrls.joinToString(","))
}
} }
} }
customView = alertBinding.root
okButton { okButton {
val text = editText?.text?.toString() val text = alertBinding.editView.text?.toString()
text?.let { text?.let {
if (!cacheUrls.contains(it)) { if (!cacheUrls.contains(it)) {
cacheUrls.add(0, it) cacheUrls.add(0, it)

Loading…
Cancel
Save