summaryrefslogtreecommitdiffstats
path: root/src/com/android
diff options
context:
space:
mode:
authorBen Murdoch <benm@google.com>2010-06-29 20:34:10 +0100
committerBen Murdoch <benm@google.com>2010-06-30 10:36:48 +0100
commit87cc65d95c80c5e3a1c343ad5177a7dc2de874f6 (patch)
treed36a072ca04d67962cab5e35bfd1664c8312d996 /src/com/android
parentd19fb2b0d9f94f15f304b88db3ee07a4dacd6db2 (diff)
downloadpackages_apps_Browser-87cc65d95c80c5e3a1c343ad5177a7dc2de874f6.zip
packages_apps_Browser-87cc65d95c80c5e3a1c343ad5177a7dc2de874f6.tar.gz
packages_apps_Browser-87cc65d95c80c5e3a1c343ad5177a7dc2de874f6.tar.bz2
Make size of the webview screenshot configurable with width/height parameters.
Although not visible at the moment, this is to enable us to take full-res screenshots to use as splash screens for the Web App runtime. Change-Id: Ib4e0e704e437f1b339e3bd0a814383dd355b9e93
Diffstat (limited to 'src/com/android')
-rw-r--r--src/com/android/browser/BrowserActivity.java23
1 files changed, 12 insertions, 11 deletions
diff --git a/src/com/android/browser/BrowserActivity.java b/src/com/android/browser/BrowserActivity.java
index 92881dd..4562c86 100644
--- a/src/com/android/browser/BrowserActivity.java
+++ b/src/com/android/browser/BrowserActivity.java
@@ -1420,7 +1420,8 @@ public class BrowserActivity extends Activity
currentTab.populatePickerData();
sharePage(this, currentTab.getTitle(),
currentTab.getUrl(), currentTab.getFavicon(),
- createScreenshot(currentTab.getWebView()));
+ createScreenshot(currentTab.getWebView(), getDesiredThumbnailWidth(this),
+ getDesiredThumbnailHeight(this)));
break;
case R.id.dump_nav_menu_id:
@@ -1483,7 +1484,8 @@ public class BrowserActivity extends Activity
i.putExtra("url", w.getUrl());
i.putExtra("title", w.getTitle());
i.putExtra("touch_icon_url", w.getTouchIconUrl());
- i.putExtra("thumbnail", createScreenshot(w));
+ i.putExtra("thumbnail", createScreenshot(w, getDesiredThumbnailWidth(this),
+ getDesiredThumbnailHeight(this)));
startActivity(i);
}
@@ -2394,7 +2396,8 @@ public class BrowserActivity extends Activity
// draw, but the API for that (WebViewCore.pictureReady()) is not
// currently accessible here.
- final Bitmap bm = createScreenshot(view);
+ final Bitmap bm = createScreenshot(view, getDesiredThumbnailWidth(this),
+ getDesiredThumbnailHeight(this));
if (bm == null) {
return;
}
@@ -2470,13 +2473,12 @@ public class BrowserActivity extends Activity
return THUMBNAIL_HEIGHT;
}
- private Bitmap createScreenshot(WebView view) {
+ private Bitmap createScreenshot(WebView view, int width, int height) {
Picture thumbnail = view.capturePicture();
if (thumbnail == null) {
return null;
}
- Bitmap bm = Bitmap.createBitmap(getDesiredThumbnailWidth(this),
- getDesiredThumbnailHeight(this), Bitmap.Config.RGB_565);
+ Bitmap bm = Bitmap.createBitmap(width, height, Bitmap.Config.RGB_565);
Canvas canvas = new Canvas(bm);
// May need to tweak these values to determine what is the
// best scale factor
@@ -2485,8 +2487,7 @@ public class BrowserActivity extends Activity
float scaleFactorX = 1.0f;
float scaleFactorY = 1.0f;
if (thumbnailWidth > 0) {
- scaleFactorX = (float) getDesiredThumbnailWidth(this) /
- (float)thumbnailWidth;
+ scaleFactorX = (float) width / (float)thumbnailWidth;
} else {
return null;
}
@@ -2496,8 +2497,7 @@ public class BrowserActivity extends Activity
// If the device is in landscape and the page is shorter
// than the height of the view, stretch the thumbnail to fill the
// space.
- scaleFactorY = (float) getDesiredThumbnailHeight(this) /
- (float)thumbnailHeight;
+ scaleFactorY = (float) height / (float)thumbnailHeight;
} else {
// In the portrait case, this looks nice.
scaleFactorY = scaleFactorX;
@@ -3707,7 +3707,8 @@ public class BrowserActivity extends Activity
CombinedBookmarkHistoryActivity.class);
String title = current.getTitle();
String url = current.getUrl();
- Bitmap thumbnail = createScreenshot(current);
+ Bitmap thumbnail = createScreenshot(current, getDesiredThumbnailWidth(this),
+ getDesiredThumbnailHeight(this));
// Just in case the user opens bookmarks before a page finishes loading
// so the current history item, and therefore the page, is null.