[Android] Preview: don't display language if unknown

Sébastien Toque git at videolan.org
Sun Apr 22 12:30:27 CEST 2012


android | branch: master | Sébastien Toque <xilasz at gmail.com> | Sun Apr 22 12:05:35 2012 +0200| [ce5be2558dca6c04b205bb779d0e680928c61e16] | committer: Sébastien Toque

Preview: don't display language if unknown

> http://git.videolan.org/gitweb.cgi/android.git/?a=commit;h=ce5be2558dca6c04b205bb779d0e680928c61e16
---

 vlc-android/res/values-fr/strings.xml              |   15 ++++++----
 vlc-android/res/values/strings.xml                 |   15 ++++++----
 .../videolan/vlc/gui/video/MediaInfoAdapter.java   |   30 +++++++++++++++----
 3 files changed, 41 insertions(+), 19 deletions(-)

diff --git a/vlc-android/res/values-fr/strings.xml b/vlc-android/res/values-fr/strings.xml
index 6ae35a1..c6c52aa 100644
--- a/vlc-android/res/values-fr/strings.xml
+++ b/vlc-android/res/values-fr/strings.xml
@@ -68,13 +68,16 @@
     <string name="detect_headset_detail">Pause lors du débranchement du casque, Reprise lors du branchement du casque</string>
     <string name="refresh">Rafraîchir</string>
     <string name="track_audio">Piste audio</string>
-    <plurals name="track_audio_info">
-        <item quantity="one">Codec: %1$s\nLangue: %2$s\n%3$d canal\nFréquence d\'échantillonage: %4$d Hz</item>
-        <item quantity="other">Codec: %1$s\nLangue: %2$s\n%3$d canaux\nFréquence d\'échantillonage: %4$d Hz</item>
-    </plurals>
     <string name="track_video">Piste vidéo</string>
-    <string name="track_video_info">Codec: %1$s\nLangue: %2$s\nRésolution: %3$dx%4$d\nDébit d\'images: %5$.3f</string>
     <string name="track_text">Piste sous-titres</string>
-    <string name="track_text_info">Codec: %1$s\nLangue: %2$s</string>
     <string name="track_unknown">Piste inconnue</string>
+    <string name="track_codec_info">Codec: %1$s\n</string>
+    <string name="track_language_info">Langue: %1$s\n</string>
+    <plurals name="track_channels_info">
+        <item quantity="one">%1$d canal\n</item>
+        <item quantity="other">%1$d canaux\n</item>
+    </plurals>
+    <string name="track_samplerate_info">Fréquence d\'échantillonage: %1$d Hz\n</string>
+    <string name="track_resolution_info">Résolution: %1$dx%2$d\n</string>
+    <string name="track_framerate_info">Débit d\'images: %1$.3f\n</string>
 </resources>
diff --git a/vlc-android/res/values/strings.xml b/vlc-android/res/values/strings.xml
index 7046ba7..11b1acc 100644
--- a/vlc-android/res/values/strings.xml
+++ b/vlc-android/res/values/strings.xml
@@ -71,15 +71,18 @@
     <string name="detect_headset_detail">Pause on headset removed, Resume on headset inserted</string>
     <string name="refresh">Refresh</string>
     <string name="track_audio">Audio track</string>
-    <plurals name="track_audio_info">
-        <item quantity="one">Codec: %1$s\nLanguage: %2$s\n%3$d channel\nSample rate: %4$d Hz</item>
-        <item quantity="other">Codec: %1$s\nLanguage: %2$s\n%3$d channels\nSample rate: %4$d Hz</item>
-    </plurals>
     <string name="track_video">Video track</string>
-    <string name="track_video_info">Codec: %1$s\nLanguage: %2$s\nResolution: %3$dx%4$d\nFrame rate: %5$.3f</string>
     <string name="track_text">Subtitles track</string>
-    <string name="track_text_info">Codec: %1$s\nLanguage: %2$s</string>
     <string name="track_unknown">Unknown track</string>
+    <string name="track_codec_info">Codec: %1$s\n</string>
+    <string name="track_language_info">Language: %1$s\n</string>
+    <plurals name="track_channels_info">
+        <item quantity="one">%1$d channel\n</item>
+        <item quantity="other">%1$d channels\n</item>
+    </plurals>
+    <string name="track_samplerate_info">Sample rate: %1$d Hz\n</string>
+    <string name="track_resolution_info">Resolution: %1$dx%2$d\n</string>
+    <string name="track_framerate_info">Frame rate: %1$.3f\n</string>
     <string name="open_mrl">Open MRL</string>
     <string name="open_mrl_dialog_title">Open network stream</string>
     <string name="open_mrl_dialog_msg">Enter network MRL: e.g. http://, mms:// or rtsp://</string>
diff --git a/vlc-android/src/org/videolan/vlc/gui/video/MediaInfoAdapter.java b/vlc-android/src/org/videolan/vlc/gui/video/MediaInfoAdapter.java
index 6f60105..18fcc8d 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/MediaInfoAdapter.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/MediaInfoAdapter.java
@@ -52,35 +52,51 @@ public class MediaInfoAdapter extends ArrayAdapter<TrackInfo> {
             holder = (ViewHolder) v.getTag();
 
         TrackInfo track = getItem(position);
-        String language = track.Language != null ? track.Language : "und";
         String title;
-        String text;
+        StringBuilder textBuilder = new StringBuilder(1024);
         Resources res = getContext().getResources();
         switch (track.Type)
         {
             case TrackInfo.TYPE_AUDIO:
                 title = res.getString(R.string.track_audio);
-                text = res.getQuantityString(R.plurals.track_audio_info, track.Channels, track.Codec, language, track.Channels, track.Samplerate);
+                appendCommon(textBuilder, res, track);
+                appendAudio(textBuilder, res, track);
                 break;
             case TrackInfo.TYPE_VIDEO:
                 title = res.getString(R.string.track_video);
-                text = res.getString(R.string.track_video_info, track.Codec, language, track.Width, track.Height, track.Framerate);
+                appendCommon(textBuilder, res, track);
+                appendVideo(textBuilder, res, track);
                 break;
             case TrackInfo.TYPE_TEXT:
                 title = res.getString(R.string.track_text);
-                text = res.getString(R.string.track_text_info, track.Codec, language);
+                appendCommon(textBuilder, res, track);
                 break;
             default:
                 title = res.getString(R.string.track_unknown);
-                text = "";
         }
 
         holder.title.setText(title);
-        holder.text.setText(text);
+        holder.text.setText(textBuilder.toString());
 
         return v;
     }
 
+    private void appendCommon(StringBuilder textBuilder, Resources res, TrackInfo track) {
+        textBuilder.append(res.getString(R.string.track_codec_info, track.Codec));
+        if (track.Language != null && !track.Language.equalsIgnoreCase("und"))
+            textBuilder.append(res.getString(R.string.track_language_info, track.Language));
+    }
+
+    private void appendAudio(StringBuilder textBuilder, Resources res, TrackInfo track) {
+        textBuilder.append(res.getQuantityString(R.plurals.track_channels_info, track.Channels, track.Channels));
+        textBuilder.append(res.getString(R.string.track_samplerate_info, track.Samplerate));
+    }
+
+    private void appendVideo(StringBuilder textBuilder, Resources res, TrackInfo track) {
+        textBuilder.append(res.getString(R.string.track_resolution_info, track.Width, track.Height));
+        textBuilder.append(res.getString(R.string.track_framerate_info, track.Framerate));
+    }
+
     static class ViewHolder {
         TextView title;
         TextView text;



More information about the Android mailing list