aboutsummaryrefslogtreecommitdiff
path: root/subsonic-android
diff options
context:
space:
mode:
Diffstat (limited to 'subsonic-android')
-rw-r--r--subsonic-android/res/layout/download_playlist.xml25
-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.java12
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/service/DownloadService.java2
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceImpl.java16
6 files changed, 55 insertions, 11 deletions
diff --git a/subsonic-android/res/layout/download_playlist.xml b/subsonic-android/res/layout/download_playlist.xml
index 8e92a984..8bd54877 100644
--- a/subsonic-android/res/layout/download_playlist.xml
+++ b/subsonic-android/res/layout/download_playlist.xml
@@ -19,11 +19,24 @@
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="2dp"
+ 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:drag_start_mode="onDown"/>
</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 a4222ce5..e4578db1 100644
--- a/subsonic-android/src/github/daneren2005/dsub/activity/DownloadActivity.java
+++ b/subsonic-android/src/github/daneren2005/dsub/activity/DownloadActivity.java
@@ -81,6 +81,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 +96,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;
@@ -145,7 +146,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);
@@ -344,6 +345,13 @@ 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();
+ }
+ });
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..c086c258 100644
--- a/subsonic-android/src/github/daneren2005/dsub/service/DownloadService.java
+++ b/subsonic-android/src/github/daneren2005/dsub/service/DownloadService.java
@@ -130,4 +130,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 9e6662cf..349252e0 100644
--- a/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceImpl.java
+++ b/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceImpl.java
@@ -981,6 +981,22 @@ public class DownloadServiceImpl extends Service implements DownloadService {
mediaPlayer.setVolume(volume, volume);
}
}
+
+ @Override
+ public 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);