Add tooltip to explain what are the actions behind the buttons

This commit is contained in:
Benoit Marty 2022-01-04 15:48:28 +01:00 committed by Benoit Marty
parent 39ff9da3c1
commit ecc4009689
2 changed files with 16 additions and 9 deletions

View File

@ -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)
}
}

View File

@ -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>