remove todo
[pub/Android/ownCloud.git] / src / com / owncloud / android / ui / activity / ErrorReportActivity.java
1 /**
2 * ownCloud Android client application
3 *
4 * Copyright (C) 2015 ownCloud Inc.
5 *
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2,
8 * as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 *
18 */
19
20 package com.owncloud.android.ui.activity;
21
22 import android.content.Intent;
23 import android.os.AsyncTask;
24 import android.os.Bundle;
25 import android.support.v4.app.Fragment;
26 import android.support.v4.app.FragmentManager;
27 import android.support.v4.app.FragmentTransaction;
28 import android.support.v7.app.AppCompatActivity;
29 import android.view.MenuItem;
30 import android.view.View;
31 import android.view.View.OnClickListener;
32 import android.widget.Button;
33 import android.widget.TextView;
34
35 import com.owncloud.android.R;
36 import com.owncloud.android.lib.common.utils.Log_OC;
37 import com.owncloud.android.ui.dialog.LoadingDialog;
38 import com.owncloud.android.utils.FileStorageUtils;
39
40 import java.io.BufferedReader;
41 import java.io.File;
42 import java.io.FileReader;
43 import java.io.IOException;
44 import java.lang.ref.WeakReference;
45
46
47 public class ErrorReportActivity extends AppCompatActivity {
48
49 private static final String TAG = ErrorReportActivity.class.getSimpleName();
50
51 private String mLogText;
52
53 @Override
54 protected void onCreate(Bundle savedInstanceState) {
55 super.onCreate(savedInstanceState);
56
57 setContentView(R.layout.error_send);
58 setTitle(getString(R.string.error_log_title));
59 Button cancelErrorLogButton = (Button) findViewById(R.id.cancelErrorLogButton);
60 Button sendErrorLogButton = (Button) findViewById(R.id.sendErrorLogButton);
61 TextView logTV = (TextView) findViewById(R.id.logTV);
62
63 Intent intent = getIntent();
64 String action = intent.getAction();
65 String type = intent.getType();
66
67 if (Intent.ACTION_SEND.equals(action) && type != null) {
68 mLogText = intent.getStringExtra(Intent.EXTRA_TEXT);
69 } else {
70 // Handle other intents, such as being started from the home screen
71 mLogText = "Error, nothing received!";
72 }
73
74 logTV.setText(mLogText);
75
76 cancelErrorLogButton.setOnClickListener(new OnClickListener() {
77 @Override
78 public void onClick(View v) {
79 finishAffinity();
80
81 }
82 });
83
84 sendErrorLogButton.setOnClickListener(new OnClickListener() {
85
86 @Override
87 public void onClick(View v) {
88 sendMail();
89 }
90 });
91 }
92
93 /**
94 * Start activity for sending email with logs attached
95 */
96 private void sendMail() {
97 Intent sendIntent = new Intent();
98 sendIntent.setAction(Intent.ACTION_SEND);
99 sendIntent.putExtra(Intent.EXTRA_TEXT, mLogText);
100 sendIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
101 sendIntent.setType("text/plain");
102 startActivity(sendIntent);
103 }
104 }