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

DROID-2072 Sharing extension | Enhancement | Display filename in the content field (#840)

This commit is contained in:
Evgenii Kozlov 2024-02-08 11:02:29 +01:00 committed by GitHub
parent 9dd320f2f6
commit 13014ee490
Signed by: github
GPG key ID: B5690EEEBB952194
19 changed files with 118 additions and 33 deletions

View file

@ -28,6 +28,28 @@ class SharedFileUploader @Inject constructor(
TODO("Not yet implemented")
}
override suspend fun getDisplayName(uri: String): String? = withContext(dispatchers.io) {
val parsed = Uri.parse(uri)
context.contentResolver.query(
parsed,
null,
null,
null,
null
).use { cursor ->
if (cursor != null && cursor.moveToFirst()) {
val idx = cursor.getColumnIndex(OpenableColumns.DISPLAY_NAME)
if (idx != -1) {
cursor.getString(idx)
} else {
context.resources.getString(R.string.untitled)
}
} else {
context.resources.getString(R.string.untitled)
}
}
}
private fun parsePathFromUri(extra: Uri) : String {
val name = if (extra.scheme == CONTENT_URI_SCHEME) {
context.contentResolver.query(