Merge pull request #2947 from kafji/kfj/room-preview-tooltip

Add tooltip for room quick actions
This commit is contained in:
Benoit Marty 2021-03-02 16:36:49 +01:00 committed by GitHub
commit 56af0b5191
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 7 deletions

View file

@ -9,6 +9,7 @@ Improvements 🙌:
- Fetch homeserver type and version and display in a new setting screen and add info in rageshakes (#2831)
- Improve initial sync performance (#983)
- PIP support for Jitsi call (#2418)
- Add tooltip for room quick actions
Bugfix 🐛:
- Try to fix crash about UrlPreview (#2640)

View file

@ -20,6 +20,7 @@ import android.content.res.ColorStateList
import android.view.View
import android.widget.ImageView
import android.widget.TextView
import androidx.appcompat.widget.TooltipCompat
import androidx.core.content.ContextCompat
import androidx.core.widget.ImageViewCompat
import com.airbnb.epoxy.EpoxyAttribute
@ -78,33 +79,46 @@ abstract class BottomSheetRoomPreviewItem : VectorEpoxyModel<BottomSheetRoomPrev
// And do the action
favoriteClickListener?.invoke()
}
holder.roomSettings.onClick(settingsClickListener)
holder.roomSettings.apply {
onClick(settingsClickListener)
TooltipCompat.setTooltipText(this, stringProvider.getString(R.string.room_list_quick_actions_room_settings))
}
}
private fun setLowPriorityState(holder: Holder, isLowPriority: Boolean) {
val description: String
val tintColor: Int
if (isLowPriority) {
holder.roomLowPriority.contentDescription = stringProvider.getString(R.string.room_list_quick_actions_low_priority_remove)
description = stringProvider.getString(R.string.room_list_quick_actions_low_priority_remove)
tintColor = ContextCompat.getColor(holder.view.context, R.color.riotx_accent)
} else {
holder.roomLowPriority.contentDescription = stringProvider.getString(R.string.room_list_quick_actions_low_priority_add)
description = stringProvider.getString(R.string.room_list_quick_actions_low_priority_add)
tintColor = ThemeUtils.getColor(holder.view.context, R.attr.riotx_text_secondary)
}
ImageViewCompat.setImageTintList(holder.roomLowPriority, ColorStateList.valueOf(tintColor))
holder.roomLowPriority.apply {
contentDescription = description
ImageViewCompat.setImageTintList(this, ColorStateList.valueOf(tintColor))
TooltipCompat.setTooltipText(this, description)
}
}
private fun setFavoriteState(holder: Holder, isFavorite: Boolean) {
val description: String
val tintColor: Int
if (isFavorite) {
holder.roomFavorite.contentDescription = stringProvider.getString(R.string.room_list_quick_actions_favorite_remove)
description = stringProvider.getString(R.string.room_list_quick_actions_favorite_remove)
holder.roomFavorite.setImageResource(R.drawable.ic_star_green_24dp)
tintColor = ContextCompat.getColor(holder.view.context, R.color.riotx_accent)
} else {
holder.roomFavorite.contentDescription = stringProvider.getString(R.string.room_list_quick_actions_favorite_add)
description = stringProvider.getString(R.string.room_list_quick_actions_favorite_add)
holder.roomFavorite.setImageResource(R.drawable.ic_star_24dp)
tintColor = ThemeUtils.getColor(holder.view.context, R.attr.riotx_text_secondary)
}
ImageViewCompat.setImageTintList(holder.roomFavorite, ColorStateList.valueOf(tintColor))
holder.roomFavorite.apply {
contentDescription = description
ImageViewCompat.setImageTintList(this, ColorStateList.valueOf(tintColor))
TooltipCompat.setTooltipText(this, description)
}
}
class Holder : VectorEpoxyHolder() {

View file

@ -1990,6 +1990,8 @@
<string name="room_list_quick_actions_low_priority_add">"Add to low priority"</string>
<string name="room_list_quick_actions_low_priority_remove">"Remove from low priority"</string>
<string name="room_list_quick_actions_leave">"Leave the room"</string>
<string name="room_list_quick_actions_room_settings">"Room settings"</string>
<string name="notice_member_no_changes">"%1$s made no changes"</string>
<string name="notice_member_no_changes_by_you">"You made no changes"</string>
<string name="command_description_spoiler">Sends the given message as a spoiler</string>