r59 - in trunk: . res/values res/values-fr src/fr/ifremer/wlo src/fr/ifremer/wlo/preferences
Author: kmorin Date: 2014-03-01 22:36:10 +0100 (Sat, 01 Mar 2014) New Revision: 59 Url: http://codelutin.com/projects/wlo/repository/revisions/59 Log: add an error report Added: trunk/src/fr/ifremer/wlo/WloApplication.java Modified: trunk/AndroidManifest.xml trunk/pom.xml trunk/res/values-fr/strings.xml trunk/res/values/strings.xml trunk/src/fr/ifremer/wlo/MainActivity.java trunk/src/fr/ifremer/wlo/preferences/MultiSelectionActivity.java Modified: trunk/AndroidManifest.xml =================================================================== --- trunk/AndroidManifest.xml 2014-03-01 20:07:03 UTC (rev 58) +++ trunk/AndroidManifest.xml 2014-03-01 21:36:10 UTC (rev 59) @@ -24,8 +24,10 @@ <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" /> <uses-permission android:name="android.permission.BLUETOOTH" /> <uses-permission android:name="android.permission.VIBRATE"/> + <uses-permission android:name="android.permission.INTERNET"/> - <application android:label="@string/app_name" + <application android:name=".WloApplication" + android:label="@string/app_name" android:icon="@drawable/wlo_ico_small" android:theme="@style/Theme.AppCompat"> @@ -128,5 +130,11 @@ <activity android:name=".utils.filechooser.FileDialog" android:configChanges="orientation|screenSize|keyboardHidden"/> + <activity android:name="org.acra.CrashReportDialog" + android:theme="@android:style/Theme.Holo.Dialog" + android:launchMode="singleInstance" + android:excludeFromRecents="true" + android:finishOnTaskLaunch="true" /> + </application> </manifest> Modified: trunk/pom.xml =================================================================== --- trunk/pom.xml 2014-03-01 20:07:03 UTC (rev 58) +++ trunk/pom.xml 2014-03-01 21:36:10 UTC (rev 59) @@ -198,6 +198,12 @@ <artifactId>commons-io</artifactId> </dependency> + <dependency> + <groupId>ch.acra</groupId> + <artifactId>acra</artifactId> + <version>4.5.0</version> + </dependency> + </dependencies> <repositories> Modified: trunk/res/values/strings.xml =================================================================== --- trunk/res/values/strings.xml 2014-03-01 20:07:03 UTC (rev 58) +++ trunk/res/values/strings.xml 2014-03-01 21:36:10 UTC (rev 59) @@ -206,4 +206,14 @@ <string name="file_chooser_no_data">No Data</string> <string name="file_chooser_err">Error</string> + <!--ACRA--> + <string name="crash_toast_text">Ooooops ! I crashed, but a report has been sent to my developer to help fix the issue !</string> + + <string name="crash_dialog_title">WLO has crashed</string> + <string name="crash_dialog_text">An unexpected error occurred forcing the + application to stop. Please help us fix this by sending us error data, + all you have to do is click OK.</string> + <string name="crash_dialog_comment_prompt">You might add your comments about the problem below:</string> + <string name="crash_dialog_ok_toast">Thank you !</string> + </resources> Modified: trunk/res/values-fr/strings.xml =================================================================== --- trunk/res/values-fr/strings.xml 2014-03-01 20:07:03 UTC (rev 58) +++ trunk/res/values-fr/strings.xml 2014-03-01 21:36:10 UTC (rev 59) @@ -199,4 +199,13 @@ <string name="file_chooser_no_data">Aucun fichier</string> <string name="file_chooser_err">Erreur</string> + <!--ACRA--> + <string name="crash_toast_text">Erreur innatendue, préparation du rapport de bug</string> + + <string name="crash_dialog_title">WLO a planté</string> + <string name="crash_dialog_text">Une erreur inattendue s\'est produite et a forcé l\'application à s\'arrêter. + Si vous voulez nous aider à corriger ce bug, merci de nous envoyer les données par mail en appuyant sur OK.</string> + <string name="crash_dialog_comment_prompt">Vous pouvez ajouter un commentaire ci-dessous:</string> + <string name="crash_dialog_ok_toast">Merci !</string> + </resources> Modified: trunk/src/fr/ifremer/wlo/MainActivity.java =================================================================== --- trunk/src/fr/ifremer/wlo/MainActivity.java 2014-03-01 20:07:03 UTC (rev 58) +++ trunk/src/fr/ifremer/wlo/MainActivity.java 2014-03-01 21:36:10 UTC (rev 59) @@ -25,6 +25,7 @@ */ import android.app.Activity; +import android.app.AlertDialog; import android.app.ProgressDialog; import android.bluetooth.BluetoothAdapter; import android.content.Intent; @@ -45,6 +46,7 @@ import fr.ifremer.wlo.storage.DataCache; import fr.ifremer.wlo.storage.Exporter; import fr.ifremer.wlo.storage.WloSqlOpenHelper; +import fr.ifremer.wlo.utils.UIUtils; import fr.ifremer.wlo.utils.filechooser.FileDialog; import fr.ifremer.wlo.utils.filechooser.SelectionMode; import org.apache.commons.io.FileUtils; @@ -75,7 +77,6 @@ protected Button connectButton; protected Button disconnectButton; - protected ProgressDialog dialog; @Override protected void onCreate(Bundle savedInstanceState) { @@ -126,90 +127,8 @@ Configuration config = getResources().getConfiguration(); setOrientation(config.orientation); - - dialog = new ProgressDialog(this); - dialog.setIndeterminate(false); - dialog.setCancelable(false); - dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); - dialog.setMax(9); - dialog.setMessage(getString(R.string.main_loading_referential)); - dialog.show(); - - new Thread(new Runnable() { - @Override - public void run() { - initData(); - } - }).start(); - } - protected void initData() { - try { - if (DataCache.getAllCommercialSpecies(this).isEmpty()) { - ImportUtil.importCommercialSpecies(this, getAssets().open("ref_import_commercial_species.csv")); - } - dialog.setProgress(1); - if (DataCache.getAllLocations(this).isEmpty()) { - ImportUtil.importLocations(this, getAssets().open("ref_import_locations.csv")); - } - dialog.setProgress(2); - if (DataCache.getAllMensurations(this).isEmpty()) { - ImportUtil.importMensurations(this, getAssets().open("ref_import_mensurations.csv")); - } - dialog.setProgress(3); - if (DataCache.getAllMetiers(this).isEmpty()) { - ImportUtil.importMetiers(this, getAssets().open("ref_import_metiers.csv")); - } - dialog.setProgress(4); - if (DataCache.getAllPresentations(this).isEmpty()) { - ImportUtil.importPresentations(this, getAssets().open("ref_import_presentations.csv")); - } - dialog.setProgress(5); - if (DataCache.getAllScientificSpecies(this).isEmpty()) { - ImportUtil.importScientificSpecies(this, getAssets().open("ref_import_scientific_species.csv")); - } - dialog.setProgress(6); - if (DataCache.getAllStates(this).isEmpty()) { - ImportUtil.importStates(this, getAssets().open("ref_import_states.csv")); - } - dialog.setProgress(7); - if (DataCache.getAllVessels(this).isEmpty()) { - ImportUtil.importVessels(this, getAssets().open("ref_import_vessels.csv")); - } - dialog.setProgress(8); - if (DataCache.getAllCategories(this).isEmpty()) { - WloSqlOpenHelper soh = new WloSqlOpenHelper(this); - - CategoryModel ageCategory = new CategoryModel(); - ageCategory.setLabel(getString(R.string.age)); - soh.saveData(ageCategory); - - CategoryModel genderCategory = new CategoryModel(); - genderCategory.setLabel(getString(R.string.gender)); - soh.saveData(genderCategory); - - CategoryModel maturityCategory = new CategoryModel(); - maturityCategory.setLabel(getString(R.string.maturity)); - soh.saveData(maturityCategory); - - soh.saveData(ImportUtil.importQualitativeValues(ageCategory, getAssets().open("ref_import_ages.csv"))); - soh.saveData(ImportUtil.importQualitativeValues(genderCategory, getAssets().open("ref_import_genders.csv"))); - soh.saveData(ImportUtil.importQualitativeValues(maturityCategory, getAssets().open("ref_import_maturities.csv"))); - - soh.close(); - } - dialog.setProgress(9); - - } catch (IOException | RuntimeException e) { - //TODO kmorin 20140130 show error to the user - Log.e(TAG, "error on initial import", e); - - } finally { - dialog.dismiss(); - } - } - protected void bigfinConnected() { disconnectButton.setVisibility(View.VISIBLE); connectButton.setVisibility(View.GONE); Added: trunk/src/fr/ifremer/wlo/WloApplication.java =================================================================== --- trunk/src/fr/ifremer/wlo/WloApplication.java (rev 0) +++ trunk/src/fr/ifremer/wlo/WloApplication.java 2014-03-01 21:36:10 UTC (rev 59) @@ -0,0 +1,101 @@ +package fr.ifremer.wlo; + +import android.app.Application; +import android.app.ProgressDialog; +import android.util.Log; +import fr.ifremer.wlo.imports.ImportUtil; +import fr.ifremer.wlo.models.categorization.CategoryModel; +import fr.ifremer.wlo.storage.DataCache; +import fr.ifremer.wlo.storage.WloSqlOpenHelper; +import org.acra.ACRA; +import org.acra.ReportingInteractionMode; +import org.acra.annotation.ReportsCrashes; + +import java.io.IOException; + +/** + * @author Kevin Morin (Code Lutin) + * @since x.x + */ +@ReportsCrashes(formKey = "", // will not be used + mailTo = "wlo-devel@list.forge.codelutin.com", + mode = ReportingInteractionMode.DIALOG, + resToastText = R.string.crash_toast_text, // optional, displayed as soon as the crash occurs, before collecting data which can take a few seconds + resDialogText = R.string.crash_dialog_text, + resDialogIcon = android.R.drawable.ic_dialog_info, //optional. default is a warning sign + resDialogTitle = R.string.crash_dialog_title, // optional. default is your application name + resDialogCommentPrompt = R.string.crash_dialog_comment_prompt, // optional. when defined, adds a user text field input with this text resource as a label + resDialogOkToast = R.string.crash_dialog_ok_toast) // optional. displays a Toast message when the user accepts to send a report. +public class WloApplication extends Application { + + private static final String TAG = "WloApplication"; + + @Override + public void onCreate() { + ACRA.init(this); + super.onCreate(); + + new Thread(new Runnable() { + @Override + public void run() { + initData(); + } + }).start(); + + } + + protected void initData() { + try { + if (DataCache.getAllCommercialSpecies(this).isEmpty()) { + ImportUtil.importCommercialSpecies(this, getAssets().open("ref_import_commercial_species.csv")); + } + if (DataCache.getAllLocations(this).isEmpty()) { + ImportUtil.importLocations(this, getAssets().open("ref_import_locations.csv")); + } + if (DataCache.getAllMensurations(this).isEmpty()) { + ImportUtil.importMensurations(this, getAssets().open("ref_import_mensurations.csv")); + } + if (DataCache.getAllMetiers(this).isEmpty()) { + ImportUtil.importMetiers(this, getAssets().open("ref_import_metiers.csv")); + } + if (DataCache.getAllPresentations(this).isEmpty()) { + ImportUtil.importPresentations(this, getAssets().open("ref_import_presentations.csv")); + } + if (DataCache.getAllScientificSpecies(this).isEmpty()) { + ImportUtil.importScientificSpecies(this, getAssets().open("ref_import_scientific_species.csv")); + } + if (DataCache.getAllStates(this).isEmpty()) { + ImportUtil.importStates(this, getAssets().open("ref_import_states.csv")); + } + if (DataCache.getAllVessels(this).isEmpty()) { + ImportUtil.importVessels(this, getAssets().open("ref_import_vessels.csv")); + } + if (DataCache.getAllCategories(this).isEmpty()) { + WloSqlOpenHelper soh = new WloSqlOpenHelper(this); + + CategoryModel ageCategory = new CategoryModel(); + ageCategory.setLabel(getString(R.string.age)); + soh.saveData(ageCategory); + + CategoryModel genderCategory = new CategoryModel(); + genderCategory.setLabel(getString(R.string.gender)); + soh.saveData(genderCategory); + + CategoryModel maturityCategory = new CategoryModel(); + maturityCategory.setLabel(getString(R.string.maturity)); + soh.saveData(maturityCategory); + + soh.saveData(ImportUtil.importQualitativeValues(ageCategory, getAssets().open("ref_import_ages.csv"))); + soh.saveData(ImportUtil.importQualitativeValues(genderCategory, getAssets().open("ref_import_genders.csv"))); + soh.saveData(ImportUtil.importQualitativeValues(maturityCategory, getAssets().open("ref_import_maturities.csv"))); + + soh.close(); + } + + } catch (IOException | RuntimeException e) { + //TODO kmorin 20140130 show error to the user + Log.e(TAG, "error on initial import", e); + } + } + +} Modified: trunk/src/fr/ifremer/wlo/preferences/MultiSelectionActivity.java =================================================================== --- trunk/src/fr/ifremer/wlo/preferences/MultiSelectionActivity.java 2014-03-01 20:07:03 UTC (rev 58) +++ trunk/src/fr/ifremer/wlo/preferences/MultiSelectionActivity.java 2014-03-01 21:36:10 UTC (rev 59) @@ -84,8 +84,6 @@ getListView().setOnItemLongClickListener(this); } - - public void cancel(View view) { setResult(RESULT_CANCELED); finish();
participants (1)
-
kmorin@users.forge.codelutin.com