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:
parent
9dd320f2f6
commit
13014ee490
19 changed files with 118 additions and 33 deletions
|
@ -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(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue