Merge branch 'report-posting-service'

Conflicts:
	ExceptionHandlerLib/bin/exceptionhandlerlib.jar
This commit is contained in:
2012-02-29 13:09:26 -05:00
16 changed files with 173 additions and 40 deletions

View File

@@ -27,6 +27,7 @@ public final class R {
public static int no_reports=0x7f030006; public static int no_reports=0x7f030006;
public static int send=0x7f030003; public static int send=0x7f030003;
public static int sending=0x7f030002; public static int sending=0x7f030002;
public static int sending_report=0x7f030007;
public static int sorry=0x7f030001; public static int sorry=0x7f030001;
public static int version=0x7f030005; public static int version=0x7f030005;
} }

View File

@@ -8,5 +8,6 @@
<string name="description">Optional: Describe what happened</string> <string name="description">Optional: Describe what happened</string>
<string name="version">Version</string> <string name="version">Version</string>
<string name="no_reports">No Reports</string> <string name="no_reports">No Reports</string>
<string name="sending_report">Sending Exception Report</string>
</resources> </resources>

View File

@@ -143,7 +143,7 @@ public class ExceptionHandler implements UncaughtExceptionHandler, Runnable {
InputStream inputStream = assetManager.open("exceptionhandler.properties"); InputStream inputStream = assetManager.open("exceptionhandler.properties");
Properties properties = new Properties(); Properties properties = new Properties();
properties.load(inputStream); properties.load(inputStream);
this.mURL = properties.getProperty("server") + properties.getProperty("file"); this.mURL = properties.getProperty("server");
this.mEmail = properties.getProperty("email"); this.mEmail = properties.getProperty("email");
this.mAppName = properties.getProperty("app"); this.mAppName = properties.getProperty("app");
this.mTracker = properties.getProperty("tracker"); this.mTracker = properties.getProperty("tracker");

View File

@@ -6,14 +6,9 @@
*/ */
package com.TwentyCodes.android.exception; package com.TwentyCodes.android.exception;
import java.io.IOException;
import org.apache.http.client.ClientProtocolException;
import android.app.Activity; import android.app.Activity;
import android.app.ProgressDialog; import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.os.Looper;
import android.util.Log; import android.util.Log;
import android.view.View; import android.view.View;
import android.view.View.OnClickListener; import android.view.View.OnClickListener;
@@ -61,21 +56,7 @@ public class ExceptionReportActivity extends Activity implements OnClickListener
EditText description = (EditText) findViewById(R.id.description); EditText description = (EditText) findViewById(R.id.description);
this.mReport.setDescription(description.getText().toString()); this.mReport.setDescription(description.getText().toString());
v.setEnabled(false); v.setEnabled(false);
final ProgressDialog progress = ProgressDialog.show(this, "", getString(R.string.sending), true, true); this.startService(new Intent(this, ReportPostingService.class).putExtra("report", this.mReport));
new Thread( new Runnable(){ this.finish();
@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();
} }
} }

View File

@@ -27,6 +27,7 @@ import org.json.JSONObject;
import android.os.Parcel; import android.os.Parcel;
import android.os.Parcelable; 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 * 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{ public class Report implements Parcelable{
private static final String TAG = "Report";
private final String mUrl; private final String mUrl;
private ArrayList<ReportItem> mReport; private ArrayList<ReportItem> mReport;
@@ -62,8 +64,9 @@ public class Report implements Parcelable{
* Creates a new Report * Creates a new Report
* @author ricky barrette * @author ricky barrette
*/ */
public Report(String mysqlUrl) { public Report(String url) {
this.mUrl = mysqlUrl; Log.d(TAG, url);
this.mUrl = url;
} }
@Override @Override

View File

@@ -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();
}
}

2
ExceptionReportViewer/.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
/gen
/bin

View File

@@ -22,6 +22,12 @@
</activity> </activity>
<activity android:name="com.TwentyCodes.android.exception.ExceptionReportActivity" > <activity android:name="com.TwentyCodes.android.exception.ExceptionReportActivity" >
</activity> </activity>
<service
android:name="com.TwentyCodes.android.exception.ReportPostingService"
android:enabled="true"
android:process=":ExceptionReportingService" >
</service>
</application> </application>
</manifest> </manifest>

View File

@@ -1,18 +1,21 @@
# exceptionhandler.properties # exceptionhandler.properties
# This is the default Twenty Codes, LLC Exception Handler properties file # @author ricky barrette <rickbarrette@gmail.com>
# # @author twenty codes <twentycodes@gmail.com>
# @author Twenty Codes, LLC
# @author ricky barrette
# This file is used to tell the Exception Handler LIbrary how to file
# The following is for using our custom server based exception handler web application # new exception reports
# HTTP ONLY # HTTP ONLY
#
# Place this file in you project's assets folder and edit as needed
#
# server is the physical web address for your server # server is the physical web address for your server
# file is the path to your filing script # file is the path to your filing script
# get is the path to your json retrieval script # get is the path to your json retrieval script
server = http://powers.doesntexist.com:666/testing # app is the redmine project name
file = /index.php?post=1 # tracker is the redmine tracker
#get = /index.php?get=1 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. # uncomment the following if you want your application to use email to file reports.
# if this is uncommented, email will always be used. # if this is uncommented, email will always be used.

View File

@@ -184,14 +184,16 @@ or to a theme attribute in the form "<code>?[<i>package</i>:][<i>type</i>:]<i>na
public static final int main=0x7f030004; public static final int main=0x7f030004;
} }
public static final class string { 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 crash=0x7f040000;
public static final int description=0x7f040004; 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 send=0x7f040003;
public static final int sending=0x7f040002; public static final int sending=0x7f040002;
public static final int sending_report=0x7f040007;
public static final int sorry=0x7f040001; 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 int version=0x7f040005;
} }
public static final class style { public static final class style {

View File

@@ -184,14 +184,16 @@ or to a theme attribute in the form "<code>?[<i>package</i>:][<i>type</i>:]<i>na
public static final int main=0x7f030004; public static final int main=0x7f030004;
} }
public static final class string { 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 crash=0x7f040000;
public static final int description=0x7f040004; 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 send=0x7f040003;
public static final int sending=0x7f040002; public static final int sending=0x7f040002;
public static final int sending_report=0x7f040007;
public static final int sorry=0x7f040001; 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 int version=0x7f040005;
} }
public static final class style { public static final class style {

View File

@@ -37,6 +37,8 @@ public class Main extends FragmentActivity {
Thread.setDefaultUncaughtExceptionHandler(new ExceptionHandler(this)); Thread.setDefaultUncaughtExceptionHandler(new ExceptionHandler(this));
setContentView(R.layout.main); setContentView(R.layout.main);
Integer.parseInt("poop");
ArrayList<Fragment> fragments = new ArrayList<Fragment>(); ArrayList<Fragment> fragments = new ArrayList<Fragment>();
fragments.add(new ReportListFragment("http://powers.doesntexist.com:666/?get=1")); fragments.add(new ReportListFragment("http://powers.doesntexist.com:666/?get=1"));
fragments.add(new ReportListFragment("http://powers.doesntexist.com:666/testing/?get=1")); fragments.add(new ReportListFragment("http://powers.doesntexist.com:666/testing/?get=1"));