From 0e89166dfc4647e23b2e8e833fa581a50c5b49b8 Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Tue, 21 Jan 2014 15:01:32 -0800 Subject: #262 Fix playing status always being true even if paused --- src/github/daneren2005/dsub/util/Util.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/github/daneren2005/dsub/util/Util.java b/src/github/daneren2005/dsub/util/Util.java index e944f125..eecdcdeb 100644 --- a/src/github/daneren2005/dsub/util/Util.java +++ b/src/github/daneren2005/dsub/util/Util.java @@ -1247,11 +1247,13 @@ public final class Util { File albumArtFile = FileUtil.getAlbumArtFile(context, song); intent.putExtra("coverart", albumArtFile.getAbsolutePath()); + avrcpIntent.putExtra("playing", true); } else { intent.putExtra("title", ""); intent.putExtra("artist", ""); intent.putExtra("album", ""); intent.putExtra("coverart", ""); + avrcpIntent.putExtra("playing", false); } addTrackInfo(context, song, avrcpIntent); @@ -1297,7 +1299,6 @@ public final class Util { DownloadService downloadService = (DownloadServiceImpl)context; File albumArtFile = FileUtil.getAlbumArtFile(context, song); - intent.putExtra("playing", true); intent.putExtra("track", song.getTitle()); intent.putExtra("artist", song.getArtist()); intent.putExtra("album", song.getAlbum()); @@ -1307,7 +1308,6 @@ public final class Util { intent.putExtra("position", (long) downloadService.getPlayerPosition()); intent.putExtra("coverart", albumArtFile.getAbsolutePath()); } else { - intent.putExtra("playing", false); intent.putExtra("track", ""); intent.putExtra("artist", ""); intent.putExtra("album", ""); -- cgit v1.2.3 From b270204acd661067f406e1afe8b3822fb7f45405 Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Tue, 21 Jan 2014 15:42:39 -0800 Subject: Fix next with repeat all not working at end for some places --- .../daneren2005/dsub/activity/SubsonicFragmentActivity.java | 4 +--- src/github/daneren2005/dsub/fragments/DownloadFragment.java | 8 +++----- .../daneren2005/dsub/service/DownloadServiceLifecycleSupport.java | 4 +--- 3 files changed, 5 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/github/daneren2005/dsub/activity/SubsonicFragmentActivity.java b/src/github/daneren2005/dsub/activity/SubsonicFragmentActivity.java index 423e1c23..9b1d307a 100644 --- a/src/github/daneren2005/dsub/activity/SubsonicFragmentActivity.java +++ b/src/github/daneren2005/dsub/activity/SubsonicFragmentActivity.java @@ -189,9 +189,7 @@ public class SubsonicFragmentActivity extends SubsonicActivity { return null; } - if (getDownloadService().getCurrentPlayingIndex() < getDownloadService().size() - 1) { - getDownloadService().next(); - } + getDownloadService().next(); return null; } diff --git a/src/github/daneren2005/dsub/fragments/DownloadFragment.java b/src/github/daneren2005/dsub/fragments/DownloadFragment.java index f345334f..ea8e8c3c 100644 --- a/src/github/daneren2005/dsub/fragments/DownloadFragment.java +++ b/src/github/daneren2005/dsub/fragments/DownloadFragment.java @@ -1281,11 +1281,9 @@ public class DownloadFragment extends SubsonicFragment implements OnGestureListe // Right to Left swipe if (e1.getX() - e2.getX() > swipeDistance && Math.abs(velocityX) > swipeVelocity) { warnIfNetworkOrStorageUnavailable(); - if (downloadService.getCurrentPlayingIndex() < downloadService.size() - 1) { - downloadService.next(); - onCurrentChanged(); - onProgressChanged(); - } + downloadService.next(); + onCurrentChanged(); + onProgressChanged(); return true; } diff --git a/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java b/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java index f0b7ceb1..021c214a 100644 --- a/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java +++ b/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java @@ -323,9 +323,7 @@ public class DownloadServiceLifecycleSupport { break; case RemoteControlClient.FLAG_KEY_MEDIA_NEXT: case KeyEvent.KEYCODE_MEDIA_NEXT: - if (downloadService.getCurrentPlayingIndex() < downloadService.size() - 1) { - downloadService.next(); - } + downloadService.next(); break; case RemoteControlClient.FLAG_KEY_MEDIA_STOP: case KeyEvent.KEYCODE_MEDIA_STOP: -- cgit v1.2.3 From a0ea69627b36abc28f5c75bf7c5651fbd2be7d98 Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Tue, 21 Jan 2014 15:49:57 -0800 Subject: When pressing previous on first song with repeat == all, go back to end --- src/github/daneren2005/dsub/service/DownloadServiceImpl.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/github/daneren2005/dsub/service/DownloadServiceImpl.java b/src/github/daneren2005/dsub/service/DownloadServiceImpl.java index 600f2d52..a50d2fe8 100644 --- a/src/github/daneren2005/dsub/service/DownloadServiceImpl.java +++ b/src/github/daneren2005/dsub/service/DownloadServiceImpl.java @@ -811,9 +811,13 @@ public class DownloadServiceImpl extends Service implements DownloadService { } // Restart song if played more than five seconds. - if (getPlayerPosition() > 5000 || index == 0) { + if (getPlayerPosition() > 5000 || (index == 0 && getRepeatMode() != RepeatMode.ALL)) { play(index); } else { + if(index == 0) { + index = size(); + } + play(index - 1); } } -- cgit v1.2.3 From f1fd9a58e97ffb71807391ceac6fe66aa160f054 Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Tue, 21 Jan 2014 16:44:38 -0800 Subject: #263 Add song/album totals to genre list --- res/layout/genre_list_item.xml | 42 ++++++++++++++++++++++ res/values/strings.xml | 2 ++ src/github/daneren2005/dsub/domain/Genre.java | 20 ++++++++++- .../dsub/service/parser/GenreParser.java | 2 ++ src/github/daneren2005/dsub/view/GenreView.java | 30 ++++++++++------ 5 files changed, 84 insertions(+), 12 deletions(-) create mode 100644 res/layout/genre_list_item.xml (limited to 'src') diff --git a/res/layout/genre_list_item.xml b/res/layout/genre_list_item.xml new file mode 100644 index 00000000..658d9cd6 --- /dev/null +++ b/res/layout/genre_list_item.xml @@ -0,0 +1,42 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/res/values/strings.xml b/res/values/strings.xml index b1fbb3c3..860d16ff 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -141,6 +141,8 @@ Failed to sync songs Blank + %d songs + %d albums This podcast had an error while downloading on the server. The server must download it first. This podcast has not been downloaded on the server. The server must download it first. diff --git a/src/github/daneren2005/dsub/domain/Genre.java b/src/github/daneren2005/dsub/domain/Genre.java index 25d226d7..4ca4c387 100644 --- a/src/github/daneren2005/dsub/domain/Genre.java +++ b/src/github/daneren2005/dsub/domain/Genre.java @@ -14,7 +14,9 @@ import github.daneren2005.dsub.util.Util; public class Genre implements Serializable { private String name; private String index; - + private Integer albumCount; + private Integer songCount; + public String getName() { return name; } @@ -36,6 +38,22 @@ public class Genre implements Serializable { return name; } + public Integer getAlbumCount() { + return albumCount; + } + + public void setAlbumCount(Integer albumCount) { + this.albumCount = albumCount; + } + + public Integer getSongCount() { + return songCount; + } + + public void setSongCount(Integer songCount) { + this.songCount = songCount; + } + public static class GenreComparator implements Comparator { @Override public int compare(Genre genre1, Genre genre2) { diff --git a/src/github/daneren2005/dsub/service/parser/GenreParser.java b/src/github/daneren2005/dsub/service/parser/GenreParser.java index f572b564..35913ba9 100644 --- a/src/github/daneren2005/dsub/service/parser/GenreParser.java +++ b/src/github/daneren2005/dsub/service/parser/GenreParser.java @@ -97,6 +97,8 @@ public class GenreParser extends AbstractParser { String name = getElementName(); if ("genre".equals(name)) { genre = new Genre(); + genre.setSongCount(getInteger("songCount")); + genre.setAlbumCount(getInteger("albumCount")); } else if ("error".equals(name)) { handleError(); } else { diff --git a/src/github/daneren2005/dsub/view/GenreView.java b/src/github/daneren2005/dsub/view/GenreView.java index 6a8e04ef..cbd5f081 100644 --- a/src/github/daneren2005/dsub/view/GenreView.java +++ b/src/github/daneren2005/dsub/view/GenreView.java @@ -21,8 +21,6 @@ package github.daneren2005.dsub.view; import android.content.Context; import android.view.LayoutInflater; import android.view.View; -import android.widget.ImageButton; -import android.widget.ImageView; import android.widget.TextView; import github.daneren2005.dsub.R; import github.daneren2005.dsub.domain.Genre; @@ -31,20 +29,30 @@ public class GenreView extends UpdateView { private static final String TAG = GenreView.class.getSimpleName(); private TextView titleView; + private TextView songsView; + private TextView albumsView; public GenreView(Context context) { super(context); - LayoutInflater.from(context).inflate(R.layout.basic_list_item, this, true); - - titleView = (TextView) findViewById(R.id.item_name); - starButton = (ImageButton) findViewById(R.id.item_star); - starButton.setFocusable(false); - moreButton = (ImageView) findViewById(R.id.item_more); - moreButton.setVisibility(View.GONE); - moreButton.setClickable(false); + LayoutInflater.from(context).inflate(R.layout.genre_list_item, this, true); + + titleView = (TextView) findViewById(R.id.genre_name); + songsView = (TextView) findViewById(R.id.genre_songs); + albumsView = (TextView) findViewById(R.id.genre_albums); } public void setObjectImpl(Object obj) { - titleView.setText(((Genre)obj).getName()); + Genre genre = (Genre) obj; + titleView.setText(genre.getName()); + + if(genre.getAlbumCount() != null) { + songsView.setVisibility(View.VISIBLE); + albumsView.setVisibility(View.VISIBLE); + songsView.setText(context.getResources().getString(R.string.select_genre_songs, genre.getSongCount())); + albumsView.setText(context.getResources().getString(R.string.select_genre_albums, genre.getAlbumCount())); + } else { + songsView.setVisibility(View.GONE); + albumsView.setVisibility(View.GONE); + } } } -- cgit v1.2.3 From e851fcaabb00cf2570de3553fcda6003181d18e6 Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Wed, 22 Jan 2014 21:24:52 -0800 Subject: Default to song list if album's in genre is 0 --- src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src') diff --git a/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java b/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java index 93558a03..58cbf3fe 100644 --- a/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java +++ b/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java @@ -495,6 +495,9 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Adapter result = service.getStarredList(context, this); } else if(("genres".equals(albumListType) && Util.checkServerVersion(context, "1.10.0")) || "years".equals(albumListType)) { result = service.getAlbumList(albumListType, albumListExtra, size, 0, context, this); + if(result.getChildrenSize() == 0 && "genres".equals(albumListType)) { + result = service.getSongsByGenre(albumListExtra, size, 0, context, this); + } } else if("genres".equals(albumListType)) { result = service.getSongsByGenre(albumListExtra, size, 0, context, this); } else { -- cgit v1.2.3 From 0d3eebaf1940c8fb6e604df6a1da33dcbb5b99e1 Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Wed, 22 Jan 2014 21:43:08 -0800 Subject: Fix a few places where the index wasn't properly updated --- src/github/daneren2005/dsub/service/DownloadServiceImpl.java | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') diff --git a/src/github/daneren2005/dsub/service/DownloadServiceImpl.java b/src/github/daneren2005/dsub/service/DownloadServiceImpl.java index a50d2fe8..e1ea56ef 100644 --- a/src/github/daneren2005/dsub/service/DownloadServiceImpl.java +++ b/src/github/daneren2005/dsub/service/DownloadServiceImpl.java @@ -414,6 +414,7 @@ public class DownloadServiceImpl extends Service implements DownloadService { downloadList.remove(getCurrentPlayingIndex()); downloadList.add(0, currentPlaying); } + currentPlayingIndex = downloadList.indexOf(currentPlaying); revision++; lifecycleSupport.serializeDownloadQueue(); updateJukeboxPlaylist(); @@ -557,6 +558,7 @@ public class DownloadServiceImpl extends Service implements DownloadService { @Override public synchronized void remove(int which) { downloadList.remove(which); + currentPlayingIndex = downloadList.indexOf(currentPlaying); } @Override @@ -570,6 +572,7 @@ public class DownloadServiceImpl extends Service implements DownloadService { setCurrentPlaying(null, false); } downloadList.remove(downloadFile); + currentPlayingIndex = downloadList.indexOf(currentPlaying); backgroundDownloadList.remove(downloadFile); revision++; lifecycleSupport.serializeDownloadQueue(); @@ -1546,6 +1549,7 @@ public class DownloadServiceImpl extends Service implements DownloadService { revision++; } } + currentPlayingIndex = downloadList.indexOf(currentPlaying); if (revisionBefore != revision) { updateJukeboxPlaylist(); -- cgit v1.2.3