diff --git a/app/src/main/java/io/legado/app/data/dao/BookSourceDao.kt b/app/src/main/java/io/legado/app/data/dao/BookSourceDao.kt index 99677054c..4790cb5c3 100644 --- a/app/src/main/java/io/legado/app/data/dao/BookSourceDao.kt +++ b/app/src/main/java/io/legado/app/data/dao/BookSourceDao.kt @@ -32,6 +32,9 @@ interface BookSourceDao { @Query("select * from book_sources where enabledExplore = 1 and trim(exploreUrl) <> '' order by customOrder asc") fun flowExplore(): Flow> + @Query("select * from book_sources where loginUrl is not null and loginUrl != ''") + fun flowLogin(): Flow> + @Query( """select * from book_sources where enabledExplore = 1 diff --git a/app/src/main/java/io/legado/app/ui/book/info/BookInfoActivity.kt b/app/src/main/java/io/legado/app/ui/book/info/BookInfoActivity.kt index 830d7a73b..2c3c739ab 100644 --- a/app/src/main/java/io/legado/app/ui/book/info/BookInfoActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/info/BookInfoActivity.kt @@ -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() } } diff --git a/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt b/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt index 7d6b9b4d4..a1e341df4 100644 --- a/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt @@ -166,6 +166,9 @@ class BookSourceActivity : VMBaseActivity { 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 { appDb.bookSourceDao.flowDisabled() } + searchKey == getString(R.string.need_login) -> { + appDb.bookSourceDao.flowLogin() + } searchKey.startsWith("group:") -> { val key = searchKey.substringAfter("group:") appDb.bookSourceDao.flowGroupSearch("%$key%") diff --git a/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceAdapter.kt b/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceAdapter.kt index 6b5b8e845..d2a7d1237 100644 --- a/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceAdapter.kt +++ b/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceAdapter.kt @@ -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) diff --git a/app/src/main/res/layout/item_book_source.xml b/app/src/main/res/layout/item_book_source.xml index 4c8aa3535..5108b4085 100644 --- a/app/src/main/res/layout/item_book_source.xml +++ b/app/src/main/res/layout/item_book_source.xml @@ -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" /> + app:layout_constraintRight_toRightOf="@id/iv_menu_more" + app:layout_constraintTop_toTopOf="@id/iv_menu_more" /> + + diff --git a/app/src/main/res/menu/book_source_item.xml b/app/src/main/res/menu/book_source_item.xml index bd9a0de7c..acc6a6ed8 100644 --- a/app/src/main/res/menu/book_source_item.xml +++ b/app/src/main/res/menu/book_source_item.xml @@ -9,6 +9,10 @@ android:id="@+id/menu_bottom" android:title="@string/to_bottom" /> + + diff --git a/app/src/main/res/values-es-rES/strings.xml b/app/src/main/res/values-es-rES/strings.xml index 0ae9b394c..01fd289cc 100644 --- a/app/src/main/res/values-es-rES/strings.xml +++ b/app/src/main/res/values-es-rES/strings.xml @@ -862,4 +862,5 @@ Background image blurring Blurring radius Disabled when 0, enable range from 1 to 25\nThe greater the radius, the stronger the effect of blurring + 需登录 diff --git a/app/src/main/res/values-ja-rJP/strings.xml b/app/src/main/res/values-ja-rJP/strings.xml index 7d47e7f10..f36623a15 100644 --- a/app/src/main/res/values-ja-rJP/strings.xml +++ b/app/src/main/res/values-ja-rJP/strings.xml @@ -862,4 +862,5 @@ Background image blurring Blurring radius Disabled when 0, enable range from 1 to 25\nThe greater the radius, the stronger the effect of blurring + 需登录 diff --git a/app/src/main/res/values-pt-rBR/strings.xml b/app/src/main/res/values-pt-rBR/strings.xml index bd9e2e975..6ea55fcb5 100644 --- a/app/src/main/res/values-pt-rBR/strings.xml +++ b/app/src/main/res/values-pt-rBR/strings.xml @@ -862,5 +862,6 @@ Background image blurring Blurring radius Disabled when 0, enable range from 1 to 25\nThe greater the radius, the stronger the effect of blurring + 需登录 diff --git a/app/src/main/res/values-zh-rHK/strings.xml b/app/src/main/res/values-zh-rHK/strings.xml index 3c55e5ddb..1f30ea160 100644 --- a/app/src/main/res/values-zh-rHK/strings.xml +++ b/app/src/main/res/values-zh-rHK/strings.xml @@ -859,5 +859,6 @@ 及时翻页,翻页时会停顿一下 校驗書源顯示詳細信息 書源校驗時顯示網絡請求步驟和時間 + 需登录 diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml index fb9a8884c..620190c0e 100644 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -860,5 +860,6 @@ 及时翻页,翻页时会停顿一下 校驗書源顯示詳細信息 書源校驗時顯示網絡請求步驟和時間 + 需登录 diff --git a/app/src/main/res/values-zh/strings.xml b/app/src/main/res/values-zh/strings.xml index e73cbfa95..611ae4930 100644 --- a/app/src/main/res/values-zh/strings.xml +++ b/app/src/main/res/values-zh/strings.xml @@ -861,5 +861,6 @@ 及时翻页,翻页时会停顿一下 校验显示详细信息 书源校验时显示网络请求步骤和时间 + 需登录 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index b4e919323..ec41c8165 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -862,5 +862,6 @@ 及时翻页,翻页时会停顿一下 Check book source shows debug message Show network status and timestamp during source checking + 需登录