Commit 7612fddd authored by Sébastien Toque's avatar Sébastien Toque
Browse files

handle unknown artist/album/genre correctly

parent ea2588c1
......@@ -340,7 +340,7 @@ jobjectArray Java_org_videolan_vlc_android_LibVLC_readMediaMeta(JNIEnv *env,
for (i=0; i < sizeof(str) / sizeof(*str); i++) {
char *meta = libvlc_media_get_meta(m, meta_id[i]);
if (!meta)
meta = strdup("unknown");
meta = strdup("");
jstring k = (*env)->NewStringUTF(env, str[i]);
(*env)->SetObjectArrayElement(env, array, 2*i, k);
......
......@@ -29,6 +29,7 @@
<string name="info_title">Information</string>
<string name="unknown_artist">Artiste inconnu</string>
<string name="unknown_album">Album inconnu</string>
<string name="unknown_genre">Genre inconnu</string>
<string name="songs">Chansons</string>
<plurals name="songs">
<item quantity="one">1 chanson</item>
......
......@@ -30,6 +30,7 @@
<string name="info_title">Information</string>
<string name="unknown_artist">Unknown Artist</string>
<string name="unknown_album">Unknown Album</string>
<string name="unknown_genre">Unknown Genre</string>
<string name="songs">Songs</string>
<plurals name="songs">
<item quantity="one">1 song</item>
......
......@@ -94,13 +94,13 @@ public class Media implements Comparable<Media> {
mTitle = v;
Log.d(TAG, "Title " + mTitle);
} else if (s.equals("artist")) {
mArtist = v != null ? v : context.getString(R.string.unknown_artist);
mArtist = Util.getValue(context, v, R.string.unknown_artist);
Log.d(TAG, "Artist " + mArtist);
} else if (s.equals("genre")) {
mGenre = v;
mGenre = Util.getValue(context, v, R.string.unknown_genre);
Log.d(TAG, "Genre " + mGenre);
} else if (s.equals("album")) {
mAlbum = v != null ? v : context.getString(R.string.unknown_album);
mAlbum = Util.getValue(context, v, R.string.unknown_album);
Log.d(TAG, "Album " + mAlbum);
}
}
......@@ -122,9 +122,9 @@ public class Media implements Comparable<Media> {
mPicture = picture;
mTitle = title;
mArtist = artist != null ? artist : context.getString(R.string.unknown_artist);
mGenre = genre;
mAlbum = album != null ? album : context.getString(R.string.unknown_album);
mArtist = Util.getValue(context, artist, R.string.unknown_artist);
mGenre = Util.getValue(context, genre, R.string.unknown_genre);
mAlbum = Util.getValue(context, album, R.string.unknown_album);
}
/**
......
......@@ -98,4 +98,9 @@ public class Util {
}
return bitmap;
}
public static String getValue(Context context, String string, int defaultId)
{
return (string != null && string.length() > 0) ? string : context.getString(defaultId);
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment