mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-25 09:17:44 +00:00
More animation
This commit is contained in:
parent
b5376cd60e
commit
f4621a4fee
@ -42,6 +42,7 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe
|
|||||||
private var threadID: Long = -1
|
private var threadID: Long = -1
|
||||||
private var actionMode: ActionMode? = null
|
private var actionMode: ActionMode? = null
|
||||||
private var isLockViewExpanded = false
|
private var isLockViewExpanded = false
|
||||||
|
private var isShowingAttachmentOptions = false
|
||||||
|
|
||||||
// TODO: Selected message background color
|
// TODO: Selected message background color
|
||||||
// TODO: Overflow menu background + text color
|
// TODO: Overflow menu background + text color
|
||||||
@ -155,6 +156,22 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe
|
|||||||
conversationRecyclerView.layoutParams = recyclerViewLayoutParams
|
conversationRecyclerView.layoutParams = recyclerViewLayoutParams
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun toggleAttachmentOptions() {
|
||||||
|
val targetAlpha = if (isShowingAttachmentOptions) 0.0f else 1.0f
|
||||||
|
val allButtons = listOf( cameraButtonContainer, libraryButtonContainer, documentButtonContainer, gifButtonContainer)
|
||||||
|
allButtons.indices.forEach { index ->
|
||||||
|
val view = allButtons[index]
|
||||||
|
val animation = ValueAnimator.ofObject(FloatEvaluator(), view.alpha, targetAlpha)
|
||||||
|
animation.duration = 250L
|
||||||
|
animation.startDelay = 50L * index.toLong()
|
||||||
|
animation.addUpdateListener { animator ->
|
||||||
|
view.alpha = animator.animatedValue as Float
|
||||||
|
}
|
||||||
|
animation.start()
|
||||||
|
}
|
||||||
|
isShowingAttachmentOptions = !isShowingAttachmentOptions
|
||||||
|
}
|
||||||
|
|
||||||
override fun showVoiceMessageUI() {
|
override fun showVoiceMessageUI() {
|
||||||
inputBarRecordingView.show()
|
inputBarRecordingView.show()
|
||||||
inputBar.alpha = 0.0f
|
inputBar.alpha = 0.0f
|
||||||
@ -167,7 +184,6 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun handleInputBarRecordingViewHidden() {
|
override fun handleInputBarRecordingViewHidden() {
|
||||||
Log.d("Test", "Here")
|
|
||||||
inputBar.alpha = 1.0f
|
inputBar.alpha = 1.0f
|
||||||
val animation = ValueAnimator.ofObject(FloatEvaluator(), 0.0f, 1.0f)
|
val animation = ValueAnimator.ofObject(FloatEvaluator(), 0.0f, 1.0f)
|
||||||
animation.duration = 250L
|
animation.duration = 250L
|
||||||
|
@ -2,6 +2,7 @@ package org.thoughtcrime.securesms.conversation.v2.input_bar
|
|||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.util.AttributeSet
|
import android.util.AttributeSet
|
||||||
|
import android.util.Log
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.MotionEvent
|
import android.view.MotionEvent
|
||||||
import android.widget.RelativeLayout
|
import android.widget.RelativeLayout
|
||||||
@ -29,12 +30,11 @@ class InputBar : RelativeLayout, InputBarEditTextDelegate {
|
|||||||
// Attachments button
|
// Attachments button
|
||||||
attachmentsButtonContainer.addView(attachmentsButton)
|
attachmentsButtonContainer.addView(attachmentsButton)
|
||||||
attachmentsButton.layoutParams = RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT)
|
attachmentsButton.layoutParams = RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT)
|
||||||
|
attachmentsButton.onPress = { toggleAttachmentOptions() }
|
||||||
// Microphone button
|
// Microphone button
|
||||||
microphoneOrSendButtonContainer.addView(microphoneButton)
|
microphoneOrSendButtonContainer.addView(microphoneButton)
|
||||||
microphoneButton.layoutParams = RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT)
|
microphoneButton.layoutParams = RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT)
|
||||||
microphoneButton.onLongPress = {
|
microphoneButton.onLongPress = { showVoiceMessageUI() }
|
||||||
showVoiceMessageUI()
|
|
||||||
}
|
|
||||||
microphoneButton.onMove = { delegate?.onMicrophoneButtonMove(it) }
|
microphoneButton.onMove = { delegate?.onMicrophoneButtonMove(it) }
|
||||||
microphoneButton.onCancel = { delegate?.onMicrophoneButtonCancel(it) }
|
microphoneButton.onCancel = { delegate?.onMicrophoneButtonCancel(it) }
|
||||||
microphoneButton.onUp = { delegate?.onMicrophoneButtonUp(it) }
|
microphoneButton.onUp = { delegate?.onMicrophoneButtonUp(it) }
|
||||||
@ -63,6 +63,10 @@ class InputBar : RelativeLayout, InputBarEditTextDelegate {
|
|||||||
delegate?.inputBarHeightChanged(newHeight)
|
delegate?.inputBarHeightChanged(newHeight)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun toggleAttachmentOptions() {
|
||||||
|
delegate?.toggleAttachmentOptions()
|
||||||
|
}
|
||||||
|
|
||||||
private fun showVoiceMessageUI() {
|
private fun showVoiceMessageUI() {
|
||||||
delegate?.showVoiceMessageUI()
|
delegate?.showVoiceMessageUI()
|
||||||
}
|
}
|
||||||
@ -72,6 +76,7 @@ class InputBar : RelativeLayout, InputBarEditTextDelegate {
|
|||||||
interface InputBarDelegate {
|
interface InputBarDelegate {
|
||||||
|
|
||||||
fun inputBarHeightChanged(newValue: Int)
|
fun inputBarHeightChanged(newValue: Int)
|
||||||
|
fun toggleAttachmentOptions()
|
||||||
fun showVoiceMessageUI()
|
fun showVoiceMessageUI()
|
||||||
fun onMicrophoneButtonMove(event: MotionEvent)
|
fun onMicrophoneButtonMove(event: MotionEvent)
|
||||||
fun onMicrophoneButtonCancel(event: MotionEvent)
|
fun onMicrophoneButtonCancel(event: MotionEvent)
|
||||||
|
@ -40,7 +40,8 @@ class InputBarButton : RelativeLayout {
|
|||||||
var onLongPress: (() -> Unit)? = null
|
var onLongPress: (() -> Unit)? = null
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
val animationDuration = 250.toLong()
|
const val animationDuration = 250.toLong()
|
||||||
|
const val longPressDurationThreshold = 250L // ms
|
||||||
}
|
}
|
||||||
|
|
||||||
private val expandedImageViewPosition by lazy { PointF(0.0f, 0.0f) }
|
private val expandedImageViewPosition by lazy { PointF(0.0f, 0.0f) }
|
||||||
@ -148,7 +149,7 @@ class InputBarButton : RelativeLayout {
|
|||||||
longPressCallback?.let { gestureHandler.removeCallbacks(it) }
|
longPressCallback?.let { gestureHandler.removeCallbacks(it) }
|
||||||
val newLongPressCallback = Runnable { onLongPress?.invoke() }
|
val newLongPressCallback = Runnable { onLongPress?.invoke() }
|
||||||
this.longPressCallback = newLongPressCallback
|
this.longPressCallback = newLongPressCallback
|
||||||
gestureHandler.postDelayed(newLongPressCallback, VisibleMessageView.longPressDurationThreshold)
|
gestureHandler.postDelayed(newLongPressCallback, InputBarButton.longPressDurationThreshold)
|
||||||
onDownTimestamp = Date().time
|
onDownTimestamp = Date().time
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -165,7 +166,7 @@ class InputBarButton : RelativeLayout {
|
|||||||
private fun onUp(event: MotionEvent) {
|
private fun onUp(event: MotionEvent) {
|
||||||
onUp?.invoke(event)
|
onUp?.invoke(event)
|
||||||
collapse()
|
collapse()
|
||||||
if ((Date().time - onDownTimestamp) < VisibleMessageView.longPressDurationThreshold) {
|
if ((Date().time - onDownTimestamp) < InputBarButton.longPressDurationThreshold) {
|
||||||
longPressCallback?.let { gestureHandler.removeCallbacks(it) }
|
longPressCallback?.let { gestureHandler.removeCallbacks(it) }
|
||||||
onPress?.invoke()
|
onPress?.invoke()
|
||||||
}
|
}
|
||||||
|
@ -24,25 +24,29 @@
|
|||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
android:id="@+id/gifButtonContainer"
|
android:id="@+id/gifButtonContainer"
|
||||||
android:layout_width="@dimen/input_bar_button_expanded_size"
|
android:layout_width="@dimen/input_bar_button_expanded_size"
|
||||||
android:layout_height="@dimen/input_bar_button_expanded_size" />
|
android:layout_height="@dimen/input_bar_button_expanded_size"
|
||||||
|
android:alpha="0" />
|
||||||
|
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
android:id="@+id/documentButtonContainer"
|
android:id="@+id/documentButtonContainer"
|
||||||
android:layout_marginTop="8dp"
|
android:layout_marginTop="8dp"
|
||||||
android:layout_width="@dimen/input_bar_button_expanded_size"
|
android:layout_width="@dimen/input_bar_button_expanded_size"
|
||||||
android:layout_height="@dimen/input_bar_button_expanded_size" />
|
android:layout_height="@dimen/input_bar_button_expanded_size"
|
||||||
|
android:alpha="0" />
|
||||||
|
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
android:id="@+id/libraryButtonContainer"
|
android:id="@+id/libraryButtonContainer"
|
||||||
android:layout_marginTop="8dp"
|
android:layout_marginTop="8dp"
|
||||||
android:layout_width="@dimen/input_bar_button_expanded_size"
|
android:layout_width="@dimen/input_bar_button_expanded_size"
|
||||||
android:layout_height="@dimen/input_bar_button_expanded_size" />
|
android:layout_height="@dimen/input_bar_button_expanded_size"
|
||||||
|
android:alpha="0" />
|
||||||
|
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
android:id="@+id/cameraButtonContainer"
|
android:id="@+id/cameraButtonContainer"
|
||||||
android:layout_marginTop="8dp"
|
android:layout_marginTop="8dp"
|
||||||
android:layout_width="@dimen/input_bar_button_expanded_size"
|
android:layout_width="@dimen/input_bar_button_expanded_size"
|
||||||
android:layout_height="@dimen/input_bar_button_expanded_size" />
|
android:layout_height="@dimen/input_bar_button_expanded_size"
|
||||||
|
android:alpha="0" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user