diff --git a/Developer's API.md b/Developer's API.md index 529f211e..d909da91 100644 --- a/Developer's API.md +++ b/Developer's API.md @@ -31,6 +31,7 @@ The possible fields for the intent (to be put in its extras bundle) are: | app-package | String | Yes | The package of the music app | | state | int | Yes | One of the states above | | album | String | No | The album name _Strongly recommended_ | + | albumartist | String | No | The album artist name _Strongly recommended_ | | artist | String | Yes | The artist name | | track | String | Yes | The track name | | duration | int | Yes | The duration of the track (in seconds) | @@ -68,12 +69,13 @@ bCast.putExtra("app-name", "Example App"); bCast.putExtra("app-package", "com.example.exampleapp"); bCast.putExtra("artist", "Chris Cornell"); bCast.putExtra("album", "Casino Royale"); +bCast.putExtra("albumartist", "David Arnold"); bCast.putExtra("track", "You Know My Name"); bCast.putExtra("duration", 244); sendBroadcast(bCast); ~~~ -And this says that James Marster's song "Looking At You" has finished playing and should be scrobbled: +And this says that James Marster's song "Looking At You" has finished playing and should be scrobbled: ~~~ java Intent bCast = new Intent("com.adam.aslfms.notify.playstatechanged"); @@ -82,6 +84,7 @@ bCast.putExtra("app-name", "Example App"); bCast.putExtra("app-package", "com.example.exampleapp"); bCast.putExtra("artist", "James Marsters"); bCast.putExtra("album", "Like A Waterfall"); +bCast.putExtra("albumartist", "James Marsters"); bCast.putExtra("track", "Looking At You"); bCast.putExtra("duration", 175); sendBroadcast(bCast); @@ -96,6 +99,7 @@ bCast.putExtra("app-name", "Example App"); bCast.putExtra("app-package", "com.example.exampleapp"); bCast.putExtra("artist", "Yohanna"); bCast.putExtra("album", "Eurovision Song Contest: Moscow 2009 (disc 2)"); +bCast.putExtra("albumartist", "Óskar Páll Sveinsson"); bCast.putExtra("track", "Is It True? (Iceland)"); bCast.putExtra("duration", 181); bCast.putExtra("track-number", 3); @@ -104,7 +108,7 @@ bCast.putExtra("source", "R"); sendBroadcast(bCast); ~~~ -The app ³ (cubed) [implements](http://github.com/fabrantes/rockonnggl/blob/master/src/org/abrantix/rockon/rockonnggl/RockOnNextGenService.java) this API. +The app � (cubed) [implements](http://github.com/fabrantes/rockonnggl/blob/master/src/org/abrantix/rockon/rockonnggl/RockOnNextGenService.java) this API. ## Internals @@ -114,7 +118,7 @@ The behavioiur to handle these API broadcasts is implemented in the `BroadcastRe When a user starts playing music in a music app using this api, she will automatically have her music scrobbled. The first broadcast to be sent to SLS will create an entry in the Supported Apps section, where the user can disable/enable scrobbling from that application (it is enabled by default). -To make this work properly, the two fields `app-name` and `app-package` are crucial. `app-name` is the string that gets displayed to the user, and `app-package` is what identifies the source of the music played. This should be the "root package" (or whatever it's called) of the music app, and it should never change. +To make this work properly, the two fields `app-name` and `app-package` are crucial. `app-name` is the string that gets displayed to the user, and `app-package` is what identifies the source of the music played. This should be the "root package" (or whatever it's called) of the music app, and it should never change. ## Troubleshooting @@ -146,8 +150,8 @@ Open an issue here on github and we'll look into an problems you might have. Sav ## Custom Broadcasts -If you already broadcast your own intents, tell me about them and I'll see if I can work them into SLS. +If you already broadcast your own intents, tell me about them and I'll see if I can work them into SLS. ## Thanks -A tip of the hat to jjc1138 of Scrobble Droid, his/her documentation is superb. \ No newline at end of file +A tip of the hat to jjc1138 of Scrobble Droid, his/her documentation is superb. diff --git a/README.md b/README.md index 68f59ec6..6a3c7300 100644 --- a/README.md +++ b/README.md @@ -103,6 +103,7 @@ Before the release of a new version of SLS, it will be available here to test fo * Sequential storage of all tracks, scrobbled, skipped, hearted, and failed with explanations * markers in scrobble cache for logged in accounts * Store scrobbles before user is logged in + * Manual scrobbling, for example Vinyl Records, CD, Cassette and other older media machines. ## Features diff --git a/app/build.gradle b/app/build.gradle index df3a7ac3..94ee6fcf 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -21,6 +21,7 @@ android { lintOptions { abortOnError false // TODO: fix all lint warnings + // TODO: decide what to do about at:Supress("Deprecation") ignoreWarnings true } diff --git a/app/debug/output.json b/app/debug/output.json index 135d94e9..de793f36 100644 --- a/app/debug/output.json +++ b/app/debug/output.json @@ -1 +1 @@ -[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":49,"versionName":"1.5.8","enabled":true,"outputFile":"app-debug.apk","fullName":"debug","baseName":"debug"},"path":"app-debug.apk","properties":{}}] \ No newline at end of file +[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":49,"versionName":"1.5.8","enabled":true,"outputFile":"app-debug.apk","fullName":"debug","baseName":"debug"},"path":"app-debug.apk","properties":{}}] \ No newline at end of file diff --git a/app/release/app-release.apk b/app/release/app-release.apk new file mode 100644 index 00000000..a340ae89 Binary files /dev/null and b/app/release/app-release.apk differ diff --git a/app/release/app.aab b/app/release/app.aab new file mode 100644 index 00000000..b4fd20fb Binary files /dev/null and b/app/release/app.aab differ diff --git a/app/release/output.json b/app/release/output.json new file mode 100644 index 00000000..673eb41e --- /dev/null +++ b/app/release/output.json @@ -0,0 +1 @@ +[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":49,"versionName":"1.5.8","enabled":true,"outputFile":"app-release.apk","fullName":"release","baseName":"release"},"path":"app-release.apk","properties":{}}] \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 3b59f8f9..bb46f33e 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -322,6 +322,16 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/com/adam/aslfms/AppleMusicOptionsActivity.java b/app/src/main/java/com/adam/aslfms/AppleMusicOptionsActivity.java index 4b59b2e0..baf8ffd0 100644 --- a/app/src/main/java/com/adam/aslfms/AppleMusicOptionsActivity.java +++ b/app/src/main/java/com/adam/aslfms/AppleMusicOptionsActivity.java @@ -35,7 +35,7 @@ public Resources.Theme getTheme() { settings = new AppSettings(this); Resources.Theme theme = super.getTheme(); theme.applyStyle(settings.getAppTheme(), true); - Log.e(TAG, getResources().getResourceName(settings.getAppTheme())); + Log.d(TAG, getResources().getResourceName(settings.getAppTheme())); // you could also use a switch if you have many themes that could apply return theme; } diff --git a/app/src/main/java/com/adam/aslfms/ChangeThemeActivity.java b/app/src/main/java/com/adam/aslfms/ChangeThemeActivity.java index 0d36556a..1d7fbb26 100644 --- a/app/src/main/java/com/adam/aslfms/ChangeThemeActivity.java +++ b/app/src/main/java/com/adam/aslfms/ChangeThemeActivity.java @@ -18,7 +18,7 @@ public Resources.Theme getTheme() { settings = new AppSettings(this); Resources.Theme theme = super.getTheme(); theme.applyStyle(settings.getAppTheme(), true); - Log.e(TAG, getResources().getResourceName(settings.getAppTheme())); + Log.d(TAG, getResources().getResourceName(settings.getAppTheme())); // you could also use a switch if you have many themes that could apply return theme; } diff --git a/app/src/main/java/com/adam/aslfms/MusicAppsActivity.java b/app/src/main/java/com/adam/aslfms/MusicAppsActivity.java index 8bc70f96..4edd8dc3 100644 --- a/app/src/main/java/com/adam/aslfms/MusicAppsActivity.java +++ b/app/src/main/java/com/adam/aslfms/MusicAppsActivity.java @@ -63,7 +63,7 @@ public Resources.Theme getTheme() { settings = new AppSettings(this); Resources.Theme theme = super.getTheme(); theme.applyStyle(settings.getAppTheme(), true); - Log.e(TAG, getResources().getResourceName(settings.getAppTheme())); + Log.d(TAG, getResources().getResourceName(settings.getAppTheme())); // you could also use a switch if you have many themes that could apply return theme; } diff --git a/app/src/main/java/com/adam/aslfms/OptionsActivity.java b/app/src/main/java/com/adam/aslfms/OptionsActivity.java index e7425b1b..8719da66 100644 --- a/app/src/main/java/com/adam/aslfms/OptionsActivity.java +++ b/app/src/main/java/com/adam/aslfms/OptionsActivity.java @@ -60,7 +60,7 @@ public Resources.Theme getTheme() { settings = new AppSettings(this); Resources.Theme theme = super.getTheme(); theme.applyStyle(settings.getAppTheme(), true); - Log.e(TAG, getResources().getResourceName(settings.getAppTheme())); + Log.d(TAG, getResources().getResourceName(settings.getAppTheme())); // you could also use a switch if you have many themes that could apply return theme; } diff --git a/app/src/main/java/com/adam/aslfms/SettingsActivity.java b/app/src/main/java/com/adam/aslfms/SettingsActivity.java index f4d0b452..e4e7e1bb 100644 --- a/app/src/main/java/com/adam/aslfms/SettingsActivity.java +++ b/app/src/main/java/com/adam/aslfms/SettingsActivity.java @@ -87,7 +87,7 @@ public Resources.Theme getTheme() { settings = new AppSettings(this); Resources.Theme theme = super.getTheme(); theme.applyStyle(settings.getAppTheme(), true); - Log.e(TAG, getResources().getResourceName(settings.getAppTheme())); + Log.d(TAG, getResources().getResourceName(settings.getAppTheme())); // you could also use a switch if you have many themes that could apply return theme; } @@ -123,10 +123,12 @@ protected void onCreate(Bundle savedInstanceState) { permsCheck(); credsCheck(); + // TODO: VERIFY EVERYTHING BELOW IS SAFE int v = Util.getAppVersionCode(this, getPackageName()); if (settings.getWhatsNewViewedVersion() < v) { new WhatsNewDialog(this).show(); settings.setWhatsNewViewedVersion(v); + mDb.alterDataBaseOnce(); // version 1.5.8 only! } // Start Apple listening service if applicabble diff --git a/app/src/main/java/com/adam/aslfms/StatusActivity.java b/app/src/main/java/com/adam/aslfms/StatusActivity.java index 05a3b10b..8f66a24b 100644 --- a/app/src/main/java/com/adam/aslfms/StatusActivity.java +++ b/app/src/main/java/com/adam/aslfms/StatusActivity.java @@ -60,7 +60,7 @@ public Resources.Theme getTheme() { settings = new AppSettings(this); Resources.Theme theme = super.getTheme(); theme.applyStyle(settings.getAppTheme(), true); - Log.e(TAG, getResources().getResourceName(settings.getAppTheme())); + Log.d(TAG, getResources().getResourceName(settings.getAppTheme())); // you could also use a switch if you have many themes that could apply return theme; } diff --git a/app/src/main/java/com/adam/aslfms/UserCredActivity.java b/app/src/main/java/com/adam/aslfms/UserCredActivity.java index 7d6fc505..787e628f 100644 --- a/app/src/main/java/com/adam/aslfms/UserCredActivity.java +++ b/app/src/main/java/com/adam/aslfms/UserCredActivity.java @@ -68,7 +68,7 @@ public Resources.Theme getTheme() { settings = new AppSettings(this); Resources.Theme theme = super.getTheme(); theme.applyStyle(settings.getAppTheme(), true); - Log.e(TAG, getResources().getResourceName(settings.getAppTheme())); + Log.d(TAG, getResources().getResourceName(settings.getAppTheme())); // you could also use a switch if you have many themes that could apply return theme; } diff --git a/app/src/main/java/com/adam/aslfms/UserCredsListActivity.java b/app/src/main/java/com/adam/aslfms/UserCredsListActivity.java index 8f1e58b5..2dcb4756 100644 --- a/app/src/main/java/com/adam/aslfms/UserCredsListActivity.java +++ b/app/src/main/java/com/adam/aslfms/UserCredsListActivity.java @@ -62,7 +62,7 @@ public Resources.Theme getTheme() { settings = new AppSettings(this); Resources.Theme theme = super.getTheme(); theme.applyStyle(settings.getAppTheme(), true); - Log.e(TAG, getResources().getResourceName(settings.getAppTheme())); + Log.d(TAG, getResources().getResourceName(settings.getAppTheme())); // you could also use a switch if you have many themes that could apply return theme; } diff --git a/app/src/main/java/com/adam/aslfms/ViewCorrectionRulesActivity.java b/app/src/main/java/com/adam/aslfms/ViewCorrectionRulesActivity.java index 3607c1e2..7181e17e 100644 --- a/app/src/main/java/com/adam/aslfms/ViewCorrectionRulesActivity.java +++ b/app/src/main/java/com/adam/aslfms/ViewCorrectionRulesActivity.java @@ -46,7 +46,7 @@ public Resources.Theme getTheme() { settings = new AppSettings(this); Resources.Theme theme = super.getTheme(); theme.applyStyle(settings.getAppTheme(), true); - Log.e(TAG, getResources().getResourceName(settings.getAppTheme())); + Log.d(TAG, getResources().getResourceName(settings.getAppTheme())); // you could also use a switch if you have many themes that could apply return theme; } diff --git a/app/src/main/java/com/adam/aslfms/ViewScrobbleCacheActivity.java b/app/src/main/java/com/adam/aslfms/ViewScrobbleCacheActivity.java index b41aca31..c4c1fc05 100644 --- a/app/src/main/java/com/adam/aslfms/ViewScrobbleCacheActivity.java +++ b/app/src/main/java/com/adam/aslfms/ViewScrobbleCacheActivity.java @@ -78,7 +78,7 @@ public Resources.Theme getTheme() { settings = new AppSettings(this); Resources.Theme theme = super.getTheme(); theme.applyStyle(settings.getAppTheme(), true); - Log.e(TAG, getResources().getResourceName(settings.getAppTheme())); + Log.d(TAG, getResources().getResourceName(settings.getAppTheme())); // you could also use a switch if you have many themes that could apply return theme; } diff --git a/app/src/main/java/com/adam/aslfms/receiver/AbstractPlayStatusReceiver.java b/app/src/main/java/com/adam/aslfms/receiver/AbstractPlayStatusReceiver.java index aec3b888..34fc35dd 100644 --- a/app/src/main/java/com/adam/aslfms/receiver/AbstractPlayStatusReceiver.java +++ b/app/src/main/java/com/adam/aslfms/receiver/AbstractPlayStatusReceiver.java @@ -48,7 +48,7 @@ */ public abstract class AbstractPlayStatusReceiver extends BroadcastReceiver { - private static final String TAG = "SLSPlayStatusReceiver"; + private static final String TAG = "AbsPlayStatusReceiver"; private MusicAPI mMusicAPI = null; private Intent mService = null; @@ -59,12 +59,12 @@ public static void dumpIntent(Bundle bundle){ if (bundle != null) { Set keys = bundle.keySet(); Iterator 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="