aboutsummaryrefslogtreecommitdiffstats
path: root/src/main
diff options
context:
space:
mode:
authorSam Whited <sam@samwhited.com>2014-11-03 08:44:19 -0500
committerSam Whited <sam@samwhited.com>2014-11-04 12:47:58 -0500
commit8bf40308c87ca62ef4b450c69c80202f09c3f80c (patch)
tree8e5a5c44549b07a61660083da7fa9d62b36ccf46 /src/main
parentdf54ee75b4802107ed28019f2284154459b0e6f5 (diff)
Move AboutDialog to correct path
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/eu/siacs/conversations/ui/AboutDialog.java33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/main/java/eu/siacs/conversations/ui/AboutDialog.java b/src/main/java/eu/siacs/conversations/ui/AboutDialog.java
new file mode 100644
index 00000000..994d1bd9
--- /dev/null
+++ b/src/main/java/eu/siacs/conversations/ui/AboutDialog.java
@@ -0,0 +1,33 @@
+package eu.siacs.conversations.ui;
+
+import android.content.Context;
+import android.content.pm.PackageManager;
+import android.preference.DialogPreference;
+import android.util.AttributeSet;
+
+public class AboutDialog extends DialogPreference {
+ public AboutDialog(final Context context, final AttributeSet attrs, final int defStyle) {
+ super(context, attrs, defStyle);
+ setSummary();
+ }
+
+ public AboutDialog(final Context context, final AttributeSet attrs) {
+ super(context, attrs);
+ setSummary();
+ }
+
+ private void setSummary() {
+ if (getContext() != null &&getContext().getPackageManager() != null) {
+ final String packageName = getContext().getPackageName();
+ final String versionName;
+ try {
+ versionName = getContext().getPackageManager().getPackageInfo(packageName, 0).versionName;
+ setSummary("Conversations " + versionName);
+ } catch (final PackageManager.NameNotFoundException e) {
+ // Using try/catch as part of the logic is sort of like this:
+ // https://xkcd.com/292/
+ }
+ }
+ }
+}
+