aboutsummaryrefslogtreecommitdiff
path: root/subsonic-android
diff options
context:
space:
mode:
Diffstat (limited to 'subsonic-android')
-rw-r--r--subsonic-android/res/layout/download_playlist.xml26
-rw-r--r--subsonic-android/res/layout/song_list_item.xml7
-rw-r--r--subsonic-android/res/values/ids.xml4
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/activity/DownloadActivity.java20
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/service/DownloadService.java4
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceImpl.java21
6 files changed, 71 insertions, 11 deletions
diff --git a/subsonic-android/res/layout/download_playlist.xml b/subsonic-android/res/layout/download_playlist.xml
index 8e92a984..dc77826d 100644
--- a/subsonic-android/res/layout/download_playlist.xml
+++ b/subsonic-android/res/layout/download_playlist.xml
@@ -19,11 +19,25 @@
android:layout_height="wrap_content"
android:padding="10dip"/>
- <ListView
- android:id="@+id/download_list"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:layout_weight="1"
- android:cacheColorHint="#00000000"/>
+ <com.mobeta.android.dslv.DragSortListView
+ xmlns:dslv="http://schemas.android.com/apk/res/github.daneren2005.dsub"
+ android:id="@+id/download_list"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ android:layout_weight="1"
+ android:cacheColorHint="#00000000"
+ dslv:drag_enabled="true"
+ dslv:collapsed_height="1dp"
+ dslv:drag_scroll_start="1.0"
+ dslv:max_drag_scroll_speed="2.0"
+ dslv:float_alpha="0.6"
+ dslv:slide_shuffle_speed="0.3"
+ dslv:track_drag_sort="false"
+ dslv:use_default_controller="true"
+ dslv:drag_handle_id="@id/drag_handle"
+ dslv:sort_enabled="true"
+ dslv:remove_enabled="false"
+ dslv:remove_mode="flingRemove"
+ dslv:drag_start_mode="onLongPress"/>
</LinearLayout> \ No newline at end of file
diff --git a/subsonic-android/res/layout/song_list_item.xml b/subsonic-android/res/layout/song_list_item.xml
index 9bbfde94..0ff738d2 100644
--- a/subsonic-android/res/layout/song_list_item.xml
+++ b/subsonic-android/res/layout/song_list_item.xml
@@ -1,8 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="horizontal"
- android:layout_width="fill_parent"
- android:layout_height="?android:attr/listPreferredItemHeight">
+ android:id="@id/drag_handle"
+ android:orientation="horizontal"
+ android:layout_width="fill_parent"
+ android:layout_height="?android:attr/listPreferredItemHeight">
<CheckedTextView
android:id="@+id/song_check"
diff --git a/subsonic-android/res/values/ids.xml b/subsonic-android/res/values/ids.xml
new file mode 100644
index 00000000..edb3bbec
--- /dev/null
+++ b/subsonic-android/res/values/ids.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<resources>
+ <item name="drag_handle" type="id"/>
+</resources> \ No newline at end of file
diff --git a/subsonic-android/src/github/daneren2005/dsub/activity/DownloadActivity.java b/subsonic-android/src/github/daneren2005/dsub/activity/DownloadActivity.java
index f7736375..954a3f02 100644
--- a/subsonic-android/src/github/daneren2005/dsub/activity/DownloadActivity.java
+++ b/subsonic-android/src/github/daneren2005/dsub/activity/DownloadActivity.java
@@ -36,6 +36,7 @@ import android.graphics.Color;
import android.graphics.Typeface;
import android.os.Bundle;
import android.os.Handler;
+import android.os.Parcelable;
import android.util.Log;
import android.view.ContextMenu;
import android.view.Display;
@@ -81,6 +82,7 @@ import github.daneren2005.dsub.util.*;
import github.daneren2005.dsub.view.AutoRepeatButton;
import java.util.ArrayList;
import java.util.concurrent.ScheduledFuture;
+import com.mobeta.android.dslv.*;
public class DownloadActivity extends SubsonicTabActivity implements OnGestureListener {
private static final String TAG = DownloadActivity.class.getSimpleName();
@@ -95,7 +97,7 @@ public class DownloadActivity extends SubsonicTabActivity implements OnGestureLi
private TextView emptyTextView;
private TextView songTitleTextView;
private ImageView albumArtImageView;
- private ListView playlistView;
+ private DragSortListView playlistView;
private TextView positionTextView;
private TextView durationTextView;
private TextView statusTextView;
@@ -146,7 +148,7 @@ public class DownloadActivity extends SubsonicTabActivity implements OnGestureLi
durationTextView = (TextView) findViewById(R.id.download_duration);
statusTextView = (TextView) findViewById(R.id.download_status);
progressBar = (HorizontalSlider) findViewById(R.id.download_progress_bar);
- playlistView = (ListView) findViewById(R.id.download_list);
+ playlistView = (DragSortListView) findViewById(R.id.download_list);
previousButton = (AutoRepeatButton)findViewById(R.id.download_previous);
nextButton = (AutoRepeatButton)findViewById(R.id.download_next);
pauseButton = findViewById(R.id.download_pause);
@@ -345,6 +347,20 @@ public class DownloadActivity extends SubsonicTabActivity implements OnGestureLi
}
}
});
+ playlistView.setDropListener(new DragSortListView.DropListener() {
+ @Override
+ public void drop(int from, int to) {
+ getDownloadService().swap(from, to);
+ onDownloadListChanged();
+ }
+ });
+ playlistView.setRemoveListener(new DragSortListView.RemoveListener() {
+ @Override
+ public void remove(int which) {
+ getDownloadService().remove(which);
+ onDownloadListChanged();
+ }
+ });
registerForContextMenu(playlistView);
diff --git a/subsonic-android/src/github/daneren2005/dsub/service/DownloadService.java b/subsonic-android/src/github/daneren2005/dsub/service/DownloadService.java
index 0536c198..889d7d2b 100644
--- a/subsonic-android/src/github/daneren2005/dsub/service/DownloadService.java
+++ b/subsonic-android/src/github/daneren2005/dsub/service/DownloadService.java
@@ -60,6 +60,8 @@ public interface DownloadService {
void clearIncomplete();
int size();
+
+ void remove(int which);
void remove(DownloadFile downloadFile);
@@ -130,4 +132,6 @@ public interface DownloadService {
boolean getSleepTimer();
void setVolume(float volume);
+
+ void swap(int from, int to);
}
diff --git a/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceImpl.java b/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceImpl.java
index c0275386..c874e8f5 100644
--- a/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceImpl.java
+++ b/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceImpl.java
@@ -420,6 +420,11 @@ public class DownloadServiceImpl extends Service implements DownloadService {
}
updateJukeboxPlaylist();
}
+
+ @Override
+ public synchronized void remove(int which) {
+ downloadList.remove(which);
+ }
@Override
public synchronized void remove(DownloadFile downloadFile) {
@@ -977,6 +982,22 @@ public class DownloadServiceImpl extends Service implements DownloadService {
mediaPlayer.setVolume(volume, volume);
}
}
+
+ @Override
+ public synchronized void swap(int from, int to) {
+ int max = size();
+ if(to >= max) {
+ to = max - 1;
+ }
+ else if(to < 0) {
+ to = 0;
+ }
+
+ downloadList.add(to, downloadList.remove(from));
+ if(jukeboxEnabled) {
+ updateJukeboxPlaylist();
+ }
+ }
private void handleError(Exception x) {
Log.w(TAG, "Media player error: " + x, x);