Add ability to send a screenshot in a bug report.

This commit is contained in:
Jos van den Oever
2012-06-11 18:32:21 +02:00
parent 62a3b09ba9
commit 1cac66a9c5
3 changed files with 50 additions and 9 deletions
@@ -1,6 +1,14 @@
package org.webodf;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Picture;
import android.net.Uri;
import android.os.Bundle;
import android.view.Menu;
@@ -46,7 +54,7 @@ public class WebODFActivity extends DroidGap {
public boolean onOptionsItemSelected(MenuItem item) {
// Handle item selection
switch (item.getItemId()) {
case R.id.report_bug:
case R.id.report_issue:
reportIssue();
return true;
case R.id.about:
@@ -74,10 +82,43 @@ public class WebODFActivity extends DroidGap {
startActivity(i);
}
private void reportIssue() {
String url = "http://webodf.org/redmine/projects/webodf/issues";
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
startActivity(i);
private Uri takeScreenShot() {
Uri screenshoturi = null;
Picture screenshot = appView.capturePicture();
Bitmap bitmap = Bitmap.createBitmap(screenshot.getWidth(),
screenshot.getHeight(), Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
screenshot.draw(canvas);
screenshot = null;
String filename = "screenshot.png";
try {
FileOutputStream out = openFileOutput(filename,
Context.MODE_WORLD_READABLE);
bitmap.compress(Bitmap.CompressFormat.PNG, 90, out);
out.flush();
out.close();
// start path from /mnt/sdcard to make gmail mail client work
screenshoturi = Uri.fromFile(new File("/mnt/sdcard/../.."
+ getFilesDir() + "/" + filename));
} catch (IOException e) {
}
return screenshoturi;
}
private void reportIssue() {
Uri screenshoturi = takeScreenShot();
Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
String aEmailList[] = { "WebODF <kogmbh-android@kogmbh.com>",
"jos@vandenoever.info" };
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, aEmailList);
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,
"Issue report");
emailIntent.setType("image/png");
emailIntent.putExtra(Intent.EXTRA_STREAM, screenshoturi);
emailIntent.putExtra(Intent.EXTRA_TEXT, "My message body.");
startActivity(emailIntent);
}
}