Merge pull request #379 from KKL369/master

push
pull/382/head
kunfei 4 years ago committed by GitHub
commit deb4ac414b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      app/src/main/java/io/legado/app/constant/EventBus.kt
  2. 3
      app/src/main/java/io/legado/app/help/AppConfig.kt
  3. 26
      app/src/main/java/io/legado/app/service/CheckSourceService.kt
  4. 6
      app/src/main/java/io/legado/app/ui/book/explore/ExploreShowAdapter.kt
  5. 19
      app/src/main/java/io/legado/app/ui/book/search/SearchAdapter.kt
  6. 31
      app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt
  7. 11
      app/src/main/java/io/legado/app/ui/main/explore/ExploreAdapter.kt
  8. 3
      app/src/main/res/values-zh-rHK/strings.xml
  9. 3
      app/src/main/res/values-zh-rTW/strings.xml
  10. 3
      app/src/main/res/values-zh/strings.xml
  11. 1
      app/src/main/res/values/pref_key_value.xml
  12. 3
      app/src/main/res/values/strings.xml
  13. 7
      app/src/main/res/xml/pref_config_other.xml

@ -20,4 +20,7 @@ object EventBus {
const val WEB_SERVICE_STOP = "webServiceStop"
const val UP_DOWNLOAD = "upDownload"
const val SAVE_CONTENT = "saveContent"
const val CHECK_INIT = "checkInit"
const val CHECK_UP_PROGRESS = "checkProgress"
const val CHECK_DONE = "checkDone"
}

@ -58,6 +58,9 @@ object AppConfig {
App.INSTANCE.putPrefBoolean(PreferKey.showRss, value)
}
val backgroundVerification: Boolean
get() = App.INSTANCE.getPrefBoolean(R.string.pk_background_verification)
val autoRefreshBook: Boolean
get() = App.INSTANCE.getPrefBoolean(R.string.pk_auto_refresh)

@ -6,12 +6,15 @@ import io.legado.app.App
import io.legado.app.R
import io.legado.app.base.BaseService
import io.legado.app.constant.AppConst
import io.legado.app.constant.EventBus
import io.legado.app.constant.IntentAction
import io.legado.app.help.AppConfig
import io.legado.app.help.AppConfig.backgroundVerification
import io.legado.app.help.IntentHelp
import io.legado.app.help.coroutine.CompositeCoroutine
import io.legado.app.service.help.CheckSource
import io.legado.app.ui.book.source.manage.BookSourceActivity
import io.legado.app.utils.postEvent
import kotlinx.coroutines.asCoroutineDispatcher
import org.jetbrains.anko.toast
import java.util.concurrent.Executors
@ -42,7 +45,9 @@ class CheckSourceService : BaseService() {
override fun onCreate() {
super.onCreate()
updateNotification(0, getString(R.string.start))
if (backgroundVerification) {
updateNotification(0, getString(R.string.start))
}
}
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
@ -59,6 +64,7 @@ class CheckSourceService : BaseService() {
super.onDestroy()
tasks.clear()
searchPool.close()
postEvent(EventBus.CHECK_DONE, 0)
}
private fun check(ids: List<String>) {
@ -72,7 +78,11 @@ class CheckSourceService : BaseService() {
allIds.addAll(ids)
processIndex = 0
threadCount = min(allIds.size, threadCount)
updateNotification(0, getString(R.string.progress_show, 0, allIds.size))
if (backgroundVerification) {
updateNotification(0, getString(R.string.progress_show, 0, allIds.size))
} else {
postEvent(EventBus.CHECK_INIT, allIds.size)
}
for (i in 0 until threadCount) {
check()
}
@ -106,10 +116,14 @@ class CheckSourceService : BaseService() {
synchronized(this) {
check()
checkedIds.add(sourceUrl)
updateNotification(
checkedIds.size,
getString(R.string.progress_show, checkedIds.size, allIds.size)
)
if (backgroundVerification) {
updateNotification(
checkedIds.size,
getString(R.string.progress_show, checkedIds.size, allIds.size)
)
} else {
postEvent(EventBus.CHECK_UP_PROGRESS, checkedIds.size)
}
if (processIndex >= allIds.size + threadCount - 1) {
stopSelf()
}

@ -26,7 +26,11 @@ class ExploreShowAdapter(context: Context, val callBack: CallBack) :
tv_lasted.text = context.getString(R.string.lasted_show, item.latestChapterTitle)
tv_lasted.visible()
}
tv_introduce.text = context.getString(R.string.intro_show, item.intro)
if (item.intro.isNullOrEmpty()) {
tv_introduce.text = context.getString(R.string.intro_show_null)
} else {
tv_introduce.text = context.getString(R.string.intro_show, item.intro)
}
val kinds = item.getKindList()
if (kinds.isEmpty()) {
ll_kind.gone()

@ -42,7 +42,13 @@ class SearchAdapter(context: Context, val callBack: CallBack) :
tv_author.text = context.getString(R.string.author_show, searchBook.author)
bv_originCount.setBadgeCount(searchBook.origins.size)
upLasted(itemView, searchBook.latestChapterTitle)
tv_introduce.text = context.getString(R.string.intro_show, searchBook.intro)
if (searchBook.intro.isNullOrEmpty()) {
tv_introduce.text =
context.getString(R.string.intro_show_null)
} else {
tv_introduce.text =
context.getString(R.string.intro_show, searchBook.intro)
}
upKind(itemView, searchBook.getKindList())
iv_cover.load(searchBook.coverUrl, searchBook.name, searchBook.author)
@ -58,8 +64,15 @@ class SearchAdapter(context: Context, val callBack: CallBack) :
context.getString(R.string.author_show, searchBook.author)
"origins" -> bv_originCount.setBadgeCount(searchBook.origins.size)
"last" -> upLasted(itemView, searchBook.latestChapterTitle)
"intro" -> tv_introduce.text =
context.getString(R.string.intro_show, searchBook.intro)
"intro" -> {
if (searchBook.intro.isNullOrEmpty()) {
tv_introduce.text =
context.getString(R.string.intro_show_null)
} else {
tv_introduce.text =
context.getString(R.string.intro_show, searchBook.intro)
}
}
"kind" -> upKind(itemView, searchBook.getKindList())
"cover" -> iv_cover.load(
searchBook.coverUrl,

@ -21,6 +21,7 @@ import io.legado.app.BuildConfig
import io.legado.app.R
import io.legado.app.base.VMBaseActivity
import io.legado.app.constant.AppPattern
import io.legado.app.constant.EventBus
import io.legado.app.data.entities.BookSource
import io.legado.app.help.IntentDataHelp
import io.legado.app.lib.dialogs.*
@ -65,6 +66,12 @@ class BookSourceActivity : VMBaseActivity<BookSourceViewModel>(R.layout.activity
private var sort = 0
private var sortAscending = 0
private val progressDialogBuilder by lazy {
progressDialog("校验书源") {
setCancelable(false)
}
}
override fun onActivityCreated(savedInstanceState: Bundle?) {
initRecyclerView()
initSearchView()
@ -263,6 +270,30 @@ class BookSourceActivity : VMBaseActivity<BookSourceViewModel>(R.layout.activity
}
override fun observeLiveBus() {
observeEvent<Int>(EventBus.CHECK_INIT) { max->
progressDialogBuilder.max = max
progressDialogBuilder.show()
}
observeEvent<Int>(EventBus.CHECK_UP_PROGRESS) { progress->
progressDialogBuilder.progress = progress
}
observeEvent<Int>(EventBus.CHECK_DONE) {
if (progressDialogBuilder.isShowing) {
progressDialogBuilder.progress = it
progressDialogBuilder.max = it
progressDialogBuilder.dismiss()
}
toast("校验完成!")
groups.map { group->
if (group.contains("失效")) {
search_view.setQuery("失效", true)
toast("发现有失效书源,已为您自动筛选!")
}
}
}
}
override fun onMenuItemClick(item: MenuItem?): Boolean {
when (item?.itemId) {
R.id.menu_enable_selection -> viewModel.enableSelection(adapter.getSelection())

@ -11,10 +11,7 @@ import io.legado.app.base.adapter.SimpleRecyclerAdapter
import io.legado.app.data.entities.BookSource
import io.legado.app.help.coroutine.Coroutine
import io.legado.app.lib.theme.accentColor
import io.legado.app.utils.ACache
import io.legado.app.utils.dp
import io.legado.app.utils.gone
import io.legado.app.utils.visible
import io.legado.app.utils.*
import kotlinx.android.synthetic.main.item_fillet_text.view.*
import kotlinx.android.synthetic.main.item_find_book.view.*
import kotlinx.coroutines.CoroutineScope
@ -55,12 +52,12 @@ class ExploreAdapter(context: Context, private val scope: CoroutineScope, val ca
.inflate(R.layout.item_fillet_text, gl_child, false)
gl_child.addView(tv)
tv.text_view.text = kind.title
tv.text_view.onClick {
kind.url?.let { kindUrl ->
if (!kind.url.isNullOrEmpty()) {
tv.text_view.onClick {
callBack.openExplore(
item.bookSourceUrl,
kind.title,
kindUrl
kind.url.toString()
)
}
}

@ -94,6 +94,8 @@
閲讀3.0下載地址:\nhttps://play.google.com/store/apps/details?id=io.legado.play.release
</string>
<string name="version_name">Version %s</string>
<string name="pt_background_verification">後臺校驗書源</string>
<string name="ps_background_verification">打開后可以在校驗書源時自由操作</string>
<string name="pt_auto_refresh">自動刷新</string>
<string name="ps_auto_refresh">打開程式時自動更新書輯</string>
<string name="pt_auto_download">自動下載最新章節</string>
@ -223,6 +225,7 @@
<string name="load_error_retry">載入失敗,點擊重試</string>
<string name="book_intro">內容簡介</string>
<string name="intro_show">簡介: %s</string>
<string name="intro_show_null">簡介: 暫無簡介</string>
<string name="open_from_other">打開外部書籍</string>
<string name="origin_show">來源: %s</string>
<string name="import_replace_rule">本地導入</string>

@ -94,6 +94,8 @@
閱讀3.0下載網址:\nhttps://play.google.com/store/apps/details?id=io.legado.play.release
</string>
<string name="version_name">Version %s</string>
<string name="pt_background_verification">後臺校驗書源</string>
<string name="ps_background_verification">打開后可以在校驗書源時自由操作</string>
<string name="pt_auto_refresh">自動重新整理</string>
<string name="ps_auto_refresh">打開軟體時自動更新書籍</string>
<string name="pt_auto_download">自動下載最新章節</string>
@ -223,6 +225,7 @@
<string name="load_error_retry">載入失敗,點擊重試</string>
<string name="book_intro">內容簡介</string>
<string name="intro_show">簡介:%s</string>
<string name="intro_show_null">簡介: 暫無簡介</string>
<string name="open_from_other">打開外部書籍</string>
<string name="origin_show">來源: %s</string>
<string name="import_replace_rule">本機匯入</string>

@ -96,6 +96,8 @@
阅读3.0下载地址:\nhttps://www.coolapk.com/apk/256030
</string>
<string name="version_name">Version %s</string>
<string name="pt_background_verification">后台校验书源</string>
<string name="ps_background_verification">打开后可以在校验书源时自由操作</string>
<string name="pt_auto_refresh">自动刷新</string>
<string name="ps_auto_refresh">打开软件时自动更新书籍</string>
<string name="pt_auto_download">自动下载最新章节</string>
@ -225,6 +227,7 @@
<string name="load_error_retry">加载失败,点击重试</string>
<string name="book_intro">内容简介</string>
<string name="intro_show">简介:%s</string>
<string name="intro_show_null">简介: 暂无简介</string>
<string name="open_from_other">打开外部书籍</string>
<string name="origin_show">来源: %s</string>
<string name="import_replace_rule">本地导入</string>

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="pk_background_verification" translatable="false">background_verification</string>
<string name="pk_auto_refresh" translatable="false">auto_refresh</string>
<string name="pk_requested_direction" translatable="false">list_screen_direction</string>
<string name="pk_full_screen" translatable="false">full_screen</string>

@ -96,6 +96,8 @@
Legado (YueDu 3.0) download link:\n https://play.google.com/store/apps/details?id=io.legado.play.release
</string>
<string name="version_name">Version %s</string>
<string name="pt_background_verification">Background-verification</string>
<string name="ps_background_verification">you can operate freely when verifying the book source</string>
<string name="pt_auto_refresh">Auto-refresh</string>
<string name="ps_auto_refresh">Update books automatically when opening the software</string>
<string name="pt_auto_download">Auto-download</string>
@ -225,6 +227,7 @@
<string name="load_error_retry">Load failed, tap to retry</string>
<string name="book_intro">Book description</string>
<string name="intro_show">Description:%s</string>
<string name="intro_show_null">Description: no introduction</string>
<string name="open_from_other">Open external book</string>
<string name="origin_show">Origin: %s</string>
<string name="import_replace_rule">Import local rules</string>

@ -51,6 +51,13 @@
app:iconSpaceReserved="false"
app:layout="@layout/view_preference_category">
<io.legado.app.ui.widget.prefs.SwitchPreference
android:defaultValue="false"
android:key="@string/pk_background_verification"
android:summary="@string/ps_background_verification"
android:title="@string/pt_background_verification"
app:iconSpaceReserved="false" />
<io.legado.app.ui.widget.prefs.SwitchPreference
android:defaultValue="true"
android:key="replaceEnableDefault"

Loading…
Cancel
Save