导入书源是自定义分组可选

pull/811/head
gedoor 4 years ago
parent 41b32f26ce
commit 0da3abcc88
  1. 5
      app/src/main/java/io/legado/app/data/dao/RssSourceDao.kt
  2. 15
      app/src/main/java/io/legado/app/ui/association/ImportRssSourceDialog.kt

@ -37,9 +37,12 @@ interface RssSourceDao {
@Query("SELECT * FROM rssSources where enabled = 1 and sourceGroup like :searchKey order by customOrder")
fun liveEnabledByGroup(searchKey: String): LiveData<List<RssSource>>
@Query("select sourceGroup from rssSources where trim(sourceGroup) <> ''")
@Query("select distinct sourceGroup from rssSources where trim(sourceGroup) <> ''")
fun liveGroup(): LiveData<List<String>>
@get:Query("select distinct sourceGroup from rssSources where trim(sourceGroup) <> ''")
val allGroup: List<String>
@get:Query("select min(customOrder) from rssSources")
val minOrder: Int

@ -10,10 +10,12 @@ import android.view.View
import android.view.ViewGroup
import androidx.appcompat.widget.Toolbar
import androidx.recyclerview.widget.LinearLayoutManager
import io.legado.app.App
import io.legado.app.R
import io.legado.app.base.BaseDialogFragment
import io.legado.app.base.adapter.ItemViewHolder
import io.legado.app.base.adapter.RecyclerAdapter
import io.legado.app.constant.AppPattern
import io.legado.app.constant.PreferKey
import io.legado.app.data.entities.RssSource
import io.legado.app.databinding.DialogEditTextBinding
@ -21,10 +23,8 @@ 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.utils.getViewModelOfActivity
import io.legado.app.utils.putPrefBoolean
import io.legado.app.utils.*
import io.legado.app.utils.viewbindingdelegate.viewBinding
import io.legado.app.utils.visible
import org.jetbrains.anko.sdk27.listeners.onClick
/**
@ -85,7 +85,14 @@ class ImportRssSourceDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListe
when (item.itemId) {
R.id.menu_new_group -> {
alert(R.string.diy_edit_source_group) {
val alertBinding = DialogEditTextBinding.inflate(layoutInflater)
val alertBinding = DialogEditTextBinding.inflate(layoutInflater).apply {
val groups = linkedSetOf<String>()
App.db.rssSourceDao.allGroup.forEach { group ->
groups.addAll(group.splitNotBlank(AppPattern.splitGroupRegex))
}
editView.setFilterValues(groups.toList())
editView.dropDownHeight = 180.dp
}
customView = alertBinding.root
okButton {
alertBinding.editView.text?.toString()?.let { group ->

Loading…
Cancel
Save