summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWu-cheng Li <wuchengli@google.com>2011-08-26 23:14:27 +0800
committerWu-cheng Li <wuchengli@google.com>2011-08-29 13:34:12 +0800
commit4591c5ecbaade585c3094be353d27b14f0592494 (patch)
tree39f271f4aa0b277ade6c8cb0ac8a2f80f1cdd83d
parent21eafb33a46aad92326df76b41771194b1f341f9 (diff)
downloadpackages_apps_LegacyCamera-4591c5ecbaade585c3094be353d27b14f0592494.zip
packages_apps_LegacyCamera-4591c5ecbaade585c3094be353d27b14f0592494.tar.gz
packages_apps_LegacyCamera-4591c5ecbaade585c3094be353d27b14f0592494.tar.bz2
Make the size of the share popup the same as preview area.
bug:5157438 Change-Id: Ib199ee62cce314c648c323304289af7e1421c59e
-rw-r--r--res/layout/share_popup.xml51
-rw-r--r--res/values-w1024dp/dimens.xml4
-rw-r--r--res/values/dimens.xml4
-rw-r--r--src/com/android/camera/Camera.java2
-rw-r--r--src/com/android/camera/VideoCamera.java2
-rw-r--r--src/com/android/camera/panorama/PanoramaActivity.java3
-rw-r--r--src/com/android/camera/ui/SharePopup.java51
7 files changed, 51 insertions, 66 deletions
diff --git a/res/layout/share_popup.xml b/res/layout/share_popup.xml
index e069595..7d386ff 100644
--- a/res/layout/share_popup.xml
+++ b/res/layout/share_popup.xml
@@ -22,34 +22,39 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/dim_background">
- <FrameLayout android:id="@+id/share_view"
+ <FrameLayout android:id="@+id/root"
android:layout_width="wrap_content"
- android:layout_height="match_parent"
- android:layout_gravity="center"
- android:background="@drawable/border_last_picture">
- <com.android.camera.ui.RotateLayout
- android:id="@+id/thumbnail_rotate_layout"
+ android:layout_height="wrap_content"
+ android:layout_gravity="left|center">
+ <FrameLayout android:id="@+id/share_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_gravity="center">
- <!-- The size of the thumbnail is calculated in SharePopup.java -->
- <ImageView android:id="@+id/thumbnail"
+ android:layout_gravity="center"
+ android:background="@drawable/border_last_picture">
+ <com.android.camera.ui.RotateLayout
+ android:id="@+id/thumbnail_rotate_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:adjustViewBounds="true"
- android:scaleType="fitCenter"/>
- </com.android.camera.ui.RotateLayout>
- <FrameLayout
- android:layout_width="@dimen/share_item_width"
- android:layout_height="match_parent"
- android:layout_gravity="right"
- android:background="@color/dim_background">
- <ListView android:id="@+id/share_list"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:orientation="vertical"
- android:choiceMode="singleChoice"
- style="@android:style/Widget.Holo.ListView" />
+ android:layout_gravity="center">
+ <!-- The size of the thumbnail is calculated in SharePopup.java -->
+ <ImageView android:id="@+id/thumbnail"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:adjustViewBounds="true"
+ android:scaleType="fitCenter"/>
+ </com.android.camera.ui.RotateLayout>
+ <FrameLayout
+ android:layout_width="@dimen/share_item_width"
+ android:layout_height="match_parent"
+ android:layout_gravity="right"
+ android:background="@color/dim_background">
+ <ListView android:id="@+id/share_list"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="vertical"
+ android:choiceMode="singleChoice"
+ style="@android:style/Widget.Holo.ListView" />
+ </FrameLayout>
</FrameLayout>
</FrameLayout>
</FrameLayout>
diff --git a/res/values-w1024dp/dimens.xml b/res/values-w1024dp/dimens.xml
index b511f45..8e97591 100644
--- a/res/values-w1024dp/dimens.xml
+++ b/res/values-w1024dp/dimens.xml
@@ -23,10 +23,6 @@
<dimen name="mode_switcher_inner_margin">10dp</dimen>
<dimen name="camera_switcher_margin_right">16dp</dimen>
<dimen name="camera_switcher_margin_bottom">24dp</dimen>
- <dimen name="share_image_max_width_landscape">960dp</dimen>
- <dimen name="share_image_max_height_landscape">720dp</dimen>
- <dimen name="share_image_max_width_portrait">720dp</dimen>
- <dimen name="share_image_max_height_portrait">960dp</dimen>
<dimen name="share_icon_length">48dp</dimen>
<dimen name="share_item_width">60dp</dimen>
<dimen name="share_item_height">90dp</dimen>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 4a5cf2d..3d61c6a 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -19,10 +19,6 @@
-->
<resources>
<dimen name="hint_y_offset">64dp</dimen>
- <dimen name="share_image_max_width_landscape">400dp</dimen>
- <dimen name="share_image_max_height_landscape">300dp</dimen>
- <dimen name="share_image_max_width_portrait">300dp</dimen>
- <dimen name="share_image_max_height_portrait">400dp</dimen>
<dimen name="share_icon_length">36dp</dimen>
<dimen name="share_item_width">54dp</dimen>
<dimen name="share_item_height">60dp</dimen>
diff --git a/src/com/android/camera/Camera.java b/src/com/android/camera/Camera.java
index a71954c..5cd6ce6 100644
--- a/src/com/android/camera/Camera.java
+++ b/src/com/android/camera/Camera.java
@@ -2177,7 +2177,7 @@ public class Camera extends ActivityBase implements FocusManager.Listener,
Uri uri = mThumbnail.getUri();
if (mSharePopup == null || !uri.equals(mSharePopup.getUri())) {
mSharePopup = new SharePopup(this, uri, mThumbnail.getBitmap(), "image/jpeg",
- mOrientationCompensation, mThumbnailView);
+ mOrientationCompensation, findViewById(R.id.frame));
}
mSharePopup.showAtLocation(mThumbnailView, Gravity.NO_GRAVITY, 0, 0);
}
diff --git a/src/com/android/camera/VideoCamera.java b/src/com/android/camera/VideoCamera.java
index ad42e5a..759e760 100644
--- a/src/com/android/camera/VideoCamera.java
+++ b/src/com/android/camera/VideoCamera.java
@@ -1804,7 +1804,7 @@ public class VideoCamera extends ActivityBase
Uri uri = mThumbnail.getUri();
if (mSharePopup == null || !uri.equals(mSharePopup.getUri())) {
mSharePopup = new SharePopup(this, uri, mThumbnail.getBitmap(),
- "video/*", mOrientationCompensation, mThumbnailView);
+ "video/*", mOrientationCompensation, findViewById(R.id.frame));
}
mSharePopup.showAtLocation(mThumbnailView, Gravity.NO_GRAVITY, 0, 0);
}
diff --git a/src/com/android/camera/panorama/PanoramaActivity.java b/src/com/android/camera/panorama/PanoramaActivity.java
index 91d56a5..848e370 100644
--- a/src/com/android/camera/panorama/PanoramaActivity.java
+++ b/src/com/android/camera/panorama/PanoramaActivity.java
@@ -549,8 +549,9 @@ public class PanoramaActivity extends Activity implements
Uri uri = mThumbnail.getUri();
if (mSharePopup == null || !uri.equals(mSharePopup.getUri())) {
// The orientation compensation is set to 0 here because we only support landscape.
+ // Panorama picture is long. Use pano_layout so the share popup can be full-screen.
mSharePopup = new SharePopup(this, uri, mThumbnail.getBitmap(), "image/jpeg",
- 0, mThumbnailView);
+ 0, findViewById(R.id.pano_layout));
}
mSharePopup.showAtLocation(mThumbnailView, Gravity.NO_GRAVITY, 0, 0);
}
diff --git a/src/com/android/camera/ui/SharePopup.java b/src/com/android/camera/ui/SharePopup.java
index 68258e0..52297fa 100644
--- a/src/com/android/camera/ui/SharePopup.java
+++ b/src/com/android/camera/ui/SharePopup.java
@@ -30,7 +30,6 @@ import android.graphics.Bitmap;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.net.Uri;
-import android.util.DisplayMetrics;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
@@ -66,17 +65,9 @@ public class SharePopup extends PopupWindow implements View.OnClickListener,
private ListView mShareList;
// A rotated view that contains the thumbnail.
private RotateLayout mThumbnailRotateLayout;
+ private View mPreviewFrame;
private ArrayList<ComponentName> mComponent = new ArrayList<ComponentName>();
- // The maximum width of the thumbnail in landscape orientation.
- private final float mImageMaxWidthLandscape;
- // The maximum height of the thumbnail in landscape orientation.
- private final float mImageMaxHeightLandscape;
- // The maximum width of the thumbnail in portrait orientation.
- private final float mImageMaxWidthPortrait;
- // The maximum height of the thumbnail in portrait orientation.
- private final float mImageMaxHeightPortrait;
-
private class MySimpleAdapter extends SimpleAdapter {
public MySimpleAdapter(Context context, List<? extends Map<String, ?>> data,
int resource, String[] from, int[] to) {
@@ -106,13 +97,14 @@ public class SharePopup extends PopupWindow implements View.OnClickListener,
};
public SharePopup(Activity activity, Uri uri, Bitmap bitmap, String mimeType, int orientation,
- View anchor) {
+ View previewFrame) {
super(activity);
// Initialize variables
mContext = activity;
mUri = uri;
mMimeType = mimeType;
+ mPreviewFrame = previewFrame;
LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(
Context.LAYOUT_INFLATER_SERVICE);
ViewGroup sharePopup = (ViewGroup) inflater.inflate(R.layout.share_popup, null, false);
@@ -127,12 +119,15 @@ public class SharePopup extends PopupWindow implements View.OnClickListener,
mBitmapWidth = bitmap.getWidth();
mBitmapHeight = bitmap.getHeight();
Resources res = mContext.getResources();
- mImageMaxWidthLandscape = res.getDimension(R.dimen.share_image_max_width_landscape);
- mImageMaxHeightLandscape = res.getDimension(R.dimen.share_image_max_height_landscape);
- mImageMaxWidthPortrait = res.getDimension(R.dimen.share_image_max_width_portrait);
- mImageMaxHeightPortrait = res.getDimension(R.dimen.share_image_max_height_portrait);
- // Initialize popup window
+ // Initialize popup window size.
+ View rootView = (View) sharePopup.findViewById(R.id.root);
+ LayoutParams params = rootView.getLayoutParams();
+ params.width = previewFrame.getWidth();
+ params.height = previewFrame.getHeight();
+ rootView.setLayoutParams(params);
+
+ // Initialize popup window.
setWidth(WindowManager.LayoutParams.MATCH_PARENT);
setHeight(WindowManager.LayoutParams.MATCH_PARENT);
setBackgroundDrawable(new ColorDrawable());
@@ -140,29 +135,21 @@ public class SharePopup extends PopupWindow implements View.OnClickListener,
setOrientation(orientation);
setFocusable(true);
setAnimationStyle(android.R.style.Animation_Dialog);
-
- initializeLocation(activity, anchor);
-
createShareMenu();
}
- private void initializeLocation(Activity activity, View anchor) {
- int location[] = new int[2];
- anchor.getLocationOnScreen(location);
- DisplayMetrics metrics = new DisplayMetrics();
- activity.getWindowManager().getDefaultDisplay().getMetrics(metrics);
- }
-
public void setOrientation(int orientation) {
mOrientation = orientation;
+ int hPadding = mShareView.getPaddingLeft() + mShareView.getPaddingRight();
+ int vPadding = mShareView.getPaddingTop() + mShareView.getPaddingBottom();
// Calculate the width and the height of the thumbnail.
float maxWidth, maxHeight;
if (orientation == 90 || orientation == 270) {
- maxWidth = mImageMaxWidthPortrait;
- maxHeight = mImageMaxHeightPortrait;
+ maxWidth = mPreviewFrame.getHeight() - hPadding;
+ maxHeight = mPreviewFrame.getWidth() - vPadding;
} else {
- maxWidth = mImageMaxWidthLandscape;
- maxHeight = mImageMaxHeightLandscape;
+ maxWidth = mPreviewFrame.getWidth() - hPadding;
+ maxHeight = mPreviewFrame.getHeight() - vPadding;
}
float actualAspect = maxWidth / maxHeight;
float desiredAspect = (float) mBitmapWidth / mBitmapHeight;
@@ -178,8 +165,8 @@ public class SharePopup extends PopupWindow implements View.OnClickListener,
mThumbnail.setLayoutParams(params);
// Calculate the width and the height of the share view.
- int width = params.width + mShareView.getPaddingLeft() + mShareView.getPaddingRight();
- int height = params.height + mShareView.getPaddingTop() + mShareView.getPaddingBottom();
+ int width = params.width + hPadding;
+ int height = params.height + vPadding;
LayoutParams rootParams = mShareView.getLayoutParams();
if (orientation == 90 || orientation == 270) {
rootParams.width = height;