aboutsummaryrefslogtreecommitdiff
path: root/subsonic-android
diff options
context:
space:
mode:
Diffstat (limited to 'subsonic-android')
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/service/OfflineMusicService.java26
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/service/RESTMusicService.java2
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/util/CacheCleaner.java5
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/util/FileUtil.java13
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/util/Util.java5
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/view/PlaylistView.java6
6 files changed, 37 insertions, 20 deletions
diff --git a/subsonic-android/src/github/daneren2005/dsub/service/OfflineMusicService.java b/subsonic-android/src/github/daneren2005/dsub/service/OfflineMusicService.java
index af8f7cf7..83d13bc3 100644
--- a/subsonic-android/src/github/daneren2005/dsub/service/OfflineMusicService.java
+++ b/subsonic-android/src/github/daneren2005/dsub/service/OfflineMusicService.java
@@ -346,18 +346,22 @@ public class OfflineMusicService extends RESTMusicService {
public List<Playlist> getPlaylists(boolean refresh, Context context, ProgressListener progressListener) throws Exception {
List<Playlist> playlists = new ArrayList<Playlist>();
File root = FileUtil.getPlaylistDirectory();
- for (File file : FileUtil.listFiles(root)) {
- if(FileUtil.isPlaylistFile(file)) {
- String id = file.getName();
- String filename = FileUtil.getBaseName(id);
- Playlist playlist = new Playlist(id, filename);
- playlists.add(playlist);
+ for (File folder : FileUtil.listFiles(root)) {
+ if(folder.isDirectory()) {
+ for(File file: FileUtil.listFiles(folder)) {
+ if(FileUtil.isPlaylistFile(file)) {
+ String id = file.getName();
+ String filename = folder.getName() + ": " + FileUtil.getBaseName(id);
+ Playlist playlist = new Playlist(id, filename);
+ playlists.add(playlist);
+ }
+ }
} else {
// Delete legacy playlist files
try {
- file.delete();
+ folder.delete();
} catch(Exception e) {
- Log.w(TAG, "Failed to delete old playlist file: " + file.getName());
+ Log.w(TAG, "Failed to delete old playlist file: " + folder.getName());
}
}
}
@@ -374,7 +378,11 @@ public class OfflineMusicService extends RESTMusicService {
Reader reader = null;
BufferedReader buffer = null;
try {
- File playlistFile = FileUtil.getPlaylistFile(name);
+ int firstIndex = name.indexOf(": ");
+ String server = name.substring(0, firstIndex);
+ name = name.substring(firstIndex + 2);
+
+ File playlistFile = FileUtil.getPlaylistFile(server, name);
reader = new FileReader(playlistFile);
buffer = new BufferedReader(reader);
diff --git a/subsonic-android/src/github/daneren2005/dsub/service/RESTMusicService.java b/subsonic-android/src/github/daneren2005/dsub/service/RESTMusicService.java
index 1f283a3b..e12c4024 100644
--- a/subsonic-android/src/github/daneren2005/dsub/service/RESTMusicService.java
+++ b/subsonic-android/src/github/daneren2005/dsub/service/RESTMusicService.java
@@ -330,7 +330,7 @@ public class RESTMusicService implements MusicService {
try {
MusicDirectory playlist = new PlaylistParser(context).parse(reader, progressListener);
- File playlistFile = FileUtil.getPlaylistFile(name);
+ File playlistFile = FileUtil.getPlaylistFile(Util.getServerName(context), name);
FileWriter fw = new FileWriter(playlistFile);
BufferedWriter bw = new BufferedWriter(fw);
try {
diff --git a/subsonic-android/src/github/daneren2005/dsub/util/CacheCleaner.java b/subsonic-android/src/github/daneren2005/dsub/util/CacheCleaner.java
index 44de369f..62204c76 100644
--- a/subsonic-android/src/github/daneren2005/dsub/util/CacheCleaner.java
+++ b/subsonic-android/src/github/daneren2005/dsub/util/CacheCleaner.java
@@ -219,10 +219,11 @@ public class CacheCleaner {
@Override
protected Void doInBackground(List<Playlist>... params) {
try {
- SortedSet<File> playlistFiles = FileUtil.listFiles(FileUtil.getPlaylistDirectory());
+ String server = Util.getServerName(context);
+ SortedSet<File> playlistFiles = FileUtil.listFiles(FileUtil.getPlaylistDirectory(server));
List<Playlist> playlists = params[0];
for (Playlist playlist : playlists) {
- playlistFiles.remove(FileUtil.getPlaylistFile(playlist.getName()));
+ playlistFiles.remove(FileUtil.getPlaylistFile(server, playlist.getName()));
}
for(File playlist : playlistFiles) {
diff --git a/subsonic-android/src/github/daneren2005/dsub/util/FileUtil.java b/subsonic-android/src/github/daneren2005/dsub/util/FileUtil.java
index 7ead874c..e63b3d76 100644
--- a/subsonic-android/src/github/daneren2005/dsub/util/FileUtil.java
+++ b/subsonic-android/src/github/daneren2005/dsub/util/FileUtil.java
@@ -93,19 +93,20 @@ public class FileUtil {
return new File(dir, fileName.toString());
}
- public static File getPlaylistFile(String name) {
- File playlistDir = getPlaylistDirectory();
+ public static File getPlaylistFile(String server, String name) {
+ File playlistDir = getPlaylistDirectory(server);
return new File(playlistDir, fileSystemSafe(name) + ".m3u");
}
- public static File getOldPlaylistFile(String name) {
- File playlistDir = getPlaylistDirectory();
- return new File(playlistDir, name);
- }
public static File getPlaylistDirectory() {
File playlistDir = new File(getSubsonicDirectory(), "playlists");
ensureDirectoryExistsAndIsReadWritable(playlistDir);
return playlistDir;
}
+ public static File getPlaylistDirectory(String server) {
+ File playlistDir = new File(getPlaylistDirectory(), server);
+ ensureDirectoryExistsAndIsReadWritable(playlistDir);
+ return playlistDir;
+ }
public static File getAlbumArtFile(Context context, MusicDirectory.Entry entry) {
File albumDir = getAlbumDirectory(context, entry);
diff --git a/subsonic-android/src/github/daneren2005/dsub/util/Util.java b/subsonic-android/src/github/daneren2005/dsub/util/Util.java
index 650d071d..8ff80bb7 100644
--- a/subsonic-android/src/github/daneren2005/dsub/util/Util.java
+++ b/subsonic-android/src/github/daneren2005/dsub/util/Util.java
@@ -218,6 +218,11 @@ public final class Util {
}
}
+ public static String getServerName(Context context) {
+ SharedPreferences prefs = getPreferences(context);
+ int instance = prefs.getInt(Constants.PREFERENCES_KEY_SERVER_INSTANCE, 1);
+ return prefs.getString(Constants.PREFERENCES_KEY_SERVER_NAME + instance, null);
+ }
public static String getServerName(Context context, int instance) {
SharedPreferences prefs = getPreferences(context);
return prefs.getString(Constants.PREFERENCES_KEY_SERVER_NAME + instance, null);
diff --git a/subsonic-android/src/github/daneren2005/dsub/view/PlaylistView.java b/subsonic-android/src/github/daneren2005/dsub/view/PlaylistView.java
index effd5a98..876e0691 100644
--- a/subsonic-android/src/github/daneren2005/dsub/view/PlaylistView.java
+++ b/subsonic-android/src/github/daneren2005/dsub/view/PlaylistView.java
@@ -37,6 +37,7 @@ import java.io.File;
public class PlaylistView extends UpdateView {
private static final String TAG = PlaylistView.class.getSimpleName();
+ private Context context;
private Playlist playlist;
private TextView titleView;
@@ -44,6 +45,7 @@ public class PlaylistView extends UpdateView {
public PlaylistView(Context context) {
super(context);
+ this.context = context;
LayoutInflater.from(context).inflate(R.layout.playlist_list_item, this, true);
titleView = (TextView) findViewById(R.id.playlist_name);
@@ -64,8 +66,8 @@ public class PlaylistView extends UpdateView {
@Override
protected void update() {
- File file = FileUtil.getPlaylistFile(playlist.getName());
- if(file.exists()) {
+ File file = FileUtil.getPlaylistFile(Util.getServerName(context), playlist.getName());
+ if(file.exists() || Util.isOffline(context)) {
moreButton.setImageResource(R.drawable.list_item_more_shaded);
} else {
moreButton.setImageResource(R.drawable.list_item_more);