diff options
author | Mark Wagner <mxw@google.com> | 2011-10-19 14:46:02 -0700 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2011-10-19 14:46:02 -0700 |
commit | fb97d6b5b215eb98bdbf52dd0ce732ba7e887036 (patch) | |
tree | 1c13a2080349688ed516c6123722cb66376310ed | |
parent | 0042b3b48b693a46030ec02f31df625b767e4977 (diff) | |
parent | f9f24d4c578a01cb09a7e5c4c66b75595d3669ee (diff) | |
download | LegacyCamera-fb97d6b5b215eb98bdbf52dd0ce732ba7e887036.zip LegacyCamera-fb97d6b5b215eb98bdbf52dd0ce732ba7e887036.tar.gz LegacyCamera-fb97d6b5b215eb98bdbf52dd0ce732ba7e887036.tar.bz2 |
am f9f24d4c: bugfix 5479807 Video preview displaced to right when orientation changed
* commit 'f9f24d4c578a01cb09a7e5c4c66b75595d3669ee':
bugfix 5479807 Video preview displaced to right when orientation changed
-rw-r--r-- | res/layout/share_popup.xml | 22 | ||||
-rw-r--r-- | src/com/android/camera/ui/SharePopup.java | 43 |
2 files changed, 23 insertions, 42 deletions
diff --git a/res/layout/share_popup.xml b/res/layout/share_popup.xml index c9beb3a..ccc74d9 100644 --- a/res/layout/share_popup.xml +++ b/res/layout/share_popup.xml @@ -37,14 +37,22 @@ android:layout_alignParentTop="true" android:layout_alignParentLeft="true"> <!-- The size of the thumbnail is calculated in SharePopup.java --> - <ImageView android:id="@+id/thumbnail" + <FrameLayout android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:adjustViewBounds="true" - android:scaleType="fitCenter"/> - </com.android.camera.ui.RotateLayout> - <ImageView android:id="@+id/play" - style="@style/ReviewPlayIcon"/> + android:layout_height="wrap_content" > + <ImageView android:id="@+id/thumbnail" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:adjustViewBounds="true" + android:scaleType="fitCenter"/> + <ImageView android:id="@+id/play" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:layout_gravity="center" + android:scaleType="center" + style="@style/ReviewPlayIcon"/> + </FrameLayout> + </com.android.camera.ui.RotateLayout> </RelativeLayout> <LinearLayout android:layout_width="@dimen/share_item_width" diff --git a/src/com/android/camera/ui/SharePopup.java b/src/com/android/camera/ui/SharePopup.java index d83ad11..384634a 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); |