[Android] Cute About whith version number

Alexandre Perraud git at videolan.org
Fri Jun 22 17:55:42 CEST 2012


android | branch: master | Alexandre Perraud <4leyx4ndre at gmail.com> | Fri Jun 22 17:43:21 2012 +0200| [e89ad4302a50789e153f50c33e9d271482c8a33f] | committer: Jean-Baptiste Kempf

Cute About whith version number

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

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

 vlc-android/res/layout/about.xml                      |   12 +++++-------
 vlc-android/res/values/strings.xml                    |    1 -
 .../src/org/videolan/vlc/gui/AboutActivity.java       |   17 +++++++++++++++++
 3 files changed, 22 insertions(+), 8 deletions(-)

diff --git a/vlc-android/res/layout/about.xml b/vlc-android/res/layout/about.xml
index a08aac6..10a22e0 100644
--- a/vlc-android/res/layout/about.xml
+++ b/vlc-android/res/layout/about.xml
@@ -2,9 +2,9 @@
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="fill_parent"
     android:layout_height="fill_parent"
-    android:gravity="center"
-    android:orientation="vertical" 
-    android:weightSum="1">
+    android:gravity="center|fill_vertical"
+    android:orientation="vertical"
+    android:weightSum="1" >
 
     <RelativeLayout
         android:layout_width="fill_parent"
@@ -30,14 +30,12 @@
             android:src="@drawable/header_logo" />
 
         <TextView
-            android:id="@+id/textView1"
+            android:id="@+id/textViewVersion"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:layout_alignParentBottom="true"
             android:layout_alignParentRight="true"
-            android:gravity="center"
-            android:text="@string/about_version" />
-
+            android:gravity="center"/>
     </RelativeLayout>
 
     <LinearLayout
diff --git a/vlc-android/res/values/strings.xml b/vlc-android/res/values/strings.xml
index 42438e2..29a4261 100644
--- a/vlc-android/res/values/strings.xml
+++ b/vlc-android/res/values/strings.xml
@@ -73,7 +73,6 @@
     <string name="surface_fill">Fill</string>
     <string name="surface_original">Center</string>
     <string name="about_text">\nVLC media player\n\nVLC authors and VideoLAN\n\nLicensed under the GPLv3\n</string>
-    <string name="about_version">version xxx</string>
     <string name="thumbnail">Thumbnail</string>
     <string name="main_prefs_category">Main</string>
     <string name="advanced_prefs_category">Advanced</string>
diff --git a/vlc-android/src/org/videolan/vlc/gui/AboutActivity.java b/vlc-android/src/org/videolan/vlc/gui/AboutActivity.java
index b584faa..ebdfa73 100644
--- a/vlc-android/src/org/videolan/vlc/gui/AboutActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/AboutActivity.java
@@ -23,7 +23,10 @@ package org.videolan.vlc.gui;
 import org.videolan.vlc.R;
 
 import android.app.Activity;
+import android.content.pm.PackageInfo;
+import android.content.pm.PackageManager.NameNotFoundException;
 import android.os.Bundle;
+import android.widget.TextView;
 
 public class AboutActivity extends Activity {
 
@@ -32,7 +35,21 @@ public class AboutActivity extends Activity {
     @Override
     protected void onCreate(Bundle savedInstanceState) {
         setContentView(R.layout.about);
+        displayVersionName();
         super.onCreate(savedInstanceState);
     }
+    
+    private void displayVersionName() {
+        String versionName = "";
+        PackageInfo packageInfo;
+        try {
+            packageInfo = getPackageManager().getPackageInfo(getPackageName(), 0);
+            versionName = "v " + packageInfo.versionName;
+        } catch (NameNotFoundException e) {
+            e.printStackTrace();
+        }
+        TextView tv = (TextView) findViewById(R.id.textViewVersion);
+        tv.setText(versionName);
+    }
 
 }



More information about the Android mailing list