diff --git a/app/src/main/java/io/legado/app/constant/PreferKey.kt b/app/src/main/java/io/legado/app/constant/PreferKey.kt index 07f22f159..c223f6f07 100644 --- a/app/src/main/java/io/legado/app/constant/PreferKey.kt +++ b/app/src/main/java/io/legado/app/constant/PreferKey.kt @@ -32,4 +32,5 @@ object PreferKey { const val webDavPassword = "web_dav_password" const val changeSourceLoadToc = "changeSourceLoadToc" const val chineseConverterType = "chineseConverterType" + const val launcherIcon = "launcherIcon" } \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/data/dao/BookGroupDao.kt b/app/src/main/java/io/legado/app/data/dao/BookGroupDao.kt index eafff6b0e..c262d60e1 100644 --- a/app/src/main/java/io/legado/app/data/dao/BookGroupDao.kt +++ b/app/src/main/java/io/legado/app/data/dao/BookGroupDao.kt @@ -13,8 +13,8 @@ interface BookGroupDao { @Query("SELECT * FROM book_groups ORDER BY `order`") fun liveDataAll(): LiveData> - @get:Query("SELECT count(groupId) FROM book_groups") - val idsCount: Int + @get:Query("SELECT sum(groupId) FROM book_groups") + val idsSum: Int @get:Query("SELECT MAX(`order`) FROM book_groups") val maxOrder: Int diff --git a/app/src/main/java/io/legado/app/help/storage/Restore.kt b/app/src/main/java/io/legado/app/help/storage/Restore.kt index ed944012a..123332df6 100644 --- a/app/src/main/java/io/legado/app/help/storage/Restore.kt +++ b/app/src/main/java/io/legado/app/help/storage/Restore.kt @@ -10,6 +10,7 @@ import com.jayway.jsonpath.ParseContext import io.legado.app.App import io.legado.app.constant.PreferKey import io.legado.app.data.entities.* +import io.legado.app.help.LauncherIconHelp import io.legado.app.help.ReadBookConfig import io.legado.app.utils.* import kotlinx.coroutines.Dispatchers.IO @@ -106,6 +107,7 @@ object Restore { edit.commit() } } + LauncherIconHelp.changeIcon(App.INSTANCE.getPrefString(PreferKey.launcherIcon)) } private inline fun fileToListT(path: String, fileName: String): List? { diff --git a/app/src/main/java/io/legado/app/ui/book/group/GroupSelectDialog.kt b/app/src/main/java/io/legado/app/ui/book/group/GroupSelectDialog.kt index 483d47dfc..8ef086168 100644 --- a/app/src/main/java/io/legado/app/ui/book/group/GroupSelectDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/group/GroupSelectDialog.kt @@ -162,7 +162,7 @@ class GroupSelectDialog : DialogFragment(), Toolbar.OnMenuItemClickListener { override fun convert(holder: ItemViewHolder, item: BookGroup, payloads: MutableList) { holder.itemView.apply { cb_group.text = item.groupName - cb_group.isChecked = (groupId or item.groupId) > 0 + cb_group.isChecked = (groupId and item.groupId) > 0 cb_group.setOnCheckedChangeListener { buttonView, isChecked -> if (buttonView.isPressed) { groupId = if (isChecked) { diff --git a/app/src/main/java/io/legado/app/ui/book/group/GroupViewModel.kt b/app/src/main/java/io/legado/app/ui/book/group/GroupViewModel.kt index e0fdc2b09..6045ad832 100644 --- a/app/src/main/java/io/legado/app/ui/book/group/GroupViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/book/group/GroupViewModel.kt @@ -10,8 +10,8 @@ class GroupViewModel(application: Application) : BaseViewModel(application) { fun addGroup(groupName: String) { execute { var id = 1 - val idsCount = App.db.bookGroupDao().idsCount - while (id and idsCount != 0) { + val idsSum = App.db.bookGroupDao().idsSum + while (id and idsSum != 0) { id *= 2 } val bookGroup = BookGroup( diff --git a/app/src/main/java/io/legado/app/ui/config/ThemeConfigFragment.kt b/app/src/main/java/io/legado/app/ui/config/ThemeConfigFragment.kt index b4d12f700..ed5e8cf9a 100644 --- a/app/src/main/java/io/legado/app/ui/config/ThemeConfigFragment.kt +++ b/app/src/main/java/io/legado/app/ui/config/ThemeConfigFragment.kt @@ -9,6 +9,7 @@ import androidx.preference.PreferenceFragmentCompat import io.legado.app.App import io.legado.app.R import io.legado.app.constant.EventBus +import io.legado.app.constant.PreferKey import io.legado.app.help.AppConfig import io.legado.app.help.LauncherIconHelp import io.legado.app.lib.dialogs.alert @@ -47,7 +48,7 @@ class ThemeConfigFragment : PreferenceFragmentCompat(), SharedPreferences.OnShar override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences?, key: String?) { sharedPreferences ?: return when (key) { - "launcherIcon" -> LauncherIconHelp.changeIcon(getPrefString(key)) + PreferKey.launcherIcon -> LauncherIconHelp.changeIcon(getPrefString(key)) "transparentStatusBar" -> { recreateActivities() }