优化
This commit is contained in:
@@ -58,6 +58,9 @@ interface BookGroupDao {
|
|||||||
@get:Query("SELECT * FROM book_groups ORDER BY `order`")
|
@get:Query("SELECT * FROM book_groups ORDER BY `order`")
|
||||||
val all: List<BookGroup>
|
val all: List<BookGroup>
|
||||||
|
|
||||||
|
@get:Query("select count(*) < 64 from book_groups where groupId >= 0 or groupId == ${Long.MIN_VALUE}")
|
||||||
|
val canAddGroup: Boolean
|
||||||
|
|
||||||
@Query("update book_groups set show = 1 where groupId = :groupId")
|
@Query("update book_groups set show = 1 where groupId = :groupId")
|
||||||
fun enableGroup(groupId: Long)
|
fun enableGroup(groupId: Long)
|
||||||
|
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ class TTS {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun addTextToSpeakList() {
|
private fun addTextToSpeakList() {
|
||||||
textToSpeech?.let { tts ->
|
val tts = textToSpeech ?: return
|
||||||
kotlin.runCatching {
|
kotlin.runCatching {
|
||||||
var result = tts.speak("", TextToSpeech.QUEUE_FLUSH, null, null)
|
var result = tts.speak("", TextToSpeech.QUEUE_FLUSH, null, null)
|
||||||
if (result == TextToSpeech.ERROR) {
|
if (result == TextToSpeech.ERROR) {
|
||||||
@@ -96,7 +96,6 @@ class TTS {
|
|||||||
appCtx.toastOnUi(it.localizedMessage)
|
appCtx.toastOnUi(it.localizedMessage)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 初始化监听
|
* 初始化监听
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import androidx.documentfile.provider.DocumentFile
|
|||||||
import io.legado.app.constant.AppLog
|
import io.legado.app.constant.AppLog
|
||||||
import io.legado.app.constant.PreferKey
|
import io.legado.app.constant.PreferKey
|
||||||
import io.legado.app.data.appDb
|
import io.legado.app.data.appDb
|
||||||
|
import io.legado.app.exception.NoStackTraceException
|
||||||
import io.legado.app.help.AppWebDav
|
import io.legado.app.help.AppWebDav
|
||||||
import io.legado.app.help.DirectLinkUpload
|
import io.legado.app.help.DirectLinkUpload
|
||||||
import io.legado.app.help.config.AppConfig
|
import io.legado.app.help.config.AppConfig
|
||||||
@@ -186,6 +187,7 @@ object Backup {
|
|||||||
}
|
}
|
||||||
AppWebDav.backUpWebDav(zipFileName)
|
AppWebDav.backUpWebDav(zipFileName)
|
||||||
}
|
}
|
||||||
|
FileUtils.delete(backupPath)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -203,15 +205,18 @@ object Backup {
|
|||||||
@Throws(Exception::class)
|
@Throws(Exception::class)
|
||||||
@Suppress("SameParameterValue")
|
@Suppress("SameParameterValue")
|
||||||
private fun copyBackup(context: Context, uri: Uri, fileName: String) {
|
private fun copyBackup(context: Context, uri: Uri, fileName: String) {
|
||||||
DocumentFile.fromTreeUri(context, uri)?.let { treeDoc ->
|
val treeDoc = DocumentFile.fromTreeUri(context, uri)!!
|
||||||
treeDoc.findFile(fileName)?.delete()
|
treeDoc.findFile(fileName)?.delete()
|
||||||
treeDoc.createFile("", fileName)?.openOutputStream()?.use { outputS ->
|
val fileDoc = treeDoc.createFile("", fileName)
|
||||||
FileInputStream(File(zipFilePath)).use { inputS ->
|
?: throw NoStackTraceException("创建文件失败")
|
||||||
|
val outputS = fileDoc.openOutputStream()
|
||||||
|
?: throw NoStackTraceException("打开OutputStream失败")
|
||||||
|
outputS.use {
|
||||||
|
FileInputStream(zipFilePath).use { inputS ->
|
||||||
inputS.copyTo(outputS)
|
inputS.copyTo(outputS)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Throws(Exception::class)
|
@Throws(Exception::class)
|
||||||
@Suppress("SameParameterValue")
|
@Suppress("SameParameterValue")
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ import io.legado.app.ui.widget.recycler.VerticalDivider
|
|||||||
import io.legado.app.utils.applyTint
|
import io.legado.app.utils.applyTint
|
||||||
import io.legado.app.utils.setLayout
|
import io.legado.app.utils.setLayout
|
||||||
import io.legado.app.utils.showDialogFragment
|
import io.legado.app.utils.showDialogFragment
|
||||||
|
import io.legado.app.utils.toastOnUi
|
||||||
import io.legado.app.utils.viewbindingdelegate.viewBinding
|
import io.legado.app.utils.viewbindingdelegate.viewBinding
|
||||||
import io.legado.app.utils.visible
|
import io.legado.app.utils.visible
|
||||||
import kotlinx.coroutines.flow.conflate
|
import kotlinx.coroutines.flow.conflate
|
||||||
@@ -82,7 +83,13 @@ class GroupManageDialog : BaseDialogFragment(R.layout.dialog_recycler_view),
|
|||||||
|
|
||||||
override fun onMenuItemClick(item: MenuItem?): Boolean {
|
override fun onMenuItemClick(item: MenuItem?): Boolean {
|
||||||
when (item?.itemId) {
|
when (item?.itemId) {
|
||||||
R.id.menu_add -> showDialogFragment(GroupEditDialog())
|
R.id.menu_add -> {
|
||||||
|
if (appDb.bookGroupDao.canAddGroup) {
|
||||||
|
showDialogFragment(GroupEditDialog())
|
||||||
|
} else {
|
||||||
|
toastOnUi("分组已达上限(64个)")
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user