pull/1493/head
fanchao 1 month ago
parent 75e53c86b1
commit c7c0519a20

@ -4,8 +4,6 @@ import android.animation.FloatEvaluator
import android.animation.IntEvaluator
import android.animation.ValueAnimator
import android.content.Context
import android.os.Handler
import android.os.Looper
import android.util.AttributeSet
import android.view.LayoutInflater
import android.widget.ImageView
@ -25,10 +23,12 @@ import java.util.Date
class InputBarRecordingView : RelativeLayout {
private lateinit var binding: ViewInputBarRecordingBinding
private var startTimestamp = 0L
private val snHandler = Handler(Looper.getMainLooper())
private var dotViewAnimation: ValueAnimator? = null
private var pulseAnimation: ValueAnimator? = null
var delegate: InputBarRecordingViewDelegate? = null
private val updateTimerRunnable = Runnable {
updateTimer()
}
val lockView: LinearLayout
get() = binding.lockView
@ -134,9 +134,21 @@ class InputBarRecordingView : RelativeLayout {
binding.recordingViewDurationTextView.text = DateUtils.formatElapsedTime(duration)
if (isAttachedToWindow) {
// Make sure there's only one runnable in the handler at a time.
removeCallbacks(updateTimerRunnable)
// Should only update the timer if the view is still attached to the window.
// Otherwise, the timer will keep running even after the view is detached.
snHandler.postDelayed({ updateTimer() }, 500)
postDelayed(updateTimerRunnable, 500)
}
}
override fun onAttachedToWindow() {
super.onAttachedToWindow()
if (isVisible) {
// If the view was visible (i.e. recording) when it was detached, start the timer again.
updateTimer()
}
}

@ -6,7 +6,6 @@ import android.content.Intent
import android.content.IntentFilter
import android.net.Uri
import android.os.Bundle
import android.os.Handler
import android.util.AttributeSet
import android.util.TypedValue
import android.view.Gravity
@ -21,7 +20,6 @@ import network.loki.messenger.R
import network.loki.messenger.databinding.ActivityPathBinding
import org.session.libsession.snode.OnionRequestAPI
import org.session.libsession.utilities.getColorFromAttr
import org.session.libsignal.utilities.Log
import org.session.libsignal.utilities.Snode
import org.thoughtcrime.securesms.PassphraseRequiredActionBarActivity
import org.thoughtcrime.securesms.util.GlowViewUtilities
@ -240,9 +238,6 @@ class PathActivity : PassphraseRequiredActionBarActivity() {
dotViewLayoutParams.addRule(CENTER_IN_PARENT)
dotView.layoutParams = dotViewLayoutParams
addView(dotView)
postDelayed({
performAnimation()
}, dotAnimationStartDelay)
}
private fun performAnimation() {
@ -258,6 +253,14 @@ class PathActivity : PassphraseRequiredActionBarActivity() {
}
}
override fun onAttachedToWindow() {
super.onAttachedToWindow()
postDelayed({
performAnimation()
}, dotAnimationStartDelay)
}
private fun expand() {
dotView.animateSizeChange(R.dimen.path_row_dot_size, R.dimen.path_row_expanded_dot_size)
@ColorRes val startColorID = if (UiModeUtilities.isDayUiMode(context)) R.color.transparent_black_30 else R.color.black

Loading…
Cancel
Save