Themed colors for waveform seek bar and general cleanup.

This commit is contained in:
Anton Chekulaev 2020-10-12 18:43:35 +11:00
parent 066234a30a
commit efbcd0b207
6 changed files with 12 additions and 37 deletions

View File

@ -70,7 +70,6 @@
</org.thoughtcrime.securesms.components.AnimatingToggle>
<!-- TODO: Extract styling attributes into a theme. -->
<org.thoughtcrime.securesms.loki.views.WaveformSeekBar
android:id="@+id/seek"
android:layout_width="0dp"
@ -79,6 +78,7 @@
android:layout_gravity="center_vertical"
android:layout_marginStart="4dp"
android:layout_marginEnd="4dp"
app:bar_progress_color="?conversation_item_audio_seek_bar_color"
app:bar_gravity="center"
app:bar_width="4dp"
app:bar_corner_radius="2dp"

View File

@ -27,6 +27,8 @@
<item name="media_keyboard_button_color">@color/core_grey_60</item>
<item name="menu_info_icon">@drawable/ic_outline_info_24</item>
<item name="conversation_item_audio_seek_bar_color">?colorControlNormal</item>
</style>
<style name="Theme.Session.DayNight" parent="Theme.Session.Light">

View File

@ -84,6 +84,7 @@
<attr name="conversation_item_sticky_date_background" format="reference" />
<attr name="conversation_item_sticky_date_text_color" format="color" />
<attr name="conversation_item_image_outline_color" format="color" />
<attr name="conversation_item_audio_seek_bar_color" format="reference|color" />
<attr name="dialog_info_icon" format="reference" />
<attr name="dialog_alert_icon" format="reference" />

View File

@ -87,6 +87,8 @@
<item name="quick_camera_icon">@drawable/ic_baseline_photo_camera_24</item>
<item name="quick_mic_icon">@drawable/ic_baseline_mic_24</item>
<item name="conversation_item_audio_seek_bar_color">?colorAccent</item>
</style>
<!-- This should be the default theme for the application. -->

View File

@ -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) {

View File

@ -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