mirror of
https://github.com/oxen-io/session-android.git
synced 2025-03-13 21:30:56 +00:00
Add auto-delete subtitle to context menu
This commit is contained in:
parent
ac37b2b9de
commit
b8aa46912a
@ -9,5 +9,6 @@ data class ActionItem @JvmOverloads constructor(
|
||||
@AttrRes val iconRes: Int,
|
||||
val title: CharSequence,
|
||||
val action: Runnable,
|
||||
val contentDescription: String? = null
|
||||
val contentDescription: String? = null,
|
||||
val subtitle: String? = null
|
||||
)
|
||||
|
@ -5,6 +5,7 @@ import android.view.View
|
||||
import android.widget.ImageView
|
||||
import android.widget.TextView
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import network.loki.messenger.R
|
||||
@ -70,6 +71,7 @@ class ContextMenuList(recyclerView: RecyclerView, onItemClick: () -> Unit) {
|
||||
) : MappingViewHolder<DisplayItem>(itemView) {
|
||||
val icon: ImageView = itemView.findViewById(R.id.context_menu_item_icon)
|
||||
val title: TextView = itemView.findViewById(R.id.context_menu_item_title)
|
||||
val subtitle: TextView = itemView.findViewById(R.id.context_menu_item_subtitle)
|
||||
|
||||
override fun bind(model: DisplayItem) {
|
||||
if (model.item.iconRes > 0) {
|
||||
@ -79,6 +81,8 @@ class ContextMenuList(recyclerView: RecyclerView, onItemClick: () -> Unit) {
|
||||
}
|
||||
itemView.contentDescription = model.item.contentDescription
|
||||
title.text = model.item.title
|
||||
subtitle.text = model.item.subtitle
|
||||
subtitle.isVisible = model.item.subtitle != null
|
||||
itemView.setOnClickListener {
|
||||
model.item.action.run()
|
||||
onItemClick()
|
||||
|
@ -37,6 +37,7 @@ import org.thoughtcrime.securesms.dependencies.DatabaseComponent.Companion.get
|
||||
import org.thoughtcrime.securesms.util.AnimationCompleteListener
|
||||
import org.thoughtcrime.securesms.util.DateUtils
|
||||
import java.util.Locale
|
||||
import kotlin.time.Duration.Companion.milliseconds
|
||||
|
||||
class ConversationReactionOverlay : FrameLayout {
|
||||
private val emojiViewGlobalRect = Rect()
|
||||
@ -518,7 +519,13 @@ class ConversationReactionOverlay : FrameLayout {
|
||||
}
|
||||
// Delete message
|
||||
if (userCanDeleteSelectedItems(context, message, openGroup, userPublicKey, blindedPublicKey)) {
|
||||
items += ActionItem(R.attr.menu_trash_icon, context.resources.getString(R.string.delete), { handleActionItemClicked(Action.DELETE) }, context.resources.getString(R.string.AccessibilityId_delete_message))
|
||||
items += ActionItem(
|
||||
R.attr.menu_trash_icon,
|
||||
context.resources.getString(R.string.delete),
|
||||
{ handleActionItemClicked(Action.DELETE) },
|
||||
context.resources.getString(R.string.AccessibilityId_delete_message),
|
||||
message.takeIf { it.expireStarted > 0 }?.run { expiresIn.milliseconds }?.let { "Auto-deletes in $it" }
|
||||
)
|
||||
}
|
||||
// Ban user
|
||||
if (userCanBanSelectedUsers(context, message, openGroup, userPublicKey, blindedPublicKey)) {
|
||||
|
@ -18,13 +18,28 @@
|
||||
android:layout_height="24dp"
|
||||
tools:src="@drawable/ic_message"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/context_menu_item_title"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Body1"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_marginStart="16dp"
|
||||
tools:text="Archive" />
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/context_menu_item_title"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Body1"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
tools:text="Archive" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/context_menu_item_subtitle"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Body1"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
tools:text="subtitle" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
Loading…
x
Reference in New Issue
Block a user