feat: 优化

pull/219/head
kunfei 5 years ago
parent 8e486e77f6
commit 086ccc4c40
  1. 4
      app/src/debug/res/values/strings.xml
  2. 5
      app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt
  3. 2
      app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceAdapter.kt
  4. 10
      app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceViewModel.kt
  5. 5
      app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceActivity.kt
  6. 2
      app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceAdapter.kt
  7. 10
      app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceViewModel.kt
  8. 4
      app/src/main/res/menu/book_source_item.xml
  9. 5
      app/src/main/res/menu/book_source_sel.xml
  10. 4
      app/src/main/res/menu/rss_source_item.xml
  11. 5
      app/src/main/res/menu/rss_source_sel.xml
  12. 1
      app/src/main/res/values-zh-rHK/strings.xml
  13. 40
      app/src/main/res/values/pref_key_value.xml
  14. 1
      app/src/main/res/values/strings.xml

@ -1,4 +1,4 @@
<resources> <resources>
<string name="app_name">阅读·D</string> <string name="app_name" translatable="false">阅读·D</string>
<string name="receiving_shared_label">阅读·D·搜索</string> <string name="receiving_shared_label" translatable="false">阅读·D·搜索</string>
</resources> </resources>

@ -204,6 +204,7 @@ class BookSourceActivity : VMBaseActivity<BookSourceViewModel>(R.layout.activity
R.id.menu_export_selection -> FilePicker.selectFolder(this, exportRequestCode) R.id.menu_export_selection -> FilePicker.selectFolder(this, exportRequestCode)
R.id.menu_check_source -> CheckSource.start(this, adapter.getSelection()) R.id.menu_check_source -> CheckSource.start(this, adapter.getSelection())
R.id.menu_top_sel -> viewModel.topSource(*adapter.getSelection().toTypedArray()) R.id.menu_top_sel -> viewModel.topSource(*adapter.getSelection().toTypedArray())
R.id.menu_bottom_sel -> viewModel.bottomSource(*adapter.getSelection().toTypedArray())
} }
return true return true
} }
@ -287,6 +288,10 @@ class BookSourceActivity : VMBaseActivity<BookSourceViewModel>(R.layout.activity
viewModel.topSource(bookSource) viewModel.topSource(bookSource)
} }
override fun toBottom(bookSource: BookSource) {
viewModel.bottomSource(bookSource)
}
override fun onFilePicked(requestCode: Int, currentPath: String) { override fun onFilePicked(requestCode: Int, currentPath: String) {
when (requestCode) { when (requestCode) {
exportRequestCode -> viewModel.exportSelection( exportRequestCode -> viewModel.exportSelection(

@ -138,6 +138,7 @@ class BookSourceAdapter(context: Context, val callBack: CallBack) :
popupMenu.setOnMenuItemClickListener { menuItem -> popupMenu.setOnMenuItemClickListener { menuItem ->
when (menuItem.itemId) { when (menuItem.itemId) {
R.id.menu_top -> callBack.toTop(source) R.id.menu_top -> callBack.toTop(source)
R.id.menu_bottom -> callBack.toBottom(source)
R.id.menu_del -> callBack.del(source) R.id.menu_del -> callBack.del(source)
R.id.menu_enable_explore -> { R.id.menu_enable_explore -> {
callBack.update(source.copy(enabledExplore = !source.enabledExplore)) callBack.update(source.copy(enabledExplore = !source.enabledExplore))
@ -197,6 +198,7 @@ class BookSourceAdapter(context: Context, val callBack: CallBack) :
fun edit(bookSource: BookSource) fun edit(bookSource: BookSource)
fun update(vararg bookSource: BookSource) fun update(vararg bookSource: BookSource)
fun toTop(bookSource: BookSource) fun toTop(bookSource: BookSource)
fun toBottom(bookSource: BookSource)
fun upOrder() fun upOrder()
fun upCountView() fun upCountView()
} }

@ -29,6 +29,16 @@ class BookSourceViewModel(application: Application) : BaseViewModel(application)
} }
} }
fun bottomSource(vararg sources: BookSource) {
execute {
val maxOrder = App.db.bookSourceDao().minOrder + 1
sources.forEachIndexed { index, bookSource ->
bookSource.customOrder = maxOrder + index
}
App.db.bookSourceDao().update(*sources)
}
}
fun del(bookSource: BookSource) { fun del(bookSource: BookSource) {
execute { App.db.bookSourceDao().delete(bookSource) } execute { App.db.bookSourceDao().delete(bookSource) }
} }

@ -107,6 +107,7 @@ class RssSourceActivity : VMBaseActivity<RssSourceViewModel>(R.layout.activity_r
R.id.menu_del_selection -> viewModel.delSelection(adapter.getSelection()) R.id.menu_del_selection -> viewModel.delSelection(adapter.getSelection())
R.id.menu_export_selection -> FilePicker.selectFolder(this, exportRequestCode) R.id.menu_export_selection -> FilePicker.selectFolder(this, exportRequestCode)
R.id.menu_top_sel -> viewModel.topSource(*adapter.getSelection().toTypedArray()) R.id.menu_top_sel -> viewModel.topSource(*adapter.getSelection().toTypedArray())
R.id.menu_bottom_sel -> viewModel.bottomSource(*adapter.getSelection().toTypedArray())
} }
return true return true
} }
@ -338,6 +339,10 @@ class RssSourceActivity : VMBaseActivity<RssSourceViewModel>(R.layout.activity_r
viewModel.topSource(source) viewModel.topSource(source)
} }
override fun toBottom(source: RssSource) {
viewModel.bottomSource(source)
}
override fun upOrder() { override fun upOrder() {
viewModel.upOrder() viewModel.upOrder()
} }

@ -111,6 +111,7 @@ class RssSourceAdapter(context: Context, val callBack: CallBack) :
popupMenu.setOnMenuItemClickListener { menuItem -> popupMenu.setOnMenuItemClickListener { menuItem ->
when (menuItem.itemId) { when (menuItem.itemId) {
R.id.menu_top -> callBack.toTop(source) R.id.menu_top -> callBack.toTop(source)
R.id.menu_bottom -> callBack.toBottom(source)
R.id.menu_del -> callBack.del(source) R.id.menu_del -> callBack.del(source)
} }
true true
@ -151,6 +152,7 @@ class RssSourceAdapter(context: Context, val callBack: CallBack) :
fun edit(source: RssSource) fun edit(source: RssSource)
fun update(vararg source: RssSource) fun update(vararg source: RssSource)
fun toTop(source: RssSource) fun toTop(source: RssSource)
fun toBottom(source: RssSource)
fun upOrder() fun upOrder()
fun upCountView() fun upCountView()
} }

@ -27,6 +27,16 @@ class RssSourceViewModel(application: Application) : BaseViewModel(application)
} }
} }
fun bottomSource(vararg sources: RssSource) {
execute {
val maxOrder = App.db.rssSourceDao().maxOrder + 1
sources.forEachIndexed { index, rssSource ->
rssSource.customOrder = maxOrder + index
}
App.db.rssSourceDao().update(*sources)
}
}
fun del(rssSource: RssSource) { fun del(rssSource: RssSource) {
execute { App.db.rssSourceDao().delete(rssSource) } execute { App.db.rssSourceDao().delete(rssSource) }
} }

@ -5,6 +5,10 @@
android:id="@+id/menu_top" android:id="@+id/menu_top"
android:title="@string/to_top" /> android:title="@string/to_top" />
<item
android:id="@+id/menu_bottom"
android:title="@string/to_bottom" />
<item <item
android:id="@+id/menu_del" android:id="@+id/menu_del"
android:title="@string/delete" /> android:title="@string/delete" />

@ -27,6 +27,11 @@
android:title="@string/to_top" android:title="@string/to_top"
app:showAsAction="never" /> app:showAsAction="never" />
<item
android:id="@+id/menu_bottom_sel"
android:title="@string/to_bottom"
app:showAsAction="never" />
<item <item
android:id="@+id/menu_export_selection" android:id="@+id/menu_export_selection"
android:title="@string/export_selection" android:title="@string/export_selection"

@ -5,6 +5,10 @@
android:id="@+id/menu_top" android:id="@+id/menu_top"
android:title="@string/to_top" /> android:title="@string/to_top" />
<item
android:id="@+id/menu_bottom"
android:title="@string/to_bottom" />
<item <item
android:id="@+id/menu_del" android:id="@+id/menu_del"
android:title="@string/delete" /> android:title="@string/delete" />

@ -17,6 +17,11 @@
android:title="@string/to_top" android:title="@string/to_top"
app:showAsAction="never" /> app:showAsAction="never" />
<item
android:id="@+id/menu_bottom_sel"
android:title="@string/to_bottom"
app:showAsAction="never" />
<item <item
android:id="@+id/menu_export_selection" android:id="@+id/menu_export_selection"
android:title="@string/export_selection" android:title="@string/export_selection"

@ -689,4 +689,5 @@
<string name="hideHeader">隱藏頁眉</string> <string name="hideHeader">隱藏頁眉</string>
<string name="hideFooter">隱藏頁脚</string> <string name="hideFooter">隱藏頁脚</string>
<string name="auto_change_source">自動換源</string> <string name="auto_change_source">自動換源</string>
<string name="to_bottom">置底</string>
</resources> </resources>

@ -1,23 +1,23 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources xmlns:tools="http://schemas.android.com/tools"> <resources>
<string name="pk_auto_refresh" tools:ignore="MissingTranslation">auto_refresh</string> <string name="pk_auto_refresh" translatable="false">auto_refresh</string>
<string name="pk_requested_direction" tools:ignore="MissingTranslation">list_screen_direction</string> <string name="pk_requested_direction" translatable="false">list_screen_direction</string>
<string name="pk_full_screen" tools:ignore="MissingTranslation">full_screen</string> <string name="pk_full_screen" translatable="false">full_screen</string>
<string name="pk_threads_num" tools:ignore="MissingTranslation">threads_num</string> <string name="pk_threads_num" translatable="false">threads_num</string>
<string name="pk_user_agent" tools:ignore="MissingTranslation">user_agent</string> <string name="pk_user_agent" translatable="false">user_agent</string>
<string name="pk_bookshelf_px" tools:ignore="MissingTranslation">bookshelf_px</string> <string name="pk_bookshelf_px" translatable="false">bookshelf_px</string>
<string name="pk_read_type" tools:ignore="MissingTranslation">read_type</string> <string name="pk_read_type" translatable="false">read_type</string>
<string name="pk_find_expand_group" tools:ignore="MissingTranslation">expandGroupFind</string> <string name="pk_find_expand_group" translatable="false">expandGroupFind</string>
<string name="pk_default_read" tools:ignore="MissingTranslation">defaultToRead</string> <string name="pk_default_read" translatable="false">defaultToRead</string>
<string name="pk_auto_download" tools:ignore="MissingTranslation">autoDownload</string> <string name="pk_auto_download" translatable="false">autoDownload</string>
<string name="pk_check_update" tools:ignore="MissingTranslation">checkUpdate</string> <string name="pk_check_update" translatable="false">checkUpdate</string>
<string name="legado_gzh" tools:ignore="MissingTranslation">开源阅读</string> <string name="legado_gzh" translatable="false">开源阅读</string>
<string name="source_rule_url" tools:ignore="MissingTranslation">https://gitee.com/alanskycn/yuedu/blob/master/Rule/README.md</string> <string name="source_rule_url" translatable="false">https://gitee.com/alanskycn/yuedu/blob/master/Rule/README.md</string>
<string name="this_github_url" tools:ignore="MissingTranslation">https://github.com/gedoor/legado</string> <string name="this_github_url" translatable="false">https://github.com/gedoor/legado</string>
<string name="contributors_url" tools:ignore="MissingTranslation">https://github.com/gedoor/legado/graphs/contributors</string> <string name="contributors_url" translatable="false">https://github.com/gedoor/legado/graphs/contributors</string>
<string name="disclaimer_url" tools:ignore="MissingTranslation">https://gedoor.github.io/MyBookshelf/disclaimer.html</string> <string name="disclaimer_url" translatable="false">https://gedoor.github.io/MyBookshelf/disclaimer.html</string>
<string name="home_page_url" tools:ignore="MissingTranslation">https://gedoor.github.io/MyBookshelf/</string> <string name="home_page_url" translatable="false">https://gedoor.github.io/MyBookshelf/</string>
<string name="latest_release_url" tools:ignore="MissingTranslation">https://github.com/gedoor/legado/releases/latest</string> <string name="latest_release_url" translatable="false">https://github.com/gedoor/legado/releases/latest</string>
<string name="latest_release_api" tools:ignore="MissingTranslation">https://api.github.com/repos/gedoor/legado/releases/latest</string> <string name="latest_release_api" translatable="false">https://api.github.com/repos/gedoor/legado/releases/latest</string>
</resources> </resources>

@ -308,6 +308,7 @@
<string name="line_size">行距</string> <string name="line_size">行距</string>
<string name="paragraph_size">段距</string> <string name="paragraph_size">段距</string>
<string name="to_top">置顶</string> <string name="to_top">置顶</string>
<string name="to_bottom">置底</string>
<string name="auto_expand_find">自动展开发现</string> <string name="auto_expand_find">自动展开发现</string>
<string name="default_expand_first">默认展开第一组发现</string> <string name="default_expand_first">默认展开第一组发现</string>
<string name="threads_num">当前线程数 %s</string> <string name="threads_num">当前线程数 %s</string>

Loading…
Cancel
Save