Ask for permission before opening the camera (#934)

This commit is contained in:
Benoit Marty 2020-02-03 20:06:37 +01:00
parent 4335fa4f72
commit e02430bcd0
3 changed files with 13 additions and 12 deletions

View File

@ -11,7 +11,7 @@ Other changes:
- -
Bugfix 🐛: Bugfix 🐛:
- - Ask for permission before opening the camera (#934)
Translations 🗣: Translations 🗣:
- -

View File

@ -43,7 +43,9 @@ import im.vector.riotx.R
import im.vector.riotx.core.extensions.getMeasurements import im.vector.riotx.core.extensions.getMeasurements
import im.vector.riotx.core.utils.PERMISSIONS_EMPTY import im.vector.riotx.core.utils.PERMISSIONS_EMPTY
import im.vector.riotx.core.utils.PERMISSIONS_FOR_PICKING_CONTACT import im.vector.riotx.core.utils.PERMISSIONS_FOR_PICKING_CONTACT
import im.vector.riotx.core.utils.PERMISSIONS_FOR_TAKING_PHOTO
import im.vector.riotx.core.utils.PERMISSIONS_FOR_WRITING_FILES import im.vector.riotx.core.utils.PERMISSIONS_FOR_WRITING_FILES
import im.vector.riotx.features.attachments.AttachmentTypeSelectorView.Callback
import kotlin.math.max import kotlin.math.max
private const val ANIMATION_DURATION = 250 private const val ANIMATION_DURATION = 250
@ -146,10 +148,10 @@ class AttachmentTypeSelectorView(context: Context,
private fun animateWindowInCircular(anchor: View, contentView: View) { private fun animateWindowInCircular(anchor: View, contentView: View) {
val coordinates = getClickCoordinates(anchor, contentView) val coordinates = getClickCoordinates(anchor, contentView)
val animator = ViewAnimationUtils.createCircularReveal(contentView, val animator = ViewAnimationUtils.createCircularReveal(contentView,
coordinates.first, coordinates.first,
coordinates.second, coordinates.second,
0f, 0f,
max(contentView.width, contentView.height).toFloat()) max(contentView.width, contentView.height).toFloat())
animator.duration = ANIMATION_DURATION.toLong() animator.duration = ANIMATION_DURATION.toLong()
animator.start() animator.start()
} }
@ -164,10 +166,10 @@ class AttachmentTypeSelectorView(context: Context,
private fun animateWindowOutCircular(anchor: View, contentView: View) { private fun animateWindowOutCircular(anchor: View, contentView: View) {
val coordinates = getClickCoordinates(anchor, contentView) val coordinates = getClickCoordinates(anchor, contentView)
val animator = ViewAnimationUtils.createCircularReveal(getContentView(), val animator = ViewAnimationUtils.createCircularReveal(getContentView(),
coordinates.first, coordinates.first,
coordinates.second, coordinates.second,
max(getContentView().width, getContentView().height).toFloat(), max(getContentView().width, getContentView().height).toFloat(),
0f) 0f)
animator.duration = ANIMATION_DURATION.toLong() animator.duration = ANIMATION_DURATION.toLong()
animator.addListener(object : AnimatorListenerAdapter() { animator.addListener(object : AnimatorListenerAdapter() {
@ -222,8 +224,7 @@ class AttachmentTypeSelectorView(context: Context,
* The all possible types to pick with their required permissions. * The all possible types to pick with their required permissions.
*/ */
enum class Type(val permissionsBit: Int) { enum class Type(val permissionsBit: Int) {
CAMERA(PERMISSIONS_FOR_TAKING_PHOTO),
CAMERA(PERMISSIONS_EMPTY),
GALLERY(PERMISSIONS_FOR_WRITING_FILES), GALLERY(PERMISSIONS_FOR_WRITING_FILES),
FILE(PERMISSIONS_FOR_WRITING_FILES), FILE(PERMISSIONS_FOR_WRITING_FILES),
STICKER(PERMISSIONS_EMPTY), STICKER(PERMISSIONS_EMPTY),

View File

@ -1316,7 +1316,7 @@ class RoomDetailFragment @Inject constructor(
AttachmentTypeSelectorView.Type.AUDIO -> attachmentsHelper.selectAudio() AttachmentTypeSelectorView.Type.AUDIO -> attachmentsHelper.selectAudio()
AttachmentTypeSelectorView.Type.CONTACT -> attachmentsHelper.selectContact() AttachmentTypeSelectorView.Type.CONTACT -> attachmentsHelper.selectContact()
AttachmentTypeSelectorView.Type.STICKER -> vectorBaseActivity.notImplemented("Adding stickers") AttachmentTypeSelectorView.Type.STICKER -> vectorBaseActivity.notImplemented("Adding stickers")
} }.exhaustive
} }
// AttachmentsHelper.Callback // AttachmentsHelper.Callback