it = keys.iterator();
- Log.e(TAG,"Dumping Intent start");
+ Log.d(TAG,"Dumping Intent start");
while (it.hasNext()) {
String key = it.next();
- Log.e(TAG,"[" + key + "=" + bundle.get(key)+"]");
+ Log.d(TAG,"[" + key + "=" + bundle.get(key)+"]");
}
- Log.e(TAG,"Dumping Intent end");
+ Log.d(TAG,"Dumping Intent end");
}
}
@@ -75,7 +75,7 @@ public final void onReceive(Context context, Intent intent) {
dumpIntent(bundle);
- Log.e(TAG, "Action received was: " + action);
+ Log.d(TAG, "Action received was: " + action);
// check to make sure we actually got something
if (action == null) {
diff --git a/app/src/main/java/com/adam/aslfms/receiver/BuiltInMusicAppReceiver.java b/app/src/main/java/com/adam/aslfms/receiver/BuiltInMusicAppReceiver.java
index 4a144e47..78b28fb9 100644
--- a/app/src/main/java/com/adam/aslfms/receiver/BuiltInMusicAppReceiver.java
+++ b/app/src/main/java/com/adam/aslfms/receiver/BuiltInMusicAppReceiver.java
@@ -218,7 +218,8 @@ void readTrackFromMediaStore(Context ctx, Track.Builder b, long audioid) {
MediaStore.Audio.AudioColumns.TITLE,
MediaStore.Audio.AudioColumns.DURATION,
MediaStore.Audio.AudioColumns.ALBUM,
- MediaStore.Audio.AudioColumns.TRACK, };
+ MediaStore.Audio.AudioColumns.TRACK,
+ MediaStore.Audio.AudioColumns.COMPOSER};
Cursor cur = ctx.getContentResolver().query(
ContentUris.withAppendedId(
@@ -242,6 +243,10 @@ void readTrackFromMediaStore(Context ctx, Track.Builder b, long audioid) {
String album = cur.getString(cur.getColumnIndex(MediaStore.Audio.AudioColumns.ALBUM));
b.setAlbum(album);
+ String albumArtist = cur.getString(cur.getColumnIndex(MediaStore.Audio.AudioColumns.COMPOSER));
+ b.setAlbumArtist(albumArtist);
+
+
int duration = (int) (cur.getLong(cur.getColumnIndex(MediaStore.Audio.AudioColumns.DURATION)) / 1000);
if (duration != 0) {
@@ -303,7 +308,17 @@ void readTrackFromBundleData(Track.Builder b, Bundle bundle) {
b.setAlbum(al.toString());
}
} else {
- b.setAlbum("");
+ b.setAlbum(""); // album is not required to scrobble
+ }
+ if (bundle.containsKey("albumartist")){
+ CharSequence al = bundle.getCharSequence("albumartist");
+ if (al == null || "Unknown albumArtist".equals(al.toString()) || "Unknown".equals(al.toString())) {
+ b.setAlbumArtist(""); // albumArtist is not required to scrobble.
+ } else {
+ b.setAlbumArtist(al.toString());
+ }
+ } else {
+ b.setAlbumArtist(""); // albumArtist is not required to scrobble
}
b.setArtist(ar.toString());
b.setTrack(tr.toString());
diff --git a/app/src/main/java/com/adam/aslfms/receiver/OrangeSqueezeReceiver.java b/app/src/main/java/com/adam/aslfms/receiver/OrangeSqueezeReceiver.java
new file mode 100644
index 00000000..c182df57
--- /dev/null
+++ b/app/src/main/java/com/adam/aslfms/receiver/OrangeSqueezeReceiver.java
@@ -0,0 +1,75 @@
+/**
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.adam.aslfms.receiver;
+
+import android.content.Context;
+import android.os.Bundle;
+import android.util.Log;
+
+import com.adam.aslfms.util.Track;
+import com.adam.aslfms.util.Util;
+
+/**
+ * A BroadcastReceiver for intents sent by the Orange Squeeze music player
+ *
+ * @see AbstractPlayStatusReceiver
+ *
+ * @author Austin Hogan
+ * @since 1.5.8
+ */
+public class OrangeSqueezeReceiver extends AbstractPlayStatusReceiver {
+
+ static final String APP_PACKAGE = "com.orangebikelabs.orangesqueeze";
+ static final String APP_NAME = "Orange Squeeze";
+
+ static final String ACTION_ORANGE_METACHANGED = "com.orangebikelabs.orangesqueeze.metachanged";
+ static final String ACTION_ORANGE_PLAYSTATECHANGED = "com.orangebikelabs.orangesqueeze.playstatechanged";
+
+ static final String TAG = "OrangeSqzReceiver";
+ static private Track track = null;
+
+ @Override
+ protected void parseIntent(Context ctx, String action, Bundle bundle) {
+
+ MusicAPI musicAPI = MusicAPI.fromReceiver(
+ ctx, APP_NAME, APP_PACKAGE, null, false);
+ setMusicAPI(musicAPI);
+
+ if (action.equals(ACTION_ORANGE_METACHANGED)) {
+ boolean isPlaying = bundle.getBoolean("isplaying");
+ boolean isPaused = bundle.getBoolean("ispaused");
+ if (isPaused) {
+ setState(Track.State.PAUSE);
+ Log.d(TAG, "Setting state to PAUSE");
+ }
+ if (isPlaying) {
+ setState(Track.State.RESUME);
+ Log.d(TAG, "Setting state to RESUME");
+ }
+ Track.Builder b = new Track.Builder();
+ b.setMusicAPI(musicAPI);
+ b.setWhen(Util.currentTimeSecsUTC());
+
+ b.setArtist(bundle.getString("artist"));
+ b.setAlbum(bundle.getString("album"));
+ b.setTrack(bundle.getString("track"));
+ b.setAlbumArtist(bundle.getString("albumartist"));
+ b.setTrackArtist(bundle.getString("trackartist"));
+ b.setTrackNr(bundle.getString("tracknr"));
+ b.setDuration(bundle.getInt("duration")/1000); // convert ms to
+ setTrack(b.build());
+ }
+ }
+}
diff --git a/app/src/main/java/com/adam/aslfms/receiver/SLSAPIReceiver.java b/app/src/main/java/com/adam/aslfms/receiver/SLSAPIReceiver.java
index 574f229a..4badffeb 100644
--- a/app/src/main/java/com/adam/aslfms/receiver/SLSAPIReceiver.java
+++ b/app/src/main/java/com/adam/aslfms/receiver/SLSAPIReceiver.java
@@ -130,6 +130,17 @@ else if (state == STATE_COMPLETE)
} else {
b.setAlbum("");
}
+ // albumartist name, optional (recommended)
+ if (bundle.containsKey("albumartist")){
+ CharSequence al = bundle.getCharSequence("albumartist");
+ if (al == null || "Unknown albumArtist".equals(al.toString()) || "Unknown".equals(al.toString())) {
+ b.setAlbumArtist(""); // albumArtist is not required to scrobble.
+ } else {
+ b.setAlbumArtist(al.toString());
+ }
+ } else {
+ b.setAlbumArtist(""); // albumArtist is not required to scrobble
+ }
// track name, required
b.setTrack(bundle.getString("track"));
diff --git a/app/src/main/java/com/adam/aslfms/service/NPNotifier.java b/app/src/main/java/com/adam/aslfms/service/NPNotifier.java
index e8246b82..f57a884e 100644
--- a/app/src/main/java/com/adam/aslfms/service/NPNotifier.java
+++ b/app/src/main/java/com/adam/aslfms/service/NPNotifier.java
@@ -386,6 +386,9 @@ public void notifyNowPlaying(Track track, HandshakeResult hInfo)
if (track.getAlbum() != null) {
params.put("album", track.getAlbum());
}
+ if (track.getAlbumArtist() != null) {
+ params.put("albumArtist", track.getAlbumArtist());
+ }
params.put("api_key", settings.rcnvK(settings.getAPIkey()));
params.put("artist", track.getArtist());
if (track.getDuration() != 180) {
diff --git a/app/src/main/java/com/adam/aslfms/service/Scrobbler.java b/app/src/main/java/com/adam/aslfms/service/Scrobbler.java
index 495df175..5e386554 100644
--- a/app/src/main/java/com/adam/aslfms/service/Scrobbler.java
+++ b/app/src/main/java/com/adam/aslfms/service/Scrobbler.java
@@ -464,6 +464,11 @@ public void scrobbleCommit(HandshakeResult hInfo, Track[] tracks)
if (track.getAlbum() != null) {
params.put("album" + is, track.getAlbum());
}
+
+ if (track.getAlbumArtist() != null) {
+ params.put("albumArtist" + is, track.getAlbumArtist());
+ }
+
params.put("artist" + is, track.getArtist());
if (track.getSource().equals("R") || track.getSource().equals("E")) {
params.put("chosenByUser" + is, 0);
diff --git a/app/src/main/java/com/adam/aslfms/service/applemusic/TrackData.java b/app/src/main/java/com/adam/aslfms/service/applemusic/TrackData.java
index 348ff8af..996aa925 100644
--- a/app/src/main/java/com/adam/aslfms/service/applemusic/TrackData.java
+++ b/app/src/main/java/com/adam/aslfms/service/applemusic/TrackData.java
@@ -13,6 +13,8 @@ class TrackData {
private String artist;
private String title;
private String album;
+ private String albumartist;
+ private String trackartist;
private Date startTime;
private PlayingState currentState = PlayingState.UNKNOWN;
private ArrayList playTimes = new ArrayList<>();
@@ -98,6 +100,14 @@ void setAlbum(String album) {
this.album = album;
}
+ void setAlbumArtist(String albumartist) {
+ this.albumartist = albumartist;
+ }
+
+ void setTrackArtist(String trackartist) {
+ this.trackartist = trackartist;
+ }
+
void setStartTime(Date startTime) {
this.startTime = startTime;
}
@@ -114,6 +124,14 @@ String getAlbum() {
return album;
}
+ String getAlbumArtist() {
+ return albumartist;
+ }
+
+ String getTrackArtist() {
+ return trackartist;
+ }
+
PlayingState getCurrentState() {
return currentState;
}
diff --git a/app/src/main/java/com/adam/aslfms/util/ScrobblesDatabase.java b/app/src/main/java/com/adam/aslfms/util/ScrobblesDatabase.java
index ca3df824..1158623b 100644
--- a/app/src/main/java/com/adam/aslfms/util/ScrobblesDatabase.java
+++ b/app/src/main/java/com/adam/aslfms/util/ScrobblesDatabase.java
@@ -83,6 +83,8 @@ public class ScrobblesDatabase {
+ "musicapp integer not null, " //
+ "artist text not null, " //
+ "album text not null, " //
+ + "albumartist text not null, " //
+ + "trackartist text not null, " //
+ "track text not null, " //
+ "tracknr text not null, " //
+ "mbid text not null, " //
@@ -219,6 +221,8 @@ public long insertTrack(Track track) {
vals.put("musicapp", track.getMusicAPI().getId());
vals.put("artist", track.getArtist());
vals.put("album", track.getAlbum());
+ vals.put("albumartist", track.getAlbumArtist());
+ vals.put("trackartist", track.getTrackArtist());
vals.put("track", track.getTrack());
vals.put("whenplayed", track.getWhen());
vals.put("duration", track.getDuration());
@@ -226,7 +230,6 @@ public long insertTrack(Track track) {
vals.put("mbid", track.getMbid());
vals.put("source", track.getSource());
vals.put("rating", track.getRating());
-
return mDb.insert(TABLENAME_SCROBBLES, null, vals);
}
@@ -261,6 +264,18 @@ public void setAlbum(String album, int trackId) {
mDb.update("scrobbles", values, "_id=" + trackId, null);
}
+ public void setAlbumArtist(String albumartist, int trackId) {
+ ContentValues values = new ContentValues();
+ values.put("albumartist", albumartist);
+ mDb.update("scrobbles", values, "_id=" + trackId, null);
+ }
+
+ public void setTrackArtist(String trackartist, int trackId) {
+ ContentValues values = new ContentValues();
+ values.put("trackartist", trackartist);
+ mDb.update("scrobbles", values, "_id=" + trackId, null);
+ }
+
public void setArtist(String artist, int trackId) {
ContentValues values = new ContentValues();
values.put("artist", artist);
@@ -296,6 +311,8 @@ private Track readTrack(Cursor c) {
b.setArtist(c.getString(c.getColumnIndex("artist")));
b.setAlbum(c.getString(c.getColumnIndex("album")));
b.setTrack(c.getString(c.getColumnIndex("track")));
+ b.setAlbumArtist(c.getString(c.getColumnIndex("albumartist")));
+ b.setTrackArtist(c.getString(c.getColumnIndex("trackartist")));
b.setWhen(c.getLong(c.getColumnIndex("whenplayed")));
b.setDuration(c.getInt(c.getColumnIndex("duration")));
b.setRowId(c.getInt(c.getColumnIndex("_id")));
@@ -487,4 +504,10 @@ public CorrectionRule fetchCorrectioneRule(int id) {
return rule;
}
+ // TODO: DELETE ME AFTER !!!
+
+ public void alterDataBaseOnce(){
+ mDb.execSQL("ALTER TABLE " + TABLENAME_SCROBBLES + " ADD COLUMN albumartist text not null");
+ mDb.execSQL("ALTER TABLE " + TABLENAME_SCROBBLES + " ADD COLUMN trackartist text not null");
+ }
}
diff --git a/app/src/main/java/com/adam/aslfms/util/Track.java b/app/src/main/java/com/adam/aslfms/util/Track.java
index 2ae7fb71..9c02af39 100644
--- a/app/src/main/java/com/adam/aslfms/util/Track.java
+++ b/app/src/main/java/com/adam/aslfms/util/Track.java
@@ -70,6 +70,8 @@ public enum State {
MusicAPI mMusicAPI;
String mArtist;
String mAlbum;
+ String mAlbumArtist;
+ String mTrackArtist;
String mTrack;
int mDuration;
boolean mUnknownDuration;
@@ -117,6 +119,14 @@ public void setAlbum(String album) {
_track.mAlbum = album == null ? "" : album;
}
+ public void setAlbumArtist(String albumArtist){
+ _track.mAlbumArtist = albumArtist == null ? "" : albumArtist;
+ }
+
+ public void setTrackArtist(String trackArtist){
+ _track.mTrackArtist = trackArtist == null ? "" : trackArtist;
+ }
+
public void setTrack(String track) {
_track.mTrack = track;
}
@@ -168,6 +178,8 @@ public Track build() throws IllegalArgumentException {
mMusicAPI = null;
mArtist = null;
mAlbum = "";
+ mAlbumArtist = "";
+ mTrackArtist = "";
mTrack = null;
mDuration = DEFAULT_TRACK_LENGTH;
mUnknownDuration = true;
@@ -196,6 +208,12 @@ void validate() throws IllegalArgumentException {
if (mAlbum == null)
throw new IllegalArgumentException("album is null");
+ if (mAlbumArtist == null)
+ throw new IllegalArgumentException("album is null");
+
+ if (mTrackArtist == null)
+ throw new IllegalArgumentException("album is null");
+
if (mTrack == null || mTrack.length() == 0)
throw new IllegalArgumentException("track is null or empty");
@@ -236,6 +254,14 @@ public String getAlbum() {
return mAlbum;
}
+ public String getAlbumArtist() {
+ return mAlbumArtist;
+ }
+
+ public String getTrackArtist() {
+ return mTrackArtist;
+ }
+
public String getTrack() {
return mTrack;
}
@@ -361,6 +387,7 @@ void incTimePlayed(long tp) {
public String toString() {
return "Track [mTrack="
+ mTrack + ", mArtist=" + mArtist + ", mAlbum=" + mAlbum
+ + ", mAlbumArtist=" + mAlbumArtist
+ ", mDuration=" + mDuration + ", mMbId=" + mMbId
+ ", mMusicAPI=" + mMusicAPI + ", mQueued=" + mQueued
+ ", mRating=" + mRating + ", mRowId=" + mRowId + ", mSource="