Finish current music when Sleep Timer stops (#629)

Implement #329.
This commit adds a CheckBox to dialog_sleep_timer, and a curresponding
option `TIMER_FINISH_MUSIC` in PreferenceUtil.

In MusicService, a new flag `pendingQuit` is to indicate if it should
stop after current music stops. A new action `ACTION_PENDING_QUIT` will
set that flag.

Canceling is a little tricky. I must bind MusicService in Dialog
activity to check if `pendingQuit` is set, and show the corresponding
canceling button.
This commit is contained in:
Peng Guanwen 2019-01-08 10:45:33 +08:00 committed by Eugene
commit 2111c41836
6 changed files with 94 additions and 25 deletions

View file

@ -1,28 +1,43 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:seekarc="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content">
android:layout_height="wrap_content"
android:orientation="vertical">
<com.triggertrap.seekarc.SeekArc
android:id="@+id/seek_arc"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:padding="30dp"
seekarc:SeekArc_clockwise="false"
seekarc:SeekArc_max="120"
seekarc:SeekArc_progressColor="?colorAccent"
seekarc:SeekArc_rotation="180"
seekarc:SeekArc_startAngle="30"
seekarc:SeekArc_sweepAngle="300" />
<TextView
android:id="@+id/timer_display"
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:textAppearance="?android:textAppearanceLarge" />
android:layout_height="wrap_content">
</FrameLayout>
<com.triggertrap.seekarc.SeekArc
android:id="@+id/seek_arc"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:padding="30dp"
seekarc:SeekArc_clockwise="false"
seekarc:SeekArc_max="120"
seekarc:SeekArc_progressColor="?colorAccent"
seekarc:SeekArc_rotation="180"
seekarc:SeekArc_startAngle="30"
seekarc:SeekArc_sweepAngle="300" />
<TextView
android:id="@+id/timer_display"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:textAppearance="?android:textAppearanceLarge" />
</FrameLayout>
<com.kabouzeid.appthemehelper.common.views.ATECheckBox
android:id="@+id/should_finish_last_song"
android:layout_width="wrap_content"
android:layout_height="42dp"
android:layout_gravity="bottom"
android:layout_margin="20dp"
android:text="@string/finish_current_music_sleep_timer" />
</LinearLayout>