mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-24 16:57:50 +00:00
Tweak UI
This commit is contained in:
parent
5a2baae15d
commit
b7000aa58b
@ -72,7 +72,7 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe
|
||||
|
||||
private val screenWidth by lazy { Resources.getSystem().displayMetrics.widthPixels }
|
||||
|
||||
private val gifButton by lazy { InputBarButton(this, R.drawable.ic_gif_white_24dp, hasOpaqueBackground = true) }
|
||||
private val gifButton by lazy { InputBarButton(this, R.drawable.ic_gif_white_24dp, hasOpaqueBackground = true, isGIFButton = true) }
|
||||
private val documentButton by lazy { InputBarButton(this, R.drawable.ic_document_small_dark, hasOpaqueBackground = true) }
|
||||
private val libraryButton by lazy { InputBarButton(this, R.drawable.ic_baseline_photo_library_24, hasOpaqueBackground = true) }
|
||||
private val cameraButton by lazy { InputBarButton(this, R.drawable.ic_baseline_photo_camera_24, hasOpaqueBackground = true) }
|
||||
|
@ -28,6 +28,7 @@ class InputBarButton : RelativeLayout {
|
||||
private val gestureHandler = Handler(Looper.getMainLooper())
|
||||
private var isSendButton = false
|
||||
private var hasOpaqueBackground = false
|
||||
private var isGIFButton = false
|
||||
@DrawableRes private var iconID = 0
|
||||
private var longPressCallback: Runnable? = null
|
||||
private var onDownTimestamp = 0L
|
||||
@ -71,7 +72,7 @@ class InputBarButton : RelativeLayout {
|
||||
|
||||
private val imageView by lazy {
|
||||
val result = ImageView(context)
|
||||
val size = toPx(16, resources)
|
||||
val size = if (isGIFButton) toPx(24, resources) else toPx(16, resources)
|
||||
result.layoutParams = LayoutParams(size, size)
|
||||
result.scaleType = ImageView.ScaleType.CENTER_INSIDE
|
||||
result.setImageResource(iconID)
|
||||
@ -84,10 +85,12 @@ class InputBarButton : RelativeLayout {
|
||||
constructor(context: Context, attrs: AttributeSet) : super(context, attrs) { throw IllegalAccessException("Use InputBarButton(context:iconID:) instead.") }
|
||||
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) { throw IllegalAccessException("Use InputBarButton(context:iconID:) instead.") }
|
||||
|
||||
constructor(context: Context, @DrawableRes iconID: Int, isSendButton: Boolean = false, hasOpaqueBackground: Boolean = false) : super(context) {
|
||||
constructor(context: Context, @DrawableRes iconID: Int, isSendButton: Boolean = false,
|
||||
hasOpaqueBackground: Boolean = false, isGIFButton: Boolean = false) : super(context) {
|
||||
this.isSendButton = isSendButton
|
||||
this.iconID = iconID
|
||||
this.hasOpaqueBackground = hasOpaqueBackground
|
||||
this.isGIFButton = isGIFButton
|
||||
val size = resources.getDimension(R.dimen.input_bar_button_expanded_size).toInt()
|
||||
val layoutParams = LayoutParams(size, size)
|
||||
this.layoutParams = layoutParams
|
||||
|
@ -4,7 +4,10 @@ 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.util.Log
|
||||
import android.view.LayoutInflater
|
||||
import android.widget.RelativeLayout
|
||||
import androidx.core.content.res.ResourcesCompat
|
||||
@ -14,8 +17,13 @@ import network.loki.messenger.R
|
||||
import org.thoughtcrime.securesms.loki.utilities.animateSizeChange
|
||||
import org.thoughtcrime.securesms.loki.utilities.disableClipping
|
||||
import org.thoughtcrime.securesms.loki.utilities.toPx
|
||||
import org.thoughtcrime.securesms.util.DateUtils
|
||||
import java.util.*
|
||||
import kotlin.math.roundToLong
|
||||
|
||||
class InputBarRecordingView : RelativeLayout {
|
||||
private var startTimestamp = 0L
|
||||
private val snHandler = Handler(Looper.getMainLooper())
|
||||
|
||||
constructor(context: Context) : super(context) { initialize() }
|
||||
constructor(context: Context, attrs: AttributeSet) : super(context, attrs) { initialize() }
|
||||
@ -27,6 +35,7 @@ class InputBarRecordingView : RelativeLayout {
|
||||
}
|
||||
|
||||
fun show() {
|
||||
startTimestamp = Date().time
|
||||
isVisible = true
|
||||
alpha = 0.0f
|
||||
val animation = ValueAnimator.ofObject(FloatEvaluator(), 0.0f, 1.0f)
|
||||
@ -38,6 +47,7 @@ class InputBarRecordingView : RelativeLayout {
|
||||
animateDotView()
|
||||
pulse()
|
||||
animateLockViewUp()
|
||||
updateTimer()
|
||||
}
|
||||
|
||||
private fun animateDotView() {
|
||||
@ -79,6 +89,13 @@ class InputBarRecordingView : RelativeLayout {
|
||||
animation.start()
|
||||
}
|
||||
|
||||
private fun updateTimer() {
|
||||
Log.d("Test", "${Date().time - startTimestamp}")
|
||||
val duration = (Date().time - startTimestamp) / 1000L
|
||||
recordingViewDurationTextView.text = DateUtils.formatElapsedTime(duration)
|
||||
snHandler.postDelayed({ updateTimer() }, 500)
|
||||
}
|
||||
|
||||
fun lock() {
|
||||
val fadeOutAnimation = ValueAnimator.ofObject(FloatEvaluator(), 1.0f, 0.0f)
|
||||
fadeOutAnimation.duration = 250L
|
||||
|
@ -38,6 +38,7 @@
|
||||
android:backgroundTint="@color/destructive" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/recordingViewDurationTextView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="@dimen/small_spacing"
|
||||
|
Loading…
x
Reference in New Issue
Block a user