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.constant.PreferKey
import io.legado.app.data.entities.BookSource
import io.legado.app.databinding.DialogEditTextBinding
import io.legado.app.databinding.DialogRecyclerViewBinding
import io.legado.app.databinding.ItemSourceImportBinding
import io.legado.app.help.AppConfig
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.putPrefBoolean
import io.legado.app.utils.viewbindingdelegate.viewBinding
@ -85,14 +85,10 @@ class ImportBookSourceDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickList
when (item.itemId) {
R.id.menu_new_group -> {
alert(R.string.diy_edit_source_group) {
var editText: AutoCompleteTextView? = null
customView {
layoutInflater.inflate(R.layout.dialog_edit_text, null).apply {
editText = findViewById(R.id.edit_view)
}
}
val alertBinding = DialogEditTextBinding.inflate(layoutInflater)
customView = alertBinding.root
okButton {
editText?.text?.toString()?.let { group ->
alertBinding.editView.text?.toString()?.let { group ->
viewModel.groupName = 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.constant.PreferKey
import io.legado.app.data.entities.RssSource
import io.legado.app.databinding.DialogEditTextBinding
import io.legado.app.databinding.DialogRecyclerViewBinding
import io.legado.app.databinding.ItemSourceImportBinding
import io.legado.app.help.AppConfig
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.putPrefBoolean
import io.legado.app.utils.viewbindingdelegate.viewBinding
@ -85,14 +85,10 @@ class ImportRssSourceDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListe
when (item.itemId) {
R.id.menu_new_group -> {
alert(R.string.diy_edit_source_group) {
var editText: AutoCompleteTextView? = null
customView {
layoutInflater.inflate(R.layout.dialog_edit_text, null).apply {
editText = findViewById(R.id.edit_view)
}
}
val alertBinding = DialogEditTextBinding.inflate(layoutInflater)
customView = alertBinding.root
okButton {
editText?.text?.toString()?.let { group ->
alertBinding.editView.text?.toString()?.let { group ->
viewModel.groupName = 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.View
import android.view.ViewGroup
import android.widget.EditText
import androidx.appcompat.widget.Toolbar
import androidx.core.view.isGone
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.SimpleRecyclerAdapter
import io.legado.app.data.entities.BookGroup
import io.legado.app.databinding.DialogEditTextBinding
import io.legado.app.databinding.DialogRecyclerViewBinding
import io.legado.app.databinding.ItemGroupManageBinding
import io.legado.app.lib.dialogs.alert
@ -99,15 +99,12 @@ class GroupManageDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener
@SuppressLint("InflateParams")
private fun addGroup() {
alert(title = getString(R.string.add_group)) {
var editText: EditText? = null
customView {
layoutInflater.inflate(R.layout.dialog_edit_text, null).apply {
editText = findViewById(R.id.edit_view)
editText?.setHint(R.string.group_name)
}
val alertBinding = DialogEditTextBinding.inflate(layoutInflater).apply {
editView.setHint(R.string.group_name)
}
customView = alertBinding.root
yesButton {
editText?.text?.toString()?.let {
alertBinding.editView.text?.toString()?.let {
if (it.isNotBlank()) {
viewModel.addGroup(it)
}
@ -120,16 +117,15 @@ class GroupManageDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener
@SuppressLint("InflateParams")
private fun editGroup(bookGroup: BookGroup) {
alert(title = getString(R.string.group_edit)) {
var editText: EditText? = null
customView {
layoutInflater.inflate(R.layout.dialog_edit_text, null).apply {
editText = findViewById(R.id.edit_view)
editText!!.setHint(R.string.group_name)
editText!!.setText(bookGroup.groupName)
}
val alertBinding = DialogEditTextBinding.inflate(layoutInflater).apply {
editView.setHint(R.string.group_name)
editView.setText(bookGroup.groupName)
}
customView = alertBinding.root
yesButton {
viewModel.upGroup(bookGroup.copy(groupName = editText?.text?.toString() ?: ""))
alertBinding.editView.text?.toString()?.let {
viewModel.upGroup(bookGroup.copy(groupName = it))
}
}
noButton()
}.show().requestInputMethod()

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

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

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

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

@ -2,7 +2,10 @@ package io.legado.app.ui.main.bookshelf
import android.annotation.SuppressLint
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.fragment.app.Fragment
import androidx.fragment.app.FragmentManager
@ -146,7 +149,7 @@ class BookshelfFragment : VMBaseFragment<BookshelfViewModel>(R.layout.fragment_b
val bookshelfLayout = getPrefInt(PreferKey.bookshelfLayout)
val bookshelfSort = getPrefInt(PreferKey.bookshelfSort)
val alertBinding =
DialogBookshelfConfigBinding.inflate(LayoutInflater.from(requireContext()))
DialogBookshelfConfigBinding.inflate(layoutInflater)
.apply {
rgLayout.checkByIndex(bookshelfLayout)
rgSort.checkByIndex(bookshelfSort)
@ -175,7 +178,7 @@ class BookshelfFragment : VMBaseFragment<BookshelfViewModel>(R.layout.fragment_b
@SuppressLint("InflateParams")
private fun addBookByUrl() {
alert(titleResource = R.string.add_book_url) {
val alertBinding = DialogEditTextBinding.inflate(LayoutInflater.from(requireContext()))
val alertBinding = DialogEditTextBinding.inflate(layoutInflater)
customView = alertBinding.root
okButton {
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.data.entities.ReplaceRule
import io.legado.app.databinding.ActivityReplaceRuleBinding
import io.legado.app.databinding.DialogEditTextBinding
import io.legado.app.help.IntentDataHelp
import io.legado.app.help.coroutine.Coroutine
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.ItemTouchCallback
import io.legado.app.ui.widget.recycler.VerticalDivider
import io.legado.app.ui.widget.text.AutoCompleteTextView
import io.legado.app.utils.*
import org.jetbrains.anko.startActivity
import org.jetbrains.anko.toast
@ -214,19 +214,16 @@ class ReplaceRuleActivity : VMBaseActivity<ActivityReplaceRuleBinding, ReplaceRu
?.splitNotBlank(",")
?.toMutableList() ?: mutableListOf()
alert(titleResource = R.string.import_replace_rule_on_line) {
var editText: AutoCompleteTextView? = null
customView {
layoutInflater.inflate(R.layout.dialog_edit_text, null).apply {
editText = findViewById(R.id.edit_view)
editText?.setFilterValues(cacheUrls)
editText?.delCallBack = {
cacheUrls.remove(it)
aCache.put(importRecordKey, cacheUrls.joinToString(","))
}
val alertBinding = DialogEditTextBinding.inflate(layoutInflater).apply {
editView.setFilterValues(cacheUrls)
editView.delCallBack = {
cacheUrls.remove(it)
aCache.put(importRecordKey, cacheUrls.joinToString(","))
}
}
customView = alertBinding.root
okButton {
val text = editText?.text?.toString()
val text = alertBinding.editView.text?.toString()
text?.let {
if (!cacheUrls.contains(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.data.entities.RssSource
import io.legado.app.databinding.ActivityRssSourceBinding
import io.legado.app.databinding.DialogEditTextBinding
import io.legado.app.help.IntentDataHelp
import io.legado.app.lib.dialogs.alert
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.ItemTouchCallback
import io.legado.app.ui.widget.recycler.VerticalDivider
import io.legado.app.ui.widget.text.AutoCompleteTextView
import io.legado.app.utils.*
import org.jetbrains.anko.startActivity
import org.jetbrains.anko.startActivityForResult
@ -228,19 +228,16 @@ class RssSourceActivity : VMBaseActivity<ActivityRssSourceBinding, RssSourceView
?.splitNotBlank(",")
?.toMutableList() ?: mutableListOf()
alert(titleResource = R.string.import_book_source_on_line) {
var editText: AutoCompleteTextView? = null
customView {
layoutInflater.inflate(R.layout.dialog_edit_text, null).apply {
editText = findViewById(R.id.edit_view)
editText?.setFilterValues(cacheUrls)
editText?.delCallBack = {
cacheUrls.remove(it)
aCache.put(importRecordKey, cacheUrls.joinToString(","))
}
val alertBinding = DialogEditTextBinding.inflate(layoutInflater).apply {
editView.setFilterValues(cacheUrls)
editView.delCallBack = {
cacheUrls.remove(it)
aCache.put(importRecordKey, cacheUrls.joinToString(","))
}
}
customView = alertBinding.root
okButton {
val text = editText?.text?.toString()
val text = alertBinding.editView.text?.toString()
text?.let {
if (!cacheUrls.contains(it)) {
cacheUrls.add(0, it)

Loading…
Cancel
Save