From efbcd0b2076c5b9e7934c07027af794bbedbef42 Mon Sep 17 00:00:00 2001 From: Anton Chekulaev Date: Mon, 12 Oct 2020 18:43:35 +1100 Subject: [PATCH] Themed colors for waveform seek bar and general cleanup. --- res/layout/message_audio_view.xml | 2 +- res/values-notnight-v21/themes.xml | 2 ++ res/values/attrs.xml | 1 + res/values/themes.xml | 2 ++ .../securesms/loki/views/MessageAudioView.kt | 25 ++----------------- .../securesms/loki/views/WaveformSeekBar.kt | 17 +++---------- 6 files changed, 12 insertions(+), 37 deletions(-) diff --git a/res/layout/message_audio_view.xml b/res/layout/message_audio_view.xml index 6f14afd919..c2d2d31700 100644 --- a/res/layout/message_audio_view.xml +++ b/res/layout/message_audio_view.xml @@ -70,7 +70,6 @@ - @color/core_grey_60 @drawable/ic_outline_info_24 + + ?colorControlNormal diff --git a/src/org/thoughtcrime/securesms/loki/views/MessageAudioView.kt b/src/org/thoughtcrime/securesms/loki/views/MessageAudioView.kt index c1b00da652..29b160ccba 100644 --- a/src/org/thoughtcrime/securesms/loki/views/MessageAudioView.kt +++ b/src/org/thoughtcrime/securesms/loki/views/MessageAudioView.kt @@ -7,7 +7,6 @@ import android.graphics.PorterDuff import android.graphics.drawable.AnimatedVectorDrawable import android.media.MediaDataSource import android.os.Build -import android.os.Handler import android.util.AttributeSet import android.view.View import android.view.View.OnTouchListener @@ -37,7 +36,6 @@ import org.thoughtcrime.securesms.mms.PartAuthority import org.thoughtcrime.securesms.mms.SlideClickListener import java.io.IOException import java.io.InputStream -import java.lang.Exception import java.util.* import java.util.concurrent.TimeUnit @@ -193,10 +191,7 @@ class MessageAudioView: FrameLayout, AudioSlidePlayer.Listener { downloadProgress.barColor = foregroundTint totalDuration.setTextColor(foregroundTint) -// val colorFilter = createBlendModeColorFilterCompat(foregroundTint, BlendModeCompat.SRC_IN) -// seekBar.progressDrawable.colorFilter = colorFilter -// seekBar.thumb.colorFilter = colorFilter - seekBar.barProgressColor = foregroundTint + // Seek bar's progress color is set from the XML template. Whereas the background is computed. seekBar.barBackgroundColor = ColorUtils.blendARGB(foregroundTint, backgroundTint, 0.75f) } @@ -210,26 +205,10 @@ class MessageAudioView: FrameLayout, AudioSlidePlayer.Listener { if (playButton.visibility != View.VISIBLE) { togglePauseToPlay() } - -// if (seekBar.progress + 5 >= seekBar.max) { -// backwardsCounter = 4 -// onProgress(0.0, 0) -// } } override fun onPlayerProgress(player: AudioSlidePlayer, progress: Double, millis: Long) { -// val seekProgress = floor(progress * seekBar.max).toInt() - //TODO Update text. seekBar.progress = progress.toFloat() -// if (/*seekProgress > 1f || */backwardsCounter > 3) { -// backwardsCounter = 0 -// seekBar.progress = 1f -// timestamp.text = String.format("%02d:%02d", -// TimeUnit.MILLISECONDS.toMinutes(millis), -// TimeUnit.MILLISECONDS.toSeconds(millis)) -// } else { -// backwardsCounter++ -// } } override fun setFocusable(focusable: Boolean) { @@ -294,7 +273,7 @@ class MessageAudioView: FrameLayout, AudioSlidePlayer.Listener { return Random(seed.toLong()).let { (0 until frames).map { i -> it.nextFloat() }.toFloatArray() } } - var rmsValues: FloatArray = floatArrayOf() + var rmsValues: FloatArray var totalDurationMs: Long = -1 if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) { diff --git a/src/org/thoughtcrime/securesms/loki/views/WaveformSeekBar.kt b/src/org/thoughtcrime/securesms/loki/views/WaveformSeekBar.kt index 411e1793b0..dc7c83eb46 100644 --- a/src/org/thoughtcrime/securesms/loki/views/WaveformSeekBar.kt +++ b/src/org/thoughtcrime/securesms/loki/views/WaveformSeekBar.kt @@ -6,8 +6,6 @@ import android.graphics.Canvas import android.graphics.Color import android.graphics.Paint import android.graphics.RectF -import android.os.Handler -import android.os.Looper import android.util.AttributeSet import android.util.Log import android.util.TypedValue @@ -125,28 +123,23 @@ class WaveformSeekBar : View { barGap = typedAttrs.getDimension(R.styleable.WaveformSeekBar_bar_gap, barGap) barCornerRadius = typedAttrs.getDimension( R.styleable.WaveformSeekBar_bar_corner_radius, - barCornerRadius - ) + barCornerRadius) barMinHeight = typedAttrs.getDimension(R.styleable.WaveformSeekBar_bar_min_height, barMinHeight) barBackgroundColor = typedAttrs.getColor( R.styleable.WaveformSeekBar_bar_background_color, - barBackgroundColor - ) + barBackgroundColor) barProgressColor = typedAttrs.getColor(R.styleable.WaveformSeekBar_bar_progress_color, barProgressColor) progress = typedAttrs.getFloat(R.styleable.WaveformSeekBar_progress, progress) - barGravity = - WaveGravity.fromString( - typedAttrs.getString(R.styleable.WaveformSeekBar_bar_gravity) - ) + barGravity = WaveGravity.fromString( + typedAttrs.getString(R.styleable.WaveformSeekBar_bar_gravity)) typedAttrs.recycle() } override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) { super.onSizeChanged(w, h, oldw, oldh) - canvasWidth = w canvasHeight = h invalidate() @@ -188,7 +181,6 @@ class WaveformSeekBar : View { when (event.action) { MotionEvent.ACTION_DOWN -> { userSeeking = true -// preUserSeekingProgress = _progress if (isParentScrolling()) { touchDownX = event.x } else { @@ -207,7 +199,6 @@ class WaveformSeekBar : View { } MotionEvent.ACTION_CANCEL -> { userSeeking = false -// updateProgress(preUserSeekingProgress, false) } } return true