From 8bf40308c87ca62ef4b450c69c80202f09c3f80c Mon Sep 17 00:00:00 2001 From: Sam Whited Date: Mon, 3 Nov 2014 08:44:19 -0500 Subject: Move AboutDialog to correct path --- .../eu/siacs/conversations/ui/AboutDialog.java | 33 ++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 src/main/java/eu/siacs/conversations/ui/AboutDialog.java (limited to 'src/main/java/eu/siacs') 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/ + } + } + } +} + -- cgit v1.2.3