Make style consistent across platforms

This commit is contained in:
nielsandriesse 2020-10-29 10:16:49 +11:00
parent c9ecd0ded3
commit e667c6ee7e
7 changed files with 28 additions and 23 deletions

View File

@ -41,8 +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:waveformFillColor="?conversation_item_audio_seek_bar_color_outgoing"
app:waveformFillColor="?conversation_item_audio_seek_bar_color"/> app:waveformBackgroundColor="?conversation_item_audio_seek_bar_background_color"/>
<org.thoughtcrime.securesms.components.DocumentView <org.thoughtcrime.securesms.components.DocumentView
android:id="@+id/attachment_document" android:id="@+id/attachment_document"

View File

@ -8,6 +8,6 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:visibility="gone" android:visibility="gone"
app:foregroundTintColor="?android:colorControlNormal" app:foregroundTintColor="?android:colorControlNormal"
app:backgroundTintColor="?message_received_background_color" app:waveformFillColor="?conversation_item_audio_seek_bar_color_incoming"
app:waveformFillColor="?conversation_item_audio_seek_bar_color" app:waveformBackgroundColor="?conversation_item_audio_seek_bar_background_color"
tools:visibility="visible"/> tools:visibility="visible"/>

View File

@ -6,6 +6,6 @@
android:layout_width="210dp" android:layout_width="210dp"
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:waveformFillColor="?conversation_item_audio_seek_bar_color_outgoing"
app:waveformFillColor="?conversation_item_audio_seek_bar_color" app:waveformBackgroundColor="?conversation_item_audio_seek_bar_background_color"
android:visibility="gone"/> android:visibility="gone"/>

View File

@ -28,7 +28,8 @@
<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> <item name="conversation_item_audio_seek_bar_color_incoming">@color/accent</item>
<item name="conversation_item_audio_seek_bar_color_outgoing">@color/white</item>
</style> </style>
<style name="Theme.Session.DayNight" parent="Theme.Session.Light"> <style name="Theme.Session.DayNight" parent="Theme.Session.Light">

View File

@ -84,7 +84,9 @@
<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="conversation_item_audio_seek_bar_color_incoming" format="reference|color" />
<attr name="conversation_item_audio_seek_bar_color_outgoing" format="reference|color" />
<attr name="conversation_item_audio_seek_bar_background_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" />
@ -173,8 +175,8 @@
<declare-styleable name="MessageAudioView"> <declare-styleable name="MessageAudioView">
<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="waveformFillColor" format="reference|color" /> <attr name="waveformFillColor" format="reference|color" />
<attr name="waveformBackgroundColor" format="reference|color" />
</declare-styleable> </declare-styleable>
<declare-styleable name="CircleColorImageView"> <declare-styleable name="CircleColorImageView">

View File

@ -88,7 +88,9 @@
<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> <item name="conversation_item_audio_seek_bar_color_incoming">@color/accent</item>
<item name="conversation_item_audio_seek_bar_color_outgoing">@color/accent</item>
<item name="conversation_item_audio_seek_bar_background_color">@color/text</item>
</style> </style>
<!-- This should be the default theme for the application. --> <!-- This should be the default theme for the application. -->

View File

@ -30,6 +30,7 @@ import org.thoughtcrime.securesms.database.DatabaseFactory
import org.thoughtcrime.securesms.events.PartProgressEvent import org.thoughtcrime.securesms.events.PartProgressEvent
import org.thoughtcrime.securesms.logging.Log import org.thoughtcrime.securesms.logging.Log
import org.thoughtcrime.securesms.loki.api.PrepareAttachmentAudioExtrasJob import org.thoughtcrime.securesms.loki.api.PrepareAttachmentAudioExtrasJob
import org.thoughtcrime.securesms.loki.utilities.getColorWithID
import org.thoughtcrime.securesms.mms.AudioSlide import org.thoughtcrime.securesms.mms.AudioSlide
import org.thoughtcrime.securesms.mms.SlideClickListener import org.thoughtcrime.securesms.mms.SlideClickListener
import java.io.IOException import java.io.IOException
@ -115,8 +116,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_waveformFillColor, Color.WHITE),
typedArray.getColor(R.styleable.MessageAudioView_waveformFillColor, Color.WHITE)) typedArray.getColor(R.styleable.MessageAudioView_waveformBackgroundColor, 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()
} }
@ -182,23 +183,22 @@ class MessageAudioView: FrameLayout, AudioSlidePlayer.Listener {
downloadListener = listener downloadListener = listener
} }
fun setTint(@ColorInt foregroundTint: Int, @ColorInt backgroundTint: Int, @ColorInt waveformFill: Int) { fun setTint(@ColorInt foregroundTint: Int, @ColorInt waveformFill: Int, @ColorInt waveformBackground: Int) {
playButton.backgroundTintList = ColorStateList.valueOf(foregroundTint) playButton.backgroundTintList = ColorStateList.valueOf(resources.getColorWithID(R.color.white, context.theme))
playButton.imageTintList = ColorStateList.valueOf(backgroundTint) playButton.imageTintList = ColorStateList.valueOf(resources.getColorWithID(R.color.black, context.theme))
pauseButton.backgroundTintList = ColorStateList.valueOf(foregroundTint) pauseButton.backgroundTintList = ColorStateList.valueOf(resources.getColorWithID(R.color.white, context.theme))
pauseButton.imageTintList = ColorStateList.valueOf(backgroundTint) pauseButton.imageTintList = ColorStateList.valueOf(resources.getColorWithID(R.color.black, context.theme))
downloadButton.setColorFilter(foregroundTint, PorterDuff.Mode.SRC_IN) downloadButton.setColorFilter(foregroundTint, PorterDuff.Mode.SRC_IN)
downloadProgress.backgroundTintList = ColorStateList.valueOf(foregroundTint) downloadProgress.backgroundTintList = ColorStateList.valueOf(resources.getColorWithID(R.color.white, context.theme))
downloadProgress.progressTintList = ColorStateList.valueOf(backgroundTint) downloadProgress.progressTintList = ColorStateList.valueOf(resources.getColorWithID(R.color.black, context.theme))
downloadProgress.indeterminateTintList = ColorStateList.valueOf(backgroundTint) downloadProgress.indeterminateTintList = ColorStateList.valueOf(resources.getColorWithID(R.color.black, context.theme))
totalDuration.setTextColor(foregroundTint) totalDuration.setTextColor(foregroundTint)
// Seek bar's progress color is set from the XML template. Whereas the background is computed.
seekBar.barProgressColor = waveformFill seekBar.barProgressColor = waveformFill
seekBar.barBackgroundColor = ColorUtils.blendARGB(foregroundTint, backgroundTint, 0.75f) seekBar.barBackgroundColor = waveformBackground
} }
override fun onPlayerStart(player: AudioSlidePlayer) { override fun onPlayerStart(player: AudioSlidePlayer) {
@ -309,7 +309,7 @@ class MessageAudioView: FrameLayout, AudioSlidePlayer.Listener {
private var active = false private var active = false
companion object { companion object {
private const val UPDATE_PERIOD = 350L // In milliseconds. private const val UPDATE_PERIOD = 250L // In milliseconds.
private val random = Random() private val random = Random()
} }