diff options
author | Sam Whited <sam@samwhited.com> | 2014-10-21 22:53:30 -0400 |
---|---|---|
committer | Sam Whited <sam@samwhited.com> | 2014-11-04 12:47:58 -0500 |
commit | df54ee75b4802107ed28019f2284154459b0e6f5 (patch) | |
tree | 94cab8e2a809c8523b45c20adc0ac682ca0a6e88 /src/eu/siacs | |
parent | ff10b094a0a210bb1c7745bd0e0f92e9a7e3ec2d (diff) |
Add about dialog with license info
Diffstat (limited to 'src/eu/siacs')
-rw-r--r-- | src/eu/siacs/conversations/ui/AboutDialog.java | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/eu/siacs/conversations/ui/AboutDialog.java b/src/eu/siacs/conversations/ui/AboutDialog.java new file mode 100644 index 00000000..994d1bd9 --- /dev/null +++ b/src/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/ + } + } + } +} + |