Skip to content

Commit

Permalink
Implement fixes for my favorite pet peeves in Vanilla (#714)
Browse files Browse the repository at this point in the history
* Ignore Visual Studio's cache.

* If only one of (ARTIST, ALBUMARTIST) is present, populate the other.
This is only natural and most applications that implement media library population do this.

* On completion of the queue, rewind to the beginning of the queue, so that a subsequent Play command will play the whole queue again.

* Correct <plurals> values according to the best practices and add a CLDR rules link for translators to look for their language's specific informaiton.
  • Loading branch information
ddv239 authored and adrian-bl committed Jan 26, 2018
1 parent 4ac73f9 commit 4462743
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 12 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Expand Up @@ -37,3 +37,6 @@ proguard/
*.iml
out
.settings/

# Visual Studio 2015 cache/options directory
.vs/
21 changes: 16 additions & 5 deletions res/values/translatable.xml
Expand Up @@ -82,24 +82,35 @@ THE SOFTWARE.
<string name="go_home">Home directory</string>
<string name="jumping_to_song">Song is already in queue, jumping…</string>

<!--
As a developer, you should always supply "one" and "other"
strings. Your translators will know which strings are actually
needed for their language. Always include %d in "one" because
translators will need to use %d for languages where "one"
doesn't mean 1 (as explained above).
Translators should use http://unicode.org/reports/tr35/tr35-numbers.html#Language_Plural_Rules and
http://www.unicode.org/cldr/charts/latest/supplemental/language_plural_rules.html, Type cardinal,
to see which categories apply to integer numbers in their languages
-->
<plurals name="playing">
<item quantity="one">1 track playing.</item>
<item quantity="one">%d track playing.</item>
<item quantity="other">%d tracks playing.</item>
</plurals>
<plurals name="enqueued">
<item quantity="one">1 track enqueued.</item>
<item quantity="one">%d track enqueued.</item>
<item quantity="other">%d tracks enqueued.</item>
</plurals>
<plurals name="added_to_playlist">
<item quantity="one">1 track added to playlist %2$s.</item>
<item quantity="one">%1$d track added to playlist %2$s.</item>
<item quantity="other">%1$d tracks added to playlist %2$s.</item>
</plurals>
<plurals name="removed_from_playlist">
<item quantity="one">1 track removed from playlist %2$s.</item>
<item quantity="one">%1$d track removed from playlist %2$s.</item>
<item quantity="other">%1$d tracks removed from playlist %2$s.</item>
</plurals>
<plurals name="deleted">
<item quantity="one">1 track deleted.</item>
<item quantity="one">%d track deleted.</item>
<item quantity="other">%d tracks deleted.</item>
</plurals>
<string name="delete_file_failed">Failed to delete %s.</string>
Expand Down
Expand Up @@ -292,8 +292,8 @@ private void extractMetadata(String path) {
Log.v("VanillaMusic", "Error creating fis for "+path+": "+e);
}

// Check if this is an useable audio file
if (nativelyReadable == false ||
// Check if this is a usable audio file
if (!nativelyReadable ||
mediaTags.extractMetadata(MediaMetadataRetriever.METADATA_KEY_HAS_AUDIO) == null ||
mediaTags.extractMetadata(MediaMetadataRetriever.METADATA_KEY_HAS_VIDEO) != null ||
mediaTags.extractMetadata(MediaMetadataRetriever.METADATA_KEY_DURATION) == null) {
Expand Down Expand Up @@ -339,7 +339,7 @@ private void extractMetadata(String path) {
convertNumericGenre();

// We consider this a media file if it has some common tags OR
// if bastp was able to parse it (which is stricter than Androids own parser)
// if bastp was able to parse it (which is stricter than Android's own parser)
mIsMediaFile = (containsKey(TITLE) || containsKey(ALBUM) || containsKey(ARTIST) || !bastpType.equals(""));

mediaTags.release();
Expand Down Expand Up @@ -369,6 +369,14 @@ private void populateSelf(HashMap bastp) {
}
}

// If only one of (ARTIST, ALBUMARTIST) is present, populate the other
if (!containsKey(ARTIST) && containsKey(ALBUMARTIST)) {
put(ARTIST, get(ALBUMARTIST));
}
if (containsKey(ARTIST) && !containsKey(ALBUMARTIST)) {
put(ALBUMARTIST, get(ARTIST));
}

// Try to guess YEAR from date field if only DATE was specified
// We expect it to match \d{4}
if (!containsKey(YEAR) && bastp.containsKey("DATE")) {
Expand Down
9 changes: 5 additions & 4 deletions src/ch/blinkenlights/android/vanilla/PlaybackService.java
Expand Up @@ -176,7 +176,7 @@ public final class PlaybackService extends Service
*/
public static final String ACTION_CYCLE_REPEAT = "ch.blinkenlights.android.vanilla.CYCLE_REPEAT";
/**
* Pause music and hide the notifcation.
* Pause music and hide the notification.
*/
public static final String ACTION_CLOSE_NOTIFICATION = "ch.blinkenlights.android.vanilla.CLOSE_NOTIFICATION";
/**
Expand Down Expand Up @@ -1420,7 +1420,7 @@ private void processSong(Song song)

/* Automatically advance to next song IF we are currently playing or already did skip something
* This will stop after skipping 10 songs to avoid endless loops (queue full of broken stuff */
if(mTimeline.isEndOfQueue() == false && getSong(1) != null && (playing || (mSkipBroken > 0 && mSkipBroken < 10))) {
if(!mTimeline.isEndOfQueue() && getSong(1) != null && (playing || (mSkipBroken > 0 && mSkipBroken < 10))) {
mSkipBroken++;
mHandler.sendMessageDelayed(mHandler.obtainMessage(MSG_SKIP_BROKEN_SONG, getTimelinePosition(), 0), 1000);
}
Expand All @@ -1443,9 +1443,10 @@ public void onCompletion(MediaPlayer player)
} else if (finishAction(mState) == SongTimeline.FINISH_STOP_CURRENT) {
unsetFlag(FLAG_PLAYING);
setCurrentSong(+1);
} else if (mTimeline.isEndOfQueue()) {
unsetFlag(FLAG_PLAYING);
} else {
if (mTimeline.isEndOfQueue()) {
unsetFlag(FLAG_PLAYING);
}
setCurrentSong(+1);
}
}
Expand Down

0 comments on commit 4462743

Please sign in to comment.