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