pull/1352/head
gedoor 3 years ago
parent 714dd7bd03
commit e9e55dfa1a
  1. 14
      app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceAdapter.kt
  2. 20
      app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceDialog.kt
  3. 2
      app/src/main/java/io/legado/app/ui/book/info/BookInfoActivity.kt
  4. 6
      app/src/main/java/io/legado/app/ui/book/source/edit/BookSourceEditViewModel.kt
  5. 2
      app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt
  6. 2
      app/src/main/java/io/legado/app/ui/main/explore/ExploreFragment.kt
  7. 12
      app/src/main/res/menu/change_source_item.xml
  8. 2
      app/src/main/res/values-es-rES/strings.xml
  9. 2
      app/src/main/res/values-ja-rJP/strings.xml
  10. 2
      app/src/main/res/values-pt-rBR/strings.xml
  11. 2
      app/src/main/res/values-zh-rHK/strings.xml
  12. 2
      app/src/main/res/values-zh-rTW/strings.xml
  13. 2
      app/src/main/res/values-zh/strings.xml
  14. 2
      app/src/main/res/values/strings.xml

@ -90,16 +90,19 @@ class ChangeSourceAdapter(
popupMenu.inflate(R.menu.change_source_item)
popupMenu.setOnMenuItemClickListener {
when (it.itemId) {
R.id.menu_disable_book_source -> {
callBack.disableSource(searchBook)
}
R.id.menu_top_source -> {
callBack.topSource(searchBook)
}
R.id.menu_bottom_source -> {
callBack.bottomSource(searchBook)
}
R.id.menu_delete_book_source -> {
R.id.menu_edit_source -> {
callBack.editSource(searchBook)
}
R.id.menu_disable_source -> {
callBack.disableSource(searchBook)
}
R.id.menu_delete_source -> {
callBack.deleteSource(searchBook)
updateItems(0, itemCount, listOf<Int>())
}
@ -112,9 +115,10 @@ class ChangeSourceAdapter(
interface CallBack {
val bookUrl: String?
fun changeTo(searchBook: SearchBook)
fun disableSource(searchBook: SearchBook)
fun topSource(searchBook: SearchBook)
fun bottomSource(searchBook: SearchBook)
fun editSource(searchBook: SearchBook)
fun disableSource(searchBook: SearchBook)
fun deleteSource(searchBook: SearchBook)
}
}

@ -20,6 +20,7 @@ import io.legado.app.data.entities.SearchBook
import io.legado.app.databinding.DialogChangeSourceBinding
import io.legado.app.help.AppConfig
import io.legado.app.lib.theme.primaryColor
import io.legado.app.ui.book.source.edit.BookSourceEditActivity
import io.legado.app.ui.book.source.manage.BookSourceActivity
import io.legado.app.ui.widget.recycler.VerticalDivider
import io.legado.app.utils.*
@ -44,6 +45,11 @@ class ChangeSourceDialog() : BaseDialogFragment(),
private var callBack: CallBack? = null
private val viewModel: ChangeSourceViewModel by viewModels()
private val adapter by lazy { ChangeSourceAdapter(requireContext(), viewModel, this) }
private val editSourceResult =
registerForActivityResult(StartActivityForResult(BookSourceEditActivity::class.java)) {
}
override fun onStart() {
super.onStart()
@ -198,10 +204,6 @@ class ChangeSourceDialog() : BaseDialogFragment(),
override val bookUrl: String?
get() = callBack?.oldBook?.bookUrl
override fun disableSource(searchBook: SearchBook) {
viewModel.disableSource(searchBook)
}
override fun topSource(searchBook: SearchBook) {
viewModel.topSource(searchBook)
}
@ -210,6 +212,16 @@ class ChangeSourceDialog() : BaseDialogFragment(),
viewModel.bottomSource(searchBook)
}
override fun editSource(searchBook: SearchBook) {
editSourceResult.launch {
putExtra("sourceUrl", searchBook.origin)
}
}
override fun disableSource(searchBook: SearchBook) {
viewModel.disableSource(searchBook)
}
override fun deleteSource(searchBook: SearchBook) {
viewModel.del(searchBook)
if (bookUrl == searchBook.bookUrl) {

@ -277,7 +277,7 @@ class BookInfoActivity :
tvOrigin.setOnClickListener {
viewModel.bookData.value?.let {
startActivity<BookSourceEditActivity> {
putExtra("data", it.origin)
putExtra("sourceUrl", it.origin)
}
}
}

@ -19,10 +19,10 @@ class BookSourceEditViewModel(application: Application) : BaseViewModel(applicat
fun initData(intent: Intent, onFinally: () -> Unit) {
execute {
val key = intent.getStringExtra("data")
val sourceUrl = intent.getStringExtra("sourceUrl")
var source: BookSource? = null
if (key != null) {
source = appDb.bookSourceDao.getBookSource(key)
if (sourceUrl != null) {
source = appDb.bookSourceDao.getBookSource(sourceUrl)
}
source?.let {
oldSourceUrl = it.bookSourceUrl

@ -527,7 +527,7 @@ class BookSourceActivity : VMBaseActivity<ActivityBookSourceBinding, BookSourceV
override fun edit(bookSource: BookSource) {
startActivity<BookSourceEditActivity> {
putExtra("data", bookSource.bookSourceUrl)
putExtra("sourceUrl", bookSource.bookSourceUrl)
}
}

@ -173,7 +173,7 @@ class ExploreFragment : VMBaseFragment<ExploreViewModel>(R.layout.fragment_explo
override fun editSource(sourceUrl: String) {
startActivity<BookSourceEditActivity> {
putExtra("data", sourceUrl)
putExtra("sourceUrl", sourceUrl)
}
}

@ -10,11 +10,15 @@
android:title="@string/to_bottom" />
<item
android:id="@+id/menu_disable_book_source"
android:title="@string/disable_book_source" />
android:id="@+id/menu_edit_source"
android:title="@string/edit_source" />
<item
android:id="@+id/menu_delete_book_source"
android:title="@string/delete" />
android:id="@+id/menu_disable_source"
android:title="@string/disable_source" />
<item
android:id="@+id/menu_delete_source"
android:title="@string/delete_source" />
</menu>

@ -887,5 +887,7 @@
<string name="download_error">下载失败</string>
<string name="downloading">下载中</string>
<string name="unknown_state">未知状态</string>
<string name="disable_source">禁用源</string>
<string name="delete_source">删除源</string>
</resources>

@ -891,5 +891,7 @@
<string name="download_error">下载失败</string>
<string name="downloading">下载中</string>
<string name="unknown_state">未知状态</string>
<string name="disable_source">禁用源</string>
<string name="delete_source">删除源</string>
</resources>

@ -891,5 +891,7 @@
<string name="download_error">下载失败</string>
<string name="downloading">下载中</string>
<string name="unknown_state">未知状态</string>
<string name="disable_source">禁用源</string>
<string name="delete_source">删除源</string>
</resources>

@ -888,5 +888,7 @@
<string name="download_error">下载失败</string>
<string name="downloading">下载中</string>
<string name="unknown_state">未知状态</string>
<string name="disable_source">禁用源</string>
<string name="delete_source">删除源</string>
</resources>

@ -890,5 +890,7 @@
<string name="download_error">下载失败</string>
<string name="downloading">下载中</string>
<string name="unknown_state">未知状态</string>
<string name="disable_source">禁用源</string>
<string name="delete_source">删除源</string>
</resources>

@ -890,5 +890,7 @@
<string name="download_error">下载失败</string>
<string name="downloading">下载中</string>
<string name="unknown_state">未知状态</string>
<string name="disable_source">禁用源</string>
<string name="delete_source">删除源</string>
</resources>

@ -891,5 +891,7 @@
<string name="download_error">下载失败</string>
<string name="downloading">下载中</string>
<string name="unknown_state">未知状态</string>
<string name="disable_source">禁用源</string>
<string name="delete_source">删除源</string>
</resources>

Loading…
Cancel
Save