Minor cleanup
This commit is contained in:
parent
8fedd2d5f1
commit
254f021903
@ -94,7 +94,7 @@ data class Manga(
|
||||
}
|
||||
|
||||
fun sortDescending(): Boolean {
|
||||
return chapterFlags and CHAPTER_SORT_DIR_MASK == CHAPTER_SORTING_DESC
|
||||
return chapterFlags and CHAPTER_SORT_DIR_MASK == CHAPTER_SORT_DESC
|
||||
}
|
||||
|
||||
companion object {
|
||||
@ -121,7 +121,6 @@ data class Manga(
|
||||
const val CHAPTER_SORTING_NUMBER = 0x00000100L
|
||||
const val CHAPTER_SORTING_UPLOAD_DATE = 0x00000200L
|
||||
const val CHAPTER_SORTING_MASK = 0x00000300L
|
||||
const val CHAPTER_SORTING_DESC = 0x00000000L
|
||||
|
||||
const val CHAPTER_DISPLAY_NAME = 0x00000000L
|
||||
const val CHAPTER_DISPLAY_NUMBER = 0x00100000L
|
||||
|
@ -15,9 +15,9 @@ import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.systemBars
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.Close
|
||||
import androidx.compose.material.icons.filled.Edit
|
||||
import androidx.compose.material.icons.filled.Save
|
||||
import androidx.compose.material.icons.filled.Share
|
||||
import androidx.compose.material.icons.outlined.Edit
|
||||
import androidx.compose.material.icons.outlined.Save
|
||||
import androidx.compose.material.icons.outlined.Share
|
||||
import androidx.compose.material3.DropdownMenuItem
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.IconButton
|
||||
@ -70,13 +70,13 @@ fun MangaCoverDialog(
|
||||
Spacer(modifier = Modifier.weight(1f))
|
||||
IconButton(onClick = onShareClick) {
|
||||
Icon(
|
||||
imageVector = Icons.Default.Share,
|
||||
imageVector = Icons.Outlined.Share,
|
||||
contentDescription = stringResource(id = R.string.action_share),
|
||||
)
|
||||
}
|
||||
IconButton(onClick = onSaveClick) {
|
||||
Icon(
|
||||
imageVector = Icons.Default.Save,
|
||||
imageVector = Icons.Outlined.Save,
|
||||
contentDescription = stringResource(id = R.string.action_save),
|
||||
)
|
||||
}
|
||||
@ -87,7 +87,7 @@ fun MangaCoverDialog(
|
||||
onClick = { if (isCustomCover) onExpand(true) else onEditClick(EditCoverAction.EDIT) },
|
||||
) {
|
||||
Icon(
|
||||
imageVector = Icons.Default.Edit,
|
||||
imageVector = Icons.Outlined.Edit,
|
||||
contentDescription = stringResource(id = R.string.action_edit_cover),
|
||||
)
|
||||
}
|
||||
|
@ -23,6 +23,7 @@ class FullBackupRestore(context: Context, notifier: BackupNotifier) : AbstractBa
|
||||
override suspend fun performRestore(uri: Uri): Boolean {
|
||||
backupManager = FullBackupManager(context)
|
||||
|
||||
@Suppress("BlockingMethodInNonBlockingContext")
|
||||
val backupString = context.contentResolver.openInputStream(uri)!!.source().gzip().buffer().use { it.readByteArray() }
|
||||
val backup = backupManager.parser.decodeFromByteArray(BackupSerializer, backupString)
|
||||
|
||||
|
@ -35,6 +35,7 @@ import eu.kanade.tachiyomi.ui.base.controller.FullComposeController
|
||||
import eu.kanade.tachiyomi.util.editCover
|
||||
import eu.kanade.tachiyomi.util.lang.launchIO
|
||||
import eu.kanade.tachiyomi.util.lang.launchUI
|
||||
import eu.kanade.tachiyomi.util.lang.withUIContext
|
||||
import eu.kanade.tachiyomi.util.system.logcat
|
||||
import eu.kanade.tachiyomi.util.system.toShareIntent
|
||||
import eu.kanade.tachiyomi.util.system.toast
|
||||
@ -44,11 +45,12 @@ import kotlinx.coroutines.cancel
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.flow.asStateFlow
|
||||
import logcat.LogPriority
|
||||
import nucleus.presenter.Presenter
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
|
||||
class MangaFullCoverDialog : FullComposeController<MangaFullCoverDialog.Presenter> {
|
||||
class MangaFullCoverDialog : FullComposeController<MangaFullCoverDialog.MangaFullCoverPresenter> {
|
||||
|
||||
private val mangaId: Long
|
||||
|
||||
@ -61,7 +63,7 @@ class MangaFullCoverDialog : FullComposeController<MangaFullCoverDialog.Presente
|
||||
this.mangaId = mangaId
|
||||
}
|
||||
|
||||
override fun createPresenter() = Presenter(mangaId)
|
||||
override fun createPresenter() = MangaFullCoverPresenter(mangaId)
|
||||
|
||||
@Composable
|
||||
override fun ComposeContent() {
|
||||
@ -157,10 +159,10 @@ class MangaFullCoverDialog : FullComposeController<MangaFullCoverDialog.Presente
|
||||
}
|
||||
}
|
||||
|
||||
class Presenter(
|
||||
inner class MangaFullCoverPresenter(
|
||||
private val mangaId: Long,
|
||||
private val getMangaById: GetMangaById = Injekt.get(),
|
||||
) : nucleus.presenter.Presenter<MangaFullCoverDialog>() {
|
||||
) : Presenter<MangaFullCoverDialog>() {
|
||||
|
||||
private var presenterScope: CoroutineScope = MainScope()
|
||||
|
||||
@ -218,6 +220,7 @@ class MangaFullCoverDialog : FullComposeController<MangaFullCoverDialog.Presente
|
||||
fun editCover(context: Context, data: Uri) {
|
||||
val manga = manga.value ?: return
|
||||
presenterScope.launchIO {
|
||||
@Suppress("BlockingMethodInNonBlockingContext")
|
||||
context.contentResolver.openInputStream(data)?.use {
|
||||
val result = try {
|
||||
manga.editCover(context, it, updateManga, coverCache)
|
||||
@ -225,7 +228,7 @@ class MangaFullCoverDialog : FullComposeController<MangaFullCoverDialog.Presente
|
||||
view?.onSetCoverError(e)
|
||||
false
|
||||
}
|
||||
launchUI { if (result) view?.onSetCoverSuccess() }
|
||||
withUIContext { if (result) view?.onSetCoverSuccess() }
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -236,14 +239,15 @@ class MangaFullCoverDialog : FullComposeController<MangaFullCoverDialog.Presente
|
||||
try {
|
||||
coverCache.deleteCustomCover(mangaId)
|
||||
updateManga.awaitUpdateCoverLastModified(mangaId)
|
||||
launchUI { view?.onSetCoverSuccess() }
|
||||
withUIContext { view?.onSetCoverSuccess() }
|
||||
} catch (e: Exception) {
|
||||
launchUI { view?.onSetCoverError(e) }
|
||||
withUIContext { view?.onSetCoverError(e) }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val MANGA_EXTRA = "mangaId"
|
||||
|
||||
@ -253,3 +257,4 @@ class MangaFullCoverDialog : FullComposeController<MangaFullCoverDialog.Presente
|
||||
private const val REQUEST_IMAGE_OPEN = 101
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user