mirror of
https://github.com/oxen-io/session-android.git
synced 2025-01-12 10:03:39 +00:00
Handle voice message recording view hiding
This commit is contained in:
parent
b7000aa58b
commit
b5376cd60e
@ -25,6 +25,7 @@ import network.loki.messenger.R
|
||||
import org.thoughtcrime.securesms.PassphraseRequiredActionBarActivity
|
||||
import org.thoughtcrime.securesms.conversation.v2.input_bar.InputBarButton
|
||||
import org.thoughtcrime.securesms.conversation.v2.input_bar.InputBarDelegate
|
||||
import org.thoughtcrime.securesms.conversation.v2.input_bar.InputBarRecordingViewDelegate
|
||||
import org.thoughtcrime.securesms.conversation.v2.menus.ConversationActionModeCallback
|
||||
import org.thoughtcrime.securesms.conversation.v2.menus.ConversationMenuHelper
|
||||
import org.thoughtcrime.securesms.database.DatabaseFactory
|
||||
@ -36,7 +37,7 @@ import kotlin.math.abs
|
||||
import kotlin.math.roundToInt
|
||||
import kotlin.math.sqrt
|
||||
|
||||
class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDelegate {
|
||||
class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDelegate, InputBarRecordingViewDelegate {
|
||||
private val lockViewHitMargin by lazy { toPx(40, resources) }
|
||||
private var threadID: Long = -1
|
||||
private var actionMode: ActionMode? = null
|
||||
@ -125,6 +126,7 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe
|
||||
|
||||
private fun setUpInputBar() {
|
||||
inputBar.delegate = this
|
||||
inputBarRecordingView.delegate = this
|
||||
// GIF button
|
||||
gifButtonContainer.addView(gifButton)
|
||||
gifButton.layoutParams = RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT)
|
||||
@ -155,6 +157,24 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe
|
||||
|
||||
override fun showVoiceMessageUI() {
|
||||
inputBarRecordingView.show()
|
||||
inputBar.alpha = 0.0f
|
||||
val animation = ValueAnimator.ofObject(FloatEvaluator(), 1.0f, 0.0f)
|
||||
animation.duration = 250L
|
||||
animation.addUpdateListener { animator ->
|
||||
inputBar.alpha = animator.animatedValue as Float
|
||||
}
|
||||
animation.start()
|
||||
}
|
||||
|
||||
override fun handleInputBarRecordingViewHidden() {
|
||||
Log.d("Test", "Here")
|
||||
inputBar.alpha = 1.0f
|
||||
val animation = ValueAnimator.ofObject(FloatEvaluator(), 0.0f, 1.0f)
|
||||
animation.duration = 250L
|
||||
animation.addUpdateListener { animator ->
|
||||
inputBar.alpha = animator.animatedValue as Float
|
||||
}
|
||||
animation.start()
|
||||
}
|
||||
// endregion
|
||||
|
||||
@ -243,7 +263,7 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe
|
||||
}
|
||||
|
||||
private fun expandLockView() {
|
||||
val animation = ValueAnimator.ofObject(FloatEvaluator(), lockView.scaleX, 1.05f)
|
||||
val animation = ValueAnimator.ofObject(FloatEvaluator(), lockView.scaleX, 1.10f)
|
||||
animation.duration = 250L
|
||||
animation.addUpdateListener { animator ->
|
||||
lockView.scaleX = animator.animatedValue as Float
|
||||
|
@ -24,6 +24,9 @@ import kotlin.math.roundToLong
|
||||
class InputBarRecordingView : RelativeLayout {
|
||||
private var startTimestamp = 0L
|
||||
private val snHandler = Handler(Looper.getMainLooper())
|
||||
private var dotViewAnimation: ValueAnimator? = null
|
||||
private var pulseAnimation: ValueAnimator? = null
|
||||
var delegate: InputBarRecordingViewDelegate? = null
|
||||
|
||||
constructor(context: Context) : super(context) { initialize() }
|
||||
constructor(context: Context, attrs: AttributeSet) : super(context, attrs) { initialize() }
|
||||
@ -32,10 +35,12 @@ class InputBarRecordingView : RelativeLayout {
|
||||
private fun initialize() {
|
||||
LayoutInflater.from(context).inflate(R.layout.view_input_bar_recording, this)
|
||||
inputBarMiddleContentContainer.disableClipping()
|
||||
inputBarCancelButton.setOnClickListener { hide() }
|
||||
}
|
||||
|
||||
fun show() {
|
||||
startTimestamp = Date().time
|
||||
recordButtonOverlayImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.ic_microphone, context.theme))
|
||||
isVisible = true
|
||||
alpha = 0.0f
|
||||
val animation = ValueAnimator.ofObject(FloatEvaluator(), 0.0f, 1.0f)
|
||||
@ -50,8 +55,25 @@ class InputBarRecordingView : RelativeLayout {
|
||||
updateTimer()
|
||||
}
|
||||
|
||||
fun hide() {
|
||||
alpha = 1.0f
|
||||
val animation = ValueAnimator.ofObject(FloatEvaluator(), 1.0f, 0.0f)
|
||||
animation.duration = 250L
|
||||
animation.addUpdateListener { animator ->
|
||||
alpha = animator.animatedValue as Float
|
||||
if (animator.animatedFraction == 1.0f) {
|
||||
isVisible = false
|
||||
dotViewAnimation?.repeatCount = 0
|
||||
pulseAnimation?.removeAllUpdateListeners()
|
||||
}
|
||||
}
|
||||
animation.start()
|
||||
delegate?.handleInputBarRecordingViewHidden()
|
||||
}
|
||||
|
||||
private fun animateDotView() {
|
||||
val animation = ValueAnimator.ofObject(FloatEvaluator(), 1.0f, 0.0f)
|
||||
dotViewAnimation = animation
|
||||
animation.duration = 500L
|
||||
animation.addUpdateListener { animator ->
|
||||
dotView.alpha = animator.animatedValue as Float
|
||||
@ -66,10 +88,11 @@ class InputBarRecordingView : RelativeLayout {
|
||||
val expandedSize = toPx(104.0f, resources)
|
||||
pulseView.animateSizeChange(collapsedSize, expandedSize, 1000)
|
||||
val animation = ValueAnimator.ofObject(FloatEvaluator(), 0.5, 0.0f)
|
||||
pulseAnimation = animation
|
||||
animation.duration = 1000L
|
||||
animation.addUpdateListener { animator ->
|
||||
pulseView.alpha = animator.animatedValue as Float
|
||||
if (animator.animatedFraction == 1.0f) { pulse() }
|
||||
if (animator.animatedFraction == 1.0f && isVisible) { pulse() }
|
||||
}
|
||||
animation.start()
|
||||
}
|
||||
@ -90,7 +113,6 @@ class InputBarRecordingView : RelativeLayout {
|
||||
}
|
||||
|
||||
private fun updateTimer() {
|
||||
Log.d("Test", "${Date().time - startTimestamp}")
|
||||
val duration = (Date().time - startTimestamp) / 1000L
|
||||
recordingViewDurationTextView.text = DateUtils.formatElapsedTime(duration)
|
||||
snHandler.postDelayed({ updateTimer() }, 500)
|
||||
@ -113,3 +135,8 @@ class InputBarRecordingView : RelativeLayout {
|
||||
recordButtonOverlayImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.ic_arrow_up, context.theme))
|
||||
}
|
||||
}
|
||||
|
||||
interface InputBarRecordingViewDelegate {
|
||||
|
||||
fun handleInputBarRecordingViewHidden()
|
||||
}
|
||||
|
@ -3,7 +3,7 @@
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="126dp">
|
||||
android:layout_height="128dp">
|
||||
|
||||
<!-- The fake input bar -->
|
||||
|
||||
@ -84,10 +84,11 @@
|
||||
|
||||
<TextView
|
||||
android:id="@+id/inputBarCancelButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="100dp"
|
||||
android:layout_height="40dp"
|
||||
android:layout_centerInParent="true"
|
||||
android:alpha="0"
|
||||
android:gravity="center"
|
||||
android:text="@string/cancel"
|
||||
android:textSize="@dimen/small_font_size"
|
||||
android:textColor="@color/text"
|
||||
|
Loading…
x
Reference in New Issue
Block a user