From 760e8a999206a08561ca0034c5341cf4a6467e51 Mon Sep 17 00:00:00 2001 From: tibbi Date: Wed, 3 Jul 2019 18:51:20 +0200 Subject: [PATCH] adding a Stop button to the sleep timer --- .../musicplayer/activities/MainActivity.kt | 6 ++++++ app/src/main/res/drawable/ic_stop_shape.xml | 8 ++++++++ app/src/main/res/layout/activity_main.xml | 19 +++++++++++++++++-- 3 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 app/src/main/res/drawable/ic_stop_shape.xml diff --git a/app/src/main/kotlin/com/simplemobiletools/musicplayer/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/musicplayer/activities/MainActivity.kt index 21b05285..58f21c36 100644 --- a/app/src/main/kotlin/com/simplemobiletools/musicplayer/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/musicplayer/activities/MainActivity.kt @@ -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() { diff --git a/app/src/main/res/drawable/ic_stop_shape.xml b/app/src/main/res/drawable/ic_stop_shape.xml new file mode 100644 index 00000000..6fdd4c5d --- /dev/null +++ b/app/src/main/res/drawable/ic_stop_shape.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 52e98d87..76bf0202 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -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"/> + +