mirror of
https://github.com/revanced/revanced-manager.git
synced 2025-04-30 05:54:26 +02:00
switch type to long
This commit is contained in:
parent
829f093afe
commit
543f9fe7e4
@ -40,7 +40,7 @@ class DownloadedAppRepository(
|
|||||||
data: Parcelable,
|
data: Parcelable,
|
||||||
expectedPackageName: String,
|
expectedPackageName: String,
|
||||||
expectedVersion: String?,
|
expectedVersion: String?,
|
||||||
onDownload: suspend (downloadProgress: Pair<Double, Double?>) -> Unit,
|
onDownload: suspend (downloadProgress: Pair<Long, Long?>) -> Unit,
|
||||||
): File {
|
): File {
|
||||||
// Converted integers cannot contain / or .. unlike the package name or version, so they are safer to use here.
|
// Converted integers cannot contain / or .. unlike the package name or version, so they are safer to use here.
|
||||||
val relativePath = File(generateUid().toString())
|
val relativePath = File(generateUid().toString())
|
||||||
@ -90,7 +90,7 @@ class DownloadedAppRepository(
|
|||||||
}
|
}
|
||||||
.conflate()
|
.conflate()
|
||||||
.flowOn(Dispatchers.IO)
|
.flowOn(Dispatchers.IO)
|
||||||
.collect { (downloaded, size) -> onDownload(downloaded.megaBytes to size.megaBytes) }
|
.collect { (downloaded, size) -> onDownload(downloaded to size) }
|
||||||
|
|
||||||
if (downloadedBytes.get() < 1) error("Downloader did not download anything.")
|
if (downloadedBytes.get() < 1) error("Downloader did not download anything.")
|
||||||
val pkgInfo =
|
val pkgInfo =
|
||||||
@ -130,8 +130,4 @@ class DownloadedAppRepository(
|
|||||||
|
|
||||||
dao.delete(downloadedApps)
|
dao.delete(downloadedApps)
|
||||||
}
|
}
|
||||||
|
|
||||||
private companion object {
|
|
||||||
val Long.megaBytes get() = toDouble() / 1_000_000
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -74,7 +74,7 @@ class PatcherWorker(
|
|||||||
val selectedPatches: PatchSelection,
|
val selectedPatches: PatchSelection,
|
||||||
val options: Options,
|
val options: Options,
|
||||||
val logger: Logger,
|
val logger: Logger,
|
||||||
val downloadProgress: MutableStateFlow<Pair<Double, Double?>?>,
|
val downloadProgress: MutableStateFlow<Pair<Long, Long?>?>,
|
||||||
val patchesProgress: MutableStateFlow<Pair<Int, Int>>,
|
val patchesProgress: MutableStateFlow<Pair<Int, Int>>,
|
||||||
val handleStartActivityRequest: suspend (LoadedDownloaderPlugin, Intent) -> ActivityResult,
|
val handleStartActivityRequest: suspend (LoadedDownloaderPlugin, Intent) -> ActivityResult,
|
||||||
val setInputFile: (File) -> Unit,
|
val setInputFile: (File) -> Unit,
|
||||||
|
@ -135,7 +135,7 @@ fun SubStep(
|
|||||||
name: String,
|
name: String,
|
||||||
state: State,
|
state: State,
|
||||||
message: String? = null,
|
message: String? = null,
|
||||||
downloadProgress: Pair<Double, Double?>? = null
|
downloadProgress: Pair<Long, Long?>? = null
|
||||||
) {
|
) {
|
||||||
var messageExpanded by rememberSaveable { mutableStateOf(true) }
|
var messageExpanded by rememberSaveable { mutableStateOf(true) }
|
||||||
|
|
||||||
@ -181,7 +181,7 @@ fun SubStep(
|
|||||||
} else {
|
} else {
|
||||||
downloadProgress?.let { (current, total) ->
|
downloadProgress?.let { (current, total) ->
|
||||||
Text(
|
Text(
|
||||||
if (total != null) "${current.formatted}/${total.formatted} MB" else "${current.formatted} MB",
|
if (total != null) "${current.megaBytes}/${total.megaBytes} MB" else "${current.megaBytes} MB",
|
||||||
style = MaterialTheme.typography.labelSmall
|
style = MaterialTheme.typography.labelSmall
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -200,7 +200,7 @@ fun SubStep(
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun StepIcon(state: State, progress: Pair<Double, Double?>? = null, size: Dp) {
|
fun StepIcon(state: State, progress: Pair<Long, Long?>? = null, size: Dp) {
|
||||||
val strokeWidth = Dp(floor(size.value / 10) + 1)
|
val strokeWidth = Dp(floor(size.value / 10) + 1)
|
||||||
|
|
||||||
when (state) {
|
when (state) {
|
||||||
@ -245,4 +245,4 @@ fun StepIcon(state: State, progress: Pair<Double, Double?>? = null, size: Dp) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private val Double.formatted get() = "%.1f".format(locale = Locale.ROOT, this)
|
private val Long.megaBytes get() = "%.1f".format(locale = Locale.ROOT, toDouble() / 1_000_000)
|
@ -19,5 +19,5 @@ data class Step(
|
|||||||
val category: StepCategory,
|
val category: StepCategory,
|
||||||
val state: State = State.WAITING,
|
val state: State = State.WAITING,
|
||||||
val message: String? = null,
|
val message: String? = null,
|
||||||
val downloadProgress: StateFlow<Pair<Double, Double?>?>? = null
|
val downloadProgress: StateFlow<Pair<Long, Long?>?>? = null
|
||||||
)
|
)
|
@ -125,7 +125,7 @@ class PatcherViewModel(
|
|||||||
}
|
}
|
||||||
|
|
||||||
val patchesProgress = MutableStateFlow(Pair(0, input.selectedPatches.values.sumOf { it.size }))
|
val patchesProgress = MutableStateFlow(Pair(0, input.selectedPatches.values.sumOf { it.size }))
|
||||||
private val downloadProgress = MutableStateFlow<Pair<Double, Double?>?>(null)
|
private val downloadProgress = MutableStateFlow<Pair<Long, Long?>?>(null)
|
||||||
val steps = generateSteps(
|
val steps = generateSteps(
|
||||||
app,
|
app,
|
||||||
input.selectedApp,
|
input.selectedApp,
|
||||||
@ -447,7 +447,7 @@ class PatcherViewModel(
|
|||||||
fun generateSteps(
|
fun generateSteps(
|
||||||
context: Context,
|
context: Context,
|
||||||
selectedApp: SelectedApp,
|
selectedApp: SelectedApp,
|
||||||
downloadProgress: StateFlow<Pair<Double, Double?>?>? = null
|
downloadProgress: StateFlow<Pair<Long, Long?>?>? = null
|
||||||
): List<Step> {
|
): List<Step> {
|
||||||
val needsDownload =
|
val needsDownload =
|
||||||
selectedApp is SelectedApp.Download || selectedApp is SelectedApp.Search
|
selectedApp is SelectedApp.Download || selectedApp is SelectedApp.Search
|
||||||
|
Loading…
x
Reference in New Issue
Block a user