Waveform fill color attribute for message audio view.

This commit is contained in:
Anton Chekulaev 2020-10-12 19:01:49 +11:00
parent efbcd0b207
commit 793e6bf10f
6 changed files with 9 additions and 4 deletions

View File

@ -41,7 +41,8 @@
android:paddingBottom="15dp" android:paddingBottom="15dp"
app:widgetBackground="?conversation_item_bubble_background" app:widgetBackground="?conversation_item_bubble_background"
app:foregroundTintColor="?android:colorControlNormal" app:foregroundTintColor="?android:colorControlNormal"
app:backgroundTintColor="?conversation_item_bubble_background"/> app:backgroundTintColor="?conversation_item_bubble_background"
app:waveformFillColor="?conversation_item_audio_seek_bar_color"/>
<org.thoughtcrime.securesms.components.DocumentView <org.thoughtcrime.securesms.components.DocumentView
android:id="@+id/attachment_document" android:id="@+id/attachment_document"

View File

@ -9,4 +9,5 @@
android:visibility="gone" android:visibility="gone"
app:foregroundTintColor="?android:colorControlNormal" app:foregroundTintColor="?android:colorControlNormal"
app:backgroundTintColor="?message_received_background_color" app:backgroundTintColor="?message_received_background_color"
app:waveformFillColor="?conversation_item_audio_seek_bar_color"
tools:visibility="visible"/> tools:visibility="visible"/>

View File

@ -7,4 +7,5 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
app:foregroundTintColor="?android:colorControlNormal" app:foregroundTintColor="?android:colorControlNormal"
app:backgroundTintColor="?message_sent_background_color" app:backgroundTintColor="?message_sent_background_color"
app:waveformFillColor="?conversation_item_audio_seek_bar_color"
android:visibility="gone"/> android:visibility="gone"/>

View File

@ -78,7 +78,6 @@
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"

View File

@ -174,6 +174,7 @@
<attr name="widgetBackground" format="color"/> <attr name="widgetBackground" format="color"/>
<attr name="foregroundTintColor" format="color" /> <attr name="foregroundTintColor" format="color" />
<attr name="backgroundTintColor" format="color" /> <attr name="backgroundTintColor" format="color" />
<attr name="waveformFillColor" format="reference|color" />
</declare-styleable> </declare-styleable>
<declare-styleable name="CircleColorImageView"> <declare-styleable name="CircleColorImageView">

View File

@ -117,7 +117,8 @@ class MessageAudioView: FrameLayout, AudioSlidePlayer.Listener {
if (attrs != null) { if (attrs != null) {
val typedArray = context.theme.obtainStyledAttributes(attrs, R.styleable.MessageAudioView, 0, 0) val typedArray = context.theme.obtainStyledAttributes(attrs, R.styleable.MessageAudioView, 0, 0)
setTint(typedArray.getColor(R.styleable.MessageAudioView_foregroundTintColor, Color.WHITE), setTint(typedArray.getColor(R.styleable.MessageAudioView_foregroundTintColor, Color.WHITE),
typedArray.getColor(R.styleable.MessageAudioView_backgroundTintColor, Color.WHITE)) typedArray.getColor(R.styleable.MessageAudioView_backgroundTintColor, Color.WHITE),
typedArray.getColor(R.styleable.MessageAudioView_waveformFillColor, Color.WHITE))
container.setBackgroundColor(typedArray.getColor(R.styleable.MessageAudioView_widgetBackground, Color.TRANSPARENT)) container.setBackgroundColor(typedArray.getColor(R.styleable.MessageAudioView_widgetBackground, Color.TRANSPARENT))
typedArray.recycle() typedArray.recycle()
} }
@ -181,7 +182,7 @@ class MessageAudioView: FrameLayout, AudioSlidePlayer.Listener {
downloadListener = listener downloadListener = listener
} }
fun setTint(@ColorInt foregroundTint: Int, @ColorInt backgroundTint: Int) { fun setTint(@ColorInt foregroundTint: Int, @ColorInt backgroundTint: Int, @ColorInt waveformFill: Int) {
playButton.backgroundTintList = ColorStateList.valueOf(foregroundTint) playButton.backgroundTintList = ColorStateList.valueOf(foregroundTint)
playButton.imageTintList = ColorStateList.valueOf(backgroundTint) playButton.imageTintList = ColorStateList.valueOf(backgroundTint)
pauseButton.backgroundTintList = ColorStateList.valueOf(foregroundTint) pauseButton.backgroundTintList = ColorStateList.valueOf(foregroundTint)
@ -192,6 +193,7 @@ class MessageAudioView: FrameLayout, AudioSlidePlayer.Listener {
totalDuration.setTextColor(foregroundTint) totalDuration.setTextColor(foregroundTint)
// Seek bar's progress color is set from the XML template. Whereas the background is computed. // Seek bar's progress color is set from the XML template. Whereas the background is computed.
seekBar.barProgressColor = waveformFill
seekBar.barBackgroundColor = ColorUtils.blendARGB(foregroundTint, backgroundTint, 0.75f) seekBar.barBackgroundColor = ColorUtils.blendARGB(foregroundTint, backgroundTint, 0.75f)
} }