Revert "Show toast after restoring the database"

This reverts commit b9880a3955.
This commit is contained in:
vfsfitvnm 2022-10-08 07:52:57 +02:00
parent b9880a3955
commit bead21be04

View file

@ -1,7 +1,6 @@
package it.vfsfitvnm.vimusic.ui.screens.settings
import android.annotation.SuppressLint
import android.widget.Toast
import androidx.activity.compose.rememberLauncherForActivityResult
import androidx.activity.result.contract.ActivityResultContracts
import androidx.compose.animation.ExperimentalAnimationApi
@ -56,11 +55,12 @@ fun DatabaseSettings() {
query {
Database.internal.checkpoint()
context.applicationContext.contentResolver.openOutputStream(uri)?.use { output ->
FileInputStream(Database.internal.path).use { input ->
input.copyTo(output)
context.applicationContext.contentResolver.openOutputStream(uri)
?.use { outputStream ->
FileInputStream(Database.internal.path).use { inputStream ->
inputStream.copyTo(outputStream)
}
}
}
}
}
@ -68,19 +68,16 @@ fun DatabaseSettings() {
rememberLauncherForActivityResult(ActivityResultContracts.OpenDocument()) { uri ->
if (uri == null) return@rememberLauncherForActivityResult
Toast.makeText(
context,
"${context.applicationInfo.nonLocalizedLabel} is going to close itself after restoring the database",
Toast.LENGTH_SHORT
).show()
query {
Database.internal.checkpoint()
Database.internal.close()
context.applicationContext.contentResolver.openInputStream(uri)?.use { input ->
FileOutputStream(Database.internal.path).use(input::copyTo)
}
context.applicationContext.contentResolver.openInputStream(uri)
?.use { inputStream ->
FileOutputStream(Database.internal.path).use { outputStream ->
inputStream.copyTo(outputStream)
}
}
context.stopService(context.intent<PlayerService>())
exitProcess(0)