Skip to content

Commit

Permalink
优化
Browse files Browse the repository at this point in the history
821938089 committed Sep 15, 2023
1 parent 464d99c commit e7df618
Showing 14 changed files with 33 additions and 4 deletions.
1 change: 1 addition & 0 deletions app/src/main/java/io/legado/app/constant/PreferKey.kt
Original file line number Diff line number Diff line change
@@ -137,6 +137,7 @@ object PreferKey {
const val batchChangeSourceDelay = "batchChangeSourceDelay"
const val openBookInfoByClickTitle = "openBookInfoByClickTitle"
const val defaultHomePage = "defaultHomePage"
const val showBookshelfFastScroller = "showBookshelfFastScroller"

const val cPrimary = "colorPrimary"
const val cAccent = "colorAccent"
6 changes: 6 additions & 0 deletions app/src/main/java/io/legado/app/help/config/AppConfig.kt
Original file line number Diff line number Diff line change
@@ -403,6 +403,12 @@ object AppConfig : SharedPreferences.OnSharedPreferenceChangeListener {
appCtx.putPrefBoolean(PreferKey.openBookInfoByClickTitle, value)
}

var showBookshelfFastScroller: Boolean
get() = appCtx.getPrefBoolean(PreferKey.showBookshelfFastScroller, false)
set(value) {
appCtx.putPrefBoolean(PreferKey.showBookshelfFastScroller, value)
}

var contentSelectSpeakMod: Int
get() = appCtx.getPrefInt(PreferKey.contentSelectSpeakMod)
set(value) {
Original file line number Diff line number Diff line change
@@ -168,6 +168,10 @@ abstract class BaseBookshelfFragment(layoutId: Int) : VMBaseFragment<BookshelfVi
AppConfig.showWaitUpCount = swShowWaitUpBooks.isChecked
activityViewModel.postUpBooksLiveData(true)
}
if (AppConfig.showBookshelfFastScroller != swShowBookshelfFastScroller.isChecked) {
AppConfig.showBookshelfFastScroller = swShowBookshelfFastScroller.isChecked
postEvent(EventBus.BOOKSHELF_REFRESH, "")
}
if (bookshelfSort != rgSort.getCheckedIndex()) {
AppConfig.bookshelfSort = rgSort.getCheckedIndex()
upSort()
Original file line number Diff line number Diff line change
@@ -86,6 +86,7 @@ class BooksFragment() : BaseFragment(R.layout.fragment_books),

private fun initRecyclerView() {
binding.rvBookshelf.setEdgeEffectColor(primaryColor)
binding.rvBookshelf.setFastScrollEnabled(AppConfig.showBookshelfFastScroller)
binding.refreshLayout.setColorSchemeColors(accentColor)
binding.refreshLayout.setOnRefreshListener {
binding.refreshLayout.isRefreshing = false
@@ -275,6 +276,7 @@ class BooksFragment() : BaseFragment(R.layout.fragment_books),
observeEvent<String>(EventBus.BOOKSHELF_REFRESH) {
booksAdapter.notifyDataSetChanged()
startLastUpdateTimeJob()
binding.rvBookshelf.setFastScrollEnabled(AppConfig.showBookshelfFastScroller)
}
}
}
}
13 changes: 11 additions & 2 deletions app/src/main/res/layout/dialog_bookshelf_config.xml
Original file line number Diff line number Diff line change
@@ -58,13 +58,22 @@
app:layout_constraintTop_toBottomOf="@+id/sw_show_last_update_time"
tools:ignore="TouchTargetSizeCheck" />

<io.legado.app.lib.theme.view.ThemeSwitch
android:id="@+id/sw_show_bookshelf_fast_scroller"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="6dp"
android:text="@string/show_bookshelf_fast_scroller"
app:layout_constraintTop_toBottomOf="@+id/sw_show_wait_up_books"
tools:ignore="TouchTargetSizeCheck" />

<LinearLayout
android:id="@+id/ll_layout"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintRight_toLeftOf="@+id/ll_sort"
app:layout_constraintTop_toBottomOf="@+id/sw_show_wait_up_books"
app:layout_constraintTop_toBottomOf="@+id/sw_show_bookshelf_fast_scroller"
app:layout_constraintLeft_toLeftOf="parent">

<io.legado.app.ui.widget.text.AccentTextView
@@ -119,7 +128,7 @@
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintLeft_toRightOf="@+id/ll_layout"
app:layout_constraintTop_toBottomOf="@id/sw_show_wait_up_books"
app:layout_constraintTop_toBottomOf="@id/sw_show_bookshelf_fast_scroller"
app:layout_constraintRight_toRightOf="parent">

<io.legado.app.ui.widget.text.AccentTextView
1 change: 0 additions & 1 deletion app/src/main/res/layout/fragment_books.xml
Original file line number Diff line number Diff line change
@@ -13,7 +13,6 @@
android:id="@+id/rv_bookshelf"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="none"
tools:listitem="@layout/item_bookshelf_list" />

</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
1 change: 1 addition & 0 deletions app/src/main/res/values-es-rES/strings.xml
Original file line number Diff line number Diff line change
@@ -1131,4 +1131,5 @@
<string name="default_home_page">默认主页</string>
<string name="use_lib_archive">Use LibArchive</string>
<string name="pref_use_lib_archive_summary">Using libarchive to extract files, it supports extracting RAR5.</string>
<string name="show_bookshelf_fast_scroller">显示快速滚动条</string>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values-ja-rJP/strings.xml
Original file line number Diff line number Diff line change
@@ -1134,4 +1134,5 @@
<string name="default_home_page">默认主页</string>
<string name="use_lib_archive">Use LibArchive</string>
<string name="pref_use_lib_archive_summary">Using libarchive to extract files, it supports extracting RAR5.</string>
<string name="show_bookshelf_fast_scroller">显示快速滚动条</string>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values-pt-rBR/strings.xml
Original file line number Diff line number Diff line change
@@ -1134,4 +1134,5 @@
<string name="default_home_page">默认主页</string>
<string name="use_lib_archive">Use LibArchive</string>
<string name="pref_use_lib_archive_summary">Using libarchive to extract files, it supports extracting RAR5.</string>
<string name="show_bookshelf_fast_scroller">显示快速滚动条</string>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values-vi/strings.xml
Original file line number Diff line number Diff line change
@@ -1129,4 +1129,5 @@ Còn </string>
<string name="export_wait">等待导出</string>
<string name="use_lib_archive">Use LibArchive</string>
<string name="pref_use_lib_archive_summary">Using libarchive to extract files, it supports extracting RAR5.</string>
<string name="show_bookshelf_fast_scroller">显示快速滚动条</string>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values-zh-rHK/strings.xml
Original file line number Diff line number Diff line change
@@ -1130,4 +1130,5 @@
<string name="export_wait">等待导出</string>
<string name="use_lib_archive">使用LibArchive</string>
<string name="pref_use_lib_archive_summary">使用libarchive解壓檔案,支持解壓RAR5。</string>
<string name="show_bookshelf_fast_scroller">显示快速滚动条</string>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values-zh-rTW/strings.xml
Original file line number Diff line number Diff line change
@@ -1132,4 +1132,5 @@
<string name="export_wait">等待导出</string>
<string name="use_lib_archive">使用LibArchive</string>
<string name="pref_use_lib_archive_summary">使用libarchive解壓檔案,支持解壓RAR5。</string>
<string name="show_bookshelf_fast_scroller">显示快速滚动条</string>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values-zh/strings.xml
Original file line number Diff line number Diff line change
@@ -1132,4 +1132,5 @@
<string name="export_wait">等待导出</string>
<string name="use_lib_archive">使用LibArchive</string>
<string name="pref_use_lib_archive_summary">使用libarchive解压文件,支持解压RAR5。</string>
<string name="show_bookshelf_fast_scroller">显示快速滚动条</string>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1134,4 +1134,5 @@
<string name="default_home_page">默认主页</string>
<string name="use_lib_archive">Use LibArchive</string>
<string name="pref_use_lib_archive_summary">Using libarchive to extract files, it supports extracting RAR5.</string>
<string name="show_bookshelf_fast_scroller">显示快速滚动条</string>
</resources>

0 comments on commit e7df618

Please sign in to comment.