From 23160ebbe2b5ec32d0e96d617b06398982835575 Mon Sep 17 00:00:00 2001 From: yuta Date: Wed, 6 Apr 2011 18:55:29 +0900 Subject: [PATCH] =?utf8?q?=E4=BF=AE=E6=AD=A3:=E3=82=A8=E3=83=A9=E3=83=BC?= =?utf8?q?=E5=A0=B1=E5=91=8A=E3=81=AE=E4=BB=95=E6=A7=98=E3=82=92=E5=A4=89?= =?utf8?q?=E6=9B=B42?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/jp/gr/java_conf/ofnhwx/olib/ErrorReporter.java | 32 ++++++++++++++-------- 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/src/jp/gr/java_conf/ofnhwx/olib/ErrorReporter.java b/src/jp/gr/java_conf/ofnhwx/olib/ErrorReporter.java index 2d64082..d8553ff 100644 --- a/src/jp/gr/java_conf/ofnhwx/olib/ErrorReporter.java +++ b/src/jp/gr/java_conf/ofnhwx/olib/ErrorReporter.java @@ -58,18 +58,25 @@ public final class ErrorReporter implements UncaughtExceptionHandler { Thread.setDefaultUncaughtExceptionHandler(new ErrorReporter()); } /** + * エラー報告の確認を行うダイアログを表示する. + * @param activity + * @param dialogId + */ + public static final void show(final Activity activity, final int dialogId) { + final File errorFile = activity.getFileStreamPath(ERROR_FILE); + if (!errorFile.exists()) { + return; + } + activity.showDialog(dialogId); + } + /** * エラー報告の確認を行うダイアログを取得する. * @param activity * @param icon * @return */ - public static final AlertDialog getConfirmDialog(final Activity activity, final int icon) { - // ファイルがない場合は'null'を返す + public static final AlertDialog getDialog(final Activity activity, final int icon) { final File errorFile = activity.getFileStreamPath(ERROR_FILE); - if (!errorFile.exists()) { - return null; - } - // ダイアログを作成して返す final AlertDialog.Builder dialog = new AlertDialog.Builder(activity); dialog.setIcon(new BitmapDrawable(OBitmapUtils.decodeResource(activity, icon, 48.0f))); dialog.setTitle(R.string.bug_report_title); @@ -78,10 +85,11 @@ public final class ErrorReporter implements UncaughtExceptionHandler { @Override public void onClick(DialogInterface dialog, int which) { try { - sendBugreport(mContext, errorFile); + sendBugreport(activity, errorFile); } catch (IOException e) { e.printStackTrace(); } + dialog.dismiss(); } }); dialog.setNegativeButton(R.string.bug_report_negative, new OnClickListener() { @@ -100,13 +108,13 @@ public final class ErrorReporter implements UncaughtExceptionHandler { } /** * エラー報告の送信 - * @param context + * @param activity * @param errorFile * @throws IOException */ - private static final void sendBugreport(final Context context, final File errorFile) throws IOException { + private static final void sendBugreport(final Activity activity, final File errorFile) throws IOException { // バグ報告ファイルをリネーム - final File reportFile = context.getFileStreamPath(REPORT_FILE); + final File reportFile = activity.getFileStreamPath(REPORT_FILE); if (!errorFile.exists() || !errorFile.renameTo(reportFile)) { return; } @@ -137,11 +145,11 @@ public final class ErrorReporter implements UncaughtExceptionHandler { reportFile.delete(); } // メールの送信 - final Uri uri = Uri.parse(context.getString(R.string.mail_to)); + final Uri uri = Uri.parse(activity.getString(R.string.mail_to)); final Intent intent = new Intent(Intent.ACTION_SENDTO, uri); intent.putExtra(Intent.EXTRA_SUBJECT, subject); intent.putExtra(Intent.EXTRA_TEXT , body.toString()); - context.startActivity(intent); + activity.startActivity(intent); } @Override public void uncaughtException(Thread thread, Throwable error) { -- 2.11.4.GIT