mirror of
https://github.com/InvertGeek/MixFile.git
synced 2026-06-01 17:10:49 +08:00
优化进度显示
This commit is contained in:
@@ -14,8 +14,8 @@ android {
|
||||
applicationId = "com.donut.mixfile"
|
||||
minSdk = 24
|
||||
targetSdk = 34
|
||||
versionCode = 5
|
||||
versionName = "1.0.4"
|
||||
versionCode = 6
|
||||
versionName = "1.0.4.1"
|
||||
|
||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||
vectorDrawables {
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -6,7 +6,7 @@
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta content="width=device-width,user-scalable=no,initial-scale=1,maximum-scale=1,minimum-scale=1" name="viewport"/>
|
||||
<title>MixFile</title>
|
||||
<script type="module" crossorigin src="/assets/index-BDpeJXT8.js"></script>
|
||||
<script type="module" crossorigin src="/assets/index-BbG3rMIQ.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="/assets/index-BuZ9x1Ok.css">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
@@ -55,9 +55,15 @@ fun readClipBoardText(): String {
|
||||
}
|
||||
|
||||
|
||||
fun formatFileSize(bytes: Long): String {
|
||||
fun formatFileSize(bytes: Long, mb: Boolean = false): String {
|
||||
if (bytes <= 0) return "0 B"
|
||||
|
||||
if (mb) {
|
||||
return String.format(
|
||||
Locale.US,
|
||||
"%.2f MB",
|
||||
bytes / 1024.0 / 1024.0
|
||||
)
|
||||
}
|
||||
val units = arrayOf("B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB")
|
||||
val digitGroups = (log10(bytes.toDouble()) / log10(1024.0)).toInt()
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.alpha
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.donut.mixfile.util.formatFileSize
|
||||
import okhttp3.Interceptor
|
||||
import okhttp3.MediaType
|
||||
import okhttp3.Response
|
||||
@@ -32,19 +33,6 @@ import java.util.Locale
|
||||
import kotlin.math.log10
|
||||
import kotlin.math.pow
|
||||
|
||||
fun formatFileSize(bytes: Long): String {
|
||||
if (bytes <= 0) return "0 B"
|
||||
|
||||
val units = arrayOf("B", "KB", "MB", "GB", "TB")
|
||||
val digitGroups = (log10(bytes.toDouble()) / log10(1024.0)).toInt()
|
||||
|
||||
return String.format(
|
||||
Locale.US,
|
||||
"%.1f %s",
|
||||
bytes / 1024.0.pow(digitGroups.toDouble()),
|
||||
units[digitGroups]
|
||||
)
|
||||
}
|
||||
|
||||
class ProgressInterceptor(private val progressListener: ProgressListener) : Interceptor {
|
||||
|
||||
@@ -178,7 +166,13 @@ fun LoadingBar(
|
||||
progress = { progress },
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
)
|
||||
Text(text = "${tip}: ${formatFileSize(bytesWritten)}/${formatFileSize(contentLength)}")
|
||||
Text(
|
||||
text = "${tip}: ${formatFileSize(bytesWritten, true)}/${
|
||||
formatFileSize(
|
||||
contentLength
|
||||
)
|
||||
}"
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user