mirror of
https://github.com/aniyomiorg/aniyomi.git
synced 2024-11-21 12:17:12 +03:00
Merge branch 'master' into MR
This commit is contained in:
commit
dd69ce5a12
8 changed files with 51 additions and 19 deletions
|
@ -21,7 +21,7 @@ android {
|
|||
defaultConfig {
|
||||
applicationId = "xyz.jmir.tachiyomi.mi"
|
||||
|
||||
versionCode = 104
|
||||
versionCode = 105
|
||||
versionName = "0.14.6"
|
||||
|
||||
buildConfigField("String", "COMMIT_COUNT", "\"${getCommitCount()}\"")
|
||||
|
|
|
@ -35,7 +35,11 @@ fun CumulativeStorage(
|
|||
var currentAngle = 0f
|
||||
rotate(180f) {
|
||||
for (item in items) {
|
||||
val itemAngle = (item.size / totalSize) * totalAngle
|
||||
val itemAngle = if (totalSize > 0f) {
|
||||
(item.size / totalSize) * totalAngle
|
||||
} else {
|
||||
0f
|
||||
}
|
||||
drawArc(
|
||||
color = item.color,
|
||||
startAngle = currentAngle,
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
package eu.kanade.tachiyomi.data.download.anime
|
||||
|
||||
import android.content.Context
|
||||
import com.hippo.unifile.UniFile
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.animesource.AnimeSource
|
||||
import eu.kanade.tachiyomi.animesource.model.Video
|
||||
import eu.kanade.tachiyomi.data.download.anime.model.AnimeDownload
|
||||
import eu.kanade.tachiyomi.util.size
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.asFlow
|
||||
import kotlinx.coroutines.flow.drop
|
||||
|
@ -23,6 +25,9 @@ import tachiyomi.domain.download.service.DownloadPreferences
|
|||
import tachiyomi.domain.entries.anime.model.Anime
|
||||
import tachiyomi.domain.items.episode.model.Episode
|
||||
import tachiyomi.domain.source.anime.service.AnimeSourceManager
|
||||
import tachiyomi.source.local.entries.anime.LocalAnimeSource
|
||||
import tachiyomi.source.local.io.ArchiveAnime
|
||||
import tachiyomi.source.local.io.anime.LocalAnimeSourceFileSystem
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
|
||||
|
@ -214,12 +219,18 @@ class AnimeDownloadManager(
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns the amount of downloaded episodes for an anime.
|
||||
* Returns the amount of downloaded/local episodes for an anime.
|
||||
*
|
||||
* @param anime the anime to check.
|
||||
*/
|
||||
fun getDownloadCount(anime: Anime): Int {
|
||||
return cache.getDownloadCount(anime)
|
||||
return if (anime.source == LocalAnimeSource.ID) {
|
||||
LocalAnimeSourceFileSystem(context).getFilesInAnimeDirectory(anime.url)
|
||||
.filter { ArchiveAnime.isSupported(it) }
|
||||
.count()
|
||||
} else {
|
||||
cache.getDownloadCount(anime)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -230,12 +241,17 @@ class AnimeDownloadManager(
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns the size of downloaded episodes for an anime.
|
||||
* Returns the size of downloaded/local episodes for an anime.
|
||||
*
|
||||
* @param anime the anime to check.
|
||||
*/
|
||||
fun getDownloadSize(anime: Anime): Long {
|
||||
return cache.getDownloadSize(anime)
|
||||
return if (anime.source == LocalAnimeSource.ID) {
|
||||
LocalAnimeSourceFileSystem(context).getAnimeDirectory(anime.url)
|
||||
.let { UniFile.fromFile(it) }?.size() ?: 0L
|
||||
} else {
|
||||
cache.getDownloadSize(anime)
|
||||
}
|
||||
}
|
||||
|
||||
fun cancelQueuedDownloads(downloads: List<AnimeDownload>) {
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
package eu.kanade.tachiyomi.data.download.manga
|
||||
|
||||
import android.content.Context
|
||||
import com.hippo.unifile.UniFile
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.data.download.manga.model.MangaDownload
|
||||
import eu.kanade.tachiyomi.source.MangaSource
|
||||
import eu.kanade.tachiyomi.source.model.Page
|
||||
import eu.kanade.tachiyomi.util.size
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.asFlow
|
||||
import kotlinx.coroutines.flow.drop
|
||||
|
@ -22,6 +24,9 @@ import tachiyomi.domain.download.service.DownloadPreferences
|
|||
import tachiyomi.domain.entries.manga.model.Manga
|
||||
import tachiyomi.domain.items.chapter.model.Chapter
|
||||
import tachiyomi.domain.source.manga.service.MangaSourceManager
|
||||
import tachiyomi.source.local.entries.manga.LocalMangaSource
|
||||
import tachiyomi.source.local.io.ArchiveManga
|
||||
import tachiyomi.source.local.io.manga.LocalMangaSourceFileSystem
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
|
||||
|
@ -193,12 +198,18 @@ class MangaDownloadManager(
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns the amount of downloaded chapters for a manga.
|
||||
* Returns the amount of downloaded/local chapters for a manga.
|
||||
*
|
||||
* @param manga the manga to check.
|
||||
*/
|
||||
fun getDownloadCount(manga: Manga): Int {
|
||||
return cache.getDownloadCount(manga)
|
||||
return if (manga.source == LocalMangaSource.ID) {
|
||||
LocalMangaSourceFileSystem(context).getFilesInMangaDirectory(manga.url)
|
||||
.filter { it.isDirectory || ArchiveManga.isSupported(it) }
|
||||
.count()
|
||||
} else {
|
||||
cache.getDownloadCount(manga)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -209,12 +220,17 @@ class MangaDownloadManager(
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns the size of downloaded chapters for a manga.
|
||||
* Returns the size of downloaded/local episodes for an manga.
|
||||
*
|
||||
* @param manga the manga to check.
|
||||
*/
|
||||
fun getDownloadSize(manga: Manga): Long {
|
||||
return cache.getDownloadSize(manga)
|
||||
return if (manga.source == LocalMangaSource.ID) {
|
||||
LocalMangaSourceFileSystem(context).getMangaDirectory(manga.url)
|
||||
.let { UniFile.fromFile(it) }?.size() ?: 0L
|
||||
} else {
|
||||
cache.getDownloadSize(manga)
|
||||
}
|
||||
}
|
||||
|
||||
fun cancelQueuedDownloads(downloads: List<MangaDownload>) {
|
||||
|
|
|
@ -94,10 +94,10 @@ private fun SubtitleFont(
|
|||
).listFiles { file ->
|
||||
file.extension.equals("ttf", true) ||
|
||||
file.extension.equals("otf", true)
|
||||
}?.map {
|
||||
}?.associate {
|
||||
TTFFile.open(it).families.values.toTypedArray()[0] to it.absolutePath
|
||||
} ?: emptyList()
|
||||
listOf("Sans Serif" to "") + customFonts
|
||||
} ?: emptyMap()
|
||||
mapOf("Sans Serif" to ("" to null)) + customFonts
|
||||
}
|
||||
}
|
||||
var selectingFont by remember { mutableStateOf(false) }
|
||||
|
@ -152,7 +152,7 @@ private fun SubtitleFont(
|
|||
|
||||
DropdownMenu(expanded = selectingFont, onDismissRequest = { selectingFont = false }) {
|
||||
fontList.map {
|
||||
val fontName = it.first
|
||||
val fontName = it.key
|
||||
DropdownMenuItem(
|
||||
text = { Text(fontName) },
|
||||
onClick = { updateFont(fontName) },
|
||||
|
|
|
@ -22,7 +22,6 @@ abstract class CommonStorageScreenModel<T>(
|
|||
private val downloadCacheIsInitializing: StateFlow<Boolean>,
|
||||
private val libraries: Flow<List<T>>,
|
||||
private val categories: Flow<List<Category>>,
|
||||
private val getTotalDownloadSize: () -> Long,
|
||||
private val getDownloadSize: T.() -> Long,
|
||||
private val getDownloadCount: T.() -> Int,
|
||||
private val getId: T.() -> Long,
|
||||
|
@ -47,14 +46,13 @@ abstract class CommonStorageScreenModel<T>(
|
|||
}.filter {
|
||||
selectedCategory == AllCategory || it.getCategoryId() == selectedCategory.id
|
||||
}
|
||||
val size = getTotalDownloadSize()
|
||||
val random = Random(size + distinctLibraries.size)
|
||||
|
||||
mutableState.update {
|
||||
StorageScreenState.Success(
|
||||
selectedCategory = selectedCategory,
|
||||
categories = listOf(AllCategory, *categories.toTypedArray()),
|
||||
items = distinctLibraries.map {
|
||||
val random = Random(it.getId())
|
||||
StorageItem(
|
||||
id = it.getId(),
|
||||
title = it.getTitle(),
|
||||
|
|
|
@ -23,7 +23,6 @@ class AnimeStorageScreenModel(
|
|||
downloadCacheIsInitializing = downloadCache.isInitializing,
|
||||
libraries = getLibraries.subscribe(),
|
||||
categories = getVisibleCategories.subscribe(),
|
||||
getTotalDownloadSize = { downloadManager.getDownloadSize() },
|
||||
getDownloadSize = { downloadManager.getDownloadSize(anime) },
|
||||
getDownloadCount = { downloadManager.getDownloadCount(anime) },
|
||||
getId = { id },
|
||||
|
|
|
@ -23,7 +23,6 @@ class MangaStorageScreenModel(
|
|||
downloadCacheIsInitializing = downloadCache.isInitializing,
|
||||
libraries = getLibraries.subscribe(),
|
||||
categories = getVisibleCategories.subscribe(),
|
||||
getTotalDownloadSize = { downloadManager.getDownloadSize() },
|
||||
getDownloadSize = { downloadManager.getDownloadSize(manga) },
|
||||
getDownloadCount = { downloadManager.getDownloadCount(manga) },
|
||||
getId = { id },
|
||||
|
|
Loading…
Reference in a new issue