diff options
author | Wu-cheng Li <wuchengli@google.com> | 2011-09-14 03:15:34 +0800 |
---|---|---|
committer | Wu-cheng Li <wuchengli@google.com> | 2011-09-15 03:07:56 +0800 |
commit | d62087915cf9e4a686db03291b7ef9d99758ebba (patch) | |
tree | fe21feadba9100ef872a722e74a72d4cd0a3d56d | |
parent | 7ef764eb76f8e1e463c143ec5c7aa9a9d678b2d8 (diff) | |
download | LegacyCamera-d62087915cf9e4a686db03291b7ef9d99758ebba.zip LegacyCamera-d62087915cf9e4a686db03291b7ef9d99758ebba.tar.gz LegacyCamera-d62087915cf9e4a686db03291b7ef9d99758ebba.tar.bz2 |
Add back arrow icon in the share popup.
+ Fix the wrong calculation of the thumbnail size.
bug:5290450
Change-Id: I80318af68f084a726b32dc98cb205013abada88d
-rw-r--r-- | res/drawable-hdpi/ic_switch_arrow.png | bin | 0 -> 1031 bytes | |||
-rw-r--r-- | res/drawable-mdpi/ic_switch_arrow.png | bin | 0 -> 802 bytes | |||
-rw-r--r-- | res/drawable-xhdpi/ic_switch_arrow.png | bin | 0 -> 1176 bytes | |||
-rw-r--r-- | res/layout/share_popup.xml | 13 | ||||
-rw-r--r-- | res/values/colors.xml | 2 | ||||
-rw-r--r-- | src/com/android/camera/ui/SharePopup.java | 46 |
6 files changed, 39 insertions, 22 deletions
diff --git a/res/drawable-hdpi/ic_switch_arrow.png b/res/drawable-hdpi/ic_switch_arrow.png Binary files differnew file mode 100644 index 0000000..3461523 --- /dev/null +++ b/res/drawable-hdpi/ic_switch_arrow.png diff --git a/res/drawable-mdpi/ic_switch_arrow.png b/res/drawable-mdpi/ic_switch_arrow.png Binary files differnew file mode 100644 index 0000000..b00bbc2 --- /dev/null +++ b/res/drawable-mdpi/ic_switch_arrow.png diff --git a/res/drawable-xhdpi/ic_switch_arrow.png b/res/drawable-xhdpi/ic_switch_arrow.png Binary files differnew file mode 100644 index 0000000..e9b46c4 --- /dev/null +++ b/res/drawable-xhdpi/ic_switch_arrow.png diff --git a/res/layout/share_popup.xml b/res/layout/share_popup.xml index 5bcce78..b4890da 100644 --- a/res/layout/share_popup.xml +++ b/res/layout/share_popup.xml @@ -27,7 +27,7 @@ android:layout_height="wrap_content" android:padding="8dp" android:layout_gravity="left|center"> - <FrameLayout android:id="@+id/share_view" + <RelativeLayout android:id="@+id/share_view" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" @@ -36,7 +36,8 @@ android:id="@+id/thumbnail_rotate_layout" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_gravity="center"> + android:layout_alignParentTop="true" + android:layout_alignParentLeft="true"> <!-- The size of the thumbnail is calculated in SharePopup.java --> <ImageView android:id="@+id/thumbnail" android:layout_width="wrap_content" @@ -44,7 +45,13 @@ android:adjustViewBounds="true" android:scaleType="fitCenter"/> </com.android.camera.ui.RotateLayout> - </FrameLayout> + <ImageView android:id="@+id/arrow" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_alignParentTop="true" + android:layout_alignParentLeft="true" + android:src="@drawable/ic_switch_arrow"/> + </RelativeLayout> <FrameLayout android:layout_width="@dimen/share_item_width" android:layout_height="match_parent" diff --git a/res/values/colors.xml b/res/values/colors.xml index bccc96b..fb18610 100644 --- a/res/values/colors.xml +++ b/res/values/colors.xml @@ -25,7 +25,7 @@ <color name="icon_disabled_color">#DD777777</color> <color name="time_lapse_arc">#FFC5C5C5</color> <color name="dark_gray">#151515</color> - <color name="share_popup_background">#B0000000</color> + <color name="share_popup_background">#C0000000</color> <color name="share_icon_background">#40000000</color> <color name="indicator_background">#40000000</color> <color name="pano_custom_dialog_background">#FF666666</color> 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; } } |