more fixes
This commit is contained in:
@@ -1,4 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
</manifest>
|
||||
@@ -8,11 +8,9 @@ import androidx.annotation.ChecksSdkIntAtLeast
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.MutableSharedFlow
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.flow.asFlow
|
||||
import kotlinx.coroutines.flow.flow
|
||||
@@ -20,10 +18,6 @@ import kotlinx.coroutines.flow.launchIn
|
||||
import kotlinx.coroutines.flow.onEach
|
||||
import kotlinx.coroutines.flow.onStart
|
||||
import kotlinx.coroutines.flow.update
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import kotlin.coroutines.CoroutineContext
|
||||
import kotlin.coroutines.EmptyCoroutineContext
|
||||
import kotlin.time.Duration
|
||||
import kotlin.time.Duration.Companion.seconds
|
||||
|
||||
@@ -98,26 +92,6 @@ fun createTimerFlow(
|
||||
}
|
||||
}
|
||||
|
||||
context(ViewModel)
|
||||
fun <T> MutableSharedFlow<T>.emitOnMainScope(value: T) = emitOnScope(Dispatchers.Main) { value }
|
||||
|
||||
context(ViewModel)
|
||||
fun <T> MutableSharedFlow<T>.emitOnScope(
|
||||
coroutineContext: CoroutineContext = EmptyCoroutineContext,
|
||||
value: () -> T,
|
||||
) {
|
||||
viewModelScope.launch(coroutineContext) {
|
||||
emit(value())
|
||||
}
|
||||
}
|
||||
|
||||
context(CoroutineScope)
|
||||
suspend fun <T> MutableSharedFlow<T>.emitWithMain(value: T) {
|
||||
withContext(Dispatchers.Main) {
|
||||
emit(value)
|
||||
}
|
||||
}
|
||||
|
||||
context(ViewModel)
|
||||
fun <T> MutableStateFlow<T>.updateValue(newValue: T) = this.update { newValue }
|
||||
|
||||
|
||||
@@ -13,11 +13,6 @@ import androidx.core.content.FileProvider
|
||||
import java.io.File
|
||||
import java.io.FileOutputStream
|
||||
|
||||
private object BuildConfig {
|
||||
const val DEBUG = true
|
||||
const val APPLICATION_ID = "dev.meloda.fast"
|
||||
}
|
||||
|
||||
object AndroidUtils {
|
||||
|
||||
fun copyText(
|
||||
@@ -95,7 +90,7 @@ object AndroidUtils {
|
||||
action = if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
|
||||
Settings.ACTION_SECURITY_SETTINGS
|
||||
} else {
|
||||
data = Uri.parse("package:${BuildConfig.APPLICATION_ID}")
|
||||
data = Uri.parse("package:dev.meloda.fast")
|
||||
Settings.ACTION_MANAGE_UNKNOWN_APP_SOURCES
|
||||
}
|
||||
})
|
||||
@@ -113,7 +108,7 @@ object AndroidUtils {
|
||||
intent.putExtra(Intent.EXTRA_NOT_UNKNOWN_SOURCE, true)
|
||||
intent.data = FileProvider.getUriForFile(
|
||||
context,
|
||||
BuildConfig.APPLICATION_ID + providerPath,
|
||||
"dev.meloda.fast$providerPath",
|
||||
fileToRead
|
||||
)
|
||||
|
||||
@@ -132,7 +127,7 @@ object AndroidUtils {
|
||||
}
|
||||
|
||||
val file = existingFile.copyTo(copyToFile)
|
||||
FileProvider.getUriForFile(context, "${BuildConfig.APPLICATION_ID}.provider", file)
|
||||
FileProvider.getUriForFile(context, "dev.meloda.fast.provider", file)
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
null
|
||||
@@ -150,7 +145,7 @@ object AndroidUtils {
|
||||
bitmap.compress(Bitmap.CompressFormat.PNG, 90, outputStream)
|
||||
outputStream.flush()
|
||||
outputStream.close()
|
||||
FileProvider.getUriForFile(context, "${BuildConfig.APPLICATION_ID}.fileprovider", file)
|
||||
FileProvider.getUriForFile(context, "dev.meloda.fast.fileprovider", file)
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
null
|
||||
@@ -188,7 +183,6 @@ object AndroidUtils {
|
||||
}
|
||||
val chooserIntent = Intent.createChooser(intent, "Share $contentType")
|
||||
|
||||
|
||||
context.startActivity(chooserIntent)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user