diff --git a/ExceptionHandlerLib/bin/exceptionhandlerlib.jar b/ExceptionHandlerLib/bin/exceptionhandlerlib.jar deleted file mode 100644 index daa4807..0000000 Binary files a/ExceptionHandlerLib/bin/exceptionhandlerlib.jar and /dev/null differ diff --git a/ExceptionHandlerLib/gen/com/TwentyCodes/android/exception/R.java b/ExceptionHandlerLib/gen/com/TwentyCodes/android/exception/R.java index 3262105..f730104 100644 --- a/ExceptionHandlerLib/gen/com/TwentyCodes/android/exception/R.java +++ b/ExceptionHandlerLib/gen/com/TwentyCodes/android/exception/R.java @@ -27,6 +27,7 @@ public final class R { public static int no_reports=0x7f030006; public static int send=0x7f030003; public static int sending=0x7f030002; + public static int sending_report=0x7f030007; public static int sorry=0x7f030001; public static int version=0x7f030005; } diff --git a/ExceptionHandlerLib/res/values/strings.xml b/ExceptionHandlerLib/res/values/strings.xml index b1d79f3..40d0133 100644 --- a/ExceptionHandlerLib/res/values/strings.xml +++ b/ExceptionHandlerLib/res/values/strings.xml @@ -8,5 +8,6 @@ Optional: Describe what happened Version No Reports + Sending Exception Report \ No newline at end of file diff --git a/ExceptionHandlerLib/src/com/TwentyCodes/android/exception/ExceptionHandler.java b/ExceptionHandlerLib/src/com/TwentyCodes/android/exception/ExceptionHandler.java index 9bef466..2e4a57a 100644 --- a/ExceptionHandlerLib/src/com/TwentyCodes/android/exception/ExceptionHandler.java +++ b/ExceptionHandlerLib/src/com/TwentyCodes/android/exception/ExceptionHandler.java @@ -143,7 +143,7 @@ public class ExceptionHandler implements UncaughtExceptionHandler, Runnable { InputStream inputStream = assetManager.open("exceptionhandler.properties"); Properties properties = new Properties(); properties.load(inputStream); - this.mURL = properties.getProperty("server") + properties.getProperty("file"); + this.mURL = properties.getProperty("server"); this.mEmail = properties.getProperty("email"); this.mAppName = properties.getProperty("app"); this.mTracker = properties.getProperty("tracker"); diff --git a/ExceptionHandlerLib/src/com/TwentyCodes/android/exception/ExceptionReportActivity.java b/ExceptionHandlerLib/src/com/TwentyCodes/android/exception/ExceptionReportActivity.java index 51d8a6d..8c818d6 100644 --- a/ExceptionHandlerLib/src/com/TwentyCodes/android/exception/ExceptionReportActivity.java +++ b/ExceptionHandlerLib/src/com/TwentyCodes/android/exception/ExceptionReportActivity.java @@ -6,14 +6,9 @@ */ package com.TwentyCodes.android.exception; -import java.io.IOException; - -import org.apache.http.client.ClientProtocolException; - import android.app.Activity; -import android.app.ProgressDialog; +import android.content.Intent; import android.os.Bundle; -import android.os.Looper; import android.util.Log; import android.view.View; import android.view.View.OnClickListener; @@ -61,21 +56,7 @@ public class ExceptionReportActivity extends Activity implements OnClickListener EditText description = (EditText) findViewById(R.id.description); this.mReport.setDescription(description.getText().toString()); v.setEnabled(false); - final ProgressDialog progress = ProgressDialog.show(this, "", getString(R.string.sending), true, true); - new Thread( new Runnable(){ - @Override - public void run(){ - Looper.prepare(); - try { - Log.d(TAG, ExceptionReportActivity.this.mReport.file()); - } catch (ClientProtocolException e) { - e.printStackTrace(); - } catch (IOException e) { - e.printStackTrace(); - } - progress.dismiss(); - ExceptionReportActivity.this.finish(); - } - }).start(); + this.startService(new Intent(this, ReportPostingService.class).putExtra("report", this.mReport)); + this.finish(); } } \ No newline at end of file diff --git a/ExceptionHandlerLib/src/com/TwentyCodes/android/exception/Report.java b/ExceptionHandlerLib/src/com/TwentyCodes/android/exception/Report.java index 2afaef2..691ca28 100644 --- a/ExceptionHandlerLib/src/com/TwentyCodes/android/exception/Report.java +++ b/ExceptionHandlerLib/src/com/TwentyCodes/android/exception/Report.java @@ -27,6 +27,7 @@ import org.json.JSONObject; import android.os.Parcel; import android.os.Parcelable; +import android.util.Log; /** * This class will be used to generate a report, and insert it into our exception report database @@ -34,6 +35,7 @@ import android.os.Parcelable; */ public class Report implements Parcelable{ + private static final String TAG = "Report"; private final String mUrl; private ArrayList mReport; @@ -62,8 +64,9 @@ public class Report implements Parcelable{ * Creates a new Report * @author ricky barrette */ - public Report(String mysqlUrl) { - this.mUrl = mysqlUrl; + public Report(String url) { + Log.d(TAG, url); + this.mUrl = url; } @Override diff --git a/ExceptionHandlerLib/src/com/TwentyCodes/android/exception/ReportPostingService.java b/ExceptionHandlerLib/src/com/TwentyCodes/android/exception/ReportPostingService.java new file mode 100644 index 0000000..5a53dca --- /dev/null +++ b/ExceptionHandlerLib/src/com/TwentyCodes/android/exception/ReportPostingService.java @@ -0,0 +1,130 @@ +/** + * ReportPostingService.java + * @date Feb 29, 2012 + * @author ricky barrette + * @author Twenty Codes, LLC + */ +package com.TwentyCodes.android.exception; + +import java.io.IOException; + +import org.apache.http.client.ClientProtocolException; + +import android.app.Notification; +import android.app.Notification.Builder; +import android.app.NotificationManager; +import android.app.Service; +import android.content.Context; +import android.content.Intent; +import android.os.IBinder; +import android.util.Log; + +/** + * This service will allow the exception handler to post reports in the backgound, + * allowing the user to do what ever they want + * @author ricky barrette + */ +public class ReportPostingService extends Service { + + public static final int NOTIFICATION_ID = 1973646478; + private NotificationManager mNotificationManager; + private static final String TAG = "ReportPostingService"; + private int mStartId; + private Report mReport; + + /** + * Extracts the report object from the intent + * @param intent + * @author ricky barrette + */ + private void getReport(Intent intent) { + mReport = (Report) intent.getParcelableExtra("report"); + } + /** + * (non-Javadoc) + * @see android.app.Service#onBind(android.content.Intent) + */ + @Override + public IBinder onBind(Intent intent) { + // Unused + return null; + } + + /** + * Called when the service is being created + * Here we want to display a notifcation, + * to inform the user what we are doing. + * (non-Javadoc) + * @see android.app.Service#onCreate() + */ + @Override + public void onCreate() { + Context context = this.getApplicationContext(); + mNotificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); + Builder builder = new Notification.Builder(context) + .setContentTitle(getText(R.string.sending)) + .setContentText(getText(R.string.sending_report)) + .setTicker(getText(R.string.sending)) + .setOngoing(true) + .setSmallIcon(android.R.drawable.stat_sys_upload) + .setWhen(System.currentTimeMillis()); + mNotificationManager.notify(NOTIFICATION_ID, builder.getNotification()); + super.onCreate(); + } + + /** + * Called when the service is being destroyed + * Here we want to dismiss the notifications + * (non-Javadoc) + * @see android.app.Service#onDestroy() + */ + @Override + public void onDestroy() { + mNotificationManager.cancel(NOTIFICATION_ID); + super.onDestroy(); + } + + /** + * (non-Javadoc) + * @see android.app.Service#onStart(android.content.Intent, int) + */ + @Override + public void onStart(Intent intent, int startId) { + mStartId = startId; + getReport(intent); + postReport(); + super.onStart(intent, startId); + } + + /** + * (non-Javadoc) + * @see android.app.Service#onStartCommand(android.content.Intent, int, int) + */ + @Override + public int onStartCommand(Intent intent, int flags, int startId) { + mStartId = startId; + getReport(intent); + postReport(); + return super.onStartCommand(intent, Service.START_STICKY, startId); + } + + /** + * Posts a copy of the report to the report handing server + * @author ricky barrette + */ + private void postReport(){ + new Thread(new Runnable() { + @Override + public void run(){ + try { + Log.d(TAG, mReport.file()); + } catch (ClientProtocolException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + ReportPostingService.this.stopSelf(mStartId); + } + }).start(); + } +} diff --git a/ExceptionReportViewer/.gitignore b/ExceptionReportViewer/.gitignore new file mode 100644 index 0000000..a02fbbe --- /dev/null +++ b/ExceptionReportViewer/.gitignore @@ -0,0 +1,2 @@ +/gen +/bin diff --git a/ExceptionReportViewer/AndroidManifest.xml b/ExceptionReportViewer/AndroidManifest.xml index 5aed54e..70881ab 100644 --- a/ExceptionReportViewer/AndroidManifest.xml +++ b/ExceptionReportViewer/AndroidManifest.xml @@ -22,6 +22,12 @@ + + + \ No newline at end of file diff --git a/ExceptionReportViewer/assets/exceptionhandler.properties b/ExceptionReportViewer/assets/exceptionhandler.properties index 3d072f2..160b9d9 100644 --- a/ExceptionReportViewer/assets/exceptionhandler.properties +++ b/ExceptionReportViewer/assets/exceptionhandler.properties @@ -1,18 +1,21 @@ # exceptionhandler.properties -# This is the default Twenty Codes, LLC Exception Handler properties file -# -# @author Twenty Codes, LLC -# @author ricky barrette +# @author ricky barrette +# @author twenty codes - -# The following is for using our custom server based exception handler web application +# This file is used to tell the Exception Handler LIbrary how to file +# new exception reports # HTTP ONLY +# +# Place this file in you project's assets folder and edit as needed +# # server is the physical web address for your server # file is the path to your filing script # get is the path to your json retrieval script -server = http://powers.doesntexist.com:666/testing -file = /index.php?post=1 -#get = /index.php?get=1 +# app is the redmine project name +# tracker is the redmine tracker +server = http://rickbarrette.dyndns.org:8080/redmine/exceptionhandler +app = test +tracker = Bug # uncomment the following if you want your application to use email to file reports. # if this is uncommented, email will always be used. diff --git a/ExceptionReportViewer/bin/ExceptionReportViewer.apk b/ExceptionReportViewer/bin/ExceptionReportViewer.apk index 7ae3c26..9b73d2b 100644 Binary files a/ExceptionReportViewer/bin/ExceptionReportViewer.apk and b/ExceptionReportViewer/bin/ExceptionReportViewer.apk differ diff --git a/ExceptionReportViewer/bin/classes.dex b/ExceptionReportViewer/bin/classes.dex index 6c84bb1..3114ced 100644 Binary files a/ExceptionReportViewer/bin/classes.dex and b/ExceptionReportViewer/bin/classes.dex differ diff --git a/ExceptionReportViewer/bin/resources.ap_ b/ExceptionReportViewer/bin/resources.ap_ index cc7751f..3290e0a 100644 Binary files a/ExceptionReportViewer/bin/resources.ap_ and b/ExceptionReportViewer/bin/resources.ap_ differ diff --git a/ExceptionReportViewer/gen/com/TwentyCodes/android/ExceptionReportViewer/R.java b/ExceptionReportViewer/gen/com/TwentyCodes/android/ExceptionReportViewer/R.java index ca1806b..e08c6ea 100644 --- a/ExceptionReportViewer/gen/com/TwentyCodes/android/ExceptionReportViewer/R.java +++ b/ExceptionReportViewer/gen/com/TwentyCodes/android/ExceptionReportViewer/R.java @@ -184,14 +184,16 @@ or to a theme attribute in the form "?[package:][type:]na public static final int main=0x7f030004; } public static final class string { - public static final int app_name=0x7f040007; + public static final int app_name=0x7f040009; public static final int crash=0x7f040000; public static final int description=0x7f040004; - public static final int hello=0x7f040006; + public static final int hello=0x7f040008; + public static final int no_reports=0x7f040006; public static final int send=0x7f040003; public static final int sending=0x7f040002; + public static final int sending_report=0x7f040007; public static final int sorry=0x7f040001; - public static final int there_was_an_error=0x7f040008; + public static final int there_was_an_error=0x7f04000a; public static final int version=0x7f040005; } public static final class style { diff --git a/ExceptionReportViewer/gen/com/TwentyCodes/android/exception/R.java b/ExceptionReportViewer/gen/com/TwentyCodes/android/exception/R.java index ade2304..8eed0a7 100644 --- a/ExceptionReportViewer/gen/com/TwentyCodes/android/exception/R.java +++ b/ExceptionReportViewer/gen/com/TwentyCodes/android/exception/R.java @@ -184,14 +184,16 @@ or to a theme attribute in the form "?[package:][type:]na public static final int main=0x7f030004; } public static final class string { - public static final int app_name=0x7f040007; + public static final int app_name=0x7f040009; public static final int crash=0x7f040000; public static final int description=0x7f040004; - public static final int hello=0x7f040006; + public static final int hello=0x7f040008; + public static final int no_reports=0x7f040006; public static final int send=0x7f040003; public static final int sending=0x7f040002; + public static final int sending_report=0x7f040007; public static final int sorry=0x7f040001; - public static final int there_was_an_error=0x7f040008; + public static final int there_was_an_error=0x7f04000a; public static final int version=0x7f040005; } public static final class style { diff --git a/ExceptionReportViewer/src/com/TwentyCodes/android/ExceptionReportViewer/Main.java b/ExceptionReportViewer/src/com/TwentyCodes/android/ExceptionReportViewer/Main.java index 131fd24..0a10b62 100644 --- a/ExceptionReportViewer/src/com/TwentyCodes/android/ExceptionReportViewer/Main.java +++ b/ExceptionReportViewer/src/com/TwentyCodes/android/ExceptionReportViewer/Main.java @@ -37,6 +37,8 @@ public class Main extends FragmentActivity { Thread.setDefaultUncaughtExceptionHandler(new ExceptionHandler(this)); setContentView(R.layout.main); + Integer.parseInt("poop"); + ArrayList fragments = new ArrayList(); fragments.add(new ReportListFragment("http://powers.doesntexist.com:666/?get=1")); fragments.add(new ReportListFragment("http://powers.doesntexist.com:666/testing/?get=1"));