aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/eu/siacs/conversations
diff options
context:
space:
mode:
authoriNPUTmice <daniel@gultsch.de>2014-11-04 22:56:36 +0100
committeriNPUTmice <daniel@gultsch.de>2014-11-04 22:56:36 +0100
commit7d4e03cc9a80c00eddc47fece8147fbaef52f536 (patch)
treed24eea8186eea60eb943ab422b4f9fed2bfc8a79 /src/main/java/eu/siacs/conversations
parent88c07936940353128dc7d446a9f14dbfbc3ce7c9 (diff)
parent39183418ab133f14bddc389dea8419980538f629 (diff)
Merge branch 'development' of https://github.com/siacs/Conversations into development
Diffstat (limited to 'src/main/java/eu/siacs/conversations')
-rw-r--r--src/main/java/eu/siacs/conversations/ui/AboutActivity.java15
-rw-r--r--src/main/java/eu/siacs/conversations/ui/AboutPreference.java41
2 files changed, 56 insertions, 0 deletions
diff --git a/src/main/java/eu/siacs/conversations/ui/AboutActivity.java b/src/main/java/eu/siacs/conversations/ui/AboutActivity.java
new file mode 100644
index 00000000..a61b872a
--- /dev/null
+++ b/src/main/java/eu/siacs/conversations/ui/AboutActivity.java
@@ -0,0 +1,15 @@
+package eu.siacs.conversations.ui;
+
+import android.app.Activity;
+import android.os.Bundle;
+
+import eu.siacs.conversations.R;
+
+public class AboutActivity extends Activity {
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_about);
+ }
+}
diff --git a/src/main/java/eu/siacs/conversations/ui/AboutPreference.java b/src/main/java/eu/siacs/conversations/ui/AboutPreference.java
new file mode 100644
index 00000000..804b4e23
--- /dev/null
+++ b/src/main/java/eu/siacs/conversations/ui/AboutPreference.java
@@ -0,0 +1,41 @@
+package eu.siacs.conversations.ui;
+
+import android.content.Context;
+import android.content.Intent;
+import android.content.pm.PackageManager;
+import android.preference.Preference;
+import android.util.AttributeSet;
+
+public class AboutPreference extends Preference {
+ public AboutPreference(final Context context, final AttributeSet attrs, final int defStyle) {
+ super(context, attrs, defStyle);
+ setSummary();
+ }
+
+ public AboutPreference(final Context context, final AttributeSet attrs) {
+ super(context, attrs);
+ setSummary();
+ }
+
+ @Override
+ protected void onClick() {
+ super.onClick();
+ final Intent intent = new Intent(getContext(), AboutActivity.class);
+ getContext().startActivity(intent);
+ }
+
+ 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/
+ }
+ }
+ }
+}
+