Add about dialog with license info

Sam Whited created

Change summary

src/eu/siacs/conversations/ui/AboutDialog.java | 33 +++++++++++++++++
src/main/res/values/strings.xml                | 37 ++++++++++++++++++++
src/main/res/xml/preferences.xml               |  7 +++
3 files changed, 77 insertions(+)

Detailed changes

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/
+			}
+		}
+	}
+}
+

src/main/res/values/strings.xml 🔗

@@ -254,6 +254,43 @@
     <string name="pref_enable_legacy_ssl_summary">Enables SSLv3 support for legacy servers. Warning: SSLv3 is considered insecure.</string>
     <string name="pref_expert_options">Expert options</string>
     <string name="pref_expert_options_summary">Please be careful with these</string>
+		<string name="pref_about_conversations">About Conversations</string>
+    <string name="pref_about_conversations_summary">Build and licensing information</string>
+		<string name="pref_about_message">
+			This program is free software; you can redistribute it and/or modify it
+			under the terms of the GNU General Public License version 3 as published
+			by the Free Software Foundation.\n
+			\n
+			Link: http://www.gnu.org/licenses/gpl-3.0.html\n
+			\n
+			OpenPGP API is licensed under the Apache License, Version 2.0; You may
+			obtain a copy of the License at:\n
+			\n
+			http://www.apache.org/licenses/LICENSE-2.0\n
+			\n
+			Minidns (c) 2014 Rene Treffer and is provided under the WTFPL\n
+			\n
+			MemorizingTrustManager Copyright (c) 2010 Georg Lukas\n
+			\n
+			Permission is hereby granted, free of charge, to any person obtaining a
+			copy of this software and associated documentation files (the
+			"Software"), to deal in the Software without restriction, including
+			without limitation the rights to use, copy, modify, merge, publish,
+			distribute, sublicense, and/or sell copies of the Software, and to permit
+			persons to whom the Software is furnished to do so, subject to the
+			following conditions:\n
+			\n
+			The above copyright notice and this permission notice shall be included
+			in all copies or substantial portions of the Software.\n
+			\n
+			THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+			OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+			MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
+			NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+			DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+			OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+			USE OR OTHER DEALINGS IN THE SOFTWARE.
+		</string>
     <string name="pref_use_larger_font">Increase font size</string>
     <string name="pref_use_larger_font_summary">Use larger font sizes across the entire app</string>
     <string name="pref_use_send_button_to_indicate_status">Send button indicates status</string>

src/main/res/xml/preferences.xml 🔗

@@ -110,5 +110,12 @@
             android:summary="@string/pref_never_send_crash_summary"
             android:title="@string/pref_never_send_crash" />
     </PreferenceCategory>
+		<eu.siacs.conversations.ui.AboutDialog
+			android:summary="@string/pref_about_conversations_summary"
+			android:title="@string/pref_about_conversations"
+			android:dialogIcon="@drawable/ic_activity"
+			android:negativeButtonText="@null"
+			android:dialogMessage="@string/pref_about_message">
+		</eu.siacs.conversations.ui.AboutDialog>
 
 </PreferenceScreen>