Merge lp:~headbangerkenny/ubuntuone-android-music/branch into lp:ubuntuone-android-music

Proposed by Joe Simpson
Status: Work in progress
Proposed branch: lp:~headbangerkenny/ubuntuone-android-music/branch
Merge into: lp:ubuntuone-android-music
Diff against target: 163 lines (+32/-8)
9 files modified
res/values/styles.xml (+2/-2)
res/xml/appwidget_info.xml (+1/-1)
src/net/sourceforge/subsonic/androidapp/activity/DownloadActivity.java (+8/-2)
src/net/sourceforge/subsonic/androidapp/activity/MainActivity.java (+1/-1)
src/net/sourceforge/subsonic/androidapp/service/CachedMusicService.java (+2/-0)
src/net/sourceforge/subsonic/androidapp/service/DownloadService.java (+2/-0)
src/net/sourceforge/subsonic/androidapp/service/DownloadServiceImpl.java (+2/-1)
src/net/sourceforge/subsonic/androidapp/util/FileUtil.java (+2/-1)
src/net/sourceforge/subsonic/androidapp/util/ShufflePlayBuffer.java (+12/-0)
To merge this branch: bzr merge lp:~headbangerkenny/ubuntuone-android-music/branch
Reviewer Review Type Date Requested Status
Chad Miller (community) Needs Fixing
Review via email: mp+71364@code.launchpad.net

Commit message

Shuffle Songs improvements -- headbangerkenny

Description of the change

Basically improves the UX a little, so that new users get "Buffering" while the app is loading the shuffled playlist and automatically plays after "Shuffle Songs" is selected.

To post a comment you must log in.
Revision history for this message
Chad Miller (cmiller) wrote :

This is good, we definitely need feedback when waiting for the shuffle-queue to download. The shuffle buffer already starts playing, though.

MainActivity starts DownloadActivity, which checks the received intent for whether this is shuffle-play, and if it is, calls setShufflePlayEnabled(), which calls checkDownloads(), which calls checkShufflePlay(), which calls then play(0) IF it is the first time a shuffle-play has been started (id est, if shuffle play hasn't been stopped in the past).

On subsequent shuffle-play taps, should the music player do anything other than return the user to the place they were before? I need convincing it should do more.

I welcome the informational change for the user. With that only that change, I'd approve. Marking "Needs Fixing" to indicate that I so far don't want the other changes.

review: Needs Fixing
530. By Joe Simpson

Removed that play(0); code that was requested. However, I have moved the cache folder from /sdcard/subsonic to /sdcard/Android/data/net.sourceforge.subsonic.u1m/music because Android says we should do that. Also, I noticed on my device that the ShuffleBuffer would randomly be empty, so when that happens on get() I tell it to grab more tracks, which works (I end up waiting up to 15 mins for this to refill on my device otherwise)

Revision history for this message
Joe Simpson (headbangerkenny) wrote :

Okay, I've done that with a few changes for you to look at :)

Revision history for this message
Chad Miller (cmiller) wrote :

I want to add some of these ideas, but I don't want to add all of them. Please don't make a proposed merge a package-deal of disparate ideas, all-or-nothing. Branches are free! :) Put one idea in per branch.

I would probably have created branches

lp:~headbangerkenny/ubuntuone-android-music/shuffle-progress-information

lp:~headbangerkenny/ubuntuone-android-music/cache-in-official-suggested-folder

lp:~headbangerkenny/ubuntuone-android-music/shuffle-grab-more-tracks-on-empty

lp:~headbangerkenny/ubuntuone-android-music/automatically-resume-on-subsequent-shuffleplay

Revision history for this message
Joe Simpson (headbangerkenny) wrote :

Okay dokie, I'm new to launchpad and I'll remember this!
On Aug 22, 2011 2:08 PM, "Chad Miller" <email address hidden> wrote:
> I want to add some of these ideas, but I don't want to add all of them.
Please don't make a proposed merge a package-deal of disparate ideas,
all-or-nothing. Branches are free! :) Put one idea in per branch.
>
> I would probably have created branches
>
> lp:~headbangerkenny/ubuntuone-android-music/shuffle-progress-information
>
>
lp:~headbangerkenny/ubuntuone-android-music/cache-in-official-suggested-folder
>
>
lp:~headbangerkenny/ubuntuone-android-music/shuffle-grab-more-tracks-on-empty
>
>
lp:~headbangerkenny/ubuntuone-android-music/automatically-resume-on-subsequent-shuffleplay
> --
>
https://code.launchpad.net/~headbangerkenny/ubuntuone-android-music/branch/+merge/71364
> You are the owner of lp:~headbangerkenny/ubuntuone-android-music/branch.

Revision history for this message
Chad Miller (cmiller) wrote :

First, cheers on using File()s to create deep path, rather than succumbing to temptation to manually construct a string with slashes in it. I don't mind moving it to a standard location, but I wonder if it should be the standard "Music" directory instead. If you're going to move the location, you should handle old data and clean it up or move it, rather than abandoning it.

I don't think you mean a recurring Task in ShufflePlayBuffer.get() .

review: Needs Fixing
Revision history for this message
Chad Miller (cmiller) wrote :

First, cheers on using File()s to create deep path, rather than succumbing to temptation to manually construct a string with slashes in it. I don't mind moving it to a standard location, but I wonder if it should be the standard "Music" directory instead. If you're going to move the location, you should handle old data and clean it up or move it, rather than abandoning it.

I don't think you mean a recurring Task in ShufflePlayBuffer.get() .

review: Needs Fixing

Unmerged revisions

530. By Joe Simpson

Removed that play(0); code that was requested. However, I have moved the cache folder from /sdcard/subsonic to /sdcard/Android/data/net.sourceforge.subsonic.u1m/music because Android says we should do that. Also, I noticed on my device that the ShuffleBuffer would randomly be empty, so when that happens on get() I tell it to grab more tracks, which works (I end up waiting up to 15 mins for this to refill on my device otherwise)

529. By Joe Simpson

I have modified the Ubuntu One Music App so that when you tell it to Shuffle, it'll say it's buffering while the playlist is sorted out. Also it'll automatically play when pressing "Shuffle Songs" from the main screen.

528. By Chad Miller

Don't make non-ui events into Page Views in analytics.

527. By Chad Miller

When overriding Activities, be sure to call the superclass's same method. Android requires it.

526. By MichaƂ Karnicki

Lower priority of media button receiver, unregister receiver when done.

525. By Chad Miller

Merge bad-index crash and trunk with analytics.

524. By Chad Miller

Don't dispatch automatically. We are going to use the network here, so dispatch only when we have the network active.

523. By Chad Miller

Revert bogus mistaken change to auth-return scheme.

522. By Chad Miller

Make analytics use more flag values, instead of magnitude values where appropriate.

Add analytics for cache miss and cache total-use. (Subtraction equals cache hit.)

Add analytics for free-space magnitude.

521. By Chad Miller

Make manual trackers dispatch events.

Make downloader start tracker correctly.

Add tracking to other Activities.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'res/values/styles.xml'
2--- res/values/styles.xml 2011-04-21 21:13:18 +0000
3+++ res/values/styles.xml 2011-08-20 12:08:25 +0000
4@@ -12,14 +12,14 @@
5 <item name="android:textColor">@color/white</item>
6 </style>
7
8- <style name="Ubuntu.Title" parent="@android:style/WindowTitle">
9+ <style name="Ubuntu.Title" parent="@android:style/TextAppearance.WindowTitle">
10 <item name="android:paddingLeft">14sp</item>
11 <item name="android:textColor">@color/white</item>
12 <item name="android:textStyle">normal</item>
13 <item name="android:textAppearance">@style/TextAppearance.WindowTitle</item>
14 </style>
15
16- <style name="Ubuntu.TitleBackground" parent="@android:style/WindowTitleBackground">
17+ <style name="Ubuntu.TitleBackground">
18 <item name="android:background">@color/project</item>
19 </style>
20
21
22=== modified file 'res/xml/appwidget_info.xml'
23--- res/xml/appwidget_info.xml 2010-10-23 17:24:51 +0000
24+++ res/xml/appwidget_info.xml 2011-08-20 12:08:25 +0000
25@@ -3,4 +3,4 @@
26 a:minWidth="294dip"
27 a:minHeight="72dip"
28 a:updatePeriodMillis="0"
29- a:initialLayout="@layout/appwidget"/>
30\ No newline at end of file
31+ a:initialLayout="@layout/appwidget"/>
32
33=== modified file 'src/net/sourceforge/subsonic/androidapp/activity/DownloadActivity.java'
34--- src/net/sourceforge/subsonic/androidapp/activity/DownloadActivity.java 2011-07-30 11:51:09 +0000
35+++ src/net/sourceforge/subsonic/androidapp/activity/DownloadActivity.java 2011-08-20 12:08:25 +0000
36@@ -199,8 +199,14 @@
37 registerForContextMenu(playlistView);
38
39 if (getIntent().getBooleanExtra(Constants.INTENT_EXTRA_NAME_SHUFFLE, false) && getDownloadService() != null) {
40- warnIfNetworkOrStorageUnavailable();
41- getDownloadService().setShufflePlayEnabled(true);
42+ Thread t = new Thread("Refresh Random-Songs Cache") {
43+ @Override
44+ public void run() {
45+ warnIfNetworkOrStorageUnavailable();
46+ getDownloadService().setShufflePlayEnabled(true);
47+ }
48+ };
49+ t.start();
50 }
51 }
52
53
54=== modified file 'src/net/sourceforge/subsonic/androidapp/activity/MainActivity.java'
55--- src/net/sourceforge/subsonic/androidapp/activity/MainActivity.java 2011-08-02 13:52:24 +0000
56+++ src/net/sourceforge/subsonic/androidapp/activity/MainActivity.java 2011-08-20 12:08:25 +0000
57@@ -108,7 +108,7 @@
58
59 MergeAdapter adapter = new MergeAdapter();
60 adapter.addViews(Arrays.asList(serverButton, shuffleButton, settingsButton), true);
61- File subsonicDir = new File(Environment.getExternalStorageDirectory(), "subsonic");
62+ File subsonicDir = new File(new File(new File(Environment.getExternalStorageDirectory(), "Android"), "data"), "net.sourceforge.subsonic.u1m");
63 File debugFlagFile = new File(subsonicDir, "showdebugmenu");
64 if (debugFlagFile.exists()) {
65 Log.d(TAG, "Revealing debug settings button.");
66
67=== modified file 'src/net/sourceforge/subsonic/androidapp/service/CachedMusicService.java'
68--- src/net/sourceforge/subsonic/androidapp/service/CachedMusicService.java 2011-07-21 21:55:28 +0000
69+++ src/net/sourceforge/subsonic/androidapp/service/CachedMusicService.java 2011-08-20 12:08:25 +0000
70@@ -24,6 +24,7 @@
71 import net.sourceforge.subsonic.androidapp.domain.Indexes;
72 import net.sourceforge.subsonic.androidapp.domain.MusicDirectory;
73 import net.sourceforge.subsonic.androidapp.domain.Playlist;
74+import net.sourceforge.subsonic.androidapp.domain.PlayerState;
75 import net.sourceforge.subsonic.androidapp.domain.Version;
76 import net.sourceforge.subsonic.androidapp.domain.SearchResult;
77 import net.sourceforge.subsonic.androidapp.domain.SearchCritera;
78@@ -151,6 +152,7 @@
79 Thread t = new Thread("Refresh Random-Songs Cache") {
80 @Override
81 public void run() {
82+ DownloadServiceImpl.getInstance().setPlayerState(PlayerState.PREPARING);
83 Log.i(TAG, "Getting new list of random songs in " + (sleepDuration/1000) + " seconds.");
84 if (sleepDuration != 0L) {
85 Log.i(TAG, "Not requesting new list of songs right away.");
86
87=== modified file 'src/net/sourceforge/subsonic/androidapp/service/DownloadService.java'
88--- src/net/sourceforge/subsonic/androidapp/service/DownloadService.java 2010-12-01 22:37:01 +0000
89+++ src/net/sourceforge/subsonic/androidapp/service/DownloadService.java 2011-08-20 12:08:25 +0000
90@@ -67,6 +67,8 @@
91
92 void reset();
93
94+ public void setPlayerState(PlayerState playerState);
95+
96 PlayerState getPlayerState();
97
98 int getPlayerPosition();
99
100=== modified file 'src/net/sourceforge/subsonic/androidapp/service/DownloadServiceImpl.java'
101--- src/net/sourceforge/subsonic/androidapp/service/DownloadServiceImpl.java 2011-08-02 13:52:24 +0000
102+++ src/net/sourceforge/subsonic/androidapp/service/DownloadServiceImpl.java 2011-08-20 12:08:25 +0000
103@@ -450,7 +450,8 @@
104 return playerState;
105 }
106
107- private synchronized void setPlayerState(PlayerState playerState) {
108+ @Override
109+ public synchronized void setPlayerState(PlayerState playerState) {
110 Log.i(TAG, this.playerState.name() + " -> " + playerState.name() + " (" + currentPlaying + ")");
111
112 boolean show = this.playerState == PAUSED && playerState == PlayerState.STARTED;
113
114=== modified file 'src/net/sourceforge/subsonic/androidapp/util/FileUtil.java'
115--- src/net/sourceforge/subsonic/androidapp/util/FileUtil.java 2011-07-05 23:16:25 +0000
116+++ src/net/sourceforge/subsonic/androidapp/util/FileUtil.java 2011-08-20 12:08:25 +0000
117@@ -153,7 +153,8 @@
118 }
119
120 private static File createDirectory(String name) {
121- File subsonicDir = new File(Environment.getExternalStorageDirectory(), "subsonic");
122+ // http://developer.android.com/guide/topics/data/data-storage.html#filesExternal states we should use this directory instead
123+ File subsonicDir = new File(new File(new File(Environment.getExternalStorageDirectory(), "Android"), "data"), "net.sourceforge.subsonic.u1m");
124 File dir = new File(subsonicDir, name);
125 if (!dir.exists() && !dir.mkdirs()) {
126 Log.e(TAG, "Failed to create " + name);
127
128=== modified file 'src/net/sourceforge/subsonic/androidapp/util/ShufflePlayBuffer.java'
129--- src/net/sourceforge/subsonic/androidapp/util/ShufflePlayBuffer.java 2011-07-22 19:01:22 +0000
130+++ src/net/sourceforge/subsonic/androidapp/util/ShufflePlayBuffer.java 2011-08-20 12:08:25 +0000
131@@ -29,6 +29,8 @@
132 import net.sourceforge.subsonic.androidapp.domain.MusicDirectory;
133 import net.sourceforge.subsonic.androidapp.service.MusicService;
134 import net.sourceforge.subsonic.androidapp.service.MusicServiceFactory;
135+import net.sourceforge.subsonic.androidapp.service.DownloadServiceImpl;
136+import net.sourceforge.subsonic.androidapp.domain.PlayerState;
137
138 /**
139 * @author Sindre Mehus
140@@ -69,6 +71,7 @@
141 }
142
143 public List<MusicDirectory.Entry> get(int size) {
144+ DownloadServiceImpl.getInstance().setPlayerState(PlayerState.PREPARING);
145 clearBufferIfnecessary();
146
147 List<MusicDirectory.Entry> result = new ArrayList<MusicDirectory.Entry>(size);
148@@ -77,6 +80,15 @@
149 result.add(buffer.remove(buffer.size() - 1));
150 }
151 }
152+ if(buffer.size() == 0 && result.size() == 0) { // my phone likes to be empty.... let's fill it up
153+ Runnable runnable = new Runnable() {
154+ @Override
155+ public void run() {
156+ refill();
157+ }
158+ };
159+ executorService.scheduleWithFixedDelay(runnable, 1, 3, TimeUnit.SECONDS);
160+ }
161 Log.i(TAG, "Taking " + result.size() + " songs from shuffle-play buffer. " + buffer.size() + " remaining.");
162 return result;
163 }

Subscribers

People subscribed via source and target branches

to status/vote changes: