From ecc4009689b1d96dff283766269560f91172aec1 Mon Sep 17 00:00:00 2001 From: Benoit Marty <benoit@matrix.org> Date: Tue, 4 Jan 2022 15:48:28 +0100 Subject: [PATCH] Add tooltip to explain what are the actions behind the buttons --- .../attachments/AttachmentTypeSelectorView.kt | 21 +++++++++++-------- vector/src/main/res/values/strings.xml | 4 ++++ 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/vector/src/main/java/im/vector/app/features/attachments/AttachmentTypeSelectorView.kt b/vector/src/main/java/im/vector/app/features/attachments/AttachmentTypeSelectorView.kt index c56b3ac832..1bc50d31fd 100644 --- a/vector/src/main/java/im/vector/app/features/attachments/AttachmentTypeSelectorView.kt +++ b/vector/src/main/java/im/vector/app/features/attachments/AttachmentTypeSelectorView.kt @@ -30,6 +30,8 @@ import android.view.animation.TranslateAnimation import android.widget.ImageButton import android.widget.LinearLayout import android.widget.PopupWindow +import androidx.annotation.StringRes +import androidx.appcompat.widget.TooltipCompat import androidx.core.view.doOnNextLayout import androidx.core.view.isVisible import im.vector.app.R @@ -190,6 +192,7 @@ class AttachmentTypeSelectorView(context: Context, private fun ImageButton.configure(type: Type): ImageButton { this.setOnClickListener(TypeClickListener(type)) + TooltipCompat.setTooltipText(this, context.getString(type.tooltipRes)) return this } @@ -202,15 +205,15 @@ class AttachmentTypeSelectorView(context: Context, } /** - * The all possible types to pick with their required permissions. + * The all possible types to pick with their required permissions and tooltip resource */ - enum class Type(val permissions: List<String>) { - CAMERA(PERMISSIONS_FOR_TAKING_PHOTO), - GALLERY(PERMISSIONS_EMPTY), - FILE(PERMISSIONS_EMPTY), - STICKER(PERMISSIONS_EMPTY), - AUDIO(PERMISSIONS_EMPTY), - CONTACT(PERMISSIONS_FOR_PICKING_CONTACT), - POLL(PERMISSIONS_EMPTY) + enum class Type(val permissions: List<String>, @StringRes val tooltipRes: Int) { + CAMERA(PERMISSIONS_FOR_TAKING_PHOTO, R.string.option_take_photo_video), + GALLERY(PERMISSIONS_EMPTY, R.string.tooltip_select_item_from_gallery), + FILE(PERMISSIONS_EMPTY, R.string.tooltip_select_file), + STICKER(PERMISSIONS_EMPTY, R.string.option_send_sticker), + AUDIO(PERMISSIONS_EMPTY, R.string.tooltip_select_audio_file), + CONTACT(PERMISSIONS_FOR_PICKING_CONTACT, R.string.tooltip_select_contact), + POLL(PERMISSIONS_EMPTY, R.string.create_poll_title) } } diff --git a/vector/src/main/res/values/strings.xml b/vector/src/main/res/values/strings.xml index 9886a9f009..ef1cb5abc8 100644 --- a/vector/src/main/res/values/strings.xml +++ b/vector/src/main/res/values/strings.xml @@ -3676,4 +3676,8 @@ <string name="poll_end_room_list_preview">Poll ended</string> <string name="delete_poll_dialog_title">Remove poll</string> <string name="delete_poll_dialog_content">Are you sure you want to remove this poll? You won\'t be able to recover it once removed.</string> + <string name="tooltip_select_item_from_gallery">Select photos and videos from your device</string> + <string name="tooltip_select_file">Select any files from your device</string> + <string name="tooltip_select_audio_file">Select audio file from your device</string> + <string name="tooltip_select_contact">Select contact from your device</string> </resources>