96331c2aa9a5d2e2a206d24daa1c2dc49efc1cf8
[pub/Android/ownCloud.git] / src / eu / alefzero / owncloud / CrashlogSendActivity.java
1 /* ownCloud Android client application
2 * Copyright (C) 2012 Bartek Przybylski
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 *
17 */
18
19 package eu.alefzero.owncloud;
20
21 import java.io.File;
22
23 import android.app.AlertDialog;
24 import android.app.Dialog;
25 import android.content.DialogInterface;
26 import android.content.DialogInterface.OnCancelListener;
27 import android.content.DialogInterface.OnClickListener;
28 import android.os.Bundle;
29 import android.util.Log;
30
31 import com.actionbarsherlock.app.SherlockActivity;
32
33 public class CrashlogSendActivity extends SherlockActivity implements OnClickListener, OnCancelListener {
34
35 private static final String TAG = "CrashlogSendActivity";
36 private static final int DIALOG_SUBMIT = 5;
37
38 private String mLogFilename;
39
40 @Override
41 protected void onCreate(Bundle savedInstanceState) {
42 super.onCreate(savedInstanceState);
43 mLogFilename = getIntent().getStringExtra(CrashHandler.KEY_CRASH_FILENAME);
44 if (mLogFilename == null) {
45 Log.wtf(TAG, "No file crashlog path given!");
46 finish();
47 return;
48 }
49 Log.i(TAG, "crashlog file path " + mLogFilename);
50
51 showDialog(DIALOG_SUBMIT);
52 }
53
54
55 @Override
56 protected Dialog onCreateDialog(int id) {
57 if (id == DIALOG_SUBMIT) {
58 AlertDialog.Builder builder = new AlertDialog.Builder(this);
59 builder.setMessage(R.string.crashlog_message);
60 builder.setNegativeButton(R.string.crashlog_dont_send_report, this);
61 builder.setPositiveButton(R.string.crashlog_send_report, this);
62 builder.setCancelable(true);
63 builder.setOnCancelListener(this);
64 return builder.create();
65 }
66 return super.onCreateDialog(id);
67 }
68
69
70 @Override
71 public void onClick(DialogInterface dialog, int which) {
72 new File(mLogFilename).delete();
73 finish();
74 }
75
76
77 @Override
78 public void onCancel(DialogInterface dialog) {
79 new File(mLogFilename).delete();
80 finish();
81 }
82
83 }