Make scrobbler configurable

This commit is contained in:
Christopher Eby 2010-02-22 18:41:28 -06:00
parent c82087c81f
commit 447634de8c
3 changed files with 19 additions and 5 deletions

View File

@ -22,4 +22,7 @@
<string name="notify_while_paused_title">Notify While Paused</string> <string name="notify_while_paused_title">Notify While Paused</string>
<string name="notify_while_paused_summary">Always display the notification</string> <string name="notify_while_paused_summary">Always display the notification</string>
<string name="scrobble_title">Use ScrobbleDroid API</string>
<string name="scrobble_summary">Send song info to Last.FM scrobblers such as ScrobbleDroid and Simple Last.FM Scrobbler</string>
</resources> </resources>

View File

@ -19,4 +19,9 @@
android:title="@string/notify_while_paused_title" android:title="@string/notify_while_paused_title"
android:defaultValue="true" android:defaultValue="true"
android:summary="@string/notify_while_paused_summary" /> android:summary="@string/notify_while_paused_summary" />
<CheckBoxPreference
android:key="scrobble"
android:title="@string/scrobble_title"
android:defaultValue="true"
android:summary="@string/scrobble_summary" />
</PreferenceScreen> </PreferenceScreen>

View File

@ -227,7 +227,8 @@ public class PlaybackService extends Service implements Runnable, MediaPlayer.On
private boolean mHeadsetOnly; private boolean mHeadsetOnly;
private boolean mUseRemotePlayer; private boolean mUseRemotePlayer;
private boolean mNotifyWhilePaused = true; private boolean mNotifyWhilePaused;
private boolean mScrobble;
private Handler mHandler; private Handler mHandler;
private MediaPlayer mMediaPlayer; private MediaPlayer mMediaPlayer;
@ -342,6 +343,7 @@ public class PlaybackService extends Service implements Runnable, MediaPlayer.On
mHeadsetOnly = mSettings.getBoolean("headset_only", false); mHeadsetOnly = mSettings.getBoolean("headset_only", false);
mUseRemotePlayer = mSettings.getBoolean("remote_player", true); mUseRemotePlayer = mSettings.getBoolean("remote_player", true);
mNotifyWhilePaused = mSettings.getBoolean("notify_while_paused", true); mNotifyWhilePaused = mSettings.getBoolean("notify_while_paused", true);
mScrobble = mSettings.getBoolean("scrobble", false);
setCurrentSong(1); setCurrentSong(1);
@ -360,6 +362,8 @@ public class PlaybackService extends Service implements Runnable, MediaPlayer.On
} else if ("notify_while_paused".equals(key)){ } else if ("notify_while_paused".equals(key)){
mNotifyWhilePaused = mSettings.getBoolean(key, true); mNotifyWhilePaused = mSettings.getBoolean(key, true);
updateNotification(); updateNotification();
} else if ("scrobble".equals(key)) {
mScrobble = mSettings.getBoolean("scrobble", false);
} }
} }
@ -383,11 +387,13 @@ public class PlaybackService extends Service implements Runnable, MediaPlayer.On
} }
mWatchers.finishBroadcast(); mWatchers.finishBroadcast();
if (mScrobble) {
Intent intent = new Intent("net.jjc1138.android.scrobbler.action.MUSIC_STATUS"); Intent intent = new Intent("net.jjc1138.android.scrobbler.action.MUSIC_STATUS");
intent.putExtra("playing", mState == STATE_PLAYING); intent.putExtra("playing", mState == STATE_PLAYING);
intent.putExtra("id", getSong(0).id); intent.putExtra("id", getSong(0).id);
sendBroadcast(intent); sendBroadcast(intent);
} }
}
private void retrieveSongs() private void retrieveSongs()
{ {