Author: kmorin Date: 2014-03-04 10:17:33 +0100 (Tue, 04 Mar 2014) New Revision: 64 Url: http://forge.codelutin.com/projects/wlo/repository/revisions/64 Log: fixes #4630 [TECH] Mise ?\195?\160 jour automatique de l'application Modified: trunk/res/values-fr/strings.xml trunk/res/values/strings.xml trunk/res/xml/preferences.xml trunk/src/fr/ifremer/wlo/WloApplication.java trunk/src/fr/ifremer/wlo/imports/QualitativeValueRowModel.java trunk/src/fr/ifremer/wlo/models/categorization/CategoryModel.java trunk/src/fr/ifremer/wlo/models/categorization/QualitativeValueModel.java trunk/src/fr/ifremer/wlo/preferences/CategoryCreationAcivity.java trunk/src/fr/ifremer/wlo/preferences/MultiSelectionActivity.java trunk/src/fr/ifremer/wlo/preferences/SettingsActivity.java trunk/src/fr/ifremer/wlo/utils/UpdateCheckTask.java Modified: trunk/res/values/strings.xml =================================================================== --- trunk/res/values/strings.xml 2014-03-03 17:36:04 UTC (rev 63) +++ trunk/res/values/strings.xml 2014-03-04 09:17:33 UTC (rev 64) @@ -127,6 +127,10 @@ <string name="qualitative_values_nb">%s qualitative values</string> <string name="category_created">The category has been successfully created.</string> + <string name="preferences_update">Update</string> + <string name="preferences_check_update">Check if the application is up to date</string> + <string name="preferences_current_version">Current version: %s</string> + <!-- Contexts --> <string name="add_context">Create a new context</string> <string name="contexts_title">Contexts</string> @@ -217,8 +221,10 @@ <string name="crash_dialog_ok_toast">Thank you !</string> <!-- Update --> + <string name="checking_update">Checking last available version</string> <string name="update_dowload_error">Error while downloading the new version of WLO</string> <string name="update_available_title">New version available</string> <string name="update_available_message">A new version of WLO is available. Would you like to install it?</string> + <string name="no_update">You already have the latest version of the application</string> </resources> Modified: trunk/res/values-fr/strings.xml =================================================================== --- trunk/res/values-fr/strings.xml 2014-03-03 17:36:04 UTC (rev 63) +++ trunk/res/values-fr/strings.xml 2014-03-04 09:17:33 UTC (rev 64) @@ -120,6 +120,10 @@ <string name="qualitative_values_nb">%s valeurs pour cette catégorie</string> <string name="category_created">La catégorie a bien été créée.</string> + <string name="preferences_update">Mise à jour</string> + <string name="preferences_check_update">Vérifier si l\'application est à jour</string> + <string name="preferences_current_version">Version actuelle : %s</string> + <!-- Contexts --> <string name="add_context">Créer un nouveau contexte</string> <string name="contexts_title">Contextes</string> @@ -209,8 +213,10 @@ <string name="crash_dialog_ok_toast">Merci !</string> <!-- Update --> + <string name="checking_update">Recherche d\'une version plus récente</string> <string name="update_dowload_error">Erreur lors du téléchargement de la dernière version de WLO</string> <string name="update_available_title">Nouvelle version disponible</string> <string name="update_available_message">Une nouvelle version de WLO est disponible. Voulez-vous la télécharger et l\'installer ?</string> + <string name="no_update">Vous avez déjà la version la plus récente de l\'application</string> </resources> Modified: trunk/res/xml/preferences.xml =================================================================== --- trunk/res/xml/preferences.xml 2014-03-03 17:36:04 UTC (rev 63) +++ trunk/res/xml/preferences.xml 2014-03-04 09:17:33 UTC (rev 64) @@ -85,4 +85,13 @@ </PreferenceCategory> + <PreferenceCategory + android:title="@string/preferences_update" + android:key="preferences_update"> + + <Preference android:title="@string/preferences_check_update" + android:key="preferences_check_update"/> + + </PreferenceCategory> + </PreferenceScreen> \ No newline at end of file Modified: trunk/src/fr/ifremer/wlo/WloApplication.java =================================================================== --- trunk/src/fr/ifremer/wlo/WloApplication.java 2014-03-03 17:36:04 UTC (rev 63) +++ trunk/src/fr/ifremer/wlo/WloApplication.java 2014-03-04 09:17:33 UTC (rev 64) @@ -1,5 +1,29 @@ package fr.ifremer.wlo; +/* + * #%L + * WLO + * $Id:$ + * $HeadURL:$ + * %% + * Copyright (C) 2013 - 2014 Ifremer + * %% + * This program 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. + * + * This program 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 this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + import android.app.Application; import android.app.DownloadManager; import android.app.ProgressDialog; Modified: trunk/src/fr/ifremer/wlo/imports/QualitativeValueRowModel.java =================================================================== --- trunk/src/fr/ifremer/wlo/imports/QualitativeValueRowModel.java 2014-03-03 17:36:04 UTC (rev 63) +++ trunk/src/fr/ifremer/wlo/imports/QualitativeValueRowModel.java 2014-03-04 09:17:33 UTC (rev 64) @@ -1,5 +1,29 @@ package fr.ifremer.wlo.imports; +/* + * #%L + * WLO + * $Id:$ + * $HeadURL:$ + * %% + * Copyright (C) 2013 - 2014 Ifremer + * %% + * This program 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. + * + * This program 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 this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + import fr.ifremer.wlo.models.categorization.CategoryModel; import fr.ifremer.wlo.models.categorization.QualitativeValueModel; import org.nuiton.csv.ValueSetter; Modified: trunk/src/fr/ifremer/wlo/models/categorization/CategoryModel.java =================================================================== --- trunk/src/fr/ifremer/wlo/models/categorization/CategoryModel.java 2014-03-03 17:36:04 UTC (rev 63) +++ trunk/src/fr/ifremer/wlo/models/categorization/CategoryModel.java 2014-03-04 09:17:33 UTC (rev 64) @@ -1,5 +1,29 @@ package fr.ifremer.wlo.models.categorization; +/* + * #%L + * WLO + * $Id:$ + * $HeadURL:$ + * %% + * Copyright (C) 2013 - 2014 Ifremer + * %% + * This program 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. + * + * This program 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 this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + import android.content.ContentValues; import android.database.Cursor; import android.util.Log; Modified: trunk/src/fr/ifremer/wlo/models/categorization/QualitativeValueModel.java =================================================================== --- trunk/src/fr/ifremer/wlo/models/categorization/QualitativeValueModel.java 2014-03-03 17:36:04 UTC (rev 63) +++ trunk/src/fr/ifremer/wlo/models/categorization/QualitativeValueModel.java 2014-03-04 09:17:33 UTC (rev 64) @@ -1,5 +1,29 @@ package fr.ifremer.wlo.models.categorization; +/* + * #%L + * WLO + * $Id:$ + * $HeadURL:$ + * %% + * Copyright (C) 2013 - 2014 Ifremer + * %% + * This program 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. + * + * This program 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 this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + import android.content.ContentValues; import android.database.Cursor; import android.util.Log; Modified: trunk/src/fr/ifremer/wlo/preferences/CategoryCreationAcivity.java =================================================================== --- trunk/src/fr/ifremer/wlo/preferences/CategoryCreationAcivity.java 2014-03-03 17:36:04 UTC (rev 63) +++ trunk/src/fr/ifremer/wlo/preferences/CategoryCreationAcivity.java 2014-03-04 09:17:33 UTC (rev 64) @@ -1,5 +1,29 @@ package fr.ifremer.wlo.preferences; +/* + * #%L + * WLO + * $Id:$ + * $HeadURL:$ + * %% + * Copyright (C) 2013 - 2014 Ifremer + * %% + * This program 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. + * + * This program 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 this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + import android.app.AlertDialog; import android.content.Intent; import android.os.Bundle; Modified: trunk/src/fr/ifremer/wlo/preferences/MultiSelectionActivity.java =================================================================== --- trunk/src/fr/ifremer/wlo/preferences/MultiSelectionActivity.java 2014-03-03 17:36:04 UTC (rev 63) +++ trunk/src/fr/ifremer/wlo/preferences/MultiSelectionActivity.java 2014-03-04 09:17:33 UTC (rev 64) @@ -1,6 +1,30 @@ package fr.ifremer.wlo.preferences; +/* + * #%L + * WLO + * $Id:$ + * $HeadURL:$ + * %% + * Copyright (C) 2013 - 2014 Ifremer + * %% + * This program 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. + * + * This program 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 this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + import android.app.ListActivity; import android.content.Intent; import android.os.Bundle; Modified: trunk/src/fr/ifremer/wlo/preferences/SettingsActivity.java =================================================================== --- trunk/src/fr/ifremer/wlo/preferences/SettingsActivity.java 2014-03-03 17:36:04 UTC (rev 63) +++ trunk/src/fr/ifremer/wlo/preferences/SettingsActivity.java 2014-03-04 09:17:33 UTC (rev 64) @@ -30,6 +30,7 @@ import android.content.DialogInterface; import android.content.Intent; import android.content.SharedPreferences; +import android.content.pm.PackageManager; import android.os.AsyncTask; import android.os.Bundle; import android.os.Environment; @@ -55,6 +56,7 @@ import fr.ifremer.wlo.storage.WloSqlOpenHelper; import fr.ifremer.wlo.utils.ImportUtil; import fr.ifremer.wlo.utils.UIUtils; +import fr.ifremer.wlo.utils.UpdateCheckTask; import fr.ifremer.wlo.utils.filechooser.FileDialog; import fr.ifremer.wlo.utils.filechooser.SelectionMode; import org.apache.commons.io.FileUtils; @@ -193,6 +195,23 @@ ScientificSpecies.class, REQUEST_FAVORITES_SCIENTIFIC_SPECIES); + // update + Preference updatePref = findPreference("preferences_check_update"); + try { + String currentVersion = context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionName; + updatePref.setSummary(getString(R.string.preferences_current_version, currentVersion)); + + } catch (PackageManager.NameNotFoundException e) { + Log.e(TAG, "error while getting the version"); + } + updatePref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { + @Override + public boolean onPreferenceClick(Preference preference) { + new UpdateCheckTask(getActivity(), true).execute(); + return true; + } + }); + } @Override Modified: trunk/src/fr/ifremer/wlo/utils/UpdateCheckTask.java =================================================================== --- trunk/src/fr/ifremer/wlo/utils/UpdateCheckTask.java 2014-03-03 17:36:04 UTC (rev 63) +++ trunk/src/fr/ifremer/wlo/utils/UpdateCheckTask.java 2014-03-04 09:17:33 UTC (rev 64) @@ -1,7 +1,32 @@ package fr.ifremer.wlo.utils; +/* + * #%L + * WLO + * $Id:$ + * $HeadURL:$ + * %% + * Copyright (C) 2013 - 2014 Ifremer + * %% + * This program 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. + * + * This program 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 this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + import android.app.AlertDialog; import android.app.DownloadManager; +import android.app.ProgressDialog; import android.content.BroadcastReceiver; import android.content.Context; import android.content.DialogInterface; @@ -41,12 +66,30 @@ public static final String URL_PROP = "application.url"; protected Context context; + protected boolean showLoading; + protected ProgressDialog loadingDialog; public UpdateCheckTask(Context context) { + this(context, false); + } + + public UpdateCheckTask(Context context, boolean showLoading) { this.context = context; + this.showLoading = showLoading; } @Override + protected void onPreExecute() { + super.onPreExecute(); + if (showLoading) { + loadingDialog = new ProgressDialog(context); + loadingDialog.setIndeterminate(true); + loadingDialog.setMessage(context.getString(R.string.checking_update)); + loadingDialog.show(); + } + } + + @Override protected String doInBackground(String... params) { String result; @@ -85,6 +128,9 @@ @Override protected void onPostExecute(final String result) { super.onPostExecute(result); + if (showLoading) { + loadingDialog.dismiss(); + } if (result != null && WloBaseActivity.getDownloadingApkId() == null) { new AlertDialog.Builder(context) @@ -105,6 +151,8 @@ .create() .show(); + } else if (showLoading) { + Toast.makeText(context, R.string.no_update, Toast.LENGTH_LONG).show(); } }