aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2014-04-26 14:23:28 -0700
committerScott Jackson <daneren2005@gmail.com>2014-04-26 14:23:28 -0700
commit71785e9ce8b6d9edea43f4f9bdb76e725c0772ca (patch)
treebace99c14883f3f59751c87aedd2fbf904e91447
parente3bcbedd7592eb25ad0c414924c9a43fe226b35f (diff)
parent80f73f1e8e265527ae0a7beb74766d02ac2da49b (diff)
downloaddsub-71785e9ce8b6d9edea43f4f9bdb76e725c0772ca.tar.gz
dsub-71785e9ce8b6d9edea43f4f9bdb76e725c0772ca.tar.bz2
dsub-71785e9ce8b6d9edea43f4f9bdb76e725c0772ca.zip
Merge branch 'master' of https://github.com/daneren2005/Subsonic
-rw-r--r--src/github/daneren2005/dsub/util/compat/RemoteControlClientKK.java82
1 files changed, 0 insertions, 82 deletions
diff --git a/src/github/daneren2005/dsub/util/compat/RemoteControlClientKK.java b/src/github/daneren2005/dsub/util/compat/RemoteControlClientKK.java
deleted file mode 100644
index 532aec5b..00000000
--- a/src/github/daneren2005/dsub/util/compat/RemoteControlClientKK.java
+++ /dev/null
@@ -1,82 +0,0 @@
-package github.daneren2005.dsub.util.compat;
-
-import github.daneren2005.dsub.domain.MusicDirectory;
-import github.daneren2005.dsub.util.ImageLoader;
-import android.annotation.TargetApi;
-import android.app.PendingIntent;
-import android.content.ComponentName;
-import android.content.Context;
-import android.content.Intent;
-import android.media.AudioManager;
-import android.media.MediaMetadataEditor;
-import android.media.MediaMetadataRetriever;
-import android.media.Rating;
-import android.media.RemoteControlClient;
-import android.os.AsyncTask;
-import android.util.Log;
-
-import github.daneren2005.dsub.activity.SubsonicActivity;
-import github.daneren2005.dsub.service.DownloadService;
-import github.daneren2005.dsub.service.MusicService;
-import github.daneren2005.dsub.service.MusicServiceFactory;
-import github.daneren2005.dsub.util.SilentBackgroundTask;
-import github.daneren2005.dsub.util.Util;
-import java.io.File;
-import java.util.Arrays;
-
-@TargetApi(19)
-public class RemoteControlClientKK extends RemoteControlClientJB {
- private static String TAG = RemoteControlClientKK.class.getSimpleName();
- protected MusicDirectory.Entry currentSong;
-
- @Override
- public void register(final Context context, final ComponentName mediaButtonReceiverComponent) {
- super.register(context, mediaButtonReceiverComponent);
-
- mRemoteControl.setMetadataUpdateListener(new RemoteControlClient.OnMetadataUpdateListener() {
- @Override
- public void onMetadataUpdate(int key, Object newValue) {
- if(key == MediaMetadataEditor.RATING_KEY_BY_USER) {
- Rating rating = (Rating) newValue;
- setStarred(currentSong, rating.hasHeart());
- }
- }
- });
- }
-
- @Override
- protected void updateMetadata(final MusicDirectory.Entry currentSong, final RemoteControlClient.MetadataEditor editor) {
- super.updateMetadata(currentSong, editor);
- editor.putObject(MediaMetadataEditor.RATING_KEY_BY_USER, Rating.newHeartRating(currentSong.isStarred()));
- editor.addEditableKey(MediaMetadataEditor.RATING_KEY_BY_USER);
- this.currentSong = currentSong;
- }
-
- @Override
- protected int getTransportFlags() {
- return super.getTransportFlags() | RemoteControlClient.FLAG_KEY_MEDIA_RATING;
- }
-
- private void setStarred(final MusicDirectory.Entry entry, final boolean starred) {
- entry.setStarred(starred);
-
- new AsyncTask<Void, Void, Void>() {
- @Override
- protected Void doInBackground(Void... params) {
- try {
- MusicService musicService = MusicServiceFactory.getMusicService(downloadService);
- musicService.setStarred(Arrays.asList(entry.getId()), null, null, starred, downloadService, null);
-
- // Make sure to clear parent cache
- String s = Util.getRestUrl(downloadService, null) + entry.getParent();
- String parentCache = "directory-" + s.hashCode() + ".ser";
- File file = new File(downloadService.getCacheDir(), parentCache);
- file.delete();
- } catch(Exception e) {
- Log.w(TAG, "Failed to set star for " + entry.getTitle());
- }
- return null;
- }
- }.execute();
- }
-}