adding a dialog for selecting a sleep timer
This commit is contained in:
parent
9396c616ad
commit
9567697e70
4 changed files with 26 additions and 0 deletions
|
@ -206,6 +206,7 @@ class MainActivity : SimpleActivity(), SongListListener {
|
|||
R.id.sort -> showSortingDialog()
|
||||
R.id.remove_current -> getSongsAdapter()?.removeCurrentSongFromPlaylist()
|
||||
R.id.delete_current -> getSongsAdapter()?.deleteCurrentSong()
|
||||
R.id.sleep_timer -> showSleepTimer()
|
||||
R.id.open_playlist -> openPlaylist()
|
||||
R.id.toggle_autoplay -> toggleAutoplay()
|
||||
R.id.add_folder_to_playlist -> addFolderToPlaylist()
|
||||
|
@ -334,6 +335,22 @@ class MainActivity : SimpleActivity(), SongListListener {
|
|||
toast(if (config.autoplay) R.string.autoplay_enabled else R.string.autoplay_disabled)
|
||||
}
|
||||
|
||||
private fun showSleepTimer() {
|
||||
val minutes = getString(R.string.minutes_raw)
|
||||
val hour = resources.getQuantityString(R.plurals.hours, 1, 1)
|
||||
|
||||
val items = arrayListOf(
|
||||
RadioItem(5, "5 $minutes"),
|
||||
RadioItem(10, "10 $minutes"),
|
||||
RadioItem(20, "20 $minutes"),
|
||||
RadioItem(30, "30 $minutes"),
|
||||
RadioItem(60, hour))
|
||||
|
||||
RadioGroupDialog(this, items, config.lastSleepTimerMinutes) {
|
||||
config.lastSleepTimerMinutes = it as Int
|
||||
}
|
||||
}
|
||||
|
||||
private fun removePlaylist() {
|
||||
if (config.currentPlaylist == ALL_SONGS_PLAYLIST_ID) {
|
||||
toast(R.string.all_songs_cannot_be_deleted)
|
||||
|
|
|
@ -50,4 +50,8 @@ class Config(context: Context) : BaseConfig(context) {
|
|||
var swapPrevNext: Boolean
|
||||
get() = prefs.getBoolean(SWAP_PREV_NEXT, false)
|
||||
set(swapPrevNext) = prefs.edit().putBoolean(SWAP_PREV_NEXT, swapPrevNext).apply()
|
||||
|
||||
var lastSleepTimerMinutes: Int
|
||||
get() = prefs.getInt(LAST_SLEEP_TIMER_MINUTES, 30)
|
||||
set(lastSleepTimerMinutes) = prefs.edit().putInt(LAST_SLEEP_TIMER_MINUTES, lastSleepTimerMinutes).apply()
|
||||
}
|
||||
|
|
|
@ -38,6 +38,7 @@ const val CURRENT_PLAYLIST = "current_playlist"
|
|||
const val SHOW_FILENAME = "show_filename"
|
||||
const val SHOW_ALBUM_COVER = "show_album_cover"
|
||||
const val SWAP_PREV_NEXT = "swap_prev_next"
|
||||
const val LAST_SLEEP_TIMER_MINUTES = "last_sleep_timer_minutes"
|
||||
|
||||
const val LIST_HEADERS_COUNT = 2
|
||||
const val LOWER_ALPHA = 0.5f
|
||||
|
|
|
@ -25,6 +25,10 @@
|
|||
android:id="@+id/delete_current"
|
||||
android:title="@string/delete_current_song"
|
||||
app:showAsAction="never"/>
|
||||
<item
|
||||
android:id="@+id/sleep_timer"
|
||||
android:title="@string/sleep_timer"
|
||||
app:showAsAction="never"/>
|
||||
<item
|
||||
android:id="@+id/menu_rotate"
|
||||
android:title="@string/playlists"
|
||||
|
|
Loading…
Reference in a new issue