Add tooltip for room quick actions

Add tooltip for low priority, favorite, and room settings quick actions.

Signed-off-by: Kafji <k@kafji.net>
This commit is contained in:
Kafji 2021-03-02 18:54:00 +07:00
parent 32e7845c2b
commit 3357c78375
3 changed files with 24 additions and 7 deletions

View File

@ -8,6 +8,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>