Merge pull request #4852 from vector-im/feature/bma/tooltip

Add tooltip to explain what are the actions behind the icons
This commit is contained in:
Benoit Marty 2022-01-05 09:47:12 +01:00 committed by GitHub
commit 5fc1efb542
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 20 additions and 30 deletions

View File

@ -1 +0,0 @@
Attachment picker UI improvements

1
changelog.d/3444.feature Normal file
View File

@ -0,0 +1 @@
New attachment picker UI

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
@ -67,7 +69,6 @@ class AttachmentTypeSelectorView(context: Context,
views.attachmentCameraButton.configure(Type.CAMERA)
views.attachmentFileButton.configure(Type.FILE)
views.attachmentStickersButton.configure(Type.STICKER)
views.attachmentAudioButton.configure(Type.AUDIO)
views.attachmentContactButton.configure(Type.CONTACT)
views.attachmentPollButton.configure(Type.POLL)
width = LinearLayout.LayoutParams.MATCH_PARENT
@ -126,7 +127,6 @@ class AttachmentTypeSelectorView(context: Context,
Type.GALLERY -> views.attachmentGalleryButton
Type.FILE -> views.attachmentFileButton
Type.STICKER -> views.attachmentStickersButton
Type.AUDIO -> views.attachmentAudioButton
Type.CONTACT -> views.attachmentContactButton
Type.POLL -> views.attachmentPollButton
}.let {
@ -190,6 +190,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 +203,14 @@ 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.tooltip_attachment_photo),
GALLERY(PERMISSIONS_EMPTY, R.string.tooltip_attachment_gallery),
FILE(PERMISSIONS_EMPTY, R.string.tooltip_attachment_file),
STICKER(PERMISSIONS_EMPTY, R.string.tooltip_attachment_sticker),
CONTACT(PERMISSIONS_FOR_PICKING_CONTACT, R.string.tooltip_attachment_contact),
POLL(PERMISSIONS_EMPTY, R.string.tooltip_attachment_poll)
}
}

View File

@ -1163,12 +1163,6 @@ class RoomDetailFragment @Inject constructor(
}
}
private val attachmentAudioActivityResultLauncher = registerStartForActivityResult {
if (it.resultCode == Activity.RESULT_OK) {
attachmentsHelper.onAudioResult(it.data)
}
}
private val attachmentContactActivityResultLauncher = registerStartForActivityResult {
if (it.resultCode == Activity.RESULT_OK) {
attachmentsHelper.onContactResult(it.data)
@ -2218,7 +2212,6 @@ class RoomDetailFragment @Inject constructor(
)
AttachmentTypeSelectorView.Type.FILE -> attachmentsHelper.selectFile(attachmentFileActivityResultLauncher)
AttachmentTypeSelectorView.Type.GALLERY -> attachmentsHelper.selectGallery(attachmentMediaActivityResultLauncher)
AttachmentTypeSelectorView.Type.AUDIO -> attachmentsHelper.selectAudio(attachmentAudioActivityResultLauncher)
AttachmentTypeSelectorView.Type.CONTACT -> attachmentsHelper.selectContact(attachmentContactActivityResultLauncher)
AttachmentTypeSelectorView.Type.STICKER -> roomDetailViewModel.handle(RoomDetailAction.SelectStickerAttachment)
AttachmentTypeSelectorView.Type.POLL -> navigator.openCreatePoll(requireContext(), roomDetailArgs.roomId)

View File

@ -82,17 +82,6 @@
android:src="@drawable/ic_attachment_camera"
app:tint="?colorPrimary" />
<!-- TODO. Request for new icon -->
<ImageButton
android:id="@+id/attachmentAudioButton"
android:layout_width="@dimen/layout_touch_size"
android:layout_height="@dimen/layout_touch_size"
android:layout_marginStart="2dp"
android:background="?android:attr/selectableItemBackground"
android:contentDescription="@string/attachment_type_audio"
android:src="@drawable/ic_attachment_audio_white_24dp"
app:tint="?colorPrimary" />
<!-- TODO. Request for new icon -->
<ImageButton
android:id="@+id/attachmentContactButton"

View File

@ -3679,4 +3679,12 @@
<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_attachment_photo">Open camera</string>
<string name="tooltip_attachment_gallery">Send images and videos</string>
<string name="tooltip_attachment_file">Upload file</string>
<string name="tooltip_attachment_sticker">Send sticker</string>
<string name="tooltip_attachment_contact">Open contacts</string>
<string name="tooltip_attachment_poll">Create poll</string>
</resources>