|
9 | 9 | import android.app.Activity; |
10 | 10 | import android.app.PendingIntent; |
11 | 11 | import android.app.PendingIntent.CanceledException; |
| 12 | +import android.content.ClipData; |
| 13 | +import android.content.ClipboardManager; |
12 | 14 | import android.content.Context; |
13 | 15 | import android.content.Intent; |
14 | 16 | import android.graphics.drawable.GradientDrawable; |
@@ -140,44 +142,42 @@ static boolean hasIntent(Intent intent) |
140 | 142 | void buildUI() |
141 | 143 | { |
142 | 144 | Context context = activity; |
143 | | - |
| 145 | + Intent intent = activity.getIntent(); |
| 146 | + final String msg = intent.getStringExtra(EXTRA_ERROR_REPORT_MSG); |
| 147 | + |
| 148 | + //container |
144 | 149 | LinearLayout layout = new LinearLayout(context); |
145 | 150 | layout.setOrientation(LinearLayout.VERTICAL); |
146 | 151 | activity.setContentView(layout); |
147 | 152 |
|
| 153 | + //header |
148 | 154 | TextView txtHeader = new TextView(context); |
149 | | - txtHeader.setText("Callstack"); |
150 | | - |
151 | | - layout.addView(txtHeader); |
| 155 | + txtHeader.setText("Unhandled Exception"); |
152 | 156 |
|
153 | | - Intent intent = activity.getIntent(); |
154 | | - String msg = intent.getStringExtra(EXTRA_ERROR_REPORT_MSG); |
155 | | - |
| 157 | + //error + stacktrace |
156 | 158 | TextView txtErrorMsg = new TextView(context); |
157 | 159 | txtErrorMsg.setText(msg); |
158 | 160 | txtErrorMsg.setHeight(1000); |
159 | 161 | txtErrorMsg.setMovementMethod(new ScrollingMovementMethod()); |
160 | 162 |
|
161 | | - GradientDrawable gd = new GradientDrawable(); |
162 | | - gd.setColor(0xFFFFFFFF); |
163 | | - gd.setCornerRadius(5); |
164 | | - gd.setStroke(1, 0xFF000000); |
165 | | - txtErrorMsg.setBackground(gd); |
166 | | - |
167 | | - layout.addView(txtErrorMsg); |
168 | | - |
169 | | - Button btnClose = new Button(context); |
170 | | - btnClose.setText("Close"); |
171 | | - btnClose.setOnClickListener(new OnClickListener() |
| 163 | + // copy button |
| 164 | + Button copyToClipboard = new Button(context); |
| 165 | + copyToClipboard.setText("Copy to clipboard"); |
| 166 | + copyToClipboard.setOnClickListener(new OnClickListener() |
172 | 167 | { |
173 | 168 | @Override |
174 | 169 | public void onClick(View v) |
175 | 170 | { |
176 | | - activity.finish(); |
| 171 | + |
| 172 | + ClipboardManager clipboard = (ClipboardManager) activity.getSystemService(Context.CLIPBOARD_SERVICE); |
| 173 | + ClipData clip = ClipData.newPlainText("nsError", msg); |
| 174 | + clipboard.setPrimaryClip(clip); |
177 | 175 | } |
178 | 176 | }); |
179 | | - |
180 | | - layout.addView(btnClose); |
| 177 | + |
| 178 | + layout.addView(txtHeader); |
| 179 | + layout.addView(txtErrorMsg); |
| 180 | + layout.addView(copyToClipboard); |
181 | 181 | } |
182 | 182 |
|
183 | 183 | private static void createErrorFile(final Context context) |
|
0 commit comments