aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--res/layout-port/download.xml13
-rw-r--r--res/layout/download_action_buttons.xml47
-rw-r--r--res/layout/drawer_list_item.xml7
-rw-r--r--res/values/attrs.xml1
-rw-r--r--res/values/strings.xml1
-rw-r--r--res/values/styles.xml22
-rw-r--r--res/values/themes.xml3
-rw-r--r--src/github/daneren2005/dsub/domain/Bookmark.java2
-rw-r--r--src/github/daneren2005/dsub/fragments/DownloadFragment.java35
-rw-r--r--src/github/daneren2005/dsub/fragments/SelectBookmarkFragment.java39
-rw-r--r--src/github/daneren2005/dsub/service/DownloadService.java2
-rw-r--r--src/github/daneren2005/dsub/service/DownloadServiceImpl.java29
12 files changed, 148 insertions, 53 deletions
diff --git a/res/layout-port/download.xml b/res/layout-port/download.xml
index 9fb5d7bf..81bb6296 100644
--- a/res/layout-port/download.xml
+++ b/res/layout-port/download.xml
@@ -38,16 +38,21 @@
android:layout_alignParentTop="true"
android:scaleType="centerCrop"/>
- <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/download_overlay_buttons"
- android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@color/overlayColor"
android:layout_alignParentBottom="true">
- <include layout="@layout/download_action_buttons"/>
- </LinearLayout>
+ <LinearLayout
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_centerHorizontal="true">
+
+ <include layout="@layout/download_action_buttons"/>
+ </LinearLayout>
+ </RelativeLayout>
<LinearLayout
android:id="@+id/download_visualizer_view_layout"
diff --git a/res/layout/download_action_buttons.xml b/res/layout/download_action_buttons.xml
index 70e8cc43..e3a45151 100644
--- a/res/layout/download_action_buttons.xml
+++ b/res/layout/download_action_buttons.xml
@@ -9,52 +9,25 @@
<Button
android:id="@+id/download_jukebox"
android:text="RC"
- android:textStyle="bold"
- android:textSize="22sp"
- android:background="@drawable/menubar_button"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="bottom"
- android:paddingTop="4dip"
- android:paddingLeft="14dip"
- android:paddingBottom="4dip"/>
+ style="@style/DownloadActionButton"/>
<Button
android:id="@+id/download_equalizer"
android:text="EQ"
- android:textStyle="bold"
- android:textSize="22sp"
- android:background="@drawable/menubar_button"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="bottom"
- android:paddingTop="4dip"
- android:paddingLeft="7dip"
- android:paddingRight="7dip"
- android:paddingBottom="4dip"/>
+ style="@style/DownloadActionButton"/>
<Button
android:id="@+id/download_visualizer"
android:text="VIS"
- android:textStyle="bold"
- android:textSize="22sp"
- android:background="@drawable/menubar_button"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="bottom"
- android:paddingTop="4dip"
- android:paddingLeft="7dip"
- android:paddingRight="7dip"
- android:paddingBottom="4dip"/>
+ style="@style/DownloadActionButton"/>
<ImageButton
android:id="@+id/download_star"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:background="@drawable/menubar_button"
- android:src="@android:drawable/star_big_off"
- android:paddingTop="8dip"
- android:paddingLeft="10dip"
- android:paddingRight="10dip"
- android:paddingBottom="8dip"/>
+ style="@style/DownloadActionImageButton"
+ android:src="@android:drawable/star_big_off"/>
+
+ <ImageButton
+ android:id="@+id/download_bookmark"
+ style="@style/DownloadActionImageButton"
+ android:src="?attr/bookmark"/>
</LinearLayout> \ No newline at end of file
diff --git a/res/layout/drawer_list_item.xml b/res/layout/drawer_list_item.xml
index 66dd5a70..a85d043e 100644
--- a/res/layout/drawer_list_item.xml
+++ b/res/layout/drawer_list_item.xml
@@ -3,8 +3,8 @@
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
- android:paddingTop="5dip"
- android:paddingBottom="6dip">
+ android:paddingTop="8dip"
+ android:paddingBottom="9dip">
<ImageView
android:id="@+id/drawer_icon"
@@ -20,6 +20,7 @@
android:id="@+id/drawer_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:textAppearance="?android:attr/textAppearanceLarge"
+ android:textSize="26sp"
+ android:textStyle="bold"
android:singleLine="true"/>
</LinearLayout> \ No newline at end of file
diff --git a/res/values/attrs.xml b/res/values/attrs.xml
index 78009e60..ae0939f1 100644
--- a/res/values/attrs.xml
+++ b/res/values/attrs.xml
@@ -18,5 +18,6 @@
<attr name="toggle_list" format="reference"/>
<attr name="select_server" format="reference"/>
<attr name="downloading" format="reference"/>
+ <attr name="bookmark" format="reference"/>
<attr name="drawerItemsIcons" format="reference"/>
</resources>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 4eb57348..b0e9d77c 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -187,6 +187,7 @@
<string name="download.need_download">Video needs to be downloaded first</string>
<string name="download.no_streaming_player">No player can play this stream</string>
<string name="download.playing_out_of">Playing: %1$d/%2$d</string>
+ <string name="download.save_bookmark">Saved bookmark</string>
<string name="starring_content_starred">Starred \"%s\"</string>
<string name="starring_content_unstarred">Unstarred \"%s\"</string>
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 6ff6c4fc..b1475eb6 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -27,6 +27,28 @@
<item name="android:textColor">?android:textColorPrimary</item>
</style>
+ <style name="DownloadActionButton">
+ <item name="android:layout_width">wrap_content</item>
+ <item name="android:layout_height">wrap_content</item>
+ <item name="android:textStyle">bold</item>
+ <item name="android:textSize">22sp</item>
+ <item name="android:background">@drawable/menubar_button</item>
+ <item name="android:paddingTop">4dip</item>
+ <item name="android:paddingBottom">4dip</item>
+ <item name="android:paddingRight">4dip</item>
+ <item name="android:paddingLeft">4dip</item>
+ </style>
+
+ <style name="DownloadActionImageButton">
+ <item name="android:layout_width">wrap_content</item>
+ <item name="android:layout_height">wrap_content</item>
+ <item name="android:background">@drawable/menubar_button</item>
+ <item name="android:paddingTop">8dip</item>
+ <item name="android:paddingBottom">8dip</item>
+ <item name="android:paddingRight">16dip</item>
+ <item name="android:paddingLeft">16dip</item>
+ </style>
+
<style name="DragDropListView">
<item name="drag_enabled">true</item>
<item name="collapsed_height">1dp</item>
diff --git a/res/values/themes.xml b/res/values/themes.xml
index 06cbab6e..1b2078a7 100644
--- a/res/values/themes.xml
+++ b/res/values/themes.xml
@@ -21,6 +21,7 @@
<item name="toggle_list">@drawable/action_toggle_list_light</item>
<item name="select_server">@drawable/main_select_server_light</item>
<item name="downloading">@drawable/downloading_light</item>
+ <item name="bookmark">@drawable/ic_menu_bookmark_light</item>
<item name="drawerItemsIcons">@array/drawerItemIconsLight</item>
<item name="android:textViewStyle">@style/DSub.TextViewStyle</item>
<item name="android:buttonStyle">@style/DSub.ButtonStyle</item>
@@ -47,6 +48,7 @@
<item name="toggle_list">@drawable/action_toggle_list_dark</item>
<item name="select_server">@drawable/main_select_server_dark</item>
<item name="downloading">@drawable/downloading_dark</item>
+ <item name="bookmark">@drawable/ic_menu_bookmark_dark</item>
<item name="drawerItemsIcons">@array/drawerItemIconsDark</item>
<item name="android:textViewStyle">@style/DSub.TextViewStyle</item>
<item name="android:buttonStyle">@style/DSub.ButtonStyle</item>
@@ -76,6 +78,7 @@
<item name="toggle_list">@drawable/action_toggle_list_dark</item>
<item name="select_server">@drawable/main_select_server_dark</item>
<item name="downloading">@drawable/downloading_dark</item>
+ <item name="bookmark">@drawable/ic_menu_bookmark_dark</item>
<item name="drawerItemsIcons">@array/drawerItemIconsDark</item>
<item name="android:textViewStyle">@style/DSub.TextViewStyle</item>
<item name="android:buttonStyle">@style/DSub.ButtonStyle</item>
diff --git a/src/github/daneren2005/dsub/domain/Bookmark.java b/src/github/daneren2005/dsub/domain/Bookmark.java
index 83002a62..d1f470ce 100644
--- a/src/github/daneren2005/dsub/domain/Bookmark.java
+++ b/src/github/daneren2005/dsub/domain/Bookmark.java
@@ -28,7 +28,7 @@ import java.util.Locale;
/**
* Created by Scott on 11/4/13.
*/
-public class Bookmark {
+public class Bookmark implements Serializable {
private int position;
private String username;
private String comment;
diff --git a/src/github/daneren2005/dsub/fragments/DownloadFragment.java b/src/github/daneren2005/dsub/fragments/DownloadFragment.java
index 057b302f..232eda85 100644
--- a/src/github/daneren2005/dsub/fragments/DownloadFragment.java
+++ b/src/github/daneren2005/dsub/fragments/DownloadFragment.java
@@ -47,6 +47,8 @@ import github.daneren2005.dsub.domain.RemoteControlState;
import github.daneren2005.dsub.domain.RepeatMode;
import github.daneren2005.dsub.service.DownloadFile;
import github.daneren2005.dsub.service.DownloadService;
+import github.daneren2005.dsub.service.MusicService;
+import github.daneren2005.dsub.service.MusicServiceFactory;
import github.daneren2005.dsub.util.Constants;
import github.daneren2005.dsub.util.SilentBackgroundTask;
import github.daneren2005.dsub.view.FadeOutAnimation;
@@ -91,6 +93,7 @@ public class DownloadFragment extends SubsonicFragment implements OnGestureListe
private Button jukeboxButton;
private View toggleListButton;
private ImageButton starButton;
+ private ImageButton bookmarkButton;
private View mainLayout;
private ScheduledExecutorService executorService;
private DownloadFile currentPlaying;
@@ -168,6 +171,7 @@ public class DownloadFragment extends SubsonicFragment implements OnGestureListe
equalizerButton = (Button)rootView.findViewById(R.id.download_equalizer);
visualizerButton = (Button)rootView.findViewById(R.id.download_visualizer);
jukeboxButton = (Button)rootView.findViewById(R.id.download_jukebox);
+ bookmarkButton = (ImageButton) rootView.findViewById(R.id.download_bookmark);
LinearLayout visualizerViewLayout = (LinearLayout)rootView.findViewById(R.id.download_visualizer_view_layout);
toggleListButton =rootView.findViewById(R.id.download_toggle_list);
@@ -196,6 +200,7 @@ public class DownloadFragment extends SubsonicFragment implements OnGestureListe
equalizerButton.setOnTouchListener(touchListener);
visualizerButton.setOnTouchListener(touchListener);
jukeboxButton.setOnTouchListener(touchListener);
+ bookmarkButton.setOnTouchListener(touchListener);
emptyTextView.setOnTouchListener(touchListener);
albumArtImageView.setOnTouchListener(touchListener);
@@ -377,6 +382,31 @@ public class DownloadFragment extends SubsonicFragment implements OnGestureListe
}
});
+ bookmarkButton.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ new SilentBackgroundTask<Void>(context) {
+ @Override
+ protected Void doInBackground() throws Throwable {
+ DownloadFile currentDownload = getDownloadService().getCurrentPlaying();
+ if (currentDownload != null) {
+ MusicDirectory.Entry currentSong = currentDownload.getSong();
+ MusicService musicService = MusicServiceFactory.getMusicService(context);
+ musicService.createBookmark(currentSong.getId(), getDownloadService().getPlayerPosition(), "", context, null);
+ }
+
+ return null;
+ }
+
+ @Override
+ protected void done(Void result) {
+ Util.toast(context, R.string.download_save_bookmark);
+ setControlsVisible(true);
+ }
+ }.execute();
+ }
+ });
+
toggleListButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
@@ -479,6 +509,7 @@ public class DownloadFragment extends SubsonicFragment implements OnGestureListe
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater menuInflater) {
+ DownloadService downloadService = getDownloadService();
if(Util.isOffline(context)) {
menuInflater.inflate(R.menu.nowplaying_offline, menu);
} else {
@@ -489,11 +520,11 @@ public class DownloadFragment extends SubsonicFragment implements OnGestureListe
menuInflater.inflate(R.menu.nowplaying_downloading, menu);
}
- if(getDownloadService() != null && getDownloadService().getSleepTimer()) {
+ if(downloadService != null && downloadService.getSleepTimer()) {
menu.findItem(R.id.menu_toggle_timer).setTitle(R.string.download_stop_timer);
}
}
- if(getDownloadService() != null && getDownloadService().getKeepScreenOn()) {
+ if(downloadService != null && downloadService.getKeepScreenOn()) {
menu.findItem(R.id.menu_screen_on_off).setTitle(R.string.download_menu_screen_off);
}
}
diff --git a/src/github/daneren2005/dsub/fragments/SelectBookmarkFragment.java b/src/github/daneren2005/dsub/fragments/SelectBookmarkFragment.java
index b0969b29..f89e7f9c 100644
--- a/src/github/daneren2005/dsub/fragments/SelectBookmarkFragment.java
+++ b/src/github/daneren2005/dsub/fragments/SelectBookmarkFragment.java
@@ -20,6 +20,7 @@ package github.daneren2005.dsub.fragments;
import android.os.Bundle;
import android.util.Log;
+import android.view.ContextMenu;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
@@ -29,12 +30,16 @@ import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ListView;
import github.daneren2005.dsub.R;
+import github.daneren2005.dsub.activity.DownloadActivity;
import github.daneren2005.dsub.domain.Bookmark;
+import github.daneren2005.dsub.domain.MusicDirectory;
+import github.daneren2005.dsub.service.DownloadService;
import github.daneren2005.dsub.service.MusicService;
import github.daneren2005.dsub.service.MusicServiceFactory;
import github.daneren2005.dsub.util.BackgroundTask;
import github.daneren2005.dsub.util.Constants;
import github.daneren2005.dsub.util.TabBackgroundTask;
+import github.daneren2005.dsub.util.Util;
import github.daneren2005.dsub.view.BookmarkAdapter;
import java.io.Serializable;
import java.util.ArrayList;
@@ -67,6 +72,7 @@ public class SelectBookmarkFragment extends SubsonicFragment implements AdapterV
bookmarkListView = (ListView)rootView.findViewById(R.id.fragment_list);
bookmarkListView.setOnItemClickListener(this);
+ registerForContextMenu(bookmarkListView);
emptyView = rootView.findViewById(R.id.fragment_list_empty);
if(bookmarks == null) {
@@ -91,6 +97,32 @@ public class SelectBookmarkFragment extends SubsonicFragment implements AdapterV
return false;
}
+
+ @Override
+ public void onCreateContextMenu(ContextMenu menu, View view, ContextMenu.ContextMenuInfo menuInfo) {
+ super.onCreateContextMenu(menu, view, menuInfo);
+ AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo;
+
+ MusicDirectory.Entry entry = bookmarks.get(info.position).getEntry();
+ onCreateContextMenu(menu, view, menuInfo, entry);
+ if(!Util.isOffline(context)) {
+ menu.removeItem(R.id.song_menu_remove_playlist);
+ }
+ }
+
+ @Override
+ public boolean onContextItemSelected(MenuItem menuItem) {
+ if(!primaryFragment) {
+ return false;
+ }
+
+ AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuItem.getMenuInfo();
+ if(onContextItemSelected(menuItem, bookmarks.get(info.position).getEntry())) {
+ return true;
+ }
+
+ return true;
+ }
@Override
protected void refresh(final boolean refresh) {
@@ -128,6 +160,13 @@ public class SelectBookmarkFragment extends SubsonicFragment implements AdapterV
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
+ DownloadService downloadService = getDownloadService();
+ if(downloadService == null) {
+ return;
+ }
+ Bookmark bookmark = (Bookmark) parent.getItemAtPosition(position);
+ downloadService.download(bookmark);
+ Util.startActivityWithoutTransition(context, DownloadActivity.class);
}
}
diff --git a/src/github/daneren2005/dsub/service/DownloadService.java b/src/github/daneren2005/dsub/service/DownloadService.java
index 7e8c8c81..1a254c73 100644
--- a/src/github/daneren2005/dsub/service/DownloadService.java
+++ b/src/github/daneren2005/dsub/service/DownloadService.java
@@ -22,6 +22,7 @@ import java.util.List;
import github.daneren2005.dsub.audiofx.EqualizerController;
import github.daneren2005.dsub.audiofx.VisualizerController;
+import github.daneren2005.dsub.domain.Bookmark;
import github.daneren2005.dsub.domain.MusicDirectory;
import github.daneren2005.dsub.domain.PlayerState;
import github.daneren2005.dsub.domain.RemoteControlState;
@@ -33,6 +34,7 @@ import github.daneren2005.dsub.domain.RepeatMode;
*/
public interface DownloadService {
+ void download(Bookmark bookmark);
void download(List<MusicDirectory.Entry> songs, boolean save, boolean autoplay, boolean playNext, boolean shuffle);
void downloadBackground(List<MusicDirectory.Entry> songs, boolean save);
diff --git a/src/github/daneren2005/dsub/service/DownloadServiceImpl.java b/src/github/daneren2005/dsub/service/DownloadServiceImpl.java
index d88b5262..e379291f 100644
--- a/src/github/daneren2005/dsub/service/DownloadServiceImpl.java
+++ b/src/github/daneren2005/dsub/service/DownloadServiceImpl.java
@@ -28,6 +28,7 @@ import static github.daneren2005.dsub.domain.PlayerState.STARTED;
import static github.daneren2005.dsub.domain.PlayerState.STOPPED;
import github.daneren2005.dsub.audiofx.EqualizerController;
import github.daneren2005.dsub.audiofx.VisualizerController;
+import github.daneren2005.dsub.domain.Bookmark;
import github.daneren2005.dsub.domain.MusicDirectory;
import github.daneren2005.dsub.domain.PlayerState;
import github.daneren2005.dsub.domain.RemoteControlState;
@@ -270,6 +271,17 @@ public class DownloadServiceImpl extends Service implements DownloadService {
return binder;
}
+ @Override
+ public synchronized void download(Bookmark bookmark) {
+ clear();
+ DownloadFile downloadFile = new DownloadFile(this, bookmark.getEntry(), false);
+ downloadList.add(downloadFile);
+ revision++;
+ updateJukeboxPlaylist();
+ play(0, true, bookmark.getPosition());
+ lifecycleSupport.serializeDownloadQueue();
+ }
+
@Override
public synchronized void download(List<MusicDirectory.Entry> songs, boolean save, boolean autoplay, boolean playNext, boolean shuffle) {
setShufflePlayEnabled(false);
@@ -666,8 +678,10 @@ public class DownloadServiceImpl extends Service implements DownloadService {
public synchronized void play(int index) {
play(index, true);
}
-
- private synchronized void play(int index, boolean start) {
+ private synchronized void play(int index, boolean start) {
+ play(index, start, 0);
+ }
+ private synchronized void play(int index, boolean start, int position) {
if (index < 0 || index >= size()) {
reset();
setCurrentPlaying(null, false);
@@ -683,7 +697,7 @@ public class DownloadServiceImpl extends Service implements DownloadService {
remoteController.changeTrack(index, downloadList.get(index));
setPlayerState(STARTED);
} else {
- bufferAndPlay();
+ bufferAndPlay(position);
}
}
if (remoteState == RemoteControlState.LOCAL) {
@@ -1071,14 +1085,17 @@ public class DownloadServiceImpl extends Service implements DownloadService {
remoteController.setVolume(up);
}
- private synchronized void bufferAndPlay() {
+ private synchronized void bufferAndPlay() {
+ bufferAndPlay(0);
+ }
+ private synchronized void bufferAndPlay(int position) {
if(playerState != PREPARED) {
reset();
- bufferTask = new BufferTask(currentPlaying, 0);
+ bufferTask = new BufferTask(currentPlaying, position);
bufferTask.start();
} else {
- doPlay(currentPlaying, 0, true);
+ doPlay(currentPlaying, position, true);
}
}