No need for WRITE_EXTERNAL permission to send attachment to the app (anymore?)
This commit is contained in:
parent
5541c2e190
commit
38843f74ab
2 changed files with 1 additions and 24 deletions
|
@ -1100,18 +1100,6 @@ class RoomDetailFragment @Inject constructor(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private val writingFileActivityResultLauncher = registerForPermissionsResult { allGranted ->
|
|
||||||
if (allGranted) {
|
|
||||||
val pendingUri = roomDetailViewModel.pendingUri
|
|
||||||
if (pendingUri != null) {
|
|
||||||
roomDetailViewModel.pendingUri = null
|
|
||||||
sendUri(pendingUri)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
cleanUpAfterPermissionNotGranted()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun setupComposer() {
|
private fun setupComposer() {
|
||||||
val composerEditText = composerLayout.composerEditText
|
val composerEditText = composerLayout.composerEditText
|
||||||
autoCompleter.setup(composerEditText)
|
autoCompleter.setup(composerEditText)
|
||||||
|
@ -1157,14 +1145,7 @@ class RoomDetailFragment @Inject constructor(
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onRichContentSelected(contentUri: Uri): Boolean {
|
override fun onRichContentSelected(contentUri: Uri): Boolean {
|
||||||
// We need WRITE_EXTERNAL permission
|
return sendUri(contentUri)
|
||||||
return if (checkPermissions(PERMISSIONS_FOR_WRITING_FILES, requireActivity(), writingFileActivityResultLauncher)) {
|
|
||||||
sendUri(contentUri)
|
|
||||||
} else {
|
|
||||||
roomDetailViewModel.pendingUri = contentUri
|
|
||||||
// Always intercept when we request some permission
|
|
||||||
true
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1561,7 +1542,6 @@ class RoomDetailFragment @Inject constructor(
|
||||||
private fun cleanUpAfterPermissionNotGranted() {
|
private fun cleanUpAfterPermissionNotGranted() {
|
||||||
// Reset all pending data
|
// Reset all pending data
|
||||||
roomDetailViewModel.pendingAction = null
|
roomDetailViewModel.pendingAction = null
|
||||||
roomDetailViewModel.pendingUri = null
|
|
||||||
attachmentsHelper.pendingType = null
|
attachmentsHelper.pendingType = null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -128,9 +128,6 @@ class RoomDetailViewModel @AssistedInject constructor(
|
||||||
// Slot to keep a pending action during permission request
|
// Slot to keep a pending action during permission request
|
||||||
var pendingAction: RoomDetailAction? = null
|
var pendingAction: RoomDetailAction? = null
|
||||||
|
|
||||||
// Slot to keep a pending uri during permission request
|
|
||||||
var pendingUri: Uri? = null
|
|
||||||
|
|
||||||
// Slot to store if we want to prevent preview of attachment
|
// Slot to store if we want to prevent preview of attachment
|
||||||
var preventAttachmentPreview = false
|
var preventAttachmentPreview = false
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue