mirror of
https://github.com/InvertGeek/MixFile.git
synced 2026-06-09 16:07:42 +08:00
1
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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 ->
|
||||
|
||||
@@ -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 {
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user