Skip to content

Commit

Permalink
Add custom intent to capture the page content to an offscreen buffer.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ariya Hidayat committed Oct 29, 2010
1 parent 2e9aa72 commit e10cab0
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions remotejs/src/android/src/com/sencha/remotejs/RemoteJS.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ of this software and associated documentation files (the "Software"), to deal

import android.app.Activity;
import android.content.Intent;
import android.graphics.*;
import android.os.Bundle;
import android.util.Log;
import android.webkit.*;
Expand Down Expand Up @@ -73,13 +74,22 @@ public boolean shouldOverrideUrlLoading(WebView view, String url) {
}
}

static final String ACTION_CAPTURE = "com.sencha.remotejs.ACTION_CAPTURE";

protected void onNewIntent(Intent intent) {
String base64 = intent.getDataString();
if (base64 != null) {
try {
String address = JSBase64.decode(base64);
mWebView.loadUrl(address);
} catch (ParseException e) {
if (ACTION_CAPTURE.equals(intent.getAction())) {
Picture picture = mWebView.capturePicture();
Bitmap buffer = Bitmap.createBitmap(picture.getWidth(), picture.getHeight(), Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(buffer);
canvas.drawPicture(picture);
} else {
String base64 = intent.getDataString();
if (base64 != null) {
try {
String address = JSBase64.decode(base64);
mWebView.loadUrl(address);
} catch (ParseException e) {
}
}
}
}
Expand Down

0 comments on commit e10cab0

Please sign in to comment.