adding a Stop button to the sleep timer

This commit is contained in:
tibbi 2019-07-03 18:51:20 +02:00
parent d17358e14f
commit 760e8a9992
3 changed files with 31 additions and 2 deletions

View file

@ -6,6 +6,7 @@ import android.content.Intent
import android.graphics.Paint
import android.graphics.drawable.BitmapDrawable
import android.graphics.drawable.ColorDrawable
import android.graphics.drawable.LayerDrawable
import android.media.AudioManager
import android.net.Uri
import android.os.Bundle
@ -96,6 +97,7 @@ class MainActivity : SimpleActivity(), SongListListener {
repeat_btn.setOnClickListener { toggleSongRepetition() }
song_progress_current.setOnClickListener { sendIntent(SKIP_BACKWARD) }
song_progress_max.setOnClickListener { sendIntent(SKIP_FORWARD) }
sleep_timer_stop.setOnClickListener { }
songs_playlist_empty_add_folder.setOnClickListener { addFolderToPlaylist() }
volumeControlStream = AudioManager.STREAM_MUSIC
@ -153,6 +155,10 @@ class MainActivity : SimpleActivity(), SongListListener {
arrayListOf(art_holder, song_list_background, top_navigation, sleep_timer_holder).forEach {
it.background = ColorDrawable(config.backgroundColor)
}
val stopDrawable = resources.getDrawable(R.drawable.ic_stop_shape)
(stopDrawable as LayerDrawable).findDrawableByLayerId(R.id.ic_stop_shape_background).applyColorFilter(config.textColor)
sleep_timer_stop.setImageDrawable(stopDrawable)
}
override fun onPause() {

View file

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/ic_stop_shape_background">
<shape android:shape="rectangle">
<solid android:color="@color/default_text_color"/>
</shape>
</item>
</layer-list>

View file

@ -98,6 +98,7 @@
android:id="@+id/sleep_timer_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:padding="@dimen/activity_margin"
android:text="@string/sleep_timer"
android:textSize="@dimen/big_text_size"/>
@ -106,10 +107,24 @@
android:id="@+id/sleep_timer_value"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:padding="@dimen/activity_margin"
android:layout_centerVertical="true"
android:layout_toStartOf="@+id/sleep_timer_stop"
android:paddingTop="@dimen/activity_margin"
android:paddingBottom="@dimen/activity_margin"
android:textSize="@dimen/big_text_size"
tools:text="05:00"/>
<ImageView
android:id="@+id/sleep_timer_stop"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:layout_marginStart="@dimen/small_margin"
android:layout_marginEnd="@dimen/small_margin"
android:background="?attr/selectableItemBackgroundBorderless"
android:padding="@dimen/normal_margin"
android:src="@drawable/ic_stop_shape"/>
</RelativeLayout>
</RelativeLayout>