1package eu.siacs.conversations.ui;
2
3import android.content.Context;
4import android.content.pm.PackageManager;
5import android.preference.DialogPreference;
6import android.util.AttributeSet;
7
8public class AboutDialog extends DialogPreference {
9 public AboutDialog(final Context context, final AttributeSet attrs, final int defStyle) {
10 super(context, attrs, defStyle);
11 setSummary();
12 }
13
14 public AboutDialog(final Context context, final AttributeSet attrs) {
15 super(context, attrs);
16 setSummary();
17 }
18
19 private void setSummary() {
20 if (getContext() != null &&getContext().getPackageManager() != null) {
21 final String packageName = getContext().getPackageName();
22 final String versionName;
23 try {
24 versionName = getContext().getPackageManager().getPackageInfo(packageName, 0).versionName;
25 setSummary("Conversations " + versionName);
26 } catch (final PackageManager.NameNotFoundException e) {
27 // Using try/catch as part of the logic is sort of like this:
28 // https://xkcd.com/292/
29 }
30 }
31 }
32}
33