summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2015-01-12 09:35:26 +0100
committerMiklos Vajna <vmiklos@collabora.co.uk>2015-01-12 11:06:46 +0100
commit4f1eef278c41997315860158d481d4fc37bd328b (patch)
tree2016ed7b7504765321020c5300b39d927e07787c
parent723b6a07e4c4dfb8fdafc186041557514b014014 (diff)
android: show version / buildid in about dialog
Note that getPackageName() also throws NameNotFoundException, so in the unlikely situations in case: - package info (class containing the package version) is not found or - the package version is not in an "a/b" form We still just don't show anything. Also, mark the new TextView as android:textIsSelectable, so it's possible to copy&paste the version for bugreport purposes. Change-Id: I63b53cca4126da17bfbda0293d7c98e8524ef41a
-rw-r--r--android/Bootstrap/Makefile.shared3
-rw-r--r--android/experimental/LOAndroid3/AndroidManifest.xml.in2
-rw-r--r--android/experimental/LOAndroid3/res/layout/about.xml9
-rw-r--r--android/experimental/LOAndroid3/res/values/strings.xml1
-rw-r--r--android/experimental/LOAndroid3/src/java/org/libreoffice/LOAbout.java23
5 files changed, 36 insertions, 2 deletions
diff --git a/android/Bootstrap/Makefile.shared b/android/Bootstrap/Makefile.shared
index 82513df68d1a..ee50d1f331f4 100644
--- a/android/Bootstrap/Makefile.shared
+++ b/android/Bootstrap/Makefile.shared
@@ -180,8 +180,9 @@ copy-stuff:
echo '[Version]' > assets/program/versionrc
echo 'AllLanguages=en-US' >> assets/program/versionrc
echo 'BuildVersion=' >> assets/program/versionrc
- echo 'buildid=dead-beef' >> assets/program/versionrc
+ echo 'buildid=$(shell cd $(SRCDIR) && git log -1 --format=%H)' >> assets/program/versionrc
echo 'ReferenceOOoMajorMinor=4.1' >> assets/program/versionrc
+ sed -i 's|android:versionName=".*"|android:versionName="$(LIBO_VERSION_MAJOR).$(LIBO_VERSION_MINOR).$(LIBO_VERSION_MICRO).$(LIBO_VERSION_PATCH)$(LIBO_VERSION_SUFFIX)$(LIBO_VERSION_SUFFIX_SUFFIX)/$(shell cd $(SRCDIR) && git log -1 --format=%H)"|' AndroidManifest.xml
#
# .res files
mkdir -p assets/program/resource
diff --git a/android/experimental/LOAndroid3/AndroidManifest.xml.in b/android/experimental/LOAndroid3/AndroidManifest.xml.in
index 6b339e704475..360687e6892d 100644
--- a/android/experimental/LOAndroid3/AndroidManifest.xml.in
+++ b/android/experimental/LOAndroid3/AndroidManifest.xml.in
@@ -3,7 +3,7 @@
package="org.libreoffice"
@ANDROID_INSTALL_LOCATION@
android:versionCode="1"
- android:versionName="1.0">
+ android:versionName="@ANDROID_VERSION@">
<!-- App requires OpenGL ES 2.0 -->
<uses-feature android:glEsVersion="0x00020000" android:required="true" />
diff --git a/android/experimental/LOAndroid3/res/layout/about.xml b/android/experimental/LOAndroid3/res/layout/about.xml
index 06c5bfe74ef7..c15f0cc83267 100644
--- a/android/experimental/LOAndroid3/res/layout/about.xml
+++ b/android/experimental/LOAndroid3/res/layout/about.xml
@@ -7,6 +7,15 @@
android:padding="20dip">
<TextView
+ android:id="@+id/about_version"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:textIsSelectable="true"
+ android:text="@string/app_version"
+ android:textColor="@android:color/secondary_text_light"
+ android:textSize="18sp"/>
+
+ <TextView
android:id="@+id/about_description"
android:layout_width="match_parent"
android:layout_height="wrap_content"
diff --git a/android/experimental/LOAndroid3/res/values/strings.xml b/android/experimental/LOAndroid3/res/values/strings.xml
index 473616a9d9e5..2d03388e5aab 100644
--- a/android/experimental/LOAndroid3/res/values/strings.xml
+++ b/android/experimental/LOAndroid3/res/values/strings.xml
@@ -4,6 +4,7 @@
<string name="app_name">LibreOffice Viewer</string>
<string name="app_about_name"><b>LibreOffice Viewer \'Beta\'</b></string>
+ <string name="app_version">Version: $VERSION\nBuild ID: $BUILDID</string>
<string name="app_description">LibreOffice Viewer is a document viewer based on LibreOffice.</string>
<string name="app_credits">http://www.libreoffice.org</string>
diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOAbout.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOAbout.java
index 2b3bf31633f2..1aca1c6c8b98 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOAbout.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOAbout.java
@@ -19,6 +19,7 @@ import android.widget.RelativeLayout;
import android.widget.TextView;
import android.content.Intent;
import android.net.Uri;
+import android.content.pm.PackageManager.NameNotFoundException;
import java.util.ArrayList;
import java.util.List;
@@ -58,6 +59,28 @@ public abstract class LOAbout extends Activity {
int defaultColor = textView.getTextColors().getDefaultColor();
textView.setTextColor(defaultColor);
+ // Take care of placeholders in the version text view.
+ textView = (TextView)messageView.findViewById(R.id.about_version);
+ try
+ {
+ String versionName = getPackageManager().getPackageInfo(getPackageName(), 0).versionName;
+ String[] tokens = versionName.split("/");
+ if (tokens.length == 2)
+ {
+ String version = textView.getText().toString();
+ version = version.replace("$VERSION", tokens[0]);
+ version = version.replace("$BUILDID", tokens[1]);
+ textView.setText(version);
+ }
+ else
+ throw new NameNotFoundException();
+ }
+ catch (NameNotFoundException e)
+ {
+ textView.setText("");
+ }
+
+
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setIcon(R.drawable.lo_icon);
builder.setTitle(R.string.app_name);