am ae59c3f5: Stretch short landscape bookmark screenshots to fill the correct amount of space.
Merge commit 'ae59c3f5a5b492f91d72e1d26702a13b91a43fa4' into eclair-mr2-plus-aosp
* commit 'ae59c3f5a5b492f91d72e1d26702a13b91a43fa4':
Stretch short landscape bookmark screenshots to fill the correct amount of space.
diff --git a/src/com/android/browser/BrowserActivity.java b/src/com/android/browser/BrowserActivity.java
index 438b386..a167b09 100644
--- a/src/com/android/browser/BrowserActivity.java
+++ b/src/com/android/browser/BrowserActivity.java
@@ -2300,11 +2300,30 @@
// May need to tweak these values to determine what is the
// best scale factor
int thumbnailWidth = thumbnail.getWidth();
+ int thumbnailHeight = thumbnail.getHeight();
+ float scaleFactorX = 1.0f;
+ float scaleFactorY = 1.0f;
if (thumbnailWidth > 0) {
- float scaleFactor = (float) getDesiredThumbnailWidth(this) /
+ scaleFactorX = (float) getDesiredThumbnailWidth(this) /
(float)thumbnailWidth;
- canvas.scale(scaleFactor, scaleFactor);
+ } else {
+ return null;
}
+
+ if (view.getWidth() > view.getHeight() &&
+ thumbnailHeight < view.getHeight() && thumbnailHeight > 0) {
+ // 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;
+ } else {
+ // In the portrait case, this looks nice.
+ scaleFactorY = scaleFactorX;
+ }
+
+ canvas.scale(scaleFactorX, scaleFactorY);
+
thumbnail.draw(canvas);
return bm;
}