From c2208f2cd20d66c990b5901621f337ad8ee04dbe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Chabot?= Date: Sun, 18 Jan 2015 22:36:15 +0100 Subject: [PATCH] Build the license dialog with an external library --- build.gradle | 4 + .../org/droidupnp/view/LicenseDialog.java | 83 ------------------- .../org/droidupnp/view/SettingsActivity.java | 35 +++++++- src/main/res/layout/about.xml | 46 ---------- src/main/res/values-de/strings.xml | 18 ---- src/main/res/values-es/strings.xml | 18 ---- src/main/res/values-fr/strings.xml | 18 ---- src/main/res/values-nl/strings.xml | 18 ---- src/main/res/values/strings.xml | 24 +----- src/main/res/xml/about.xml | 6 +- 10 files changed, 41 insertions(+), 229 deletions(-) delete mode 100644 src/main/java/org/droidupnp/view/LicenseDialog.java delete mode 100644 src/main/res/layout/about.xml diff --git a/build.gradle b/build.gradle index 3f57817..a218c8d 100644 --- a/build.gradle +++ b/build.gradle @@ -30,6 +30,10 @@ dependencies { // Pull To Refresh compile 'com.github.chrisbanes.actionbarpulltorefresh:library:+' + + compile('de.psdev.licensesdialog:licensesdialog:1.6.0') { + exclude module: 'support-v4' + } } android { diff --git a/src/main/java/org/droidupnp/view/LicenseDialog.java b/src/main/java/org/droidupnp/view/LicenseDialog.java deleted file mode 100644 index 6dcc29e..0000000 --- a/src/main/java/org/droidupnp/view/LicenseDialog.java +++ /dev/null @@ -1,83 +0,0 @@ -/** - * Copyright (C) 2013 Aurélien Chabot - * - * This file is part of DroidUPNP. - * - * DroidUPNP is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * DroidUPNP is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with DroidUPNP. If not, see . - */ - -package org.droidupnp.view; - -import org.droidupnp.R; - -import android.app.Activity; -import android.app.AlertDialog; -import android.app.Dialog; -import android.app.DialogFragment; -import android.content.pm.PackageManager.NameNotFoundException; -import android.os.Bundle; -import android.text.Html; -import android.text.method.LinkMovementMethod; -import android.util.Log; -import android.view.LayoutInflater; -import android.widget.TextView; - -public class LicenseDialog extends DialogFragment { - - private static final String TAG = "LicenseDialog"; - - public static void showDialog(Activity ctx) - { - LicenseDialog newFragment = new LicenseDialog(); - newFragment.show(ctx.getFragmentManager(), ctx.getString(R.string.about_license_other)); - } - - @Override - public Dialog onCreateDialog(Bundle savedInstanceState) - { - AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); - LayoutInflater inflater = getActivity().getLayoutInflater(); - builder.setView(inflater.inflate(R.layout.about, null)); - builder.setTitle(R.string.menu_about); - - Dialog d = builder.create(); - - d.show(); - - TextView textView; - - textView = (TextView) d.findViewById(R.id.about_cling); - if (textView != null) - { - textView.setMovementMethod(LinkMovementMethod.getInstance()); - textView.setText(Html.fromHtml(getString(R.string.about_cling))); - } - - textView = (TextView) d.findViewById(R.id.about_nanohttpd); - if (textView != null) - { - textView.setMovementMethod(LinkMovementMethod.getInstance()); - textView.setText(Html.fromHtml(getString(R.string.about_nanohttpd))); - } - - textView = (TextView) d.findViewById(R.id.about_pulltorefresh); - if (textView != null) - { - textView.setMovementMethod(LinkMovementMethod.getInstance()); - textView.setText(Html.fromHtml(getString(R.string.about_pulltorefresh))); - } - - return d; - } -} diff --git a/src/main/java/org/droidupnp/view/SettingsActivity.java b/src/main/java/org/droidupnp/view/SettingsActivity.java index df45d17..be64494 100644 --- a/src/main/java/org/droidupnp/view/SettingsActivity.java +++ b/src/main/java/org/droidupnp/view/SettingsActivity.java @@ -48,6 +48,13 @@ import java.util.ArrayList; import java.util.List; +import de.psdev.licensesdialog.LicensesDialog; +import de.psdev.licensesdialog.licenses.ApacheSoftwareLicense20; +import de.psdev.licensesdialog.licenses.BSD3ClauseLicense; +import de.psdev.licensesdialog.licenses.GnuLesserGeneralPublicLicense21; +import de.psdev.licensesdialog.model.Notice; +import de.psdev.licensesdialog.model.Notices; + public class SettingsActivity extends PreferenceActivity { public static final String CONTENTDIRECTORY_SERVICE = "pref_contentDirectoryService"; @@ -248,14 +255,34 @@ public void onCreate(Bundle savedInstanceState) } // Dialog for external license - Preference customPref = findPreference("license_other"); - customPref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { + Preference pref = findPreference("licenses_other"); + pref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { public boolean onPreferenceClick(Preference preference) { - LicenseDialog.showDialog(getActivity()); + Notices notices = new Notices(); + notices.addNotice(new Notice( + "AppCompat", "http://developer.android.com/tools/support-library/", + "Copyright (C) The Android Open Source Project", new ApacheSoftwareLicense20())); + notices.addNotice(new Notice( + "Cling", "http://4thline.org/projects/cling/", + "Copyright (C) 4th Line GmbH", new GnuLesserGeneralPublicLicense21())); + notices.addNotice(new Notice( + "NanoHttpd", "https://github.com/NanoHttpd/nanohttpd", + "Copyright (C) 2012-2013 by Paul S. Hawke, 2001,2005-2013 by Jarno Elonen, 2010 by Konstantinos Togias", new BSD3ClauseLicense())); + notices.addNotice(new Notice( + "ActionBar-PullToRefresh", "https://github.com/chrisbanes/ActionBar-PullToRefresh", + "Copyright (C) Chris Banes", new ApacheSoftwareLicense20())); + notices.addNotice(new Notice( + "LicenseDialog", "http://psdev.de/LicensesDialog/", + "Copyright (C) Philip Schiffer", new ApacheSoftwareLicense20())); + + LicensesDialog.Builder licensesDialog = new LicensesDialog.Builder(getActivity()); + licensesDialog.setNotices(notices); + licensesDialog.setTitle(R.string.licenses_other); + licensesDialog.build().show(); return false; } - }); + }); } } diff --git a/src/main/res/layout/about.xml b/src/main/res/layout/about.xml deleted file mode 100644 index 2361d7f..0000000 --- a/src/main/res/layout/about.xml +++ /dev/null @@ -1,46 +0,0 @@ - - - - - - - - - - - diff --git a/src/main/res/values-de/strings.xml b/src/main/res/values-de/strings.xml index df13b53..2e51303 100644 --- a/src/main/res/values-de/strings.xml +++ b/src/main/res/values-de/strings.xml @@ -94,23 +94,5 @@ Wenn sie Entwickler sind dürfen sie gern beitragen!

]]> - - DroidUPnP nutzt die Java/Android UPnP Bibliothek Cling. Cling ist lizenziert unter LGPLv2. - Der Quellcode steht auf 4thline.org zur Verfügung.

- ]]> -
- - DroidUPnP nutzt NanoHttpd. NanoHttpd ist lizenziert unter einer angepassten BSD Lizenz. - Der Quellcode steht auf GitHub zur Verfügung. - ]]> - - - DroidUPnP nutzt ActionBar-PullToRefresh. ActionBar-PullToRefresh unter einer Apache License, Version 2.0. - SDer Quellcode steht auf GitHub zur Verfügung. - ]]> - diff --git a/src/main/res/values-es/strings.xml b/src/main/res/values-es/strings.xml index 265cdc2..e7e95d4 100644 --- a/src/main/res/values-es/strings.xml +++ b/src/main/res/values-es/strings.xml @@ -93,23 +93,5 @@ El código fuente está disponible en GitHub.

]]> - - DroidUPnP usa Cling que es una biblioteca UPnP Java/Android. Cling está licenciado bajo LGPLv2. - El código fuente está disponible en 4thline.org

- ]]> -
- - DroidUPnP usa NanoHttpd. NanoHttpd está bajo una licencia BSD modificada. - El código fuente está disponible en GitHub. - ]]> - - - DroidUPnP usa ActionBar-PullToRefresh. ActionBar-PullToRefresh está licenciado bajo Apache License, Version 2.0. - El código fuente está disponible en GitHub. - ]]> - diff --git a/src/main/res/values-fr/strings.xml b/src/main/res/values-fr/strings.xml index 51a2797..cbde41b 100644 --- a/src/main/res/values-fr/strings.xml +++ b/src/main/res/values-fr/strings.xml @@ -94,23 +94,5 @@ Les contributions sont les bienvenues !

]]> - - DroidUPnP utilise Cling, une librairie UPNP écrite en Java/Android. Cling est sous license LGPLv2. - Le code source est disponible à 4thline.org

- ]]> -
- - DroidUPnP utilise NanoHttpd. NanoHttpd est sous une license BSD modifi�. - Le code source est disponible à GitHub

- ]]> -
- - DroidUPnP utilise ActionBar-PullToRefresh. ActionBar-PullToRefresh est sous une license Apache License, Version 2.0. - Le code source est disponible à GitHub. - ]]> - diff --git a/src/main/res/values-nl/strings.xml b/src/main/res/values-nl/strings.xml index d5514ed..319502f 100644 --- a/src/main/res/values-nl/strings.xml +++ b/src/main/res/values-nl/strings.xml @@ -94,23 +94,5 @@ Als je een develloper bijdrage zijn van harte welkom !

]]> - - DroidUPnP gebruik Cling dat is een Java/Android UPnP bibliotheek. Cling is gelicenseerd onder LGPLv2. - Broncode is beschikbaar op 4thline.org

- ]]> -
- - DroidUPnP gebruik NanoHttpd. NanoHttpd is onder een modify BSD licentie. - Broncode is beschikbaar op GitHub. - ]]> - - - DroidUPnP gebruik ActionBar-PullToRefresh. ActionBar-PullToRefresh is gelicenseerd onder Apache License, Version 2.0. - Broncode is beschikbaar op GitHub. - ]]> - diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml index 74d3b2f..4ca589f 100644 --- a/src/main/res/values/strings.xml +++ b/src/main/res/values/strings.xml @@ -88,13 +88,13 @@ Copyright - Copyright © 2013 Aurélien Chabot + Copyright © 2014 Aurélien Chabot Contact : aurelien@chabot.fr License GPLv3 http://www.gnu.org/licenses/gpl-3.0.html - Library license - + Library licenses + Source Code http://github.com/trishika/droidupnp More information @@ -106,23 +106,5 @@ If you\'re a develloper contribution are welcome !

]]> - - DroidUPnP use Cling which is a Java/Android UPnP library. Cling is licensed under LGPLv2. - Source code is available at 4thline.org

- ]]> -
- - DroidUPnP use NanoHttpd. NanoHttpd is under a modify BSD license. - Source code is available on GitHub. - ]]> - - - DroidUPnP use ActionBar-PullToRefresh. ActionBar-PullToRefresh is under the Apache License, Version 2.0. - Source code is available on GitHub. - ]]> - diff --git a/src/main/res/xml/about.xml b/src/main/res/xml/about.xml index 919ff5d..0536841 100644 --- a/src/main/res/xml/about.xml +++ b/src/main/res/xml/about.xml @@ -48,9 +48,9 @@ along with DroidUPNP. If not, see . + android:key="licenses_other" + android:title="@string/licenses_other" + android:summary="@string/about_licenses_other" >