mirror of
https://github.com/oxen-io/session-android.git
synced 2025-01-03 13:47:45 +00:00
Fix context auto delete timer doesn't show if opened before successful send
This commit is contained in:
parent
701e3cbf8b
commit
84e92e186b
@ -1,5 +1,6 @@
|
|||||||
package org.thoughtcrime.securesms.components.menu
|
package org.thoughtcrime.securesms.components.menu
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
import androidx.annotation.AttrRes
|
import androidx.annotation.AttrRes
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -10,5 +11,5 @@ data class ActionItem(
|
|||||||
val title: Int,
|
val title: Int,
|
||||||
val action: Runnable,
|
val action: Runnable,
|
||||||
val contentDescription: Int? = null,
|
val contentDescription: Int? = null,
|
||||||
val subtitle: (() -> CharSequence?)? = null
|
val subtitle: ((Context) -> CharSequence?)? = null
|
||||||
)
|
)
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package org.thoughtcrime.securesms.components.menu
|
package org.thoughtcrime.securesms.components.menu
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
import android.util.TypedValue
|
import android.util.TypedValue
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.widget.ImageView
|
import android.widget.ImageView
|
||||||
@ -101,8 +102,8 @@ class ContextMenuList(recyclerView: RecyclerView, onItemClick: () -> Unit) {
|
|||||||
}.let(itemView::setBackgroundResource)
|
}.let(itemView::setBackgroundResource)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun startSubtitleJob(textView: TextView, getSubtitle: () -> CharSequence?) {
|
private fun startSubtitleJob(textView: TextView, getSubtitle: (Context) -> CharSequence?) {
|
||||||
fun updateText() = getSubtitle().let {
|
fun updateText() = getSubtitle(context).let {
|
||||||
textView.isGone = it == null
|
textView.isGone = it == null
|
||||||
textView.text = it
|
textView.text = it
|
||||||
}
|
}
|
||||||
|
@ -549,13 +549,7 @@ class ConversationReactionOverlay : FrameLayout {
|
|||||||
}
|
}
|
||||||
// Delete message
|
// Delete message
|
||||||
if (userCanDeleteSelectedItems(context, message, openGroup, userPublicKey, blindedPublicKey)) {
|
if (userCanDeleteSelectedItems(context, message, openGroup, userPublicKey, blindedPublicKey)) {
|
||||||
val subtitle = { message.takeIf { it.expireStarted > 0 }
|
items += ActionItem(R.attr.menu_trash_icon, R.string.delete, { handleActionItemClicked(Action.DELETE) }, R.string.AccessibilityId_delete_message, message.subtitle)
|
||||||
?.run { expiresIn - (SnodeAPI.nowWithOffset - expireStarted) }
|
|
||||||
?.coerceAtLeast(0L)
|
|
||||||
?.milliseconds
|
|
||||||
?.to2partString()
|
|
||||||
?.let { context.getString(R.string.auto_deletes_in, it) } }
|
|
||||||
items += ActionItem(R.attr.menu_trash_icon, R.string.delete, { handleActionItemClicked(Action.DELETE) }, R.string.AccessibilityId_delete_message, subtitle)
|
|
||||||
}
|
}
|
||||||
// Ban user
|
// Ban user
|
||||||
if (userCanBanSelectedUsers(context, message, openGroup, userPublicKey, blindedPublicKey)) {
|
if (userCanBanSelectedUsers(context, message, openGroup, userPublicKey, blindedPublicKey)) {
|
||||||
@ -716,3 +710,14 @@ class ConversationReactionOverlay : FrameLayout {
|
|||||||
private fun Duration.to2partString(): String? =
|
private fun Duration.to2partString(): String? =
|
||||||
toComponents { days, hours, minutes, seconds, nanoseconds -> listOf(days.days, hours.hours, minutes.minutes, seconds.seconds) }
|
toComponents { days, hours, minutes, seconds, nanoseconds -> listOf(days.days, hours.hours, minutes.minutes, seconds.seconds) }
|
||||||
.filter { it.inWholeSeconds > 0L }.take(2).takeIf { it.isNotEmpty() }?.joinToString(" ")
|
.filter { it.inWholeSeconds > 0L }.take(2).takeIf { it.isNotEmpty() }?.joinToString(" ")
|
||||||
|
|
||||||
|
private val MessageRecord.subtitle: ((Context) -> CharSequence?)?
|
||||||
|
get() = if (expiresIn <= 0) {
|
||||||
|
null
|
||||||
|
} else { context ->
|
||||||
|
(expiresIn - (SnodeAPI.nowWithOffset - (expireStarted.takeIf { it > 0 } ?: timestamp)))
|
||||||
|
.coerceAtLeast(0L)
|
||||||
|
.milliseconds
|
||||||
|
.to2partString()
|
||||||
|
?.let { context.getString(R.string.auto_deletes_in, it) }
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user