Skip to content

Commit

Permalink
fix SimpleMobileTools#45, make "Add folder to playlist" recursive
Browse files Browse the repository at this point in the history
  • Loading branch information
tibbi committed Sep 20, 2017
1 parent 2ce7f1c commit 6b2f3db
Show file tree
Hide file tree
Showing 13 changed files with 31 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ android {
}

dependencies {
compile 'com.simplemobiletools:commons:2.27.9'
compile 'com.simplemobiletools:commons:2.28.3'
compile 'com.squareup:otto:1.3.8'
compile 'com.facebook.stetho:stetho:1.4.2'
compile 'com.bignerdranch.android:recyclerview-multiselect:0.2'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,11 +199,26 @@ class MainActivity : SimpleActivity(), SeekBar.OnSeekBarChangeListener {
private fun addFolderToPlaylist() {
val initialPath = if (mSongs.isEmpty()) Environment.getExternalStorageDirectory().toString() else mSongs[0].path
FilePickerDialog(this, initialPath, pickFile = false) {
val files = File(it).listFiles() ?: return@FilePickerDialog
val paths = files.mapTo(ArrayList<String>()) { it.absolutePath }
dbHelper.addSongsToPlaylist(paths)
sendIntent(REFRESH_LIST)
toast(R.string.fetching_songs)
Thread({
val songs = getFolderSongs(File(it))
dbHelper.addSongsToPlaylist(songs)
sendIntent(REFRESH_LIST)
}).start()
}
}

private fun getFolderSongs(folder: File): ArrayList<String> {
val songFiles = ArrayList<String>()
val files = folder.listFiles() ?: return songFiles
files.forEach {
if (it.isDirectory) {
songFiles.addAll(getFolderSongs(it))
} else if (it.isAudioFast()) {
songFiles.add(it.absolutePath)
}
}
return songFiles
}

private fun addFileToPlaylist() {
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
<string name="initial_playlist">Initial playlist</string>
<string name="initial_playlist_cannot_be_deleted">The initial playlist cannot be deleted</string>
<string name="empty_playlist">Current playlist is empty</string>
<string name="fetching_songs">Fetching songs…</string>

<!-- Settings -->
<string name="equalizer">Equalizer</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-es/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
<string name="initial_playlist">Initial playlist</string>
<string name="initial_playlist_cannot_be_deleted">The initial playlist cannot be deleted</string>
<string name="empty_playlist">Current playlist is empty</string>
<string name="fetching_songs">Fetching songs…</string>

<!-- Settings -->
<string name="equalizer">Ecualizador</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-it/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
<string name="initial_playlist">Initial playlist</string>
<string name="initial_playlist_cannot_be_deleted">The initial playlist cannot be deleted</string>
<string name="empty_playlist">Current playlist is empty</string>
<string name="fetching_songs">Fetching songs…</string>

<!-- Settings -->
<string name="equalizer">Equalizzatore</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-ja/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
<string name="initial_playlist">Initial playlist</string>
<string name="initial_playlist_cannot_be_deleted">The initial playlist cannot be deleted</string>
<string name="empty_playlist">Current playlist is empty</string>
<string name="fetching_songs">Fetching songs…</string>

<!-- Settings -->
<string name="equalizer">イコライザー</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-nl/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
<string name="initial_playlist">Aanvankelijke afspeellijst</string>
<string name="initial_playlist_cannot_be_deleted">De aanvankelijke afspeellijst kan niet worden verwijderd</string>
<string name="empty_playlist">Huidige afspeellijst is leeg</string>
<string name="fetching_songs">Fetching songs…</string>

<!-- Settings -->
<string name="equalizer">Equalizer</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-pl/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
<string name="initial_playlist">Początkowa playlista</string>
<string name="initial_playlist_cannot_be_deleted">Początkowa playlista nie może zostać usunięta</string>
<string name="empty_playlist">Obecna playlista jest pusta</string>
<string name="fetching_songs">Fetching songs…</string>

<!-- Settings -->
<string name="equalizer">Korektor</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-pt/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
<string name="initial_playlist">Lista de reprodução inicial</string>
<string name="initial_playlist_cannot_be_deleted">Não pode apagar a lista de reprodução inicial</string>
<string name="empty_playlist">A lista de reprodução está vazia</string>
<string name="fetching_songs">Fetching songs…</string>

<!-- Settings -->
<string name="equalizer">Equalizador</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-ru/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
<string name="initial_playlist">Начальный плейлист</string>
<string name="initial_playlist_cannot_be_deleted">Начальный плейлист не может быть удалён</string>
<string name="empty_playlist">Текущий плейлист пуст</string>
<string name="fetching_songs">Fetching songs…</string>

<!-- Settings -->
<string name="equalizer">Эквалайзер</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-sk/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
<string name="initial_playlist">Východzí zoznam skladieb</string>
<string name="initial_playlist_cannot_be_deleted">Východzí zoznam skladieb nemôže byť vymazaný</string>
<string name="empty_playlist">Súčasný zoznam skladieb je prázdny</string>
<string name="fetching_songs">Pridávajú sa pesničky…</string>

<!-- Settings -->
<string name="equalizer">Ekvalizér</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-sv/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
<string name="initial_playlist">Förinställd spellista</string>
<string name="initial_playlist_cannot_be_deleted">Den förinställda spellistan kan inte tas bort</string>
<string name="empty_playlist">Den aktuella spellistan är tom</string>
<string name="fetching_songs">Fetching songs…</string>

<!-- Settings -->
<string name="equalizer">Equalizer</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
<string name="initial_playlist">Initial playlist</string>
<string name="initial_playlist_cannot_be_deleted">The initial playlist cannot be deleted</string>
<string name="empty_playlist">Current playlist is empty</string>
<string name="fetching_songs">Fetching songs…</string>

<!-- Settings -->
<string name="equalizer">Equalizer</string>
Expand Down

0 comments on commit 6b2f3db

Please sign in to comment.