mirror of
https://github.com/Myzel394/Alibi.git
synced 2025-06-18 23:05:26 +02:00
feat: Add media option to SaveFolderTile
This commit is contained in:
parent
b1167577ef
commit
99085b2176
@ -9,6 +9,8 @@ val MAX_AMPLITUDE = 20000
|
||||
val SUPPORTS_DARK_MODE_NATIVELY = Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q
|
||||
val RECORDER_SUBFOLDER_NAME = ".recordings"
|
||||
val VIDEO_RECORDER_SUPPORTS_CUSTOM_FOLDER = Build.VERSION.SDK_INT >= Build.VERSION_CODES.O
|
||||
val MEDIA_RECORDINGS_PREFIX = "alibi-recording-"
|
||||
val RECORDER_MEDIA_SELECTED_VALUE = "_'media"
|
||||
|
||||
// You are not allowed to change the constants below.
|
||||
// If you do so, you will be blocked on GitHub.
|
||||
|
@ -39,6 +39,7 @@ import androidx.documentfile.provider.DocumentFile
|
||||
import app.myzel394.alibi.R
|
||||
import app.myzel394.alibi.dataStore
|
||||
import app.myzel394.alibi.db.AppSettings
|
||||
import app.myzel394.alibi.ui.RECORDER_MEDIA_SELECTED_VALUE
|
||||
import app.myzel394.alibi.ui.VIDEO_RECORDER_SUPPORTS_CUSTOM_FOLDER
|
||||
import app.myzel394.alibi.ui.components.atoms.SettingsTile
|
||||
import app.myzel394.alibi.ui.utils.rememberFolderSelectorDialog
|
||||
@ -54,7 +55,7 @@ fun SaveFolderTile(
|
||||
val dataStore = context.dataStore
|
||||
|
||||
fun updateValue(path: String?) {
|
||||
if (settings.saveFolder != null) {
|
||||
if (settings.saveFolder != null && settings.saveFolder != RECORDER_MEDIA_SELECTED_VALUE) {
|
||||
runCatching {
|
||||
context.contentResolver.releasePersistableUriPermission(
|
||||
Uri.parse(settings.saveFolder),
|
||||
@ -63,7 +64,7 @@ fun SaveFolderTile(
|
||||
}
|
||||
}
|
||||
|
||||
if (path != null) {
|
||||
if (path != null && path != RECORDER_MEDIA_SELECTED_VALUE) {
|
||||
context.contentResolver.takePersistableUriPermission(
|
||||
Uri.parse(path),
|
||||
Intent.FLAG_GRANT_READ_URI_PERMISSION or Intent.FLAG_GRANT_WRITE_URI_PERMISSION
|
||||
@ -249,6 +250,12 @@ fun SaveFolderTile(
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Button(
|
||||
onClick = { updateValue(RECORDER_MEDIA_SELECTED_VALUE) }
|
||||
) {
|
||||
Text("Use Media")
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user