summaryrefslogtreecommitdiffstats
path: root/src/com
diff options
context:
space:
mode:
authorMark Wagner <mxw@google.com>2011-10-19 11:33:15 -0700
committerMark Wagner <mxw@google.com>2011-10-19 14:04:32 -0700
commitf9f24d4c578a01cb09a7e5c4c66b75595d3669ee (patch)
tree3810f06e24597959f7c77f5e3463bf928149a5bf /src/com
parent7b52266b6f9af570f1fdb200a1d0fa7947344e1a (diff)
downloadpackages_apps_LegacyCamera-f9f24d4c578a01cb09a7e5c4c66b75595d3669ee.zip
packages_apps_LegacyCamera-f9f24d4c578a01cb09a7e5c4c66b75595d3669ee.tar.gz
packages_apps_LegacyCamera-f9f24d4c578a01cb09a7e5c4c66b75595d3669ee.tar.bz2
bugfix 5479807 Video preview displaced to right when orientation changed
Three changes: (1) center the play button over the thumbnail (2) leverage the existing mechanism for scaling the image for video thumbnails which want to be 4/3 (3) use center_crop for video previews so that they properly align in the ui. Not doing so means we were getting black bars at the top and bottom which was wrong. Change-Id: Ifc416455d03136a393239487db07493dc27f151e
Diffstat (limited to 'src/com')
-rw-r--r--src/com/android/camera/ui/SharePopup.java43
1 files changed, 8 insertions, 35 deletions
diff --git a/src/com/android/camera/ui/SharePopup.java b/src/com/android/camera/ui/SharePopup.java
index 3917c54..de78f66 100644
--- a/src/com/android/camera/ui/SharePopup.java
+++ b/src/com/android/camera/ui/SharePopup.java
@@ -130,41 +130,6 @@ public class SharePopup extends PopupWindow implements View.OnClickListener,
// Show play button if this is a video thumbnail.
if (mMimeType.startsWith("video/")) {
sharePopup.findViewById(R.id.play).setVisibility(View.VISIBLE);
-
- // for some reason we want to show video thumbnail in a 4/3 ratio
- // crop the image here, for dispaly, as necessary
- final float targetRatio = 4F/3F;
- final float existingRatio = (float)mBitmapWidth / (float)mBitmapHeight;
-
- if (existingRatio > targetRatio) {
- int newWidth = (int) ((float)mBitmapHeight * targetRatio);
-
- // check if we end up with the same width due to rounding
- if (newWidth != mBitmapWidth) {
- bitmap = Bitmap.createBitmap(
- bitmap,
- (mBitmapWidth - newWidth) / 2,
- 0, // yCoord
- newWidth,
- mBitmapHeight,
- null,
- false);
- }
- } else if (existingRatio < targetRatio) {
- int newHeight = (int) ((float)mBitmapWidth * targetRatio);
-
- // check if we end up with the same width due to rounding
- if (newHeight != mBitmapHeight) {
- bitmap = Bitmap.createBitmap(
- bitmap,
- 0, // xCoord
- (mBitmapHeight - newHeight) / 2,
- mBitmapWidth,
- newHeight,
- null,
- false);
- }
- }
}
mBitmapWidth = bitmap.getWidth();
mBitmapHeight = bitmap.getHeight();
@@ -242,6 +207,14 @@ public class SharePopup extends PopupWindow implements View.OnClickListener,
}
float actualAspect = maxWidth / maxHeight;
float desiredAspect = (float) mBitmapWidth / mBitmapHeight;
+
+ if (mMimeType.startsWith("video/")) {
+ desiredAspect = 4F/3F;
+ mThumbnail.setScaleType(ImageView.ScaleType.CENTER_CROP);
+ } else {
+ mThumbnail.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
+ }
+
LayoutParams params = mThumbnail.getLayoutParams();
if (actualAspect > desiredAspect) {
params.width = Math.round(maxHeight * desiredAspect);