summaryrefslogtreecommitdiffstats
path: root/src/com/android/browser/Controller.java
diff options
context:
space:
mode:
authorJohn Reck <jreck@google.com>2010-11-16 17:09:37 -0800
committerJohn Reck <jreck@google.com>2010-11-17 13:43:37 -0800
commitfe49ab43d138ee52c04de77729870daf2a890c46 (patch)
treef45ca1dd8f429415bd80ce31a1e4e63f0a131254 /src/com/android/browser/Controller.java
parent8233facddcc51865d612a919d450db6954aa48e3 (diff)
downloadpackages_apps_browser-fe49ab43d138ee52c04de77729870daf2a890c46.zip
packages_apps_browser-fe49ab43d138ee52c04de77729870daf2a890c46.tar.gz
packages_apps_browser-fe49ab43d138ee52c04de77729870daf2a890c46.tar.bz2
Thumbnail asset and algorithm tweak
Bug: 3203597 This update replaces the preloaded thumbnails with the desktop versions of the sites rather than the mobile one. It also corrects the thumbnail generation behavior to prevent stretching. Change-Id: Ic122962496079d4ebf0111585bbcaadf47a06165
Diffstat (limited to 'src/com/android/browser/Controller.java')
-rw-r--r--src/com/android/browser/Controller.java18
1 files changed, 8 insertions, 10 deletions
diff --git a/src/com/android/browser/Controller.java b/src/com/android/browser/Controller.java
index 6b0ab0e..7d183f6 100644
--- a/src/com/android/browser/Controller.java
+++ b/src/com/android/browser/Controller.java
@@ -1776,25 +1776,23 @@ public class Controller
// best scale factor
int thumbnailWidth = thumbnail.getWidth();
int thumbnailHeight = thumbnail.getHeight();
- float scaleFactorX = 1.0f;
- float scaleFactorY = 1.0f;
+ float scaleFactor = 1.0f;
if (thumbnailWidth > 0) {
- scaleFactorX = (float) width / (float)thumbnailWidth;
+ scaleFactor = (float) width / (float)thumbnailWidth;
} 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) height / (float)thumbnailHeight;
- } else {
- // In the portrait case, this looks nice.
- scaleFactorY = scaleFactorX;
+ // than the height of the view, center the thumnail and crop the sides
+ scaleFactor = (float) height / (float)thumbnailHeight;
+ float wx = (thumbnailWidth * scaleFactor) - width;
+ canvas.translate((int) -(wx / 2), 0);
}
- canvas.scale(scaleFactorX, scaleFactorY);
+ canvas.scale(scaleFactor, scaleFactor);
thumbnail.draw(canvas);
return bm;