Remove timer from message view

This commit is contained in:
andrew 2023-10-27 16:24:56 +10:30
parent 617dbc8799
commit 61c51ecf64
3 changed files with 45 additions and 64 deletions

View File

@ -45,6 +45,8 @@ public class ExpirationTimerView extends androidx.appcompat.widget.AppCompatImag
public ExpirationTimerView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) { public ExpirationTimerView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr); super(context, attrs, defStyleAttr);
setContentDescription(context.getString(R.string.AccessibilityId_timer_icon));
} }
public void setExpirationTime(long startedAt, long expiresIn) { public void setExpirationTime(long startedAt, long expiresIn) {

View File

@ -12,6 +12,7 @@ import android.view.Gravity
import android.view.HapticFeedbackConstants import android.view.HapticFeedbackConstants
import android.view.MotionEvent import android.view.MotionEvent
import android.view.View import android.view.View
import android.view.ViewGroup
import android.widget.FrameLayout import android.widget.FrameLayout
import android.widget.LinearLayout import android.widget.LinearLayout
import androidx.annotation.ColorInt import androidx.annotation.ColorInt
@ -115,7 +116,6 @@ class VisibleMessageView : LinearLayout {
binding.root.disableClipping() binding.root.disableClipping()
binding.mainContainer.disableClipping() binding.mainContainer.disableClipping()
binding.messageInnerContainer.disableClipping() binding.messageInnerContainer.disableClipping()
binding.messageInnerLayout.disableClipping()
binding.messageContentView.root.disableClipping() binding.messageContentView.root.disableClipping()
} }
// endregion // endregion
@ -342,46 +342,45 @@ class VisibleMessageView : LinearLayout {
} }
private fun updateExpirationTimer(message: MessageRecord) { private fun updateExpirationTimer(message: MessageRecord) {
val container = binding.messageInnerContainer messageContentView.layoutParams = messageContentView.layoutParams
val layout = binding.messageInnerLayout .apply {
this as FrameLayout.LayoutParams
if (message.isOutgoing) binding.messageContentView.root.bringToFront() this.gravity = if (message.isOutgoing) Gravity.END else Gravity.START
else binding.expirationTimerView.bringToFront()
layout.layoutParams = layout.layoutParams.let { it as FrameLayout.LayoutParams }
.apply { gravity = if (message.isOutgoing) Gravity.END else Gravity.START }
val containerParams = container.layoutParams as ConstraintLayout.LayoutParams
containerParams.horizontalBias = if (message.isOutgoing) 1f else 0f
container.layoutParams = containerParams
if (message.expiresIn > 0 && !message.isPending) {
binding.expirationTimerView.setColorFilter(context.getColorFromAttr(android.R.attr.textColorPrimary))
binding.expirationTimerView.isInvisible = false
binding.expirationTimerView.setPercentComplete(0.0f)
if (message.expireStarted > 0) {
binding.expirationTimerView.setExpirationTime(message.expireStarted, message.expiresIn)
binding.expirationTimerView.startAnimation()
if (message.expireStarted + message.expiresIn <= SnodeAPI.nowWithOffset) {
ApplicationContext.getInstance(context).expiringMessageManager.checkSchedule()
}
} else if (!message.isMediaPending) {
binding.expirationTimerView.setPercentComplete(0.0f)
binding.expirationTimerView.stopAnimation()
ThreadUtils.queue {
val expirationManager = ApplicationContext.getInstance(context).expiringMessageManager
val id = message.getId()
val mms = message.isMms
if (mms) mmsDb.markExpireStarted(id) else smsDb.markExpireStarted(id)
expirationManager.scheduleDeletion(id, mms, message.expiresIn)
}
} else {
binding.expirationTimerView.stopAnimation()
binding.expirationTimerView.setPercentComplete(0.0f)
} }
} else {
binding.expirationTimerView.isInvisible = true // val container = binding.messageInnerContainer
} // container.layoutParams = (container.layoutParams as ConstraintLayout.LayoutParams)
container.requestLayout() // .apply { horizontalBias = if (message.isOutgoing) 1f else 0f }
// container.layoutParams = containerParams
// if (message.expiresIn > 0 && !message.isPending) {
// binding.expirationTimerView.setColorFilter(context.getColorFromAttr(android.R.attr.textColorPrimary))
// binding.expirationTimerView.isInvisible = false
// binding.expirationTimerView.setPercentComplete(0.0f)
// if (message.expireStarted > 0) {
// binding.expirationTimerView.setExpirationTime(message.expireStarted, message.expiresIn)
// binding.expirationTimerView.startAnimation()
// if (message.expireStarted + message.expiresIn <= SnodeAPI.nowWithOffset) {
// ApplicationContext.getInstance(context).expiringMessageManager.checkSchedule()
// }
// } else if (!message.isMediaPending) {
// binding.expirationTimerView.setPercentComplete(0.0f)
// binding.expirationTimerView.stopAnimation()
// ThreadUtils.queue {
// val expirationManager = ApplicationContext.getInstance(context).expiringMessageManager
// val id = message.getId()
// val mms = message.isMms
// if (mms) mmsDb.markExpireStarted(id) else smsDb.markExpireStarted(id)
// expirationManager.scheduleDeletion(id, mms, message.expiresIn)
// }
// } else {
// binding.expirationTimerView.stopAnimation()
// binding.expirationTimerView.setPercentComplete(0.0f)
// }
// } else {
// binding.expirationTimerView.isInvisible = true
// }
// container.requestLayout()
} }
private fun handleIsSelectedChanged() { private fun handleIsSelectedChanged() {
@ -404,7 +403,7 @@ class VisibleMessageView : LinearLayout {
swipeToReplyIconRect.right = right swipeToReplyIconRect.right = right
swipeToReplyIconRect.bottom = bottom swipeToReplyIconRect.bottom = bottom
if (translationX < 0 && !binding.expirationTimerView.isVisible) { if (translationX < 0 /*&& !binding.expirationTimerView.isVisible*/) {
val threshold = swipeToReplyThreshold val threshold = swipeToReplyThreshold
swipeToReplyIcon.bounds = swipeToReplyIconRect swipeToReplyIcon.bounds = swipeToReplyIconRect
swipeToReplyIcon.alpha = (255.0f * (min(abs(translationX), threshold) / threshold)).roundToInt() swipeToReplyIcon.alpha = (255.0f * (min(abs(translationX), threshold) / threshold)).roundToInt()

View File

@ -115,30 +115,10 @@
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@+id/senderNameTextView"> app:layout_constraintTop_toBottomOf="@+id/senderNameTextView">
<LinearLayout <include layout="@layout/view_visible_message_content"
android:id="@+id/messageInnerLayout" android:id="@+id/messageContentView"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content" />
android:orientation="horizontal">
<include layout="@layout/view_visible_message_content"
android:id="@+id/messageContentView"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<org.thoughtcrime.securesms.conversation.v2.components.ExpirationTimerView
android:id="@+id/expirationTimerView"
android:layout_width="12dp"
android:layout_height="12dp"
android:layout_gravity="center_vertical"
android:layout_marginHorizontal="@dimen/small_spacing"
android:contentDescription="@string/AccessibilityId_timer_icon"
android:visibility="invisible"
tools:visibility="visible"
tools:src="@drawable/timer60"
tools:tint="@color/black"/>
</LinearLayout>
</FrameLayout> </FrameLayout>
<include layout="@layout/view_emoji_reactions" <include layout="@layout/view_emoji_reactions"