mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-25 09:17:44 +00:00
New design for audio view progress bar.
This commit is contained in:
parent
82c5df48e7
commit
42b9468c63
4
res/drawable/circle_tintable_4dp_inset.xml
Normal file
4
res/drawable/circle_tintable_4dp_inset.xml
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<inset xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:drawable="@drawable/circle_tintable"
|
||||||
|
android:inset="4dp"/>
|
@ -15,25 +15,28 @@
|
|||||||
|
|
||||||
<org.thoughtcrime.securesms.components.AnimatingToggle
|
<org.thoughtcrime.securesms.components.AnimatingToggle
|
||||||
android:id="@+id/control_toggle"
|
android:id="@+id/control_toggle"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="48dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="48dp"
|
||||||
android:layout_gravity="center"
|
android:layout_gravity="center"
|
||||||
android:gravity="center">
|
android:gravity="center">
|
||||||
|
|
||||||
<com.pnikosis.materialishprogress.ProgressWheel
|
<ProgressBar
|
||||||
android:id="@+id/download_progress"
|
android:id="@+id/download_progress"
|
||||||
android:layout_width="48dp"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="48dp"
|
android:layout_height="match_parent"
|
||||||
|
android:padding="8dp"
|
||||||
|
android:background="@drawable/circle_tintable_4dp_inset"
|
||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
android:layout_gravity="center"
|
android:layout_gravity="center_vertical"
|
||||||
app:matProg_barColor="@color/white"
|
android:min="0"
|
||||||
app:matProg_linearProgress="true"
|
android:max="100"
|
||||||
app:matProg_spinSpeed="0.333"
|
tools:visibility="gone"
|
||||||
tools:visibility="gone"/>
|
tools:backgroundTint="@android:color/black"
|
||||||
|
tools:indeterminateTint="@android:color/white"/>
|
||||||
|
|
||||||
<ImageView android:id="@+id/play"
|
<ImageView android:id="@+id/play"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="match_parent"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
android:clickable="true"
|
android:clickable="true"
|
||||||
@ -45,8 +48,8 @@
|
|||||||
tools:visibility="visible"/>
|
tools:visibility="visible"/>
|
||||||
|
|
||||||
<ImageView android:id="@+id/pause"
|
<ImageView android:id="@+id/pause"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="match_parent"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
android:clickable="true"
|
android:clickable="true"
|
||||||
@ -58,8 +61,8 @@
|
|||||||
tools:visibility="gone"/>
|
tools:visibility="gone"/>
|
||||||
|
|
||||||
<ImageView android:id="@+id/download"
|
<ImageView android:id="@+id/download"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="match_parent"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
android:clickable="true"
|
android:clickable="true"
|
||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
|
@ -11,11 +11,11 @@ import android.view.View.OnTouchListener
|
|||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.widget.FrameLayout
|
import android.widget.FrameLayout
|
||||||
import android.widget.ImageView
|
import android.widget.ImageView
|
||||||
|
import android.widget.ProgressBar
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import androidx.annotation.ColorInt
|
import androidx.annotation.ColorInt
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
import androidx.core.graphics.ColorUtils
|
import androidx.core.graphics.ColorUtils
|
||||||
import com.pnikosis.materialishprogress.ProgressWheel
|
|
||||||
import kotlinx.coroutines.*
|
import kotlinx.coroutines.*
|
||||||
import network.loki.messenger.R
|
import network.loki.messenger.R
|
||||||
import org.greenrobot.eventbus.EventBus
|
import org.greenrobot.eventbus.EventBus
|
||||||
@ -47,7 +47,7 @@ class MessageAudioView: FrameLayout, AudioSlidePlayer.Listener {
|
|||||||
private val playButton: ImageView
|
private val playButton: ImageView
|
||||||
private val pauseButton: ImageView
|
private val pauseButton: ImageView
|
||||||
private val downloadButton: ImageView
|
private val downloadButton: ImageView
|
||||||
private val downloadProgress: ProgressWheel
|
private val downloadProgress: ProgressBar
|
||||||
private val seekBar: WaveformSeekBar
|
private val seekBar: WaveformSeekBar
|
||||||
private val totalDuration: TextView
|
private val totalDuration: TextView
|
||||||
|
|
||||||
@ -147,20 +147,22 @@ class MessageAudioView: FrameLayout, AudioSlidePlayer.Listener {
|
|||||||
controlToggle.displayQuick(downloadButton)
|
controlToggle.displayQuick(downloadButton)
|
||||||
seekBar.isEnabled = false
|
seekBar.isEnabled = false
|
||||||
downloadButton.setOnClickListener { v -> downloadListener?.onClick(v, audio) }
|
downloadButton.setOnClickListener { v -> downloadListener?.onClick(v, audio) }
|
||||||
if (downloadProgress.isSpinning) {
|
if (downloadProgress.isIndeterminate) {
|
||||||
downloadProgress.stopSpinning()
|
downloadProgress.isIndeterminate = false
|
||||||
|
downloadProgress.progress = 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
(showControls && audio.transferState == AttachmentDatabase.TRANSFER_PROGRESS_STARTED) -> {
|
(showControls && audio.transferState == AttachmentDatabase.TRANSFER_PROGRESS_STARTED) -> {
|
||||||
controlToggle.displayQuick(downloadProgress)
|
controlToggle.displayQuick(downloadProgress)
|
||||||
seekBar.isEnabled = false
|
seekBar.isEnabled = false
|
||||||
downloadProgress.spin()
|
downloadProgress.isIndeterminate = true
|
||||||
}
|
}
|
||||||
else -> {
|
else -> {
|
||||||
controlToggle.displayQuick(playButton)
|
controlToggle.displayQuick(playButton)
|
||||||
seekBar.isEnabled = true
|
seekBar.isEnabled = true
|
||||||
if (downloadProgress.isSpinning) {
|
if (downloadProgress.isIndeterminate) {
|
||||||
downloadProgress.stopSpinning()
|
downloadProgress.isIndeterminate = false
|
||||||
|
downloadProgress.progress = 100
|
||||||
}
|
}
|
||||||
|
|
||||||
// Post to make sure it executes only when the view is attached to a window.
|
// Post to make sure it executes only when the view is attached to a window.
|
||||||
@ -187,7 +189,11 @@ class MessageAudioView: FrameLayout, AudioSlidePlayer.Listener {
|
|||||||
pauseButton.imageTintList = ColorStateList.valueOf(backgroundTint)
|
pauseButton.imageTintList = ColorStateList.valueOf(backgroundTint)
|
||||||
|
|
||||||
downloadButton.setColorFilter(foregroundTint, PorterDuff.Mode.SRC_IN)
|
downloadButton.setColorFilter(foregroundTint, PorterDuff.Mode.SRC_IN)
|
||||||
downloadProgress.barColor = foregroundTint
|
|
||||||
|
downloadProgress.backgroundTintList = ColorStateList.valueOf(foregroundTint)
|
||||||
|
downloadProgress.progressTintList = ColorStateList.valueOf(backgroundTint)
|
||||||
|
downloadProgress.indeterminateTintList = ColorStateList.valueOf(backgroundTint)
|
||||||
|
|
||||||
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.
|
||||||
@ -284,7 +290,8 @@ class MessageAudioView: FrameLayout, AudioSlidePlayer.Listener {
|
|||||||
@Subscribe(sticky = true, threadMode = ThreadMode.MAIN)
|
@Subscribe(sticky = true, threadMode = ThreadMode.MAIN)
|
||||||
fun onEvent(event: PartProgressEvent) {
|
fun onEvent(event: PartProgressEvent) {
|
||||||
if (audioSlidePlayer != null && event.attachment == audioSlidePlayer!!.audioSlide.asAttachment()) {
|
if (audioSlidePlayer != null && event.attachment == audioSlidePlayer!!.audioSlide.asAttachment()) {
|
||||||
downloadProgress.setInstantProgress(event.progress.toFloat() / event.total)
|
val progress = ((event.progress.toFloat() / event.total) * 100f).toInt()
|
||||||
|
downloadProgress.progress = progress
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user