diff options
| author | Ben Murdoch <benm@google.com> | 2009-10-20 18:30:28 +0100 |
|---|---|---|
| committer | Ben Murdoch <benm@google.com> | 2009-10-27 12:26:28 +0000 |
| commit | ae59c3f5a5b492f91d72e1d26702a13b91a43fa4 (patch) | |
| tree | edd2bbd286100925144089460131e3e6547ed973 | |
| parent | 9e19e44f0b27f12cd07913548c23a885d822e716 (diff) | |
| download | packages_apps_Browser-ae59c3f5a5b492f91d72e1d26702a13b91a43fa4.tar.gz packages_apps_Browser-ae59c3f5a5b492f91d72e1d26702a13b91a43fa4.tar.bz2 packages_apps_Browser-ae59c3f5a5b492f91d72e1d26702a13b91a43fa4.zip | |
Stretch short landscape bookmark screenshots to fill the correct amount of space.
Change-Id: Iea18faab7ef08ace675e19c1047d15a39f12ec97
(cherry picked from commit 85b59baf17a443e6d89aed50d77149513ceb526c)
| -rw-r--r-- | src/com/android/browser/BrowserActivity.java | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/src/com/android/browser/BrowserActivity.java b/src/com/android/browser/BrowserActivity.java index 438b38687..a167b099d 100644 --- a/src/com/android/browser/BrowserActivity.java +++ b/src/com/android/browser/BrowserActivity.java @@ -2300,11 +2300,30 @@ public class BrowserActivity extends Activity // 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; } |
