Cleaned up code
This commit is contained in:
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
<uses-sdk
|
<uses-sdk
|
||||||
android:minSdkVersion="8"
|
android:minSdkVersion="8"
|
||||||
android:targetSdkVersion="15" />
|
android:targetSdkVersion="16" />
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.INTERNET" />
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
|
|
||||||
|
|||||||
@@ -30,18 +30,20 @@ import android.util.Log;
|
|||||||
import anroid.v4.compat.NotificationCompat;
|
import anroid.v4.compat.NotificationCompat;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is Twenty Codes, LLC Exception Handler of Awesomeness!
|
* This is Twenty Codes, LLC Exception Handler of Awesomeness! This class will
|
||||||
* This class will be used to generate reports that will be emailed to us via the users email client after the users approval
|
* be used to generate reports that will be emailed to us via the users email
|
||||||
|
* client after the users approval
|
||||||
|
*
|
||||||
* @author ricky barrette
|
* @author ricky barrette
|
||||||
*/
|
*/
|
||||||
public class ExceptionHandler implements UncaughtExceptionHandler, Runnable {
|
public class ExceptionHandler implements UncaughtExceptionHandler, Runnable {
|
||||||
|
|
||||||
private static final String MSG_SUBJECT_TAG = "Exception Report";
|
private static final String MSG_SUBJECT_TAG = "Exception Report";
|
||||||
private static final String MSG_BODY = "Just click send to help make this application better. "+
|
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).";
|
+ "No personal information is being sent (you can check by reading the rest of the email).";
|
||||||
protected static final int SIMPLE_NOTFICATION_ID = 45684645;
|
protected static final int SIMPLE_NOTFICATION_ID = 45684645;
|
||||||
private final Thread.UncaughtExceptionHandler mDefaultUEH;
|
private final Thread.UncaughtExceptionHandler mDefaultUEH;
|
||||||
private Activity mApp= null;
|
private Activity mApp = null;
|
||||||
private Service mService = null;
|
private Service mService = null;
|
||||||
private BroadcastReceiver mBroadcastReceiver = null;
|
private BroadcastReceiver mBroadcastReceiver = null;
|
||||||
private final Context mContext;
|
private final Context mContext;
|
||||||
@@ -54,6 +56,7 @@ public class ExceptionHandler implements UncaughtExceptionHandler, Runnable {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new ExceptionHandler
|
* Creates a new ExceptionHandler
|
||||||
|
*
|
||||||
* @param app
|
* @param app
|
||||||
* @author ricky barrette
|
* @author ricky barrette
|
||||||
*/
|
*/
|
||||||
@@ -66,10 +69,11 @@ public class ExceptionHandler implements UncaughtExceptionHandler, Runnable {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new ExceptionHandler
|
* Creates a new ExceptionHandler
|
||||||
|
*
|
||||||
* @param broadcastReceiver
|
* @param broadcastReceiver
|
||||||
* @author ricky barrette
|
* @author ricky barrette
|
||||||
*/
|
*/
|
||||||
public ExceptionHandler(final BroadcastReceiver broadcastReceiver, final Context context){
|
public ExceptionHandler(final BroadcastReceiver broadcastReceiver, final Context context) {
|
||||||
mDefaultUEH = Thread.getDefaultUncaughtExceptionHandler();
|
mDefaultUEH = Thread.getDefaultUncaughtExceptionHandler();
|
||||||
mBroadcastReceiver = broadcastReceiver;
|
mBroadcastReceiver = broadcastReceiver;
|
||||||
mContext = context;
|
mContext = context;
|
||||||
@@ -78,10 +82,11 @@ public class ExceptionHandler implements UncaughtExceptionHandler, Runnable {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new ExceptionHandler
|
* Creates a new ExceptionHandler
|
||||||
|
*
|
||||||
* @param service
|
* @param service
|
||||||
* @author ricky barrette
|
* @author ricky barrette
|
||||||
*/
|
*/
|
||||||
public ExceptionHandler(final Service service){
|
public ExceptionHandler(final Service service) {
|
||||||
mDefaultUEH = Thread.getDefaultUncaughtExceptionHandler();
|
mDefaultUEH = Thread.getDefaultUncaughtExceptionHandler();
|
||||||
mService = service;
|
mService = service;
|
||||||
mContext = service;
|
mContext = service;
|
||||||
@@ -90,25 +95,26 @@ public class ExceptionHandler implements UncaughtExceptionHandler, Runnable {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates an email from the report
|
* Generates an email from the report
|
||||||
|
*
|
||||||
* @author ricky barrette
|
* @author ricky barrette
|
||||||
*/
|
*/
|
||||||
private void displayEmailNotification(){
|
private void displayEmailNotification() {
|
||||||
Log.i(TAG, "displayEmailNotification");
|
Log.i(TAG, "displayEmailNotification");
|
||||||
|
|
||||||
CharSequence title = null;
|
CharSequence title = null;
|
||||||
if(mApp != null)
|
if (mApp != null)
|
||||||
title = mApp.getTitle();
|
title = mApp.getTitle();
|
||||||
|
|
||||||
if(mService != null)
|
if (mService != null)
|
||||||
title = mService.getClass().getName();
|
title = mService.getClass().getName();
|
||||||
|
|
||||||
if(mBroadcastReceiver != null)
|
if (mBroadcastReceiver != null)
|
||||||
title = mBroadcastReceiver.getClass().getName();
|
title = mBroadcastReceiver.getClass().getName();
|
||||||
|
|
||||||
final Intent intent = new Intent(Intent.ACTION_SEND);
|
final Intent intent = new Intent(Intent.ACTION_SEND);
|
||||||
final String theSubject = title + " " + MSG_SUBJECT_TAG;
|
final String theSubject = title + " " + MSG_SUBJECT_TAG;
|
||||||
final String theBody = "\n\n"+MSG_BODY+mReport.toString();
|
final String theBody = "\n\n" + MSG_BODY + mReport.toString();
|
||||||
intent.putExtra(Intent.EXTRA_EMAIL,new String[] {mEmail});
|
intent.putExtra(Intent.EXTRA_EMAIL, new String[] { mEmail });
|
||||||
intent.putExtra(Intent.EXTRA_TEXT, theBody);
|
intent.putExtra(Intent.EXTRA_TEXT, theBody);
|
||||||
intent.putExtra(Intent.EXTRA_SUBJECT, theSubject);
|
intent.putExtra(Intent.EXTRA_SUBJECT, theSubject);
|
||||||
intent.setType("message/rfc822");
|
intent.setType("message/rfc822");
|
||||||
@@ -117,7 +123,9 @@ public class ExceptionHandler implements UncaughtExceptionHandler, Runnable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* displays an notification in the status bar, letting the user know that there was an issue
|
* displays an notification in the status bar, letting the user know that
|
||||||
|
* there was an issue
|
||||||
|
*
|
||||||
* @param generatedReportIntent
|
* @param generatedReportIntent
|
||||||
*/
|
*/
|
||||||
private void displayNotification(final Intent generatedReportIntent) {
|
private void displayNotification(final Intent generatedReportIntent) {
|
||||||
@@ -125,19 +133,16 @@ public class ExceptionHandler implements UncaughtExceptionHandler, Runnable {
|
|||||||
final Context context = mContext.getApplicationContext();
|
final Context context = mContext.getApplicationContext();
|
||||||
final NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
|
final NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||||
final PendingIntent intent = PendingIntent.getActivity(context, 0, generatedReportIntent, android.content.Intent.FLAG_ACTIVITY_NEW_TASK);
|
final PendingIntent intent = PendingIntent.getActivity(context, 0, generatedReportIntent, android.content.Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
final NotificationCompat.Builder builder = new NotificationCompat.Builder(context)
|
final NotificationCompat.Builder builder = new NotificationCompat.Builder(context).setContentTitle(context.getString(R.string.crash))
|
||||||
.setContentTitle(context.getString(R.string.crash))
|
.setContentText(context.getString(R.string.sorry)).setTicker(context.getString(R.string.crash)).setSmallIcon(android.R.drawable.stat_notify_error)
|
||||||
.setContentText(context.getString(R.string.sorry))
|
.setWhen(System.currentTimeMillis()).setAutoCancel(true).setContentIntent(intent);
|
||||||
.setTicker(context.getString(R.string.crash))
|
notificationManager.notify(SIMPLE_NOTFICATION_ID, builder.getNotification());
|
||||||
.setSmallIcon(android.R.drawable.stat_notify_error)
|
|
||||||
.setWhen(System.currentTimeMillis())
|
|
||||||
.setAutoCancel(true)
|
|
||||||
.setContentIntent(intent);
|
|
||||||
notificationManager.notify(SIMPLE_NOTFICATION_ID, builder.getNotification());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* parses in the exception handler options from the client application's assets folder. /assets/exceptionhandler.properties
|
* parses in the exception handler options from the client application's
|
||||||
|
* assets folder. /assets/exceptionhandler.properties
|
||||||
|
*
|
||||||
* @author ricky barrette
|
* @author ricky barrette
|
||||||
*/
|
*/
|
||||||
private void parseProperties() {
|
private void parseProperties() {
|
||||||
@@ -160,35 +165,36 @@ public class ExceptionHandler implements UncaughtExceptionHandler, Runnable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if(mEmail == null)
|
if (mEmail == null)
|
||||||
displayNotification(new Intent(mContext, ExceptionReportActivity.class).putExtra("report", mReport));
|
displayNotification(new Intent(mContext, ExceptionReportActivity.class).putExtra("report", mReport));
|
||||||
else
|
else
|
||||||
displayEmailNotification();
|
displayEmailNotification();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when there is an uncaught exception.
|
* Called when there is an uncaught exception. (non-Javadoc)
|
||||||
* (non-Javadoc)
|
*
|
||||||
* @see java.lang.Thread.UncaughtExceptionHandler#uncaughtException(java.lang.Thread, java.lang.Throwable)
|
* @see java.lang.Thread.UncaughtExceptionHandler#uncaughtException(java.lang.Thread,
|
||||||
|
* java.lang.Throwable)
|
||||||
* @author ricky barrette
|
* @author ricky barrette
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void uncaughtException(final Thread t, final Throwable e) {
|
public void uncaughtException(final Thread t, final Throwable e) {
|
||||||
Log.d(TAG, "uncaughtException()");
|
Log.d(TAG, "uncaughtException()");
|
||||||
|
|
||||||
// Log.d(TAG,"mURL = "+ this.mURL);
|
// Log.d(TAG,"mURL = "+ this.mURL);
|
||||||
// Log.d(TAG,"mEmail = "+ this.mEmail);
|
// Log.d(TAG,"mEmail = "+ this.mEmail);
|
||||||
|
|
||||||
final Date theDate = new Date();
|
final Date theDate = new Date();
|
||||||
final SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM.dd_HH.mm.ss_zzz");
|
final SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM.dd_HH.mm.ss_zzz");
|
||||||
final PackageManager pm = mContext.getPackageManager();
|
final PackageManager pm = mContext.getPackageManager();
|
||||||
|
|
||||||
//app environment;
|
// app environment;
|
||||||
PackageInfo pi;
|
PackageInfo pi;
|
||||||
try {
|
try {
|
||||||
pi = pm.getPackageInfo(mContext.getPackageName(), 0);
|
pi = pm.getPackageInfo(mContext.getPackageName(), 0);
|
||||||
} catch (final NameNotFoundException eNnf) {
|
} catch (final NameNotFoundException eNnf) {
|
||||||
//doubt this will ever run since we want info about our own package
|
// doubt this will ever run since we want info about our own package
|
||||||
pi = new PackageInfo();
|
pi = new PackageInfo();
|
||||||
pi.versionName = "unknown";
|
pi.versionName = "unknown";
|
||||||
pi.versionCode = 69;
|
pi.versionCode = 69;
|
||||||
@@ -196,37 +202,37 @@ public class ExceptionHandler implements UncaughtExceptionHandler, Runnable {
|
|||||||
|
|
||||||
final StringBuffer report = new StringBuffer();
|
final StringBuffer report = new StringBuffer();
|
||||||
for (final StackTraceElement item : e.getStackTrace())
|
for (final StackTraceElement item : e.getStackTrace())
|
||||||
report.append("at "+item.toString() + "\n");
|
report.append("at " + item.toString() + "\n");
|
||||||
|
|
||||||
final StringBuffer causereport = new StringBuffer();
|
final StringBuffer causereport = new StringBuffer();
|
||||||
final Throwable cause = e.getCause();
|
final Throwable cause = e.getCause();
|
||||||
if (cause != null) {
|
if (cause != null) {
|
||||||
causereport.append(cause.toString() + "\n \n");
|
causereport.append(cause.toString() + "\n \n");
|
||||||
for (final StackTraceElement item : cause.getStackTrace())
|
for (final StackTraceElement item : cause.getStackTrace())
|
||||||
causereport.append("at "+item.toString() + "\n");
|
causereport.append("at " + item.toString() + "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
//generate the report
|
// generate the report
|
||||||
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());
|
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)
|
// try to send file contents via email (need to do so via the UI thread)
|
||||||
if(mApp != null)
|
if (mApp != null)
|
||||||
mApp.runOnUiThread(this);
|
mApp.runOnUiThread(this);
|
||||||
|
|
||||||
|
if (mService != null)
|
||||||
if(mService != null)
|
if (mEmail == null)
|
||||||
if(mEmail == null)
|
|
||||||
displayNotification(new Intent(mContext, ExceptionReportActivity.class).putExtra("report", mReport));
|
displayNotification(new Intent(mContext, ExceptionReportActivity.class).putExtra("report", mReport));
|
||||||
else
|
else
|
||||||
displayEmailNotification();
|
displayEmailNotification();
|
||||||
|
|
||||||
if(mBroadcastReceiver != null)
|
if (mBroadcastReceiver != null)
|
||||||
if(mEmail == null)
|
if (mEmail == null)
|
||||||
displayNotification(new Intent(mContext, ExceptionReportActivity.class).putExtra("report", mReport));
|
displayNotification(new Intent(mContext, ExceptionReportActivity.class).putExtra("report", mReport));
|
||||||
else
|
else
|
||||||
displayEmailNotification();
|
displayEmailNotification();
|
||||||
|
|
||||||
//do not forget to pass this exception through up the chain
|
// do not forget to pass this exception through up the chain
|
||||||
mDefaultUEH.uncaughtException(t,e);
|
mDefaultUEH.uncaughtException(t, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -16,7 +16,9 @@ import android.widget.EditText;
|
|||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This activity will be used to present the user with the exception report, and allows them to send it, or not
|
* This activity will be used to present the user with the exception report, and
|
||||||
|
* allows them to send it, or not
|
||||||
|
*
|
||||||
* @author ricky barrette
|
* @author ricky barrette
|
||||||
*/
|
*/
|
||||||
public class ExceptionReportActivity extends Activity implements OnClickListener {
|
public class ExceptionReportActivity extends Activity implements OnClickListener {
|
||||||
@@ -26,6 +28,7 @@ public class ExceptionReportActivity extends Activity implements OnClickListener
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
* @see android.view.View.OnClickListener#onClick(android.view.View)
|
* @see android.view.View.OnClickListener#onClick(android.view.View)
|
||||||
* @author ricky barrette
|
* @author ricky barrette
|
||||||
*/
|
*/
|
||||||
@@ -40,6 +43,7 @@ public class ExceptionReportActivity extends Activity implements OnClickListener
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
* @see android.app.Activity#onCreate(android.os.Bundle)
|
* @see android.app.Activity#onCreate(android.os.Bundle)
|
||||||
* @author ricky barrette
|
* @author ricky barrette
|
||||||
*/
|
*/
|
||||||
@@ -49,7 +53,7 @@ public class ExceptionReportActivity extends Activity implements OnClickListener
|
|||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
mReport = (Report) getIntent().getParcelableExtra("report");
|
mReport = (Report) getIntent().getParcelableExtra("report");
|
||||||
|
|
||||||
if(getIntent().hasExtra("display"))
|
if (getIntent().hasExtra("display"))
|
||||||
this.setContentView(R.layout.list);
|
this.setContentView(R.layout.list);
|
||||||
else {
|
else {
|
||||||
this.setContentView(R.layout.exception_activity);
|
this.setContentView(R.layout.exception_activity);
|
||||||
|
|||||||
@@ -29,10 +29,12 @@ import android.os.Parcel;
|
|||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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
|
||||||
|
*
|
||||||
* @author ricky barrette
|
* @author ricky barrette
|
||||||
*/
|
*/
|
||||||
public class Report implements Parcelable{
|
public class Report implements Parcelable {
|
||||||
|
|
||||||
private final String mUrl;
|
private final String mUrl;
|
||||||
private ArrayList<ReportItem> mReport;
|
private ArrayList<ReportItem> mReport;
|
||||||
@@ -51,10 +53,11 @@ public class Report implements Parcelable{
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new Report
|
* Creates a new Report
|
||||||
|
*
|
||||||
* @param in
|
* @param in
|
||||||
* @author ricky barrette
|
* @author ricky barrette
|
||||||
*/
|
*/
|
||||||
public Report(final Parcel in){
|
public Report(final Parcel in) {
|
||||||
mUrl = in.readString();
|
mUrl = in.readString();
|
||||||
mReport = new ArrayList<ReportItem>();
|
mReport = new ArrayList<ReportItem>();
|
||||||
in.readTypedList(mReport, ReportItem.CREATOR);
|
in.readTypedList(mReport, ReportItem.CREATOR);
|
||||||
@@ -62,10 +65,11 @@ public class Report implements Parcelable{
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new Report
|
* Creates a new Report
|
||||||
|
*
|
||||||
* @author ricky barrette
|
* @author ricky barrette
|
||||||
*/
|
*/
|
||||||
public Report(final String url) {
|
public Report(final String url) {
|
||||||
// Log.d(TAG, url);
|
// Log.d(TAG, url);
|
||||||
mUrl = url;
|
mUrl = url;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -76,24 +80,25 @@ public class Report implements Parcelable{
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Files the report with the remote database
|
* Files the report with the remote database
|
||||||
|
*
|
||||||
* @author ricky barrette
|
* @author ricky barrette
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
* @throws ClientProtocolException
|
* @throws ClientProtocolException
|
||||||
* @return String result
|
* @return String result
|
||||||
*/
|
*/
|
||||||
public String file() throws ClientProtocolException, IOException{
|
public String file() throws ClientProtocolException, IOException {
|
||||||
final HttpClient httpclient = new DefaultHttpClient();
|
final HttpClient httpclient = new DefaultHttpClient();
|
||||||
final HttpPost httppost = new HttpPost(mUrl);
|
final HttpPost httppost = new HttpPost(mUrl);
|
||||||
httppost.setEntity(new UrlEncodedFormEntity(getNameValuePairs()));
|
httppost.setEntity(new UrlEncodedFormEntity(getNameValuePairs()));
|
||||||
//return the results
|
// return the results
|
||||||
final HttpResponse response = httpclient.execute(httppost);
|
final HttpResponse response = httpclient.execute(httppost);
|
||||||
final HttpEntity entity = response.getEntity();
|
final HttpEntity entity = response.getEntity();
|
||||||
final InputStream is = entity.getContent();
|
final InputStream is = entity.getContent();
|
||||||
|
|
||||||
final BufferedReader reader = new BufferedReader(new InputStreamReader(is,"iso-8859-1"),8);
|
final BufferedReader reader = new BufferedReader(new InputStreamReader(is, "iso-8859-1"), 8);
|
||||||
final StringBuilder sb = new StringBuilder();
|
final StringBuilder sb = new StringBuilder();
|
||||||
sb.append(reader.readLine() + "\n");
|
sb.append(reader.readLine() + "\n");
|
||||||
String line="0";
|
String line = "0";
|
||||||
while ((line = reader.readLine()) != null)
|
while ((line = reader.readLine()) != null)
|
||||||
sb.append(line + "\n");
|
sb.append(line + "\n");
|
||||||
is.close();
|
is.close();
|
||||||
@@ -103,24 +108,26 @@ public class Report implements Parcelable{
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates a report to be displayed form a downloaded JSON object
|
* Generates a report to be displayed form a downloaded JSON object
|
||||||
|
*
|
||||||
* @param report
|
* @param report
|
||||||
* @return
|
* @return
|
||||||
* @author ricky barrette
|
* @author ricky barrette
|
||||||
* @throws JSONException
|
* @throws JSONException
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
public Report generateReport(final JSONObject report) throws JSONException{
|
public Report generateReport(final JSONObject report) throws JSONException {
|
||||||
mReport = new ArrayList<ReportItem>();
|
mReport = new ArrayList<ReportItem>();
|
||||||
final Iterator iter = report.keys();
|
final Iterator iter = report.keys();
|
||||||
while(iter.hasNext()){
|
while (iter.hasNext()) {
|
||||||
final String key = (String)iter.next();
|
final String key = (String) iter.next();
|
||||||
mReport.add(new ReportItem(key , report.getString(key)));
|
mReport.add(new ReportItem(key, report.getString(key)));
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates a report to be sent.
|
* Generates a report to be sent.
|
||||||
|
*
|
||||||
* @param msg
|
* @param msg
|
||||||
* @param stackTrace
|
* @param stackTrace
|
||||||
* @param cause
|
* @param cause
|
||||||
@@ -130,28 +137,30 @@ public class Report implements Parcelable{
|
|||||||
* @return this
|
* @return this
|
||||||
* @author ricky barrette
|
* @author ricky barrette
|
||||||
*/
|
*/
|
||||||
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){
|
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<ReportItem>();
|
mReport = new ArrayList<ReportItem>();
|
||||||
mReport.add(new ReportItem("app",app));
|
mReport.add(new ReportItem("app", app));
|
||||||
mReport.add(new ReportItem("version",appVersion));
|
mReport.add(new ReportItem("version", appVersion));
|
||||||
mReport.add(new ReportItem("date",date));
|
mReport.add(new ReportItem("date", date));
|
||||||
mReport.add(new ReportItem("msg",msg));
|
mReport.add(new ReportItem("msg", msg));
|
||||||
mReport.add(new ReportItem("stackTrace",stackTrace));
|
mReport.add(new ReportItem("stackTrace", stackTrace));
|
||||||
mReport.add(new ReportItem("cause",cause));
|
mReport.add(new ReportItem("cause", cause));
|
||||||
mReport.add(new ReportItem("device",device));
|
mReport.add(new ReportItem("device", device));
|
||||||
mReport.add(new ReportItem("tracker",tracker));
|
mReport.add(new ReportItem("tracker", tracker));
|
||||||
mReport.add(new ReportItem("package",packageName));
|
mReport.add(new ReportItem("package", packageName));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extracts the name value pairs from the report bundle
|
* Extracts the name value pairs from the report bundle
|
||||||
|
*
|
||||||
* @return
|
* @return
|
||||||
* @author ricky barrette
|
* @author ricky barrette
|
||||||
*/
|
*/
|
||||||
private ArrayList<NameValuePair> getNameValuePairs() {
|
private ArrayList<NameValuePair> getNameValuePairs() {
|
||||||
final ArrayList<NameValuePair> list = new ArrayList<NameValuePair>();
|
final ArrayList<NameValuePair> list = new ArrayList<NameValuePair>();
|
||||||
for(final ReportItem entry : mReport)
|
for (final ReportItem entry : mReport)
|
||||||
list.add(new BasicNameValuePair(entry.getKey(), entry.getValue()));
|
list.add(new BasicNameValuePair(entry.getKey(), entry.getValue()));
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
@@ -160,12 +169,13 @@ public class Report implements Parcelable{
|
|||||||
* @return the generated exception report
|
* @return the generated exception report
|
||||||
* @author ricky barrette
|
* @author ricky barrette
|
||||||
*/
|
*/
|
||||||
public ArrayList<NameValuePair> getReport(){
|
public ArrayList<NameValuePair> getReport() {
|
||||||
return getNameValuePairs();
|
return getNameValuePairs();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the optional users description of what happened
|
* Sets the optional users description of what happened
|
||||||
|
*
|
||||||
* @param string
|
* @param string
|
||||||
* @author ricky barrette
|
* @author ricky barrette
|
||||||
*/
|
*/
|
||||||
@@ -179,11 +189,11 @@ public class Report implements Parcelable{
|
|||||||
* @author ricky barrette
|
* @author ricky barrette
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String toString(){
|
public String toString() {
|
||||||
final StringBuilder s = new StringBuilder();
|
final StringBuilder s = new StringBuilder();
|
||||||
for(final ReportItem item : mReport){
|
for (final ReportItem item : mReport) {
|
||||||
s.append("\n\n-----"+ item.getKey()+"-----");
|
s.append("\n\n-----" + item.getKey() + "-----");
|
||||||
s.append("\n"+item.getValue());
|
s.append("\n" + item.getValue());
|
||||||
}
|
}
|
||||||
return s.toString();
|
return s.toString();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,9 @@ import android.widget.BaseAdapter;
|
|||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class will be used to populate a custom Listview used to display the Generated exception report
|
* This class will be used to populate a custom Listview used to display the
|
||||||
|
* Generated exception report
|
||||||
|
*
|
||||||
* @author ricky barrette
|
* @author ricky barrette
|
||||||
*/
|
*/
|
||||||
public class ReportAdapter extends BaseAdapter {
|
public class ReportAdapter extends BaseAdapter {
|
||||||
@@ -27,12 +29,14 @@ public class ReportAdapter extends BaseAdapter {
|
|||||||
TextView title;
|
TextView title;
|
||||||
TextView body;
|
TextView body;
|
||||||
}
|
}
|
||||||
|
|
||||||
private final ArrayList<NameValuePair> mReport;
|
private final ArrayList<NameValuePair> mReport;
|
||||||
|
|
||||||
private final LayoutInflater mInflater;
|
private final LayoutInflater mInflater;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new ReportAdapter
|
* Creates a new ReportAdapter
|
||||||
|
*
|
||||||
* @author ricky barrette
|
* @author ricky barrette
|
||||||
*/
|
*/
|
||||||
public ReportAdapter(final Context context, final ArrayList<NameValuePair> report) {
|
public ReportAdapter(final Context context, final ArrayList<NameValuePair> report) {
|
||||||
@@ -44,6 +48,7 @@ public class ReportAdapter extends BaseAdapter {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
* @see android.widget.Adapter#getCount()
|
* @see android.widget.Adapter#getCount()
|
||||||
* @author ricky barrette
|
* @author ricky barrette
|
||||||
*/
|
*/
|
||||||
@@ -54,6 +59,7 @@ public class ReportAdapter extends BaseAdapter {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
* @see android.widget.Adapter#getItem(int)
|
* @see android.widget.Adapter#getItem(int)
|
||||||
* @author ricky barrette
|
* @author ricky barrette
|
||||||
*/
|
*/
|
||||||
@@ -64,6 +70,7 @@ public class ReportAdapter extends BaseAdapter {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
* @see android.widget.Adapter#getItemId(int)
|
* @see android.widget.Adapter#getItemId(int)
|
||||||
* @author ricky barrette
|
* @author ricky barrette
|
||||||
*/
|
*/
|
||||||
@@ -78,16 +85,20 @@ public class ReportAdapter extends BaseAdapter {
|
|||||||
@Override
|
@Override
|
||||||
public View getView(final int position, View convertView, final ViewGroup parent) {
|
public View getView(final int position, View convertView, final ViewGroup parent) {
|
||||||
|
|
||||||
// A ViewHolder keeps references to children views to avoid unnecessary calls to findViewById() on each row.
|
// A ViewHolder keeps references to children views to avoid unnecessary
|
||||||
|
// calls to findViewById() on each row.
|
||||||
ViewHolder holder;
|
ViewHolder holder;
|
||||||
|
|
||||||
// When convertView is not null, we can reuse it directly, there is no need
|
// When convertView is not null, we can reuse it directly, there is no
|
||||||
// to reinflate it. We only inflate a new View when the convertView supplied
|
// need
|
||||||
|
// to reinflate it. We only inflate a new View when the convertView
|
||||||
|
// supplied
|
||||||
// by ListView is null.
|
// by ListView is null.
|
||||||
if (convertView == null) {
|
if (convertView == null) {
|
||||||
convertView = mInflater.inflate(R.layout.exception_list_item, null);
|
convertView = mInflater.inflate(R.layout.exception_list_item, null);
|
||||||
|
|
||||||
// Creates a ViewHolder and store references to the two children views
|
// Creates a ViewHolder and store references to the two children
|
||||||
|
// views
|
||||||
// we want to bind data to.
|
// we want to bind data to.
|
||||||
holder = new ViewHolder();
|
holder = new ViewHolder();
|
||||||
holder.title = (TextView) convertView.findViewById(R.id.exception_title);
|
holder.title = (TextView) convertView.findViewById(R.id.exception_title);
|
||||||
|
|||||||
@@ -10,8 +10,10 @@ import android.os.Parcel;
|
|||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class will represent an individual report item. The ReportItems will be used in an array list that will be passed via intent.
|
* This class will represent an individual report item. The ReportItems will be
|
||||||
* This will allow for our report items to stay in the proper order.
|
* used in an array list that will be passed via intent. This will allow for our
|
||||||
|
* report items to stay in the proper order.
|
||||||
|
*
|
||||||
* @author ricky
|
* @author ricky
|
||||||
*/
|
*/
|
||||||
public final class ReportItem implements Parcelable {
|
public final class ReportItem implements Parcelable {
|
||||||
@@ -33,15 +35,17 @@ public final class ReportItem implements Parcelable {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new ReportItem from a parcel
|
* Creates a new ReportItem from a parcel
|
||||||
|
*
|
||||||
* @param in
|
* @param in
|
||||||
*/
|
*/
|
||||||
public ReportItem(final Parcel in){
|
public ReportItem(final Parcel in) {
|
||||||
mKey = in.readString();
|
mKey = in.readString();
|
||||||
mValue = in.readString();
|
mValue = in.readString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new ReportItem
|
* Creates a new ReportItem
|
||||||
|
*
|
||||||
* @author ricky barrette
|
* @author ricky barrette
|
||||||
*/
|
*/
|
||||||
public ReportItem(final String key, final String value) {
|
public ReportItem(final String key, final String value) {
|
||||||
@@ -49,7 +53,9 @@ public final class ReportItem implements Parcelable {
|
|||||||
mValue = value;
|
mValue = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
* @see android.os.Parcelable#describeContents()
|
* @see android.os.Parcelable#describeContents()
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@@ -72,7 +78,9 @@ public final class ReportItem implements Parcelable {
|
|||||||
return mValue;
|
return mValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
* @see android.os.Parcelable#writeToParcel(android.os.Parcel, int)
|
* @see android.os.Parcelable#writeToParcel(android.os.Parcel, int)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -21,8 +21,9 @@ import android.util.Log;
|
|||||||
import anroid.v4.compat.NotificationCompat;
|
import anroid.v4.compat.NotificationCompat;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This service will allow the exception handler to post reports in the backgound,
|
* This service will allow the exception handler to post reports in the
|
||||||
* allowing the user to do what ever they want
|
* backgound, allowing the user to do what ever they want
|
||||||
|
*
|
||||||
* @author ricky barrette
|
* @author ricky barrette
|
||||||
*/
|
*/
|
||||||
public class ReportPostingService extends Service {
|
public class ReportPostingService extends Service {
|
||||||
@@ -38,6 +39,7 @@ public class ReportPostingService extends Service {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Fires of a notification based upon api level
|
* Fires of a notification based upon api level
|
||||||
|
*
|
||||||
* @param title
|
* @param title
|
||||||
* @param contentText
|
* @param contentText
|
||||||
* @param ticker
|
* @param ticker
|
||||||
@@ -48,21 +50,17 @@ public class ReportPostingService extends Service {
|
|||||||
*/
|
*/
|
||||||
private void fireNotification(final String title, final String contentText, final String ticker, final int icon, final Intent intent, final 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;
|
PendingIntent pendingIntent = null;
|
||||||
if(intent != null)
|
if (intent != null)
|
||||||
pendingIntent = PendingIntent.getService(getApplicationContext(), 0, intent, 0);
|
pendingIntent = PendingIntent.getService(getApplicationContext(), 0, intent, 0);
|
||||||
|
|
||||||
final NotificationCompat.Builder builder = new NotificationCompat.Builder(getApplicationContext())
|
final NotificationCompat.Builder builder = new NotificationCompat.Builder(getApplicationContext()).setContentTitle(title).setContentText(contentText)
|
||||||
.setContentTitle(title)
|
.setTicker(ticker).setSmallIcon(icon).setWhen(System.currentTimeMillis());
|
||||||
.setContentText(contentText)
|
|
||||||
.setTicker(ticker)
|
if (isOngoing)
|
||||||
.setSmallIcon(icon)
|
|
||||||
.setWhen(System.currentTimeMillis());
|
|
||||||
|
|
||||||
if(isOngoing)
|
|
||||||
builder.setOngoing(true);
|
builder.setOngoing(true);
|
||||||
else
|
else
|
||||||
builder.setAutoCancel(true);
|
builder.setAutoCancel(true);
|
||||||
|
|
||||||
if (intent != null)
|
if (intent != null)
|
||||||
builder.setContentIntent(pendingIntent);
|
builder.setContentIntent(pendingIntent);
|
||||||
mNotificationManager.notify(NOTIFICATION_ID, builder.getNotification());
|
mNotificationManager.notify(NOTIFICATION_ID, builder.getNotification());
|
||||||
@@ -70,6 +68,7 @@ public class ReportPostingService extends Service {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Extracts the report object from the intent
|
* Extracts the report object from the intent
|
||||||
|
*
|
||||||
* @param intent
|
* @param intent
|
||||||
* @author ricky barrette
|
* @author ricky barrette
|
||||||
*/
|
*/
|
||||||
@@ -79,32 +78,26 @@ public class ReportPostingService extends Service {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* notifiys the user that we are sending a report
|
* notifiys the user that we are sending a report
|
||||||
|
*
|
||||||
* @author ricky barrette
|
* @author ricky barrette
|
||||||
*/
|
*/
|
||||||
private void notifyError() {
|
private void notifyError() {
|
||||||
fireNotification(getString(R.string.reporting_error),
|
fireNotification(getString(R.string.reporting_error), getString(R.string.reporting_error_msg), 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);
|
||||||
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
|
* notifiys the user that we are sending a report
|
||||||
|
*
|
||||||
* @author ricky barrette
|
* @author ricky barrette
|
||||||
*/
|
*/
|
||||||
private void notifySending() {
|
private void notifySending() {
|
||||||
fireNotification(getString(R.string.sending),
|
fireNotification(getString(R.string.sending), getString(R.string.sending_report), getString(R.string.sending), android.R.drawable.stat_sys_upload, null, true);
|
||||||
getString(R.string.sending_report),
|
|
||||||
getString(R.string.sending),
|
|
||||||
android.R.drawable.stat_sys_upload,
|
|
||||||
null,
|
|
||||||
true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
* @see android.app.Service#onBind(android.content.Intent)
|
* @see android.app.Service#onBind(android.content.Intent)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@@ -114,10 +107,9 @@ public class ReportPostingService extends Service {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when the service is being created
|
* Called when the service is being created Here we want to display a
|
||||||
* Here we want to display a notifcation,
|
* notifcation, to inform the user what we are doing. (non-Javadoc)
|
||||||
* to inform the user what we are doing.
|
*
|
||||||
* (non-Javadoc)
|
|
||||||
* @see android.app.Service#onCreate()
|
* @see android.app.Service#onCreate()
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@@ -128,10 +120,11 @@ public class ReportPostingService extends Service {
|
|||||||
notifySending();
|
notifySending();
|
||||||
super.onCreate();
|
super.onCreate();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when the service is being destroyed
|
* Called when the service is being destroyed Here we want to dismiss the
|
||||||
* Here we want to dismiss the notifications
|
* notifications (non-Javadoc)
|
||||||
* (non-Javadoc)
|
*
|
||||||
* @see android.app.Service#onDestroy()
|
* @see android.app.Service#onDestroy()
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@@ -144,6 +137,7 @@ public class ReportPostingService extends Service {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
* @see android.app.Service#onStart(android.content.Intent, int)
|
* @see android.app.Service#onStart(android.content.Intent, int)
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
@@ -158,6 +152,7 @@ public class ReportPostingService extends Service {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
* @see android.app.Service#onStartCommand(android.content.Intent, int, int)
|
* @see android.app.Service#onStartCommand(android.content.Intent, int, int)
|
||||||
*/
|
*/
|
||||||
@TargetApi(5)
|
@TargetApi(5)
|
||||||
@@ -172,14 +167,15 @@ public class ReportPostingService extends Service {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Posts a copy of the report to the report handing server
|
* Posts a copy of the report to the report handing server
|
||||||
|
*
|
||||||
* @author ricky barrette
|
* @author ricky barrette
|
||||||
*/
|
*/
|
||||||
private void postReport(){
|
private void postReport() {
|
||||||
if(!isStarted){
|
if (!isStarted) {
|
||||||
isStarted = true;
|
isStarted = true;
|
||||||
new Thread(new Runnable(){
|
new Thread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run(){
|
public void run() {
|
||||||
try {
|
try {
|
||||||
Log.d(TAG, mReport.file());
|
Log.d(TAG, mReport.file());
|
||||||
} catch (final ClientProtocolException e) {
|
} catch (final ClientProtocolException e) {
|
||||||
|
|||||||
@@ -20,7 +20,9 @@ import android.widget.LinearLayout;
|
|||||||
import android.widget.TextView;
|
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
|
* @author ricky barrette
|
||||||
*/
|
*/
|
||||||
public class VersionInformationPreference extends Preference {
|
public class VersionInformationPreference extends Preference {
|
||||||
@@ -29,6 +31,7 @@ public class VersionInformationPreference extends Preference {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* creates a preference that is nothing but a text view
|
* creates a preference that is nothing but a text view
|
||||||
|
*
|
||||||
* @param context
|
* @param context
|
||||||
*/
|
*/
|
||||||
public VersionInformationPreference(final Context context) {
|
public VersionInformationPreference(final Context context) {
|
||||||
@@ -38,6 +41,7 @@ public class VersionInformationPreference extends Preference {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* creates a preference that is nothing but a text view
|
* creates a preference that is nothing but a text view
|
||||||
|
*
|
||||||
* @param context
|
* @param context
|
||||||
* @param attrs
|
* @param attrs
|
||||||
*/
|
*/
|
||||||
@@ -48,6 +52,7 @@ public class VersionInformationPreference extends Preference {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* creates a preference that is nothing but a text view
|
* creates a preference that is nothing but a text view
|
||||||
|
*
|
||||||
* @param context
|
* @param context
|
||||||
* @param attrs
|
* @param attrs
|
||||||
* @param defStyle
|
* @param defStyle
|
||||||
@@ -57,17 +62,16 @@ public class VersionInformationPreference extends Preference {
|
|||||||
mContext = context;
|
mContext = context;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* creates a linear layout the contains only a textview.
|
* creates a linear layout the contains only a textview. (non-Javadoc)
|
||||||
* (non-Javadoc)
|
*
|
||||||
* @see android.preference.Preference#onCreateView(android.view.ViewGroup)
|
* @see android.preference.Preference#onCreateView(android.view.ViewGroup)
|
||||||
* @param parent
|
* @param parent
|
||||||
* @return
|
* @return
|
||||||
* @author ricky barrette
|
* @author ricky barrette
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected View onCreateView(final ViewGroup parent){
|
protected View onCreateView(final ViewGroup parent) {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* get the build information, and build the string
|
* get the build information, and build the string
|
||||||
@@ -77,29 +81,30 @@ public class VersionInformationPreference extends Preference {
|
|||||||
try {
|
try {
|
||||||
pi = pm.getPackageInfo(mContext.getPackageName(), 0);
|
pi = pm.getPackageInfo(mContext.getPackageName(), 0);
|
||||||
} catch (final NameNotFoundException eNnf) {
|
} catch (final NameNotFoundException eNnf) {
|
||||||
//doubt this will ever run since we want info about our own package
|
// doubt this will ever run since we want info about our own package
|
||||||
pi = new PackageInfo();
|
pi = new PackageInfo();
|
||||||
pi.versionName = "unknown";
|
pi.versionName = "unknown";
|
||||||
pi.versionCode = 1;
|
pi.versionCode = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* create a vertical linear layout that width and height that wraps content
|
* create a vertical linear layout that width and height that wraps
|
||||||
|
* content
|
||||||
*/
|
*/
|
||||||
final LinearLayout layout = new LinearLayout(getContext());
|
final LinearLayout layout = new LinearLayout(getContext());
|
||||||
final LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
|
final LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
|
||||||
// params.gravity = Gravity.CENTER;
|
// params.gravity = Gravity.CENTER;
|
||||||
layout.setPadding(15, 5, 10, 5);
|
layout.setPadding(15, 5, 10, 5);
|
||||||
layout.setOrientation(LinearLayout.VERTICAL);
|
layout.setOrientation(LinearLayout.VERTICAL);
|
||||||
|
|
||||||
layout.removeAllViews();
|
layout.removeAllViews();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* create a textview that will be used to display the application's name and build information
|
* create a textview that will be used to display the application's name
|
||||||
* and add it to the layout
|
* and build information and add it to the layout
|
||||||
*/
|
*/
|
||||||
final TextView title = new TextView(getContext());
|
final TextView title = new TextView(getContext());
|
||||||
title.setText(mContext.getString(R.string.version)+" "+pi.versionName+" bulid "+pi.versionCode);
|
title.setText(mContext.getString(R.string.version) + " " + pi.versionName + " bulid " + pi.versionCode);
|
||||||
title.setTextSize(16);
|
title.setTextSize(16);
|
||||||
title.setTypeface(Typeface.SANS_SERIF);
|
title.setTypeface(Typeface.SANS_SERIF);
|
||||||
title.setGravity(Gravity.LEFT);
|
title.setGravity(Gravity.LEFT);
|
||||||
|
|||||||
Reference in New Issue
Block a user