adding some coloring related improvements

This commit is contained in:
tibbi 2020-04-02 15:56:45 +02:00
parent cd88ac1343
commit 0c768d5cb8
2 changed files with 15 additions and 15 deletions

View File

@ -3,6 +3,7 @@ package com.simplemobiletools.voicerecorder.fragments
import android.annotation.SuppressLint import android.annotation.SuppressLint
import android.content.Context import android.content.Context
import android.database.Cursor import android.database.Cursor
import android.graphics.drawable.Drawable
import android.media.AudioManager import android.media.AudioManager
import android.media.MediaMetadataRetriever import android.media.MediaMetadataRetriever
import android.media.MediaPlayer import android.media.MediaPlayer
@ -28,7 +29,6 @@ import org.greenrobot.eventbus.ThreadMode
import java.util.* import java.util.*
import kotlin.collections.ArrayList import kotlin.collections.ArrayList
class PlayerFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerFragment(context, attributeSet), RefreshRecordingsListener { class PlayerFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerFragment(context, attributeSet), RefreshRecordingsListener {
private val FAST_FORWARD_SKIP_MS = 10000 private val FAST_FORWARD_SKIP_MS = 10000
@ -214,7 +214,7 @@ class PlayerFragment(context: Context, attributeSet: AttributeSet) : MyViewPager
progressTimer.cancel() progressTimer.cancel()
player_progressbar.progress = player_progressbar.max player_progressbar.progress = player_progressbar.max
player_progress_current.text = player_progress_max.text player_progress_current.text = player_progress_max.text
playbackStateChanged(false) play_pause_btn.setImageDrawable(getToggleButtonIcon(false))
} }
setOnPreparedListener { setOnPreparedListener {
@ -234,8 +234,7 @@ class PlayerFragment(context: Context, attributeSet: AttributeSet) : MyViewPager
prepare() prepare()
} }
playbackStateChanged(true) play_pause_btn.setImageDrawable(getToggleButtonIcon(true))
player_progressbar.setOnSeekBarChangeListener(object : SeekBar.OnSeekBarChangeListener { player_progressbar.setOnSeekBarChangeListener(object : SeekBar.OnSeekBarChangeListener {
override fun onProgressChanged(seekBar: SeekBar, progress: Int, fromUser: Boolean) { override fun onProgressChanged(seekBar: SeekBar, progress: Int, fromUser: Boolean) {
if (fromUser && !playedRecordingIDs.isEmpty()) { if (fromUser && !playedRecordingIDs.isEmpty()) {
@ -291,19 +290,19 @@ class PlayerFragment(context: Context, attributeSet: AttributeSet) : MyViewPager
private fun pausePlayback() { private fun pausePlayback() {
player?.pause() player?.pause()
playbackStateChanged(false) play_pause_btn.setImageDrawable(getToggleButtonIcon(false))
progressTimer.cancel() progressTimer.cancel()
} }
private fun resumePlayback() { private fun resumePlayback() {
player?.start() player?.start()
playbackStateChanged(true) play_pause_btn.setImageDrawable(getToggleButtonIcon(true))
setupProgressTimer() setupProgressTimer()
} }
private fun playbackStateChanged(isPlaying: Boolean) { private fun getToggleButtonIcon(isPlaying: Boolean): Drawable {
val drawable = resources.getDrawable(if (isPlaying) R.drawable.ic_pause_vector else R.drawable.ic_play_vector) val drawable = if (isPlaying) R.drawable.ic_pause_vector else R.drawable.ic_play_vector
play_pause_btn.setImageDrawable(drawable) return resources.getColoredDrawableWithColor(drawable, context.getFABIconColor())
} }
private fun skip(forward: Boolean) { private fun skip(forward: Boolean) {
@ -328,12 +327,15 @@ class PlayerFragment(context: Context, attributeSet: AttributeSet) : MyViewPager
private fun setupColors() { private fun setupColors() {
recordings_fastscroller.updatePrimaryColor() recordings_fastscroller.updatePrimaryColor()
recordings_fastscroller.updateBubbleColors() recordings_fastscroller.updateBubbleColors()
context.updateTextColors(player_controls_wrapper) context.updateTextColors(player_holder)
val textColor = context.config.textColor val textColor = context.config.textColor
arrayListOf(previous_btn, play_pause_btn, next_btn).forEach { arrayListOf(previous_btn, next_btn).forEach {
it.applyColorFilter(textColor) it.applyColorFilter(textColor)
} }
play_pause_btn.background.applyColorFilter(context.getAdjustedPrimaryColor())
play_pause_btn.setImageDrawable(getToggleButtonIcon(false))
} }
@Subscribe(threadMode = ThreadMode.MAIN) @Subscribe(threadMode = ThreadMode.MAIN)

View File

@ -13,11 +13,11 @@
android:layout_centerHorizontal="true" android:layout_centerHorizontal="true"
android:layout_marginTop="@dimen/activity_margin" android:layout_marginTop="@dimen/activity_margin"
android:gravity="center" android:gravity="center"
android:padding="@dimen/activity_margin"
android:lineSpacingExtra="@dimen/medium_margin" android:lineSpacingExtra="@dimen/medium_margin"
android:padding="@dimen/activity_margin"
android:text="@string/no_recordings_found" android:text="@string/no_recordings_found"
android:textSize="@dimen/bigger_text_size" android:textSize="@dimen/bigger_text_size"
android:visibility="visible"/> android:visibility="visible" />
<com.simplemobiletools.commons.views.MyRecyclerView <com.simplemobiletools.commons.views.MyRecyclerView
android:id="@+id/recordings_list" android:id="@+id/recordings_list"
@ -123,7 +123,6 @@
android:layout_alignBottom="@+id/play_pause_btn" android:layout_alignBottom="@+id/play_pause_btn"
android:layout_centerVertical="true" android:layout_centerVertical="true"
android:layout_toStartOf="@+id/play_pause_btn" android:layout_toStartOf="@+id/play_pause_btn"
android:alpha="0.8"
android:background="?attr/selectableItemBackgroundBorderless" android:background="?attr/selectableItemBackgroundBorderless"
android:contentDescription="@string/previous" android:contentDescription="@string/previous"
android:padding="@dimen/medium_margin" android:padding="@dimen/medium_margin"
@ -151,7 +150,6 @@
android:layout_alignBottom="@+id/play_pause_btn" android:layout_alignBottom="@+id/play_pause_btn"
android:layout_centerVertical="true" android:layout_centerVertical="true"
android:layout_toEndOf="@+id/play_pause_btn" android:layout_toEndOf="@+id/play_pause_btn"
android:alpha="0.8"
android:background="?attr/selectableItemBackgroundBorderless" android:background="?attr/selectableItemBackgroundBorderless"
android:contentDescription="@string/next" android:contentDescription="@string/next"
android:padding="@dimen/medium_margin" android:padding="@dimen/medium_margin"