aboutsummaryrefslogtreecommitdiff
path: root/subsonic-android
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2013-01-23 21:32:32 -0800
committerScott Jackson <daneren2005@gmail.com>2013-01-23 21:32:32 -0800
commit89637322e012f8c6277513783b5721eb79487e7d (patch)
tree53a4bfdbca00b86a682baef96f85bfc2e39a3e27 /subsonic-android
parent96d30caf5fcde2ad4ba2faa9303178c7032190cd (diff)
downloaddsub-89637322e012f8c6277513783b5721eb79487e7d.tar.gz
dsub-89637322e012f8c6277513783b5721eb79487e7d.tar.bz2
dsub-89637322e012f8c6277513783b5721eb79487e7d.zip
Closes #75 Add ability to delete albums/artists en mass
Diffstat (limited to 'subsonic-android')
-rw-r--r--subsonic-android/res/menu/select_album_context.xml4
-rw-r--r--subsonic-android/res/menu/select_album_context_offline.xml4
-rw-r--r--subsonic-android/res/menu/select_artist_context.xml4
-rw-r--r--subsonic-android/res/menu/select_artist_context_offline.xml6
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/activity/SelectAlbumActivity.java11
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/activity/SelectArtistActivity.java13
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/util/Util.java17
7 files changed, 58 insertions, 1 deletions
diff --git a/subsonic-android/res/menu/select_album_context.xml b/subsonic-android/res/menu/select_album_context.xml
index ddfd134e..00fe7993 100644
--- a/subsonic-android/res/menu/select_album_context.xml
+++ b/subsonic-android/res/menu/select_album_context.xml
@@ -25,6 +25,10 @@
android:id="@+id/album_menu_pin"
android:title="@string/common.pin"
/>
+
+ <item
+ android:id="@+id/album_menu_delete"
+ android:title="@string/common.delete"/>
<item
android:id="@+id/album_menu_star"
diff --git a/subsonic-android/res/menu/select_album_context_offline.xml b/subsonic-android/res/menu/select_album_context_offline.xml
index 801b6c5d..af9272c2 100644
--- a/subsonic-android/res/menu/select_album_context_offline.xml
+++ b/subsonic-android/res/menu/select_album_context_offline.xml
@@ -14,4 +14,8 @@
android:id="@+id/album_menu_play_last"
android:title="@string/common.play_last"
/>
+
+ <item
+ android:id="@+id/album_menu_delete"
+ android:title="@string/common.delete"/>
</menu> \ No newline at end of file
diff --git a/subsonic-android/res/menu/select_artist_context.xml b/subsonic-android/res/menu/select_artist_context.xml
index 428e23a1..23d64c4e 100644
--- a/subsonic-android/res/menu/select_artist_context.xml
+++ b/subsonic-android/res/menu/select_artist_context.xml
@@ -25,4 +25,8 @@
android:id="@+id/artist_menu_pin"
android:title="@string/common.pin"
/>
+
+ <item
+ android:id="@+id/artist_menu_delete"
+ android:title="@string/common.delete"/>
</menu>
diff --git a/subsonic-android/res/menu/select_artist_context_offline.xml b/subsonic-android/res/menu/select_artist_context_offline.xml
index 2a6ed744..c80db020 100644
--- a/subsonic-android/res/menu/select_artist_context_offline.xml
+++ b/subsonic-android/res/menu/select_artist_context_offline.xml
@@ -14,5 +14,9 @@
<item
android:id="@+id/artist_menu_play_last"
android:title="@string/common.play_last"
- />
+ />
+
+ <item
+ android:id="@+id/artist_menu_delete"
+ android:title="@string/common.delete"/>
</menu>
diff --git a/subsonic-android/src/github/daneren2005/dsub/activity/SelectAlbumActivity.java b/subsonic-android/src/github/daneren2005/dsub/activity/SelectAlbumActivity.java
index f1072e39..392401bf 100644
--- a/subsonic-android/src/github/daneren2005/dsub/activity/SelectAlbumActivity.java
+++ b/subsonic-android/src/github/daneren2005/dsub/activity/SelectAlbumActivity.java
@@ -295,6 +295,9 @@ public class SelectAlbumActivity extends SubsonicTabActivity {
case R.id.album_menu_star:
toggleStarred(entry);
break;
+ case R.id.album_menu_delete:
+ deleteRecursively(entry);
+ break;
case R.id.song_menu_play_now:
getDownloadService().clear();
getDownloadService().download(songs, false, true, true, false);
@@ -593,6 +596,14 @@ public class SelectAlbumActivity extends SubsonicTabActivity {
Util.toast(this, R.string.download_no_streaming_player);
}
}
+
+ public void deleteRecursively(MusicDirectory.Entry album) {
+ File dir = FileUtil.getAlbumDirectory(this, album);
+ Util.recursiveDelete(dir);
+ if(Util.isOffline(this)) {
+ refresh();
+ }
+ }
private void checkLicenseAndTrialPeriod(Runnable onValid) {
if (licenseValid) {
diff --git a/subsonic-android/src/github/daneren2005/dsub/activity/SelectArtistActivity.java b/subsonic-android/src/github/daneren2005/dsub/activity/SelectArtistActivity.java
index 225b70ee..b439df15 100644
--- a/subsonic-android/src/github/daneren2005/dsub/activity/SelectArtistActivity.java
+++ b/subsonic-android/src/github/daneren2005/dsub/activity/SelectArtistActivity.java
@@ -39,8 +39,10 @@ import github.daneren2005.dsub.service.MusicServiceFactory;
import github.daneren2005.dsub.view.ArtistAdapter;
import github.daneren2005.dsub.util.BackgroundTask;
import github.daneren2005.dsub.util.Constants;
+import github.daneren2005.dsub.util.FileUtil;
import github.daneren2005.dsub.util.TabActivityBackgroundTask;
import github.daneren2005.dsub.util.Util;
+import java.io.File;
import java.util.ArrayList;
import java.util.List;
@@ -126,6 +128,14 @@ public class SelectArtistActivity extends SubsonicTabActivity implements Adapter
private void selectFolder() {
folderButton.showContextMenu();
}
+
+ public void deleteRecursively(Artist artist) {
+ File dir = FileUtil.getArtistDirectory(this, artist);
+ Util.recursiveDelete(dir);
+ if(Util.isOffline(this)) {
+ refresh();
+ }
+ }
private void load() {
BackgroundTask<Indexes> task = new TabActivityBackgroundTask<Indexes>(this) {
@@ -233,6 +243,9 @@ public class SelectArtistActivity extends SubsonicTabActivity implements Adapter
case R.id.artist_menu_pin:
downloadRecursively(artist.getId(), true, true, false, false, true);
break;
+ case R.id.artist_menu_delete:
+ deleteRecursively(artist);
+ break;
default:
return super.onContextItemSelected(menuItem);
}
diff --git a/subsonic-android/src/github/daneren2005/dsub/util/Util.java b/subsonic-android/src/github/daneren2005/dsub/util/Util.java
index 1733bf62..0b7118d0 100644
--- a/subsonic-android/src/github/daneren2005/dsub/util/Util.java
+++ b/subsonic-android/src/github/daneren2005/dsub/util/Util.java
@@ -369,6 +369,23 @@ public final class Util {
}
return true;
}
+ public static boolean recursiveDelete(File dir) {
+ if (dir != null && dir.exists()) {
+ for(File file: dir.listFiles()) {
+ if(file.isDirectory()) {
+ if(!recursiveDelete(file)) {
+ return false;
+ }
+ } else if(file.exists()) {
+ if(!file.delete()) {
+ return false;
+ }
+ }
+ }
+ return dir.delete();
+ }
+ return false;
+ }
public static void toast(Context context, int messageId) {
toast(context, messageId, true);