From e02430bcd0d32f5edb602c967ca023ae47bba3d1 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Mon, 3 Feb 2020 20:06:37 +0100 Subject: [PATCH] Ask for permission before opening the camera (#934) --- CHANGES.md | 2 +- .../attachments/AttachmentTypeSelectorView.kt | 21 ++++++++++--------- .../home/room/detail/RoomDetailFragment.kt | 2 +- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index e6e1dd2a64..b8c2e202b9 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -11,7 +11,7 @@ Other changes: - Bugfix 🐛: - - + - Ask for permission before opening the camera (#934) Translations 🗣: - diff --git a/vector/src/main/java/im/vector/riotx/features/attachments/AttachmentTypeSelectorView.kt b/vector/src/main/java/im/vector/riotx/features/attachments/AttachmentTypeSelectorView.kt index e27fa70aed..0c2d958564 100644 --- a/vector/src/main/java/im/vector/riotx/features/attachments/AttachmentTypeSelectorView.kt +++ b/vector/src/main/java/im/vector/riotx/features/attachments/AttachmentTypeSelectorView.kt @@ -43,7 +43,9 @@ import im.vector.riotx.R import im.vector.riotx.core.extensions.getMeasurements 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_TAKING_PHOTO import im.vector.riotx.core.utils.PERMISSIONS_FOR_WRITING_FILES +import im.vector.riotx.features.attachments.AttachmentTypeSelectorView.Callback import kotlin.math.max private const val ANIMATION_DURATION = 250 @@ -146,10 +148,10 @@ class AttachmentTypeSelectorView(context: Context, private fun animateWindowInCircular(anchor: View, contentView: View) { val coordinates = getClickCoordinates(anchor, contentView) val animator = ViewAnimationUtils.createCircularReveal(contentView, - coordinates.first, - coordinates.second, - 0f, - max(contentView.width, contentView.height).toFloat()) + coordinates.first, + coordinates.second, + 0f, + max(contentView.width, contentView.height).toFloat()) animator.duration = ANIMATION_DURATION.toLong() animator.start() } @@ -164,10 +166,10 @@ class AttachmentTypeSelectorView(context: Context, private fun animateWindowOutCircular(anchor: View, contentView: View) { val coordinates = getClickCoordinates(anchor, contentView) val animator = ViewAnimationUtils.createCircularReveal(getContentView(), - coordinates.first, - coordinates.second, - max(getContentView().width, getContentView().height).toFloat(), - 0f) + coordinates.first, + coordinates.second, + max(getContentView().width, getContentView().height).toFloat(), + 0f) animator.duration = ANIMATION_DURATION.toLong() animator.addListener(object : AnimatorListenerAdapter() { @@ -222,8 +224,7 @@ class AttachmentTypeSelectorView(context: Context, * The all possible types to pick with their required permissions. */ enum class Type(val permissionsBit: Int) { - - CAMERA(PERMISSIONS_EMPTY), + CAMERA(PERMISSIONS_FOR_TAKING_PHOTO), GALLERY(PERMISSIONS_FOR_WRITING_FILES), FILE(PERMISSIONS_FOR_WRITING_FILES), STICKER(PERMISSIONS_EMPTY), diff --git a/vector/src/main/java/im/vector/riotx/features/home/room/detail/RoomDetailFragment.kt b/vector/src/main/java/im/vector/riotx/features/home/room/detail/RoomDetailFragment.kt index 6bc423ba7b..497cb7c733 100644 --- a/vector/src/main/java/im/vector/riotx/features/home/room/detail/RoomDetailFragment.kt +++ b/vector/src/main/java/im/vector/riotx/features/home/room/detail/RoomDetailFragment.kt @@ -1316,7 +1316,7 @@ class RoomDetailFragment @Inject constructor( AttachmentTypeSelectorView.Type.AUDIO -> attachmentsHelper.selectAudio() AttachmentTypeSelectorView.Type.CONTACT -> attachmentsHelper.selectContact() AttachmentTypeSelectorView.Type.STICKER -> vectorBaseActivity.notImplemented("Adding stickers") - } + }.exhaustive } // AttachmentsHelper.Callback