Themed colors for waveform seek bar and general cleanup.

pull/365/head
Anton Chekulaev 5 years ago
parent 066234a30a
commit efbcd0b207

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

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

@ -84,6 +84,7 @@
<attr name="conversation_item_sticky_date_background" format="reference" /> <attr name="conversation_item_sticky_date_background" format="reference" />
<attr name="conversation_item_sticky_date_text_color" format="color" /> <attr name="conversation_item_sticky_date_text_color" format="color" />
<attr name="conversation_item_image_outline_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_info_icon" format="reference" />
<attr name="dialog_alert_icon" format="reference" /> <attr name="dialog_alert_icon" format="reference" />

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

@ -7,7 +7,6 @@ import android.graphics.PorterDuff
import android.graphics.drawable.AnimatedVectorDrawable import android.graphics.drawable.AnimatedVectorDrawable
import android.media.MediaDataSource import android.media.MediaDataSource
import android.os.Build import android.os.Build
import android.os.Handler
import android.util.AttributeSet import android.util.AttributeSet
import android.view.View import android.view.View
import android.view.View.OnTouchListener import android.view.View.OnTouchListener
@ -37,7 +36,6 @@ import org.thoughtcrime.securesms.mms.PartAuthority
import org.thoughtcrime.securesms.mms.SlideClickListener import org.thoughtcrime.securesms.mms.SlideClickListener
import java.io.IOException import java.io.IOException
import java.io.InputStream import java.io.InputStream
import java.lang.Exception
import java.util.* import java.util.*
import java.util.concurrent.TimeUnit import java.util.concurrent.TimeUnit
@ -193,10 +191,7 @@ class MessageAudioView: FrameLayout, AudioSlidePlayer.Listener {
downloadProgress.barColor = foregroundTint downloadProgress.barColor = foregroundTint
totalDuration.setTextColor(foregroundTint) totalDuration.setTextColor(foregroundTint)
// val colorFilter = createBlendModeColorFilterCompat(foregroundTint, BlendModeCompat.SRC_IN) // Seek bar's progress color is set from the XML template. Whereas the background is computed.
// seekBar.progressDrawable.colorFilter = colorFilter
// seekBar.thumb.colorFilter = colorFilter
seekBar.barProgressColor = foregroundTint
seekBar.barBackgroundColor = ColorUtils.blendARGB(foregroundTint, backgroundTint, 0.75f) seekBar.barBackgroundColor = ColorUtils.blendARGB(foregroundTint, backgroundTint, 0.75f)
} }
@ -210,26 +205,10 @@ class MessageAudioView: FrameLayout, AudioSlidePlayer.Listener {
if (playButton.visibility != View.VISIBLE) { if (playButton.visibility != View.VISIBLE) {
togglePauseToPlay() togglePauseToPlay()
} }
// if (seekBar.progress + 5 >= seekBar.max) {
// backwardsCounter = 4
// onProgress(0.0, 0)
// }
} }
override fun onPlayerProgress(player: AudioSlidePlayer, progress: Double, millis: Long) { override fun onPlayerProgress(player: AudioSlidePlayer, progress: Double, millis: Long) {
// val seekProgress = floor(progress * seekBar.max).toInt()
//TODO Update text.
seekBar.progress = progress.toFloat() 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) { 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() } return Random(seed.toLong()).let { (0 until frames).map { i -> it.nextFloat() }.toFloatArray() }
} }
var rmsValues: FloatArray = floatArrayOf() var rmsValues: FloatArray
var totalDurationMs: Long = -1 var totalDurationMs: Long = -1
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {

@ -6,8 +6,6 @@ import android.graphics.Canvas
import android.graphics.Color import android.graphics.Color
import android.graphics.Paint import android.graphics.Paint
import android.graphics.RectF import android.graphics.RectF
import android.os.Handler
import android.os.Looper
import android.util.AttributeSet import android.util.AttributeSet
import android.util.Log import android.util.Log
import android.util.TypedValue import android.util.TypedValue
@ -125,28 +123,23 @@ class WaveformSeekBar : View {
barGap = typedAttrs.getDimension(R.styleable.WaveformSeekBar_bar_gap, barGap) barGap = typedAttrs.getDimension(R.styleable.WaveformSeekBar_bar_gap, barGap)
barCornerRadius = typedAttrs.getDimension( barCornerRadius = typedAttrs.getDimension(
R.styleable.WaveformSeekBar_bar_corner_radius, R.styleable.WaveformSeekBar_bar_corner_radius,
barCornerRadius barCornerRadius)
)
barMinHeight = barMinHeight =
typedAttrs.getDimension(R.styleable.WaveformSeekBar_bar_min_height, barMinHeight) typedAttrs.getDimension(R.styleable.WaveformSeekBar_bar_min_height, barMinHeight)
barBackgroundColor = typedAttrs.getColor( barBackgroundColor = typedAttrs.getColor(
R.styleable.WaveformSeekBar_bar_background_color, R.styleable.WaveformSeekBar_bar_background_color,
barBackgroundColor barBackgroundColor)
)
barProgressColor = barProgressColor =
typedAttrs.getColor(R.styleable.WaveformSeekBar_bar_progress_color, barProgressColor) typedAttrs.getColor(R.styleable.WaveformSeekBar_bar_progress_color, barProgressColor)
progress = typedAttrs.getFloat(R.styleable.WaveformSeekBar_progress, progress) progress = typedAttrs.getFloat(R.styleable.WaveformSeekBar_progress, progress)
barGravity = barGravity = WaveGravity.fromString(
WaveGravity.fromString( typedAttrs.getString(R.styleable.WaveformSeekBar_bar_gravity))
typedAttrs.getString(R.styleable.WaveformSeekBar_bar_gravity)
)
typedAttrs.recycle() typedAttrs.recycle()
} }
override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) { override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) {
super.onSizeChanged(w, h, oldw, oldh) super.onSizeChanged(w, h, oldw, oldh)
canvasWidth = w canvasWidth = w
canvasHeight = h canvasHeight = h
invalidate() invalidate()
@ -188,7 +181,6 @@ class WaveformSeekBar : View {
when (event.action) { when (event.action) {
MotionEvent.ACTION_DOWN -> { MotionEvent.ACTION_DOWN -> {
userSeeking = true userSeeking = true
// preUserSeekingProgress = _progress
if (isParentScrolling()) { if (isParentScrolling()) {
touchDownX = event.x touchDownX = event.x
} else { } else {
@ -207,7 +199,6 @@ class WaveformSeekBar : View {
} }
MotionEvent.ACTION_CANCEL -> { MotionEvent.ACTION_CANCEL -> {
userSeeking = false userSeeking = false
// updateProgress(preUserSeekingProgress, false)
} }
} }
return true return true

Loading…
Cancel
Save