Merge lp:~cmiller/ubuntuone-android-music/last-fm-scrobbling into lp:ubuntuone-android-music
- last-fm-scrobbling
- Merge into trunk
Proposed by
Chad Miller
Status: | Merged |
---|---|
Merged at revision: | 452 |
Proposed branch: | lp:~cmiller/ubuntuone-android-music/last-fm-scrobbling |
Merge into: | lp:ubuntuone-android-music |
Diff against target: |
202 lines (+80/-2) 6 files modified
assets/html/en/index.html (+12/-0) res/values/strings.xml (+3/-0) res/xml/settings.xml (+10/-0) src/net/sourceforge/subsonic/androidapp/activity/SettingsActivity.java (+4/-1) src/net/sourceforge/subsonic/androidapp/service/DownloadServiceImpl.java (+31/-0) src/net/sourceforge/subsonic/androidapp/util/Constants.java (+20/-1) |
To merge this branch: | bzr merge lp:~cmiller/ubuntuone-android-music/last-fm-scrobbling |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Ubuntu One hackers | Pending | ||
Review via email: mp+37796@code.launchpad.net |
Commit message
Description of the change
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'assets/html/en/index.html' | |||
2 | --- assets/html/en/index.html 2010-09-01 14:23:38 +0000 | |||
3 | +++ assets/html/en/index.html 2010-10-06 21:34:43 +0000 | |||
4 | @@ -30,5 +30,17 @@ | |||
5 | 30 | <li>Includes photos and contacts sync for iPhone and Android devices.</li><!-- May need to alter depending on the delivery date of photos sync --> | 30 | <li>Includes photos and contacts sync for iPhone and Android devices.</li><!-- May need to alter depending on the delivery date of photos sync --> |
6 | 31 | </ul> | 31 | </ul> |
7 | 32 | 32 | ||
8 | 33 | <h2>Scrobbling</h2> | ||
9 | 34 | |||
10 | 35 | <p>If you use <a href="http://last.fm/">Last.fm</a> to track your music and get recommendations, then you can install an "scrobbling" app to to send playlist events. Ubuntu One Mobile Music Streaming supports a number of apps:</a></p> | ||
11 | 36 | |||
12 | 37 | <ul> | ||
13 | 38 | <li><i><disableda href="http://market.android.com/details?id=com.adam.aslfms">Simple Last.fm Scrobbler</disableda></i></li> | ||
14 | 39 | <li>official <i><disableda href="http://market.android.com/search?q=fm.last.android">Last.fm</disableda></i></li> | ||
15 | 40 | </ul> | ||
16 | 41 | |||
17 | 42 | <p>To use, enable scrobbling in the Ubuntu One Mobile Music Streaming settings, after you install and set up a scrobbling app.</p> | ||
18 | 43 | |||
19 | 44 | |||
20 | 33 | </body> | 45 | </body> |
21 | 34 | </html> | 46 | </html> |
22 | 35 | 47 | ||
23 | === modified file 'res/values/strings.xml' | |||
24 | --- res/values/strings.xml 2010-10-01 12:16:53 +0000 | |||
25 | +++ res/values/strings.xml 2010-10-06 21:34:43 +0000 | |||
26 | @@ -137,6 +137,9 @@ | |||
27 | 137 | <string name="settings.cache_size_10000">10 GB</string> | 137 | <string name="settings.cache_size_10000">10 GB</string> |
28 | 138 | <string name="settings.cache_size_20000">20 GB</string> | 138 | <string name="settings.cache_size_20000">20 GB</string> |
29 | 139 | <string name="settings.cache_size_unlimited">Unlimited</string> | 139 | <string name="settings.cache_size_unlimited">Unlimited</string> |
30 | 140 | <string name="settings.lastfm_title">Last.fm</string> | ||
31 | 141 | <string name="settings.lastfm_scrobble">Scrobbling Support</string> | ||
32 | 142 | <string name="settings.lastfm_description">Report plays to Last.fm app (see Help)</string> | ||
33 | 140 | 143 | ||
34 | 141 | <string name="music_service.retry">A network error occurred. Retrying %d of %d.</string> | 144 | <string name="music_service.retry">A network error occurred. Retrying %d of %d.</string> |
35 | 142 | 145 | ||
36 | 143 | 146 | ||
37 | === modified file 'res/xml/settings.xml' | |||
38 | --- res/xml/settings.xml 2010-09-07 09:14:31 +0000 | |||
39 | +++ res/xml/settings.xml 2010-10-06 21:34:43 +0000 | |||
40 | @@ -34,4 +34,14 @@ | |||
41 | 34 | 34 | ||
42 | 35 | </PreferenceCategory> | 35 | </PreferenceCategory> |
43 | 36 | 36 | ||
44 | 37 | <PreferenceCategory | ||
45 | 38 | a:title="@string/settings.lastfm_title"> | ||
46 | 39 | <CheckBoxPreference | ||
47 | 40 | a:title="@string/settings.lastfm_scrobble" | ||
48 | 41 | a:key="lastfmScrobbling" | ||
49 | 42 | a:defaultValue="false" | ||
50 | 43 | a:summary="@string/settings.lastfm_description" | ||
51 | 44 | /> | ||
52 | 45 | </PreferenceCategory> | ||
53 | 46 | |||
54 | 37 | </PreferenceScreen> | 47 | </PreferenceScreen> |
55 | 38 | 48 | ||
56 | === modified file 'src/net/sourceforge/subsonic/androidapp/activity/SettingsActivity.java' | |||
57 | --- src/net/sourceforge/subsonic/androidapp/activity/SettingsActivity.java 2010-08-23 06:27:00 +0000 | |||
58 | +++ src/net/sourceforge/subsonic/androidapp/activity/SettingsActivity.java 2010-10-06 21:34:43 +0000 | |||
59 | @@ -20,6 +20,7 @@ | |||
60 | 20 | 20 | ||
61 | 21 | import android.content.SharedPreferences; | 21 | import android.content.SharedPreferences; |
62 | 22 | import android.os.Bundle; | 22 | import android.os.Bundle; |
63 | 23 | import android.preference.CheckBoxPreference; | ||
64 | 23 | import android.preference.ListPreference; | 24 | import android.preference.ListPreference; |
65 | 24 | import android.preference.PreferenceActivity; | 25 | import android.preference.PreferenceActivity; |
66 | 25 | import android.util.Log; | 26 | import android.util.Log; |
67 | @@ -33,6 +34,7 @@ | |||
68 | 33 | private ListPreference theme; | 34 | private ListPreference theme; |
69 | 34 | private ListPreference cacheSize; | 35 | private ListPreference cacheSize; |
70 | 35 | private ListPreference preloadCount; | 36 | private ListPreference preloadCount; |
71 | 37 | private CheckBoxPreference lastfmScrobbling; | ||
72 | 36 | 38 | ||
73 | 37 | @Override | 39 | @Override |
74 | 38 | public void onCreate(Bundle savedInstanceState) { | 40 | public void onCreate(Bundle savedInstanceState) { |
75 | @@ -42,6 +44,7 @@ | |||
76 | 42 | theme = (ListPreference) findPreference(Constants.PREFERENCES_KEY_THEME); | 44 | theme = (ListPreference) findPreference(Constants.PREFERENCES_KEY_THEME); |
77 | 43 | cacheSize = (ListPreference) findPreference(Constants.PREFERENCES_KEY_CACHE_SIZE); | 45 | cacheSize = (ListPreference) findPreference(Constants.PREFERENCES_KEY_CACHE_SIZE); |
78 | 44 | preloadCount = (ListPreference) findPreference(Constants.PREFERENCES_KEY_PRELOAD_COUNT); | 46 | preloadCount = (ListPreference) findPreference(Constants.PREFERENCES_KEY_PRELOAD_COUNT); |
79 | 47 | lastfmScrobbling = (CheckBoxPreference) findPreference(Constants.PREFERENCES_KEY_LASTFM_SCROBBLING); | ||
80 | 45 | 48 | ||
81 | 46 | SharedPreferences prefs = Util.getPreferences(this); | 49 | SharedPreferences prefs = Util.getPreferences(this); |
82 | 47 | prefs.registerOnSharedPreferenceChangeListener(this); | 50 | prefs.registerOnSharedPreferenceChangeListener(this); |
83 | @@ -69,4 +72,4 @@ | |||
84 | 69 | preloadCount.setSummary(preloadCount.getEntry()); | 72 | preloadCount.setSummary(preloadCount.getEntry()); |
85 | 70 | } | 73 | } |
86 | 71 | 74 | ||
87 | 72 | } | ||
88 | 73 | \ No newline at end of file | 75 | \ No newline at end of file |
89 | 76 | } | ||
90 | 74 | 77 | ||
91 | === modified file 'src/net/sourceforge/subsonic/androidapp/service/DownloadServiceImpl.java' | |||
92 | --- src/net/sourceforge/subsonic/androidapp/service/DownloadServiceImpl.java 2010-09-07 09:14:31 +0000 | |||
93 | +++ src/net/sourceforge/subsonic/androidapp/service/DownloadServiceImpl.java 2010-10-06 21:34:43 +0000 | |||
94 | @@ -28,6 +28,7 @@ | |||
95 | 28 | import android.app.Service; | 28 | import android.app.Service; |
96 | 29 | import android.content.Context; | 29 | import android.content.Context; |
97 | 30 | import android.content.Intent; | 30 | import android.content.Intent; |
98 | 31 | import android.content.SharedPreferences; | ||
99 | 31 | import android.media.AudioManager; | 32 | import android.media.AudioManager; |
100 | 32 | import android.media.MediaPlayer; | 33 | import android.media.MediaPlayer; |
101 | 33 | import android.os.Handler; | 34 | import android.os.Handler; |
102 | @@ -38,6 +39,7 @@ | |||
103 | 38 | import net.sourceforge.subsonic.androidapp.domain.MusicDirectory; | 39 | import net.sourceforge.subsonic.androidapp.domain.MusicDirectory; |
104 | 39 | import net.sourceforge.subsonic.androidapp.domain.PlayerState; | 40 | import net.sourceforge.subsonic.androidapp.domain.PlayerState; |
105 | 40 | import net.sourceforge.subsonic.androidapp.util.CancellableTask; | 41 | import net.sourceforge.subsonic.androidapp.util.CancellableTask; |
106 | 42 | import net.sourceforge.subsonic.androidapp.util.Constants; | ||
107 | 41 | import net.sourceforge.subsonic.androidapp.util.ShufflePlayBuffer; | 43 | import net.sourceforge.subsonic.androidapp.util.ShufflePlayBuffer; |
108 | 42 | import net.sourceforge.subsonic.androidapp.util.SimpleServiceBinder; | 44 | import net.sourceforge.subsonic.androidapp.util.SimpleServiceBinder; |
109 | 43 | import net.sourceforge.subsonic.androidapp.util.Util; | 45 | import net.sourceforge.subsonic.androidapp.util.Util; |
110 | @@ -226,8 +228,10 @@ | |||
111 | 226 | 228 | ||
112 | 227 | if (currentPlaying != null && showNotification) { | 229 | if (currentPlaying != null && showNotification) { |
113 | 228 | Util.showPlayingNotification(this, handler, currentPlaying.getSong()); | 230 | Util.showPlayingNotification(this, handler, currentPlaying.getSong()); |
114 | 231 | scrobbleLastfm(Constants.LASTFM_STATE_START); | ||
115 | 229 | } else { | 232 | } else { |
116 | 230 | Util.hidePlayingNotification(this, handler); | 233 | Util.hidePlayingNotification(this, handler); |
117 | 234 | scrobbleLastfm(Constants.LASTFM_STATE_COMPLETE); | ||
118 | 231 | } | 235 | } |
119 | 232 | } | 236 | } |
120 | 233 | 237 | ||
121 | @@ -380,8 +384,10 @@ | |||
122 | 380 | 384 | ||
123 | 381 | if (this.playerState == PAUSED && playerState == PlayerState.STARTED) { | 385 | if (this.playerState == PAUSED && playerState == PlayerState.STARTED) { |
124 | 382 | Util.showPlayingNotification(this, handler, currentPlaying.getSong()); | 386 | Util.showPlayingNotification(this, handler, currentPlaying.getSong()); |
125 | 387 | scrobbleLastfm(Constants.LASTFM_STATE_START); | ||
126 | 383 | } else if (this.playerState == STARTED && playerState == PlayerState.PAUSED) { | 388 | } else if (this.playerState == STARTED && playerState == PlayerState.PAUSED) { |
127 | 384 | Util.hidePlayingNotification(this, handler); | 389 | Util.hidePlayingNotification(this, handler); |
128 | 390 | scrobbleLastfm(Constants.LASTFM_STATE_PAUSE); | ||
129 | 385 | } | 391 | } |
130 | 386 | 392 | ||
131 | 387 | this.playerState = playerState; | 393 | this.playerState = playerState; |
132 | @@ -572,6 +578,31 @@ | |||
133 | 572 | return revision; | 578 | return revision; |
134 | 573 | } | 579 | } |
135 | 574 | 580 | ||
136 | 581 | private void scrobbleLastfm(final int aState) { | ||
137 | 582 | SharedPreferences prefs = Util.getPreferences(this); | ||
138 | 583 | |||
139 | 584 | if (prefs.getBoolean(Constants.PREFERENCES_KEY_LASTFM_SCROBBLING, false)) { | ||
140 | 585 | // Launch Last.fm intent here | ||
141 | 586 | Intent lastfm = new Intent(); | ||
142 | 587 | |||
143 | 588 | lastfm.setAction(Constants.INTENT_SCROBBLE_LASTFM); | ||
144 | 589 | lastfm.putExtra(Constants.INTENT_EXTRA_LASTFM_APP_NAME, Constants.LASTFM_APP_NAME); | ||
145 | 590 | lastfm.putExtra(Constants.INTENT_EXTRA_LASTFM_APP_PACKAGE, Constants.LASTFM_APP_PACKAGE); | ||
146 | 591 | |||
147 | 592 | if (currentPlaying != null && currentPlaying.getSong() != null) { | ||
148 | 593 | lastfm.putExtra(Constants.INTENT_EXTRA_LASTFM_TRACK, currentPlaying.getSong().getTitle()); | ||
149 | 594 | lastfm.putExtra(Constants.INTENT_EXTRA_LASTFM_ARTIST, currentPlaying.getSong().getArtist()); | ||
150 | 595 | lastfm.putExtra(Constants.INTENT_EXTRA_LASTFM_ALBUM, currentPlaying.getSong().getAlbum()); | ||
151 | 596 | // lastfm.putExtra(Constants.INTENT_EXTRA_LASTFM_PLAYER, Constants.LASTFM_APP_NAME); | ||
152 | 597 | lastfm.putExtra(Constants.INTENT_EXTRA_LASTFM_DURATION, currentPlaying.getSong().getDuration()); | ||
153 | 598 | } | ||
154 | 599 | |||
155 | 600 | lastfm.putExtra(Constants.INTENT_EXTRA_LASTFM_STATE, aState); | ||
156 | 601 | |||
157 | 602 | sendBroadcast(lastfm); | ||
158 | 603 | } | ||
159 | 604 | } | ||
160 | 605 | |||
161 | 575 | private synchronized void cleanup() { | 606 | private synchronized void cleanup() { |
162 | 576 | Iterator<DownloadFile> iterator = cleanupCandidates.iterator(); | 607 | Iterator<DownloadFile> iterator = cleanupCandidates.iterator(); |
163 | 577 | while (iterator.hasNext()) { | 608 | while (iterator.hasNext()) { |
164 | 578 | 609 | ||
165 | === modified file 'src/net/sourceforge/subsonic/androidapp/util/Constants.java' | |||
166 | --- src/net/sourceforge/subsonic/androidapp/util/Constants.java 2010-09-29 21:08:46 +0000 | |||
167 | +++ src/net/sourceforge/subsonic/androidapp/util/Constants.java 2010-10-06 21:34:43 +0000 | |||
168 | @@ -44,7 +44,25 @@ | |||
169 | 44 | public static final String INTENT_EXTRA_NAME_ALBUM_LIST_OFFSET = "subsonic.albumlistoffset"; | 44 | public static final String INTENT_EXTRA_NAME_ALBUM_LIST_OFFSET = "subsonic.albumlistoffset"; |
170 | 45 | public static final String INTENT_EXTRA_NAME_SHUFFLE = "subsonic.shuffle"; | 45 | public static final String INTENT_EXTRA_NAME_SHUFFLE = "subsonic.shuffle"; |
171 | 46 | public static final String INTENT_EXTRA_NAME_REFRESH = "subsonic.refresh"; | 46 | public static final String INTENT_EXTRA_NAME_REFRESH = "subsonic.refresh"; |
173 | 47 | 47 | public static final String INTENT_EXTRA_LASTFM_APP_NAME = "app-name"; | |
174 | 48 | public static final String INTENT_EXTRA_LASTFM_APP_PACKAGE = "app-package"; | ||
175 | 49 | public static final String INTENT_EXTRA_LASTFM_TRACK = "track"; | ||
176 | 50 | public static final String INTENT_EXTRA_LASTFM_ARTIST = "artist"; | ||
177 | 51 | public static final String INTENT_EXTRA_LASTFM_ALBUM = "album"; | ||
178 | 52 | public static final String INTENT_EXTRA_LASTFM_PLAYER = "player"; | ||
179 | 53 | public static final String INTENT_EXTRA_LASTFM_DURATION = "duration"; | ||
180 | 54 | public static final String INTENT_EXTRA_LASTFM_STATE = "state"; | ||
181 | 55 | |||
182 | 56 | // Names for external intents | ||
183 | 57 | public static final String INTENT_SCROBBLE_LASTFM = "com.adam.aslfms.notify.playstatechanged"; | ||
184 | 58 | |||
185 | 59 | // Last.fm scrobbling values | ||
186 | 60 | public static final String LASTFM_APP_NAME = "Ubuntu One Music"; | ||
187 | 61 | public static final String LASTFM_APP_PACKAGE = "net.sourceforge.subsonic.androidapp"; | ||
188 | 62 | public static final int LASTFM_STATE_START = 0; | ||
189 | 63 | public static final int LASTFM_STATE_RESUME = 1; | ||
190 | 64 | public static final int LASTFM_STATE_PAUSE = 2; | ||
191 | 65 | public static final int LASTFM_STATE_COMPLETE = 3; | ||
192 | 48 | 66 | ||
193 | 49 | // Notification IDs. | 67 | // Notification IDs. |
194 | 50 | public static final int NOTIFICATION_ID_PLAYING = 100; | 68 | public static final int NOTIFICATION_ID_PLAYING = 100; |
195 | @@ -62,6 +80,7 @@ | |||
196 | 62 | public static final String PREFERENCES_KEY_MAX_BITRATE_MOBILE = "maxBitrateMobile"; | 80 | public static final String PREFERENCES_KEY_MAX_BITRATE_MOBILE = "maxBitrateMobile"; |
197 | 63 | public static final String PREFERENCES_KEY_CACHE_SIZE = "cacheSize"; | 81 | public static final String PREFERENCES_KEY_CACHE_SIZE = "cacheSize"; |
198 | 64 | public static final String PREFERENCES_KEY_PRELOAD_COUNT = "preloadCount"; | 82 | public static final String PREFERENCES_KEY_PRELOAD_COUNT = "preloadCount"; |
199 | 83 | public static final String PREFERENCES_KEY_LASTFM_SCROBBLING = "lastfmScrobbling"; | ||
200 | 65 | 84 | ||
201 | 66 | // Name of the preferences file. | 85 | // Name of the preferences file. |
202 | 67 | public static final String PREFERENCES_FILE_NAME = "net.sourceforge.subsonic.u1m_preferences"; | 86 | public static final String PREFERENCES_FILE_NAME = "net.sourceforge.subsonic.u1m_preferences"; |