|
|
@ -3,17 +3,19 @@ package org.thoughtcrime.securesms.conversation.v2.components
|
|
|
|
import android.content.Context
|
|
|
|
import android.content.Context
|
|
|
|
import android.graphics.drawable.AnimationDrawable
|
|
|
|
import android.graphics.drawable.AnimationDrawable
|
|
|
|
import android.util.AttributeSet
|
|
|
|
import android.util.AttributeSet
|
|
|
|
|
|
|
|
import android.util.Log
|
|
|
|
import android.widget.ImageView
|
|
|
|
import android.widget.ImageView
|
|
|
|
|
|
|
|
import androidx.appcompat.widget.AppCompatImageView
|
|
|
|
import androidx.core.content.ContextCompat
|
|
|
|
import androidx.core.content.ContextCompat
|
|
|
|
import network.loki.messenger.R
|
|
|
|
import network.loki.messenger.R
|
|
|
|
import org.session.libsession.snode.SnodeAPI.nowWithOffset
|
|
|
|
import org.session.libsession.snode.SnodeAPI.nowWithOffset
|
|
|
|
import kotlin.math.round
|
|
|
|
import kotlin.math.round
|
|
|
|
|
|
|
|
|
|
|
|
class ExpirationTimerView @JvmOverloads constructor(
|
|
|
|
class ExpirationTimerView @JvmOverloads constructor(
|
|
|
|
context: Context?,
|
|
|
|
context: Context,
|
|
|
|
attrs: AttributeSet? = null,
|
|
|
|
attrs: AttributeSet? = null,
|
|
|
|
defStyleAttr: Int = 0
|
|
|
|
defStyleAttr: Int = 0
|
|
|
|
) : ImageView(context, attrs, defStyleAttr) {
|
|
|
|
) : AppCompatImageView(context, attrs, defStyleAttr) {
|
|
|
|
private val frames = intArrayOf(
|
|
|
|
private val frames = intArrayOf(
|
|
|
|
R.drawable.timer00,
|
|
|
|
R.drawable.timer00,
|
|
|
|
R.drawable.timer05,
|
|
|
|
R.drawable.timer05,
|
|
|
@ -36,6 +38,12 @@ class ExpirationTimerView @JvmOverloads constructor(
|
|
|
|
return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (startedAt == 0L) {
|
|
|
|
|
|
|
|
// timer has not started
|
|
|
|
|
|
|
|
setImageResource(R.drawable.timer60)
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
val elapsedTime = nowWithOffset - startedAt
|
|
|
|
val elapsedTime = nowWithOffset - startedAt
|
|
|
|
val remainingTime = expiresIn - elapsedTime
|
|
|
|
val remainingTime = expiresIn - elapsedTime
|
|
|
|
val remainingPercent = (remainingTime / expiresIn.toFloat()).coerceIn(0f, 1f)
|
|
|
|
val remainingPercent = (remainingTime / expiresIn.toFloat()).coerceIn(0f, 1f)
|
|
|
|