add an Open playlist actionmenu button

This commit is contained in:
tibbi 2017-03-30 20:25:52 +02:00
parent e5bd96a7b2
commit 527f1e6b7c
7 changed files with 18 additions and 0 deletions

View file

@ -12,10 +12,12 @@ import android.view.Menu
import android.view.MenuItem
import android.widget.SeekBar
import com.simplemobiletools.commons.dialogs.FilePickerDialog
import com.simplemobiletools.commons.dialogs.RadioGroupDialog
import com.simplemobiletools.commons.extensions.*
import com.simplemobiletools.commons.helpers.LICENSE_KOTLIN
import com.simplemobiletools.commons.helpers.LICENSE_MULTISELECT
import com.simplemobiletools.commons.helpers.LICENSE_OTTO
import com.simplemobiletools.commons.models.RadioItem
import com.simplemobiletools.commons.models.Release
import com.simplemobiletools.commons.views.RecyclerViewDivider
import com.simplemobiletools.musicplayer.BuildConfig
@ -87,6 +89,7 @@ class MainActivity : SimpleActivity(), SeekBar.OnSeekBarChangeListener {
when (item.itemId) {
R.id.sort -> showSortingDialog()
R.id.toggle_song_repetition -> toggleSongRepetition()
R.id.open_playlist -> openPlaylist()
R.id.toggle_shuffle -> toggleShuffle()
R.id.add_folder_to_playlist -> addFolderToPlaylist()
R.id.add_file_to_playlist -> addFileToPlaylist()
@ -135,6 +138,16 @@ class MainActivity : SimpleActivity(), SeekBar.OnSeekBarChangeListener {
toast(if (config.repeatSong) R.string.song_repetition_enabled else R.string.song_repetition_disabled)
}
private fun openPlaylist() {
dbHelper.getPlaylists {
val items = arrayListOf<RadioItem>()
it.mapTo(items) { RadioItem(it.id, it.title) }
RadioGroupDialog(this, items, config.currentPlaylist) {
playlistChanged(it as Int)
}
}
}
private fun addFolderToPlaylist() {
val initialPath = if (mSongs.isEmpty()) Environment.getExternalStorageDirectory().toString() else mSongs[0].path
FilePickerDialog(this, initialPath, pickFile = false) {

Binary file not shown.

After

Width:  |  Height:  |  Size: 143 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 117 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 160 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 188 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 219 B

View file

@ -11,6 +11,11 @@
android:icon="@drawable/ic_repeat"
android:title="@string/disable_song_repetition"
app:showAsAction="ifRoom"/>
<item
android:id="@+id/open_playlist"
android:icon="@drawable/ic_open_playlist"
android:title="@string/open_playlist"
app:showAsAction="ifRoom"/>
<item
android:id="@+id/toggle_shuffle"
android:icon="@drawable/ic_shuffle"