diff --git a/app/src/main/java/io/legado/app/constant/AppConst.kt b/app/src/main/java/io/legado/app/constant/AppConst.kt index fb197b3bb..810e6deb2 100644 --- a/app/src/main/java/io/legado/app/constant/AppConst.kt +++ b/app/src/main/java/io/legado/app/constant/AppConst.kt @@ -4,8 +4,6 @@ import android.annotation.SuppressLint import io.legado.app.App import io.legado.app.R import io.legado.app.data.entities.BookGroup -import io.legado.app.utils.getPrefBoolean -import io.legado.app.utils.putPrefBoolean import java.text.SimpleDateFormat import javax.script.ScriptEngine import javax.script.ScriptEngineManager @@ -52,18 +50,6 @@ object AppConst { val bookGroupLocal = BookGroup(-2, App.INSTANCE.getString(R.string.local)) val bookGroupAudio = BookGroup(-3, App.INSTANCE.getString(R.string.audio)) - var bookGroupLocalShow: Boolean - get() = App.INSTANCE.getPrefBoolean("bookGroupLocal", false) - set(value) { - App.INSTANCE.putPrefBoolean("bookGroupLocal", value) - } - - var bookGroupAudioShow: Boolean - get() = App.INSTANCE.getPrefBoolean("bookGroupAudio", false) - set(value) { - App.INSTANCE.putPrefBoolean("bookGroupAudio", value) - } - const val notificationIdRead = 1144771 const val notificationIdAudio = 1144772 const val notificationIdWeb = 1144773 diff --git a/app/src/main/java/io/legado/app/help/AppConfig.kt b/app/src/main/java/io/legado/app/help/AppConfig.kt index f71652c23..7c5bc4eac 100644 --- a/app/src/main/java/io/legado/app/help/AppConfig.kt +++ b/app/src/main/java/io/legado/app/help/AppConfig.kt @@ -92,4 +92,23 @@ object AppConfig { set(value) { App.INSTANCE.putPrefInt(PreferKey.systemTypefaces, value) } + + var bookGroupAllShow: Boolean + get() = App.INSTANCE.getPrefBoolean("bookGroupAll", false) + set(value) { + App.INSTANCE.putPrefBoolean("bookGroupAll", value) + } + + var bookGroupLocalShow: Boolean + get() = App.INSTANCE.getPrefBoolean("bookGroupLocal", false) + set(value) { + App.INSTANCE.putPrefBoolean("bookGroupLocal", value) + } + + var bookGroupAudioShow: Boolean + get() = App.INSTANCE.getPrefBoolean("bookGroupAudio", false) + set(value) { + App.INSTANCE.putPrefBoolean("bookGroupAudio", value) + } + } diff --git a/app/src/main/java/io/legado/app/ui/book/group/GroupManageDialog.kt b/app/src/main/java/io/legado/app/ui/book/group/GroupManageDialog.kt index 5ac8c49f6..ea4d2b61e 100644 --- a/app/src/main/java/io/legado/app/ui/book/group/GroupManageDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/group/GroupManageDialog.kt @@ -20,9 +20,9 @@ import io.legado.app.App import io.legado.app.R import io.legado.app.base.adapter.ItemViewHolder import io.legado.app.base.adapter.SimpleRecyclerAdapter -import io.legado.app.constant.AppConst import io.legado.app.constant.Theme import io.legado.app.data.entities.BookGroup +import io.legado.app.help.AppConfig import io.legado.app.help.ItemTouchCallback import io.legado.app.lib.dialogs.alert import io.legado.app.lib.dialogs.customView @@ -84,26 +84,35 @@ class GroupManageDialog : DialogFragment(), Toolbar.OnMenuItemClickListener { } private fun initMenu() { - tool_bar.inflateMenu(R.menu.book_group_manage) - tool_bar.menu.applyTint(requireContext(), Theme.getTheme()) tool_bar.setOnMenuItemClickListener(this) - tool_bar.menu.findItem(R.id.menu_group_local) - .isChecked = AppConst.bookGroupLocalShow - tool_bar.menu.findItem(R.id.menu_group_audio) - .isChecked = AppConst.bookGroupAudioShow + tool_bar.inflateMenu(R.menu.book_group_manage) + tool_bar.menu.let { + it.applyTint(requireContext(), Theme.getTheme()) + it.findItem(R.id.menu_group_all) + .isChecked = AppConfig.bookGroupAllShow + it.findItem(R.id.menu_group_local) + .isChecked = AppConfig.bookGroupLocalShow + it.findItem(R.id.menu_group_audio) + .isChecked = AppConfig.bookGroupAudioShow + } } override fun onMenuItemClick(item: MenuItem?): Boolean { when (item?.itemId) { R.id.menu_add -> addGroup() + R.id.menu_group_all -> { + item.isChecked = !item.isChecked + AppConfig.bookGroupAllShow = item.isChecked + callBack?.upGroup() + } R.id.menu_group_local -> { item.isChecked = !item.isChecked - AppConst.bookGroupLocalShow = item.isChecked + AppConfig.bookGroupLocalShow = item.isChecked callBack?.upGroup() } R.id.menu_group_audio -> { item.isChecked = !item.isChecked - AppConst.bookGroupAudioShow = item.isChecked + AppConfig.bookGroupAudioShow = item.isChecked callBack?.upGroup() } } diff --git a/app/src/main/res/menu/book_group_manage.xml b/app/src/main/res/menu/book_group_manage.xml index 4c887905d..94ad26c3d 100644 --- a/app/src/main/res/menu/book_group_manage.xml +++ b/app/src/main/res/menu/book_group_manage.xml @@ -10,6 +10,13 @@ app:showAsAction="always" tools:ignore="AlwaysShowAction" /> + +