1
0
Fork 0
mirror of https://github.com/anyproto/anytype-kotlin.git synced 2025-06-08 05:47:05 +09:00

DROID-2353 Self-host | Fix | Select config file (#1072)

This commit is contained in:
Konstantin Ivanov 2024-04-07 19:03:24 +02:00 committed by GitHub
parent 5d2f01cfe3
commit d96359f93c
Signed by: github
GPG key ID: B5690EEEBB952194
2 changed files with 11 additions and 6 deletions

View file

@ -5,6 +5,7 @@ import android.content.ActivityNotFoundException
import android.content.ClipboardManager
import android.content.Context
import android.content.Intent
import android.content.Intent.EXTRA_MIME_TYPES
import android.content.res.Resources
import android.graphics.Point
import android.graphics.Rect
@ -287,10 +288,7 @@ fun Fragment.startFilePicker(mime: Mimetype, requestCode: Int? = null) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
val intent = Intent(Intent.ACTION_OPEN_DOCUMENT).apply {
addCategory(Intent.CATEGORY_OPENABLE)
type = mime.value
if (mime == Mimetype.MIME_YAML) {
putExtra(Intent.EXTRA_MIME_TYPES, MIME_EXTRA_YAML)
}
configureTypeOfIntentForMime(this, mime)
}
val code = if (mime == Mimetype.MIME_FILE_ALL) {
REQUEST_FILE_SAF_CODE
@ -306,7 +304,7 @@ fun Fragment.startFilePicker(mime: Mimetype, requestCode: Int? = null) {
Intent(Intent.ACTION_PICK, MediaStore.Video.Media.INTERNAL_CONTENT_URI)
}
intent.apply {
type = mime.value
configureTypeOfIntentForMime(this, mime)
action = Intent.ACTION_GET_CONTENT
putExtra("return-data", true)
addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
@ -317,6 +315,14 @@ fun Fragment.startFilePicker(mime: Mimetype, requestCode: Int? = null) {
}
}
private fun configureTypeOfIntentForMime(intent: Intent, mime: Mimetype) {
if (mime == Mimetype.MIME_YAML) {
intent.putExtra(EXTRA_MIME_TYPES, MIME_EXTRA_YAML)
} else {
intent.type = mime.value
}
}
private fun Fragment.startMediaPicker(mime: Mimetype, requestCode: Int? = null) {
val intent = Intent(Intent.ACTION_OPEN_DOCUMENT).apply {
addCategory(Intent.CATEGORY_OPENABLE)

View file

@ -7,5 +7,4 @@ enum class Mimetype(val value: String) {
MIME_FILE_ALL("*/*"),
MIME_IMAGE_AND_VIDEO("image/*,video/*"),
MIME_YAML("application/zip"),
MIME_APPLICATION_ALL("application/*")
}