This commit is contained in:
Evan You
2025-03-19 14:02:25 +08:00
parent 492cb45c02
commit b27d3f61b5
3 changed files with 10 additions and 4 deletions

View File

@@ -53,6 +53,7 @@ import com.donut.mixfile.util.file.filePreview
import com.donut.mixfile.util.file.multiUploadTaskCount
import com.donut.mixfile.util.file.uploadLogs
import com.donut.mixfile.util.showToast
import androidx.core.net.toUri
var useShortCode by cachedMutableOf(true, "use_short_code")
@@ -89,7 +90,7 @@ fun isIgnoringBatteryOptimizations(context: Context = currentActivity): Boolean
@SuppressLint("BatteryLife")
fun openBatteryOptimizationSettings(context: Context = currentActivity) {
val intent = Intent(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS).apply {
data = Uri.parse("package:${context.packageName}")
data = "package:${context.packageName}".toUri()
}
context.startActivity(intent)
}

View File

@@ -294,14 +294,18 @@ fun getCurrentTime(): String {
return formatter.format(currentTime)
}
fun genRandomString(length: Int = 32): String {
val charPool: List<Char> = ('a'..'z') + ('A'..'Z') + ('0'..'9')
fun genRandomString(
length: Int = 32,
charPool: List<Char> = ('a'..'z') + ('A'..'Z') + ('0'..'9')
): String {
return (1..length)
.map { kotlin.random.Random.nextInt(0, charPool.size) }
.map(charPool::get)
.joinToString("")
}
fun genRandomHexString(length: Int = 32) = genRandomString(length, ('0'..'9') + ('a'..'f'))
fun compressGzip(input: String): ByteArray {
val byteArrayOutputStream = ByteArrayOutputStream()
GZIPOutputStream(byteArrayOutputStream).use { gzip ->

View File

@@ -1,5 +1,6 @@
package com.donut.mixfile
import com.donut.mixfile.util.file.encodeHex
import kotlinx.coroutines.runBlocking
import org.junit.Test
@@ -17,7 +18,7 @@ class ExampleUnitTest {
fun main() {
runBlocking {
}
}