diff --git a/ExceptionHandlerLib/.settings/org.eclipse.jdt.core.prefs b/ExceptionHandlerLib/.settings/org.eclipse.jdt.core.prefs
deleted file mode 100644
index 8000cd6..0000000
--- a/ExceptionHandlerLib/.settings/org.eclipse.jdt.core.prefs
+++ /dev/null
@@ -1,11 +0,0 @@
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
-org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
-org.eclipse.jdt.core.compiler.compliance=1.6
-org.eclipse.jdt.core.compiler.debug.lineNumber=generate
-org.eclipse.jdt.core.compiler.debug.localVariable=generate
-org.eclipse.jdt.core.compiler.debug.sourceFile=generate
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.source=1.6
diff --git a/ExceptionHandlerLib/AndroidManifest.xml b/ExceptionHandlerLib/AndroidManifest.xml
index 2ad6726..c02ac16 100644
--- a/ExceptionHandlerLib/AndroidManifest.xml
+++ b/ExceptionHandlerLib/AndroidManifest.xml
@@ -5,8 +5,8 @@
android:versionName="1.0" >
+ android:minSdkVersion="8"
+ android:targetSdkVersion="15" />
diff --git a/ExceptionHandlerLib/src/com/TwentyCodes/android/exception/ExceptionHandler.java b/ExceptionHandlerLib/src/com/TwentyCodes/android/exception/ExceptionHandler.java
index be540d8..206521c 100644
--- a/ExceptionHandlerLib/src/com/TwentyCodes/android/exception/ExceptionHandler.java
+++ b/ExceptionHandlerLib/src/com/TwentyCodes/android/exception/ExceptionHandler.java
@@ -35,84 +35,84 @@ import android.util.Log;
* @author ricky barrette
*/
public class ExceptionHandler implements UncaughtExceptionHandler, Runnable {
-
+
private static final String MSG_SUBJECT_TAG = "Exception Report";
private static final String MSG_BODY = "Just click send to help make this application better. "+
"No personal information is being sent (you can check by reading the rest of the email).";
protected static final int SIMPLE_NOTFICATION_ID = 45684645;
- private Thread.UncaughtExceptionHandler mDefaultUEH;
+ private final Thread.UncaughtExceptionHandler mDefaultUEH;
private Activity mApp= null;
private Service mService = null;
private BroadcastReceiver mBroadcastReceiver = null;
- private Context mContext;
+ private final Context mContext;
private Report mReport;
private static final String TAG = "ExceptionHandler";
private String mURL = null;
private String mEmail;
private String mAppName;
private String mTracker;
-
+
/**
* Creates a new ExceptionHandler
* @param app
* @author ricky barrette
*/
- public ExceptionHandler(Activity app) {
- this.mDefaultUEH = Thread.getDefaultUncaughtExceptionHandler();
- this.mApp = app;
- this.mContext = app;
- parseProperties();
- }
+ public ExceptionHandler(final Activity app) {
+ mDefaultUEH = Thread.getDefaultUncaughtExceptionHandler();
+ mApp = app;
+ mContext = app;
+ parseProperties();
+ }
/**
* Creates a new ExceptionHandler
* @param broadcastReceiver
* @author ricky barrette
*/
- public ExceptionHandler(BroadcastReceiver broadcastReceiver, Context context){
- this.mDefaultUEH = Thread.getDefaultUncaughtExceptionHandler();
- this.mBroadcastReceiver = broadcastReceiver;
- this.mContext = context;
+ public ExceptionHandler(final BroadcastReceiver broadcastReceiver, final Context context){
+ mDefaultUEH = Thread.getDefaultUncaughtExceptionHandler();
+ mBroadcastReceiver = broadcastReceiver;
+ mContext = context;
parseProperties();
}
-
+
/**
* Creates a new ExceptionHandler
* @param service
* @author ricky barrette
*/
- public ExceptionHandler(Service service){
- this.mDefaultUEH = Thread.getDefaultUncaughtExceptionHandler();
- this.mService = service;
- this.mContext = service;
+ public ExceptionHandler(final Service service){
+ mDefaultUEH = Thread.getDefaultUncaughtExceptionHandler();
+ mService = service;
+ mContext = service;
parseProperties();
}
-
+
/**
* Generates an email from the report
* @author ricky barrette
*/
private void displayEmailNotification(){
Log.i(TAG, "displayEmailNotification");
-
+
CharSequence title = null;
if(mApp != null)
title = mApp.getTitle();
-
+
if(mService != null)
title = mService.getClass().getName();
-
+
if(mBroadcastReceiver != null)
title = mBroadcastReceiver.getClass().getName();
-
- Intent intent = new Intent(Intent.ACTION_SEND);
- String theSubject = title + " " + MSG_SUBJECT_TAG;
- String theBody = "\n\n"+MSG_BODY+this.mReport.toString();
- intent.putExtra(Intent.EXTRA_EMAIL,new String[] {this.mEmail});
+
+ final Intent intent = new Intent(Intent.ACTION_SEND);
+ final String theSubject = title + " " + MSG_SUBJECT_TAG;
+ final String theBody = "\n\n"+MSG_BODY+mReport.toString();
+ intent.putExtra(Intent.EXTRA_EMAIL,new String[] {mEmail});
intent.putExtra(Intent.EXTRA_TEXT, theBody);
intent.putExtra(Intent.EXTRA_SUBJECT, theSubject);
intent.setType("message/rfc822");
-
+
displayNotification(intent);
}
@@ -121,12 +121,12 @@ public class ExceptionHandler implements UncaughtExceptionHandler, Runnable {
* @param generatedReportIntent
*/
@SuppressWarnings("deprecation")
- private void displayNotification(Intent generatedReportIntent) {
+ private void displayNotification(final Intent generatedReportIntent) {
Log.i(TAG, "displayNotification");
- Context context = mContext.getApplicationContext();
- NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
- Notification notifyDetails = new Notification(android.R.drawable.stat_notify_error, context.getString(R.string.sorry), System.currentTimeMillis());
- PendingIntent intent = PendingIntent.getActivity(context, 0, generatedReportIntent, android.content.Intent.FLAG_ACTIVITY_NEW_TASK);
+ final Context context = mContext.getApplicationContext();
+ final NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
+ final Notification notifyDetails = new Notification(android.R.drawable.stat_notify_error, context.getString(R.string.sorry), System.currentTimeMillis());
+ final PendingIntent intent = PendingIntent.getActivity(context, 0, generatedReportIntent, android.content.Intent.FLAG_ACTIVITY_NEW_TASK);
notifyDetails.setLatestEventInfo(context, context.getString(R.string.crash), context.getString(R.string.sorry), intent);
notifyDetails.flags |= Notification.FLAG_AUTO_CANCEL;
notificationManager.notify(SIMPLE_NOTFICATION_ID, notifyDetails);
@@ -137,30 +137,31 @@ public class ExceptionHandler implements UncaughtExceptionHandler, Runnable {
* @author ricky barrette
*/
private void parseProperties() {
- Resources resources = this.mContext.getResources();
- AssetManager assetManager = resources.getAssets();
+ final Resources resources = mContext.getResources();
+ final AssetManager assetManager = resources.getAssets();
// Read from the /assets directory
try {
- InputStream inputStream = assetManager.open("exceptionhandler.properties");
- Properties properties = new Properties();
- properties.load(inputStream);
- this.mURL = properties.getProperty("server");
- this.mEmail = properties.getProperty("email");
- this.mAppName = properties.getProperty("app");
- this.mTracker = properties.getProperty("tracker");
- } catch (IOException e) {
- Log.e(TAG, "Failed to open exceptionhandler.properties");
- e.printStackTrace();
+ final InputStream inputStream = assetManager.open("exceptionhandler.properties");
+ final Properties properties = new Properties();
+ properties.load(inputStream);
+ mURL = properties.getProperty("server");
+ mEmail = properties.getProperty("email");
+ mAppName = properties.getProperty("app");
+ mTracker = properties.getProperty("tracker");
+ } catch (final IOException e) {
+ Log.e(TAG, "Failed to open exceptionhandler.properties");
+ e.printStackTrace();
}
}
-
+
+ @Override
public void run() {
- if(this.mEmail == null)
- displayNotification(new Intent(this.mContext, ExceptionReportActivity.class).putExtra("report", this.mReport));
+ if(mEmail == null)
+ displayNotification(new Intent(mContext, ExceptionReportActivity.class).putExtra("report", mReport));
else
displayEmailNotification();
}
-
+
/**
* Called when there is an uncaught exception.
* (non-Javadoc)
@@ -168,62 +169,59 @@ public class ExceptionHandler implements UncaughtExceptionHandler, Runnable {
* @author ricky barrette
*/
@Override
- public void uncaughtException(Thread t, Throwable e) {
+ public void uncaughtException(final Thread t, final Throwable e) {
Log.d(TAG, "uncaughtException()");
-
-// Log.d(TAG,"mURL = "+ this.mURL);
-// Log.d(TAG,"mEmail = "+ this.mEmail);
- Date theDate = new Date();
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM.dd_HH.mm.ss_zzz");
- PackageManager pm = mContext.getPackageManager();
-
+ // Log.d(TAG,"mURL = "+ this.mURL);
+ // Log.d(TAG,"mEmail = "+ this.mEmail);
+
+ final Date theDate = new Date();
+ final SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM.dd_HH.mm.ss_zzz");
+ final PackageManager pm = mContext.getPackageManager();
+
//app environment;
PackageInfo pi;
try {
pi = pm.getPackageInfo(mContext.getPackageName(), 0);
- } catch (NameNotFoundException eNnf) {
+ } catch (final NameNotFoundException eNnf) {
//doubt this will ever run since we want info about our own package
pi = new PackageInfo();
pi.versionName = "unknown";
pi.versionCode = 69;
}
-
- StringBuffer report = new StringBuffer();
- for (StackTraceElement item : e.getStackTrace())
+
+ final StringBuffer report = new StringBuffer();
+ for (final StackTraceElement item : e.getStackTrace())
report.append("at "+item.toString() + "\n");
-
- StringBuffer causereport = new StringBuffer();
- Throwable cause = e.getCause();
+
+ final StringBuffer causereport = new StringBuffer();
+ final Throwable cause = e.getCause();
if (cause != null) {
causereport.append(cause.toString() + "\n \n");
- for (StackTraceElement item : cause.getStackTrace())
+ for (final StackTraceElement item : cause.getStackTrace())
causereport.append("at "+item.toString() + "\n");
}
-
+
//generate the report
- this.mReport = new Report(mURL).generateReport(e.toString(), report.toString(), causereport.toString(), sdf.format(theDate), Build.FINGERPRINT, pi.versionName+"b"+pi.versionCode, mAppName != null ? mAppName : mContext.getPackageName(), this.mTracker, mContext.getPackageName());
-
+ mReport = new Report(mURL).generateReport(e.toString(), report.toString(), causereport.toString(), sdf.format(theDate), Build.FINGERPRINT, pi.versionName+"b"+pi.versionCode, mAppName != null ? mAppName : mContext.getPackageName(), mTracker, mContext.getPackageName());
+
//try to send file contents via email (need to do so via the UI thread)
- if(this.mApp != null){
- this.mApp.runOnUiThread(this);
- }
-
-
- if(this.mService != null){
- if(this.mEmail == null)
- displayNotification(new Intent(this.mContext, ExceptionReportActivity.class).putExtra("report", this.mReport));
+ if(mApp != null)
+ mApp.runOnUiThread(this);
+
+
+ if(mService != null)
+ if(mEmail == null)
+ displayNotification(new Intent(mContext, ExceptionReportActivity.class).putExtra("report", mReport));
else
displayEmailNotification();
- }
-
- if(this.mBroadcastReceiver != null){
- if(this.mEmail == null)
- displayNotification(new Intent(this.mContext, ExceptionReportActivity.class).putExtra("report", this.mReport));
+
+ if(mBroadcastReceiver != null)
+ if(mEmail == null)
+ displayNotification(new Intent(mContext, ExceptionReportActivity.class).putExtra("report", mReport));
else
displayEmailNotification();
- }
-
+
//do not forget to pass this exception through up the chain
mDefaultUEH.uncaughtException(t,e);
}
diff --git a/ExceptionHandlerLib/src/com/TwentyCodes/android/exception/ExceptionReportActivity.java b/ExceptionHandlerLib/src/com/TwentyCodes/android/exception/ExceptionReportActivity.java
index 8c818d6..7d258b7 100644
--- a/ExceptionHandlerLib/src/com/TwentyCodes/android/exception/ExceptionReportActivity.java
+++ b/ExceptionHandlerLib/src/com/TwentyCodes/android/exception/ExceptionReportActivity.java
@@ -24,39 +24,39 @@ public class ExceptionReportActivity extends Activity implements OnClickListener
private static final String TAG = "ExceptionActivity";
private Report mReport;
- /**
- * (non-Javadoc)
- * @see android.app.Activity#onCreate(android.os.Bundle)
- * @author ricky barrette
- */
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- Log.d(TAG, "onCreate()");
- super.onCreate(savedInstanceState);
- this.mReport = (Report) this.getIntent().getParcelableExtra("report");
-
- if(this.getIntent().hasExtra("display"))
- this.setContentView(R.layout.list);
- else {
- this.setContentView(R.layout.exception_activity);
- this.findViewById(R.id.send).setOnClickListener(this);
- }
- ListView list = (ListView) this.findViewById(android.R.id.list);
- list.setAdapter(new ReportAdapter(this, this.mReport.getReport()));
- list.setClickable(false);
- }
-
/**
* (non-Javadoc)
* @see android.view.View.OnClickListener#onClick(android.view.View)
* @author ricky barrette
*/
@Override
- public void onClick(View v) {
- EditText description = (EditText) findViewById(R.id.description);
- this.mReport.setDescription(description.getText().toString());
+ public void onClick(final View v) {
+ final EditText description = (EditText) findViewById(R.id.description);
+ mReport.setDescription(description.getText().toString());
v.setEnabled(false);
- this.startService(new Intent(this, ReportPostingService.class).putExtra("report", this.mReport));
- this.finish();
+ startService(new Intent(this, ReportPostingService.class).putExtra("report", mReport));
+ finish();
+ }
+
+ /**
+ * (non-Javadoc)
+ * @see android.app.Activity#onCreate(android.os.Bundle)
+ * @author ricky barrette
+ */
+ @Override
+ protected void onCreate(final Bundle savedInstanceState) {
+ Log.d(TAG, "onCreate()");
+ super.onCreate(savedInstanceState);
+ mReport = (Report) getIntent().getParcelableExtra("report");
+
+ if(getIntent().hasExtra("display"))
+ this.setContentView(R.layout.list);
+ else {
+ this.setContentView(R.layout.exception_activity);
+ findViewById(R.id.send).setOnClickListener(this);
+ }
+ final ListView list = (ListView) findViewById(android.R.id.list);
+ list.setAdapter(new ReportAdapter(this, mReport.getReport()));
+ list.setClickable(false);
}
}
\ 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 6a880ed..8058cdb 100644
--- a/ExceptionHandlerLib/src/com/TwentyCodes/android/exception/Report.java
+++ b/ExceptionHandlerLib/src/com/TwentyCodes/android/exception/Report.java
@@ -36,13 +36,15 @@ public class Report implements Parcelable{
private final String mUrl;
private ArrayList mReport;
-
+
public static final Parcelable.Creator CREATOR = new Parcelable.Creator() {
- public Report createFromParcel(Parcel in) {
+ @Override
+ public Report createFromParcel(final Parcel in) {
return new Report(in);
}
-
- public Report[] newArray(int size) {
+
+ @Override
+ public Report[] newArray(final int size) {
return new Report[size];
}
};
@@ -52,71 +54,71 @@ public class Report implements Parcelable{
* @param in
* @author ricky barrette
*/
- public Report(Parcel in){
- this.mUrl = in.readString();
- this.mReport = new ArrayList();
- in.readTypedList(this.mReport, ReportItem.CREATOR);
+ public Report(final Parcel in){
+ mUrl = in.readString();
+ mReport = new ArrayList();
+ in.readTypedList(mReport, ReportItem.CREATOR);
}
-
+
/**
* Creates a new Report
* @author ricky barrette
*/
- public Report(String url) {
-// Log.d(TAG, url);
- this.mUrl = url;
+ public Report(final String url) {
+ // Log.d(TAG, url);
+ mUrl = url;
}
@Override
public int describeContents() {
return 0;
}
-
+
/**
* Files the report with the remote database
* @author ricky barrette
- * @throws IOException
- * @throws ClientProtocolException
+ * @throws IOException
+ * @throws ClientProtocolException
* @return String result
*/
public String file() throws ClientProtocolException, IOException{
- HttpClient httpclient = new DefaultHttpClient();
- HttpPost httppost = new HttpPost(mUrl);
+ final HttpClient httpclient = new DefaultHttpClient();
+ final HttpPost httppost = new HttpPost(mUrl);
httppost.setEntity(new UrlEncodedFormEntity(getNameValuePairs()));
//return the results
- HttpResponse response = httpclient.execute(httppost);
- HttpEntity entity = response.getEntity();
- InputStream is = entity.getContent();
-
- BufferedReader reader = new BufferedReader(new InputStreamReader(is,"iso-8859-1"),8);
- StringBuilder sb = new StringBuilder();
- sb.append(reader.readLine() + "\n");
- String line="0";
- while ((line = reader.readLine()) != null)
- sb.append(line + "\n");
- is.close();
- reader.close();
- return sb.toString();
+ final HttpResponse response = httpclient.execute(httppost);
+ final HttpEntity entity = response.getEntity();
+ final InputStream is = entity.getContent();
+
+ final BufferedReader reader = new BufferedReader(new InputStreamReader(is,"iso-8859-1"),8);
+ final StringBuilder sb = new StringBuilder();
+ sb.append(reader.readLine() + "\n");
+ String line="0";
+ while ((line = reader.readLine()) != null)
+ sb.append(line + "\n");
+ is.close();
+ reader.close();
+ return sb.toString();
}
-
+
/**
* Generates a report to be displayed form a downloaded JSON object
* @param report
* @return
* @author ricky barrette
- * @throws JSONException
+ * @throws JSONException
*/
@SuppressWarnings("rawtypes")
- public Report generateReport(JSONObject report) throws JSONException{
- this.mReport = new ArrayList();
- Iterator iter = report.keys();
- while(iter.hasNext()){
- String key = (String)iter.next();
- this.mReport.add(new ReportItem(key , report.getString(key)));
- }
+ public Report generateReport(final JSONObject report) throws JSONException{
+ mReport = new ArrayList();
+ final Iterator iter = report.keys();
+ while(iter.hasNext()){
+ final String key = (String)iter.next();
+ mReport.add(new ReportItem(key , report.getString(key)));
+ }
return this;
}
-
+
/**
* Generates a report to be sent.
* @param msg
@@ -128,17 +130,17 @@ public class Report implements Parcelable{
* @return this
* @author ricky barrette
*/
- public Report generateReport(String msg, String stackTrace, String cause, String date, String device, String appVersion, String app, String tracker, String packageName){
- this.mReport = new ArrayList();
- this.mReport.add(new ReportItem("app",app));
- this.mReport.add(new ReportItem("version",appVersion));
- this.mReport.add(new ReportItem("date",date));
- this.mReport.add(new ReportItem("msg",msg));
- this.mReport.add(new ReportItem("stackTrace",stackTrace));
- this.mReport.add(new ReportItem("cause",cause));
- this.mReport.add(new ReportItem("device",device));
- this.mReport.add(new ReportItem("tracker",tracker));
- this.mReport.add(new ReportItem("package",packageName));
+ public Report generateReport(final String msg, final String stackTrace, final String cause, final String date, final String device, final String appVersion, final String app, final String tracker, final String packageName){
+ mReport = new ArrayList();
+ mReport.add(new ReportItem("app",app));
+ mReport.add(new ReportItem("version",appVersion));
+ mReport.add(new ReportItem("date",date));
+ mReport.add(new ReportItem("msg",msg));
+ mReport.add(new ReportItem("stackTrace",stackTrace));
+ mReport.add(new ReportItem("cause",cause));
+ mReport.add(new ReportItem("device",device));
+ mReport.add(new ReportItem("tracker",tracker));
+ mReport.add(new ReportItem("package",packageName));
return this;
}
@@ -148,9 +150,9 @@ public class Report implements Parcelable{
* @author ricky barrette
*/
private ArrayList getNameValuePairs() {
- ArrayList list = new ArrayList();
- for(ReportItem entry : this.mReport)
- list.add(new BasicNameValuePair(entry.getKey(), (String) entry.getValue()));
+ final ArrayList list = new ArrayList();
+ for(final ReportItem entry : mReport)
+ list.add(new BasicNameValuePair(entry.getKey(), entry.getValue()));
return list;
}
@@ -167,8 +169,8 @@ public class Report implements Parcelable{
* @param string
* @author ricky barrette
*/
- public Report setDescription(String description) {
- this.mReport.add(new ReportItem("description", description));
+ public Report setDescription(final String description) {
+ mReport.add(new ReportItem("description", description));
return this;
}
@@ -178,17 +180,17 @@ public class Report implements Parcelable{
*/
@Override
public String toString(){
- StringBuilder s = new StringBuilder();
- for(ReportItem item : this.mReport){
+ final StringBuilder s = new StringBuilder();
+ for(final ReportItem item : mReport){
s.append("\n\n-----"+ item.getKey()+"-----");
s.append("\n"+item.getValue());
}
return s.toString();
}
-
+
@Override
- public void writeToParcel(Parcel out, int flags) {
- out.writeString(this.mUrl);
- out.writeTypedList(this.mReport);
+ public void writeToParcel(final Parcel out, final int flags) {
+ out.writeString(mUrl);
+ out.writeTypedList(mReport);
}
}
\ No newline at end of file
diff --git a/ExceptionHandlerLib/src/com/TwentyCodes/android/exception/ReportAdapter.java b/ExceptionHandlerLib/src/com/TwentyCodes/android/exception/ReportAdapter.java
index 1ec7cef..3b47083 100644
--- a/ExceptionHandlerLib/src/com/TwentyCodes/android/exception/ReportAdapter.java
+++ b/ExceptionHandlerLib/src/com/TwentyCodes/android/exception/ReportAdapter.java
@@ -17,26 +17,29 @@ import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
-import com.TwentyCodes.android.exception.R;
-
/**
* This class will be used to populate a custom Listview used to display the Generated exception report
* @author ricky barrette
*/
public class ReportAdapter extends BaseAdapter {
- private ArrayList mReport;
- private LayoutInflater mInflater;
+ class ViewHolder {
+ TextView title;
+ TextView body;
+ }
+ private final ArrayList mReport;
+
+ private final LayoutInflater mInflater;
/**
* Creates a new ReportAdapter
* @author ricky barrette
*/
- public ReportAdapter(Context context, ArrayList report) {
+ public ReportAdapter(final Context context, final ArrayList report) {
super();
// Cache the LayoutInflate to avoid asking for a new one each time.
- this.mInflater = LayoutInflater.from(context);
- this.mReport = report;
+ mInflater = LayoutInflater.from(context);
+ mReport = report;
}
/**
@@ -46,7 +49,7 @@ public class ReportAdapter extends BaseAdapter {
*/
@Override
public int getCount() {
- return this.mReport.size();
+ return mReport.size();
}
/**
@@ -55,8 +58,8 @@ public class ReportAdapter extends BaseAdapter {
* @author ricky barrette
*/
@Override
- public NameValuePair getItem(int index) {
- return this.mReport.get(index);
+ public NameValuePair getItem(final int index) {
+ return mReport.get(index);
}
/**
@@ -65,7 +68,7 @@ public class ReportAdapter extends BaseAdapter {
* @author ricky barrette
*/
@Override
- public long getItemId(int index) {
+ public long getItemId(final int index) {
return index;
}
@@ -73,40 +76,34 @@ public class ReportAdapter extends BaseAdapter {
*
*/
@Override
- public View getView(final int position, View convertView, ViewGroup parent) {
-
- // A ViewHolder keeps references to children views to avoid unnecessary calls to findViewById() on each row.
- ViewHolder holder;
+ public View getView(final int position, View convertView, final ViewGroup parent) {
- // When convertView is not null, we can reuse it directly, there is no need
- // to reinflate it. We only inflate a new View when the convertView supplied
- // by ListView is null.
- if (convertView == null) {
- convertView = mInflater.inflate(R.layout.exception_list_item, null);
+ // A ViewHolder keeps references to children views to avoid unnecessary calls to findViewById() on each row.
+ ViewHolder holder;
- // Creates a ViewHolder and store references to the two children views
- // we want to bind data to.
- holder = new ViewHolder();
- holder.title = (TextView) convertView.findViewById(R.id.exception_title);
- holder.body = (TextView) convertView.findViewById(R.id.exception_text);
+ // When convertView is not null, we can reuse it directly, there is no need
+ // to reinflate it. We only inflate a new View when the convertView supplied
+ // by ListView is null.
+ if (convertView == null) {
+ convertView = mInflater.inflate(R.layout.exception_list_item, null);
- convertView.setTag(holder);
- } else {
- holder = (ViewHolder) convertView.getTag();
- }
-
- /*
- * Bind the data efficiently with the holder.
- */
- holder.title.setText(getItem(position).getName());
- holder.body.setText(getItem(position).getValue());
-
- return convertView;
+ // Creates a ViewHolder and store references to the two children views
+ // we want to bind data to.
+ holder = new ViewHolder();
+ holder.title = (TextView) convertView.findViewById(R.id.exception_title);
+ holder.body = (TextView) convertView.findViewById(R.id.exception_text);
+
+ convertView.setTag(holder);
+ } else
+ holder = (ViewHolder) convertView.getTag();
+
+ /*
+ * Bind the data efficiently with the holder.
+ */
+ holder.title.setText(getItem(position).getName());
+ holder.body.setText(getItem(position).getValue());
+
+ return convertView;
}
-
- class ViewHolder {
- TextView title;
- TextView body;
- }
}
diff --git a/ExceptionHandlerLib/src/com/TwentyCodes/android/exception/ReportItem.java b/ExceptionHandlerLib/src/com/TwentyCodes/android/exception/ReportItem.java
index 71b3037..f1d573b 100644
--- a/ExceptionHandlerLib/src/com/TwentyCodes/android/exception/ReportItem.java
+++ b/ExceptionHandlerLib/src/com/TwentyCodes/android/exception/ReportItem.java
@@ -17,34 +17,36 @@ import android.os.Parcelable;
public final class ReportItem implements Parcelable {
public static final Parcelable.Creator CREATOR = new Parcelable.Creator() {
- public ReportItem createFromParcel(Parcel in) {
+ @Override
+ public ReportItem createFromParcel(final Parcel in) {
return new ReportItem(in);
}
-
- public ReportItem[] newArray(int size) {
+
+ @Override
+ public ReportItem[] newArray(final int size) {
return new ReportItem[size];
}
};
-
+
private final String mKey;
private final String mValue;
-
- /**
- * Creates a new ReportItem
- * @author ricky barrette
- */
- public ReportItem(String key, String value) {
- this.mKey = key;
- this.mValue = value;
- }
-
+
/**
* Creates a new ReportItem from a parcel
* @param in
*/
- public ReportItem(Parcel in){
- this.mKey = in.readString();
- this.mValue = in.readString();
+ public ReportItem(final Parcel in){
+ mKey = in.readString();
+ mValue = in.readString();
+ }
+
+ /**
+ * Creates a new ReportItem
+ * @author ricky barrette
+ */
+ public ReportItem(final String key, final String value) {
+ mKey = key;
+ mValue = value;
}
/* (non-Javadoc)
@@ -56,27 +58,27 @@ public final class ReportItem implements Parcelable {
return 0;
}
- /* (non-Javadoc)
- * @see android.os.Parcelable#writeToParcel(android.os.Parcel, int)
- */
- @Override
- public void writeToParcel(Parcel dest, int flags) {
- dest.writeString(this.mKey);
- dest.writeString(this.mValue);
- }
-
/**
* @return the key
*/
public String getKey() {
- return this.mKey;
+ return mKey;
}
/**
* @return the value
*/
public String getValue() {
- return this.mValue;
+ return mValue;
+ }
+
+ /* (non-Javadoc)
+ * @see android.os.Parcelable#writeToParcel(android.os.Parcel, int)
+ */
+ @Override
+ public void writeToParcel(final Parcel dest, final int flags) {
+ dest.writeString(mKey);
+ dest.writeString(mValue);
}
}
\ No newline at end of file
diff --git a/ExceptionHandlerLib/src/com/TwentyCodes/android/exception/ReportPostingService.java b/ExceptionHandlerLib/src/com/TwentyCodes/android/exception/ReportPostingService.java
index 2348096..2f9ebfe 100644
--- a/ExceptionHandlerLib/src/com/TwentyCodes/android/exception/ReportPostingService.java
+++ b/ExceptionHandlerLib/src/com/TwentyCodes/android/exception/ReportPostingService.java
@@ -28,7 +28,7 @@ import android.util.Log;
* @author ricky barrette
*/
public class ReportPostingService extends Service {
-
+
public static final int NOTIFICATION_ID = 1973646478;
private NotificationManager mNotificationManager;
private static final String TAG = "ReportPostingService";
@@ -50,20 +50,20 @@ public class ReportPostingService extends Service {
*/
@SuppressLint("NewApi")
@SuppressWarnings("deprecation")
- private void fireNotification(String title, String contentText, String ticker, int icon, Intent intent, boolean isOngoing) {
+ private void fireNotification(final String title, final String contentText, final String ticker, final int icon, final Intent intent, final boolean isOngoing) {
PendingIntent pendingIntent = null;
if(intent != null)
- pendingIntent = PendingIntent.getService(this.getApplicationContext(), 0, intent, 0);
+ pendingIntent = PendingIntent.getService(getApplicationContext(), 0, intent, 0);
/*
* Use the appropriate notificafation methods
*/
if(Integer.valueOf(android.os.Build.VERSION.SDK_INT) > 11){
- Builder builder = new Notification.Builder(this.getApplicationContext())
- .setContentTitle(title)
- .setContentText(contentText)
- .setTicker(ticker)
- .setSmallIcon(icon)
- .setWhen(System.currentTimeMillis());
+ final Builder builder = new Notification.Builder(getApplicationContext())
+ .setContentTitle(title)
+ .setContentText(contentText)
+ .setTicker(ticker)
+ .setSmallIcon(icon)
+ .setWhen(System.currentTimeMillis());
if(isOngoing)
builder.setOngoing(true);
else
@@ -72,22 +72,22 @@ public class ReportPostingService extends Service {
builder.setContentIntent(pendingIntent);
mNotificationManager.notify(NOTIFICATION_ID, builder.getNotification());
} else {
- Notification notification = new Notification(icon, title , System.currentTimeMillis());
+ final Notification notification = new Notification(icon, title , System.currentTimeMillis());
if(isOngoing)
notification.flags |= Notification.FLAG_ONGOING_EVENT;
else
notification.flags |= Notification.FLAG_AUTO_CANCEL;
- notification.setLatestEventInfo(this.getApplicationContext(), title, contentText, pendingIntent);
+ notification.setLatestEventInfo(getApplicationContext(), title, contentText, pendingIntent);
mNotificationManager.notify(NOTIFICATION_ID, notification);
}
}
-
+
/**
* Extracts the report object from the intent
* @param intent
* @author ricky barrette
*/
- private void getReport(Intent intent) {
+ private void getReport(final Intent intent) {
mReport = (Report) intent.getParcelableExtra("report");
}
@@ -96,26 +96,26 @@ public class ReportPostingService extends Service {
* @author ricky barrette
*/
private void notifyError() {
- fireNotification(getString(R.string.reporting_error),
- getString(R.string.reporting_error_msg),
- getString(R.string.reporting_error_msg),
- android.R.drawable.stat_notify_error,
- new Intent(this.getApplicationContext(), ReportPostingService.class).putExtras(mIntent),
+ fireNotification(getString(R.string.reporting_error),
+ getString(R.string.reporting_error_msg),
+ getString(R.string.reporting_error_msg),
+ android.R.drawable.stat_notify_error,
+ new Intent(getApplicationContext(), ReportPostingService.class).putExtras(mIntent),
false);
}
-
+
/**
* notifiys the user that we are sending a report
* @author ricky barrette
*/
private void notifySending() {
- fireNotification(getString(R.string.sending),
- getString(R.string.sending_report),
- getString(R.string.sending),
- android.R.drawable.stat_sys_upload,
- null,
+ fireNotification(getString(R.string.sending),
+ getString(R.string.sending_report),
+ getString(R.string.sending),
+ android.R.drawable.stat_sys_upload,
+ null,
true);
-
+
}
/**
@@ -123,11 +123,11 @@ public class ReportPostingService extends Service {
* @see android.app.Service#onBind(android.content.Intent)
*/
@Override
- public IBinder onBind(Intent intent) {
+ public IBinder onBind(final Intent intent) {
// Unused
return null;
}
-
+
/**
* Called when the service is being created
* Here we want to display a notifcation,
@@ -137,9 +137,9 @@ public class ReportPostingService extends Service {
*/
@Override
public void onCreate() {
- Context context = this.getApplicationContext();
+ final Context context = getApplicationContext();
mNotificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
-
+
notifySending();
super.onCreate();
}
@@ -163,7 +163,7 @@ public class ReportPostingService extends Service {
*/
@SuppressWarnings("deprecation")
@Override
- public void onStart(Intent intent, int startId) {
+ public void onStart(final Intent intent, final int startId) {
mStartId = startId;
getReport(intent);
postReport();
@@ -177,7 +177,7 @@ public class ReportPostingService extends Service {
*/
@TargetApi(5)
@Override
- public int onStartCommand(Intent intent, int flags, int startId) {
+ public int onStartCommand(final Intent intent, final int flags, final int startId) {
mStartId = startId;
getReport(intent);
postReport();
@@ -197,14 +197,14 @@ public class ReportPostingService extends Service {
public void run(){
try {
Log.d(TAG, mReport.file());
- } catch (ClientProtocolException e) {
+ } catch (final ClientProtocolException e) {
e.printStackTrace();
hasErrored = true;
- } catch (IOException e) {
+ } catch (final IOException e) {
e.printStackTrace();
hasErrored = true;
} finally {
- ReportPostingService.this.stopSelf(mStartId);
+ ReportPostingService.this.stopSelf(mStartId);
}
}
}).start();
diff --git a/ExceptionHandlerLib/src/com/TwentyCodes/android/exception/VersionInformationPreference.java b/ExceptionHandlerLib/src/com/TwentyCodes/android/exception/VersionInformationPreference.java
index 0765923..5f6197e 100644
--- a/ExceptionHandlerLib/src/com/TwentyCodes/android/exception/VersionInformationPreference.java
+++ b/ExceptionHandlerLib/src/com/TwentyCodes/android/exception/VersionInformationPreference.java
@@ -15,33 +15,34 @@ import android.util.AttributeSet;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
+import android.view.ViewGroup.LayoutParams;
import android.widget.LinearLayout;
import android.widget.TextView;
/**
- * this class will be a simple preference that contains only a text view that will display the application build information
+ * this class will be a simple preference that contains only a text view that will display the application build information
* @author ricky barrette
*/
public class VersionInformationPreference extends Preference {
- private Context mContext;
+ private final Context mContext;
/**
- * creates a preference that is nothing but a text view
+ * creates a preference that is nothing but a text view
* @param context
*/
- public VersionInformationPreference(Context context) {
+ public VersionInformationPreference(final Context context) {
super(context);
mContext = context;
}
-
+
/**
* creates a preference that is nothing but a text view
* @param context
* @param attrs
*/
- public VersionInformationPreference(Context context, AttributeSet attrs) {
+ public VersionInformationPreference(final Context context, final AttributeSet attrs) {
super(context, attrs);
mContext = context;
}
@@ -52,12 +53,12 @@ public class VersionInformationPreference extends Preference {
* @param attrs
* @param defStyle
*/
- public VersionInformationPreference(Context context, AttributeSet attrs, int defStyle) {
+ public VersionInformationPreference(final Context context, final AttributeSet attrs, final int defStyle) {
super(context, attrs, defStyle);
mContext = context;
}
-
+
/**
* creates a linear layout the contains only a textview.
* (non-Javadoc)
@@ -67,38 +68,38 @@ public class VersionInformationPreference extends Preference {
* @author ricky barrette
*/
@Override
- protected View onCreateView(ViewGroup parent){
-
+ protected View onCreateView(final ViewGroup parent){
+
/*
* get the build information, and build the string
*/
- PackageManager pm = mContext.getPackageManager();
+ final PackageManager pm = mContext.getPackageManager();
PackageInfo pi;
try {
pi = pm.getPackageInfo(mContext.getPackageName(), 0);
- } catch (NameNotFoundException eNnf) {
+ } catch (final NameNotFoundException eNnf) {
//doubt this will ever run since we want info about our own package
pi = new PackageInfo();
pi.versionName = "unknown";
pi.versionCode = 1;
}
-
+
/*
* create a vertical linear layout that width and height that wraps content
*/
- LinearLayout layout = new LinearLayout(getContext());
- LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
-// params.gravity = Gravity.CENTER;
+ final LinearLayout layout = new LinearLayout(getContext());
+ final LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
+ // params.gravity = Gravity.CENTER;
layout.setPadding(15, 5, 10, 5);
layout.setOrientation(LinearLayout.VERTICAL);
layout.removeAllViews();
-
+
/*
* create a textview that will be used to display the application's name and build information
* and add it to the layout
*/
- TextView title = new TextView(getContext());
+ final TextView title = new TextView(getContext());
title.setText(mContext.getString(R.string.version)+" "+pi.versionName+" bulid "+pi.versionCode);
title.setTextSize(16);
title.setTypeface(Typeface.SANS_SERIF);