Merge remote-tracking branch 'upstream/master'

pull/1264/head
github-actions 3 years ago
commit 2855702279
  1. 3
      app/src/main/java/io/legado/app/data/dao/BookSourceDao.kt
  2. 4
      app/src/main/java/io/legado/app/ui/book/info/BookInfoActivity.kt
  3. 6
      app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt
  4. 46
      app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceAdapter.kt
  5. 9
      app/src/main/res/layout/item_book_source.xml
  6. 4
      app/src/main/res/menu/book_source.xml
  7. 4
      app/src/main/res/menu/book_source_item.xml
  8. 1
      app/src/main/res/values-es-rES/strings.xml
  9. 1
      app/src/main/res/values-ja-rJP/strings.xml
  10. 1
      app/src/main/res/values-pt-rBR/strings.xml
  11. 1
      app/src/main/res/values-zh-rHK/strings.xml
  12. 1
      app/src/main/res/values-zh-rTW/strings.xml
  13. 1
      app/src/main/res/values-zh/strings.xml
  14. 1
      app/src/main/res/values/strings.xml

@ -32,6 +32,9 @@ interface BookSourceDao {
@Query("select * from book_sources where enabledExplore = 1 and trim(exploreUrl) <> '' order by customOrder asc")
fun flowExplore(): Flow<List<BookSource>>
@Query("select * from book_sources where loginUrl is not null and loginUrl != ''")
fun flowLogin(): Flow<List<BookSource>>
@Query(
"""select * from book_sources
where enabledExplore = 1

@ -401,6 +401,10 @@ class BookInfoActivity :
viewModel.bookData.value?.group = groupId
if (viewModel.inBookshelf) {
viewModel.saveBook()
} else if (groupId > 0) {
viewModel.saveBook()
viewModel.inBookshelf = true
upTvBookshelf()
}
}

@ -166,6 +166,9 @@ class BookSourceActivity : VMBaseActivity<ActivityBookSourceBinding, BookSourceV
R.id.menu_disabled_group -> {
searchView.setQuery(getString(R.string.disabled), true)
}
R.id.menu_group_login -> {
searchView.setQuery(getString(R.string.need_login), true)
}
R.id.menu_help -> showHelp()
}
if (item.groupId == R.id.source_group) {
@ -211,6 +214,9 @@ class BookSourceActivity : VMBaseActivity<ActivityBookSourceBinding, BookSourceV
searchKey == getString(R.string.disabled) -> {
appDb.bookSourceDao.flowDisabled()
}
searchKey == getString(R.string.need_login) -> {
appDb.bookSourceDao.flowLogin()
}
searchKey.startsWith("group:") -> {
val key = searchKey.substringAfter("group:")
appDb.bookSourceDao.flowGroupSearch("%$key%")

@ -49,41 +49,9 @@ class BookSourceAdapter(context: Context, val callBack: CallBack) :
}
override fun areContentsTheSame(oldItem: BookSource, newItem: BookSource): Boolean {
if (oldItem.bookSourceName != newItem.bookSourceName)
return false
if (oldItem.bookSourceGroup != newItem.bookSourceGroup)
return false
if (oldItem.enabled != newItem.enabled)
return false
if (oldItem.enabledExplore != newItem.enabledExplore
|| oldItem.exploreUrl != newItem.exploreUrl
) {
return false
}
return true
return false
}
override fun getChangePayload(oldItem: BookSource, newItem: BookSource): Any? {
val payload = Bundle()
if (oldItem.bookSourceName != newItem.bookSourceName) {
payload.putString("name", newItem.bookSourceName)
}
if (oldItem.bookSourceGroup != newItem.bookSourceGroup) {
payload.putString("group", newItem.bookSourceGroup)
}
if (oldItem.enabled != newItem.enabled) {
payload.putBoolean("enabled", newItem.enabled)
}
if (oldItem.enabledExplore != newItem.enabledExplore
|| oldItem.exploreUrl != newItem.exploreUrl
) {
payload.putBoolean("showExplore", true)
}
if (payload.isEmpty) {
return null
}
return payload
}
}
override fun getViewBinding(parent: ViewGroup): ItemBookSourceBinding {
@ -109,17 +77,19 @@ class BookSourceAdapter(context: Context, val callBack: CallBack) :
swtEnabled.isChecked = item.enabled
cbBookSource.isChecked = selected.contains(item)
ivDebugText.text = Debug.debugMessageMap[item.bookSourceUrl] ?: ""
ivDebugText.visibility = if(ivDebugText.text.toString().length > 1) View.VISIBLE else View.GONE
ivDebugText.visibility =
if (ivDebugText.text.toString().length > 1) View.VISIBLE else View.GONE
upShowExplore(ivExplore, item)
} else {
payload.keySet().map {
when (it) {
"selected" -> cbBookSource.isChecked = selected.contains(item)
"selected" -> cbBookSource.isChecked = selected.contains(item)
"checkSourceMessage" -> {
ivDebugText.text = Debug.debugMessageMap[item.bookSourceUrl] ?: ""
val isEmpty = ivDebugText.text.toString().isEmpty()
var isFinalMessage = ivDebugText.text.toString().contains(Regex("成功|失败"))
if (!isEmpty && !Debug.isChecking && !isFinalMessage){
var isFinalMessage =
ivDebugText.text.toString().contains(Regex("成功|失败"))
if (!isEmpty && !Debug.isChecking && !isFinalMessage) {
Debug.updateFinalMessage(item.bookSourceUrl, "失败")
ivDebugText.text = Debug.debugMessageMap[item.bookSourceUrl] ?: ""
isFinalMessage = true
@ -190,6 +160,8 @@ class BookSourceAdapter(context: Context, val callBack: CallBack) :
qyMenu.setTitle(R.string.enable_explore)
}
}
val loginMenu = popupMenu.menu.findItem(R.id.menu_login)
loginMenu.isVisible = !source.loginUrl.isNullOrBlank()
popupMenu.setOnMenuItemClickListener { menuItem ->
when (menuItem.itemId) {
R.id.menu_top -> callBack.toTop(source)

@ -18,8 +18,8 @@
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toLeftOf="@id/swt_enabled"
app:layout_constraintTop_toTopOf="parent"
tools:text="@string/book_source"
tools:ignore="TouchTargetSizeCheck" />
tools:ignore="TouchTargetSizeCheck"
tools:text="@string/book_source" />
<io.legado.app.lib.theme.view.ATESwitch
android:id="@+id/swt_enabled"
@ -66,8 +66,8 @@
android:contentDescription="@string/more_menu"
android:scaleType="centerCrop"
android:src="@color/md_green_600"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
app:layout_constraintRight_toRightOf="@id/iv_menu_more"
app:layout_constraintTop_toTopOf="@id/iv_menu_more" />
<TextView
android:id="@+id/iv_debug_text"
@ -75,6 +75,7 @@
android:layout_height="wrap_content"
android:singleLine="true"
android:visibility="gone"
android:layout_marginTop="6dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toLeftOf="@id/iv_progressBar"

@ -70,6 +70,10 @@
android:id="@+id/menu_disabled_group"
android:title="@string/disabled" />
<item
android:id="@+id/menu_group_login"
android:title="@string/need_login" />
<group android:id="@+id/source_group">
</group>

@ -9,6 +9,10 @@
android:id="@+id/menu_bottom"
android:title="@string/to_bottom" />
<item
android:id="@+id/menu_login"
android:title="@string/login" />
<item
android:id="@+id/menu_debug_source"
android:title="@string/debug" />

@ -862,4 +862,5 @@
<string name="background_image_blurring">Background image blurring</string>
<string name="background_image_blurring_radius">Blurring radius</string>
<string name="background_image_hint">Disabled when 0, enable range from 1 to 25\nThe greater the radius, the stronger the effect of blurring</string>
<string name="need_login">需登录</string>
</resources>

@ -862,4 +862,5 @@
<string name="background_image_blurring">Background image blurring</string>
<string name="background_image_blurring_radius">Blurring radius</string>
<string name="background_image_hint">Disabled when 0, enable range from 1 to 25\nThe greater the radius, the stronger the effect of blurring</string>
<string name="need_login">需登录</string>
</resources>

@ -862,5 +862,6 @@
<string name="background_image_blurring">Background image blurring</string>
<string name="background_image_blurring_radius">Blurring radius</string>
<string name="background_image_hint">Disabled when 0, enable range from 1 to 25\nThe greater the radius, the stronger the effect of blurring</string>
<string name="need_login">需登录</string>
</resources>

@ -859,5 +859,6 @@
<string name="read_aloud_by_page_summary">及时翻页,翻页时会停顿一下</string>
<string name="check_source_show_debug_message">校驗書源顯示詳細信息</string>
<string name="check_source_show_debug_message_summary">書源校驗時顯示網絡請求步驟和時間</string>
<string name="need_login">需登录</string>
</resources>

@ -860,5 +860,6 @@
<string name="read_aloud_by_page_summary">及时翻页,翻页时会停顿一下</string>
<string name="check_source_show_debug_message">校驗書源顯示詳細信息</string>
<string name="check_source_show_debug_message_summary">書源校驗時顯示網絡請求步驟和時間</string>
<string name="need_login">需登录</string>
</resources>

@ -861,5 +861,6 @@
<string name="read_aloud_by_page_summary">及时翻页,翻页时会停顿一下</string>
<string name="check_source_show_debug_message">校验显示详细信息</string>
<string name="check_source_show_debug_message_summary">书源校验时显示网络请求步骤和时间</string>
<string name="need_login">需登录</string>
</resources>

@ -862,5 +862,6 @@
<string name="read_aloud_by_page_summary">及时翻页,翻页时会停顿一下</string>
<string name="check_source_show_debug_message">Check book source shows debug message</string>
<string name="check_source_show_debug_message_summary">Show network status and timestamp during source checking</string>
<string name="need_login">需登录</string>
</resources>

Loading…
Cancel
Save