diff options
| author | Wu-cheng Li <wuchengli@google.com> | 2011-09-14 14:31:20 -0700 |
|---|---|---|
| committer | Android (Google) Code Review <android-gerrit@google.com> | 2011-09-14 14:31:20 -0700 |
| commit | c24192e3b9a3d4f6e5e77e408fd4d91333b1275e (patch) | |
| tree | 5c9acc99f3d95997ba04439b3616e15f322fed43 /src | |
| parent | c718193efe9b13f1e00f6bd8e3c145e9c28d9309 (diff) | |
| parent | d62087915cf9e4a686db03291b7ef9d99758ebba (diff) | |
| download | LegacyCamera-c24192e3b9a3d4f6e5e77e408fd4d91333b1275e.zip LegacyCamera-c24192e3b9a3d4f6e5e77e408fd4d91333b1275e.tar.gz LegacyCamera-c24192e3b9a3d4f6e5e77e408fd4d91333b1275e.tar.bz2 | |
Merge "Add back arrow icon in the share popup."
Diffstat (limited to 'src')
| -rw-r--r-- | src/com/android/camera/ui/SharePopup.java | 46 |
1 files changed, 28 insertions, 18 deletions
diff --git a/src/com/android/camera/ui/SharePopup.java b/src/com/android/camera/ui/SharePopup.java index b532789..cdc7756 100644 --- a/src/com/android/camera/ui/SharePopup.java +++ b/src/com/android/camera/ui/SharePopup.java @@ -59,8 +59,10 @@ public class SharePopup extends PopupWindow implements View.OnClickListener, private int mBitmapWidth; private int mBitmapHeight; private int mOrientation; - // A view that contains a thumbnail and a list of application icons. + // A view that contains a thumbnail and an back arrow icon. private ViewGroup mShareView; + // A view that contains a list of application icons and the share view. + private View mRootView; // The list of the application icons. private ListView mShareList; // A rotated view that contains the thumbnail. @@ -116,16 +118,17 @@ public class SharePopup extends PopupWindow implements View.OnClickListener, mThumbnail.setImageBitmap(bitmap); mShareView = (ViewGroup) sharePopup.findViewById(R.id.share_view); mShareView.setOnClickListener(this); + sharePopup.findViewById(R.id.arrow).setOnClickListener(this); mBitmapWidth = bitmap.getWidth(); mBitmapHeight = bitmap.getHeight(); Resources res = mContext.getResources(); // Initialize popup window size. - View rootView = (View) sharePopup.findViewById(R.id.root); - LayoutParams params = rootView.getLayoutParams(); + mRootView = (View) sharePopup.findViewById(R.id.root); + LayoutParams params = mRootView.getLayoutParams(); params.width = previewFrame.getWidth(); params.height = previewFrame.getHeight(); - rootView.setLayoutParams(params); + mRootView.setLayoutParams(params); // Initialize popup window. setWidth(WindowManager.LayoutParams.MATCH_PARENT); @@ -140,20 +143,24 @@ public class SharePopup extends PopupWindow implements View.OnClickListener, public void setOrientation(int orientation) { mOrientation = orientation; + + int hPaddingRootView = mRootView.getPaddingLeft() + mRootView.getPaddingRight(); + int vPaddingRootView = mRootView.getPaddingTop() + mRootView.getPaddingBottom(); int hPadding = mShareView.getPaddingLeft() + mShareView.getPaddingRight(); int vPadding = mShareView.getPaddingTop() + mShareView.getPaddingBottom(); - // Calculate the width and the height of the thumbnail. - float maxWidth, maxHeight; + + // Calculate the width and the height of the thumbnail. Reserve the + // space for paddings. + float maxWidth = mPreviewFrame.getWidth() - hPadding - hPaddingRootView; + float maxHeight = mPreviewFrame.getHeight() - vPadding - vPaddingRootView; + // Swap the width and height if it is portrait mode. if (orientation == 90 || orientation == 270) { - maxWidth = mPreviewFrame.getHeight() - hPadding; - maxHeight = mPreviewFrame.getWidth() - vPadding; - } else { - maxWidth = mPreviewFrame.getWidth() - hPadding; - maxHeight = mPreviewFrame.getHeight() - vPadding; + float temp = maxWidth; + maxWidth = maxHeight; + maxHeight = temp; } float actualAspect = maxWidth / maxHeight; float desiredAspect = (float) mBitmapWidth / mBitmapHeight; - LayoutParams params = mThumbnail.getLayoutParams(); if (actualAspect > desiredAspect) { params.width = Math.round(maxHeight * desiredAspect); @@ -167,15 +174,15 @@ public class SharePopup extends PopupWindow implements View.OnClickListener, // Calculate the width and the height of the share view. int width = params.width + hPadding; int height = params.height + vPadding; - LayoutParams rootParams = mShareView.getLayoutParams(); + LayoutParams shareViewParams = mShareView.getLayoutParams(); if (orientation == 90 || orientation == 270) { - rootParams.width = height; - rootParams.height = width; + shareViewParams.width = height; + shareViewParams.height = width; } else { - rootParams.width = width; - rootParams.height = height; + shareViewParams.width = width; + shareViewParams.height = height; } - mShareView.setLayoutParams(rootParams); + mShareView.setLayoutParams(shareViewParams); if (mThumbnailRotateLayout != null) mThumbnailRotateLayout.setOrientation(orientation); @@ -193,6 +200,9 @@ public class SharePopup extends PopupWindow implements View.OnClickListener, case R.id.share_view: Util.viewUri(mUri, mContext); break; + case R.id.arrow: + dismiss(); + break; } } |
