mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-27 12:05:22 +00:00
Remove timer from message view
This commit is contained in:
parent
617dbc8799
commit
61c51ecf64
@ -45,6 +45,8 @@ public class ExpirationTimerView extends androidx.appcompat.widget.AppCompatImag
|
||||
|
||||
public ExpirationTimerView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
|
||||
setContentDescription(context.getString(R.string.AccessibilityId_timer_icon));
|
||||
}
|
||||
|
||||
public void setExpirationTime(long startedAt, long expiresIn) {
|
||||
|
@ -12,6 +12,7 @@ import android.view.Gravity
|
||||
import android.view.HapticFeedbackConstants
|
||||
import android.view.MotionEvent
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.FrameLayout
|
||||
import android.widget.LinearLayout
|
||||
import androidx.annotation.ColorInt
|
||||
@ -115,7 +116,6 @@ class VisibleMessageView : LinearLayout {
|
||||
binding.root.disableClipping()
|
||||
binding.mainContainer.disableClipping()
|
||||
binding.messageInnerContainer.disableClipping()
|
||||
binding.messageInnerLayout.disableClipping()
|
||||
binding.messageContentView.root.disableClipping()
|
||||
}
|
||||
// endregion
|
||||
@ -342,46 +342,45 @@ class VisibleMessageView : LinearLayout {
|
||||
}
|
||||
|
||||
private fun updateExpirationTimer(message: MessageRecord) {
|
||||
val container = binding.messageInnerContainer
|
||||
val layout = binding.messageInnerLayout
|
||||
|
||||
if (message.isOutgoing) binding.messageContentView.root.bringToFront()
|
||||
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)
|
||||
messageContentView.layoutParams = messageContentView.layoutParams
|
||||
.apply {
|
||||
this as FrameLayout.LayoutParams
|
||||
this.gravity = if (message.isOutgoing) Gravity.END else Gravity.START
|
||||
}
|
||||
} else {
|
||||
binding.expirationTimerView.isInvisible = true
|
||||
}
|
||||
container.requestLayout()
|
||||
|
||||
// val container = binding.messageInnerContainer
|
||||
// container.layoutParams = (container.layoutParams as ConstraintLayout.LayoutParams)
|
||||
// .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() {
|
||||
@ -404,7 +403,7 @@ class VisibleMessageView : LinearLayout {
|
||||
swipeToReplyIconRect.right = right
|
||||
swipeToReplyIconRect.bottom = bottom
|
||||
|
||||
if (translationX < 0 && !binding.expirationTimerView.isVisible) {
|
||||
if (translationX < 0 /*&& !binding.expirationTimerView.isVisible*/) {
|
||||
val threshold = swipeToReplyThreshold
|
||||
swipeToReplyIcon.bounds = swipeToReplyIconRect
|
||||
swipeToReplyIcon.alpha = (255.0f * (min(abs(translationX), threshold) / threshold)).roundToInt()
|
||||
|
@ -115,30 +115,10 @@
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/senderNameTextView">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/messageInnerLayout"
|
||||
<include layout="@layout/view_visible_message_content"
|
||||
android:id="@+id/messageContentView"
|
||||
android:layout_width="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>
|
||||
android:layout_height="wrap_content" />
|
||||
</FrameLayout>
|
||||
|
||||
<include layout="@layout/view_emoji_reactions"
|
||||
|
Loading…
Reference in New Issue
Block a user