summaryrefslogtreecommitdiffstats
path: root/src/com/android
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android')
-rw-r--r--src/com/android/camera/Camera.java20
-rw-r--r--src/com/android/camera/FocusManager.java4
-rw-r--r--src/com/android/camera/ui/OneRowGridView.java26
-rw-r--r--src/com/android/camera/ui/SharePopup.java72
-rw-r--r--src/com/android/camera/ui/StackLayout.java59
5 files changed, 127 insertions, 54 deletions
diff --git a/src/com/android/camera/Camera.java b/src/com/android/camera/Camera.java
index 1fad8a83..ff98f4a0 100644
--- a/src/com/android/camera/Camera.java
+++ b/src/com/android/camera/Camera.java
@@ -1402,8 +1402,10 @@ public class Camera extends ActivityBase implements FocusManager.Listener,
// If the user wants to do a snapshot while the previous one is still
// in progress, remember the fact and do it after we finish the previous
- // one and re-start the preview.
- if (mCameraState == SNAPSHOT_IN_PROGRESS) {
+ // one and re-start the preview. Snapshot in progress also includes the
+ // state that autofocus is focusing and a picture will be taken when
+ // focus callback arrives.
+ if (mFocusManager.isFocusingSnapOnFinish() || mCameraState == SNAPSHOT_IN_PROGRESS) {
mSnapshotOnIdle = true;
return;
}
@@ -1765,13 +1767,15 @@ public class Camera extends ActivityBase implements FocusManager.Listener,
setPreviewDisplay(mSurfaceHolder);
setDisplayOrientation();
- mFocusManager.setAeAwbLock(false); // Unlock AE and AWB.
- setCameraParameters(UPDATE_PARAM_ALL);
- // If the focus mode is continuous autofocus, call cancelAutoFocus to
- // resume it because it may have been paused by autoFocus call.
- if (Parameters.FOCUS_MODE_CONTINUOUS_PICTURE.equals(mParameters.getFocusMode())) {
- mCameraDevice.cancelAutoFocus();
+ if (!mSnapshotOnIdle) {
+ // If the focus mode is continuous autofocus, call cancelAutoFocus to
+ // resume it because it may have been paused by autoFocus call.
+ if (Parameters.FOCUS_MODE_CONTINUOUS_PICTURE.equals(mFocusManager.getFocusMode())) {
+ mCameraDevice.cancelAutoFocus();
+ }
+ mFocusManager.setAeAwbLock(false); // Unlock AE and AWB.
}
+ setCameraParameters(UPDATE_PARAM_ALL);
// Inform the mainthread to go on the UI initialization.
if (mCameraPreviewThread != null) {
diff --git a/src/com/android/camera/FocusManager.java b/src/com/android/camera/FocusManager.java
index bdf47660..76a8737a 100644
--- a/src/com/android/camera/FocusManager.java
+++ b/src/com/android/camera/FocusManager.java
@@ -471,6 +471,10 @@ public class FocusManager {
return mState == STATE_SUCCESS || mState == STATE_FAIL;
}
+ public boolean isFocusingSnapOnFinish() {
+ return mState == STATE_FOCUSING_SNAP_ON_FINISH;
+ }
+
public void removeMessages() {
mHandler.removeMessages(RESET_TOUCH_FOCUS);
}
diff --git a/src/com/android/camera/ui/OneRowGridView.java b/src/com/android/camera/ui/OneRowGridView.java
index 5e37d35e..2545f1cc 100644
--- a/src/com/android/camera/ui/OneRowGridView.java
+++ b/src/com/android/camera/ui/OneRowGridView.java
@@ -16,28 +16,32 @@
package com.android.camera.ui;
-import com.android.camera.R;
-import com.android.camera.Util;
-
import android.content.Context;
import android.util.AttributeSet;
import android.widget.GridView;
public class OneRowGridView extends GridView {
+ private int mInternalRequestedColumnWidth;
public OneRowGridView(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
+ public void setColumnWidth(int columnWidth) {
+ super.setColumnWidth(columnWidth);
+ if (mInternalRequestedColumnWidth != columnWidth) {
+ mInternalRequestedColumnWidth = columnWidth;
+ requestLayout();
+ }
+ }
+
+ @Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
- // Once we know the number of children in this view, we have to set
- // the correct width and height for containing the icons in one row.
- int n = getChildCount();
- if (n == 0) {
- super.onMeasure(widthMeasureSpec, heightMeasureSpec);
- } else {
- setMeasuredDimension((n * getChildAt(0).getMeasuredWidth()),
- getMeasuredHeight());
+ if (mInternalRequestedColumnWidth != 0) {
+ int n = (getAdapter() == null) ? 0 : getAdapter().getCount();
+ int size = mInternalRequestedColumnWidth * n;
+ widthMeasureSpec = MeasureSpec.makeMeasureSpec(size, MeasureSpec.EXACTLY);
}
+ super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}
}
diff --git a/src/com/android/camera/ui/SharePopup.java b/src/com/android/camera/ui/SharePopup.java
index 134b7c05..43f3ae82 100644
--- a/src/com/android/camera/ui/SharePopup.java
+++ b/src/com/android/camera/ui/SharePopup.java
@@ -31,6 +31,7 @@ import android.graphics.Bitmap;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.net.Uri;
+import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
@@ -38,10 +39,10 @@ import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.view.WindowManager;
import android.widget.AdapterView;
-import android.widget.ImageView;
+import android.widget.FrameLayout;
import android.widget.GridView;
+import android.widget.ImageView;
import android.widget.PopupWindow;
-import android.widget.RelativeLayout;
import android.widget.SimpleAdapter;
import java.util.ArrayList;
@@ -61,17 +62,17 @@ public class SharePopup extends PopupWindow implements View.OnClickListener,
private int mBitmapWidth;
private int mBitmapHeight;
private int mOrientation;
- // A view that contains a thumbnail and an arrow icon.
- private ViewGroup mShareView;
+ private int mActivityOrientation;
// A view that contains a list of application icons and the share view.
private View mRootView;
// The list of the application icons.
private GridView mShareList;
- // A rotated view that contains the thumbnail.
+ // A rotated view that contains the thumbnail and the play icon.
private RotateLayout mThumbnailRotateLayout;
private RotateLayout mGotoGalleryRotate;
private View mPreviewFrame;
private ArrayList<ComponentName> mComponent = new ArrayList<ComponentName>();
+ private View mImageViewFrame;
private class MySimpleAdapter extends SimpleAdapter {
public MySimpleAdapter(Context context, List<? extends Map<String, ?>> data,
@@ -94,7 +95,7 @@ public class SharePopup extends PopupWindow implements View.OnClickListener,
public boolean setViewValue(final View view, final Object data,
final String text) {
if (view instanceof ImageView) {
- ((ImageView)view).setImageDrawable((Drawable) data);
+ ((ImageView) view).setImageDrawable((Drawable) data);
return true;
}
return false;
@@ -105,6 +106,8 @@ public class SharePopup extends PopupWindow implements View.OnClickListener,
View previewFrame) {
super(activity);
+ mActivityOrientation = activity.getRequestedOrientation();
+
// Initialize variables
mContext = activity;
mUri = uri;
@@ -114,14 +117,18 @@ public class SharePopup extends PopupWindow implements View.OnClickListener,
ViewGroup sharePopup = (ViewGroup) inflater.inflate(R.layout.share_popup, null, false);
// This is required because popup window is full screen.
sharePopup.setOnTouchListener(this);
- mThumbnailRotateLayout = (RotateLayout) sharePopup.findViewById(R.id.thumbnail_rotate_layout);
+ mThumbnailRotateLayout =
+ (RotateLayout) sharePopup.findViewById(R.id.thumbnail_rotate_layout);
mShareList = (GridView) sharePopup.findViewById(R.id.share_list);
mThumbnail = (ImageView) sharePopup.findViewById(R.id.thumbnail);
mThumbnail.setImageBitmap(bitmap);
- mShareView = (ViewGroup) sharePopup.findViewById(R.id.share_view);
- mShareView.setOnClickListener(this);
+ mImageViewFrame =
+ (View) sharePopup.findViewById(R.id.thumbnail_image_frame);
+ mImageViewFrame.setOnClickListener(this);
- mGotoGalleryRotate =(RotateLayout) sharePopup.findViewById(R.id.goto_gallery_button_rotate);
+
+ mGotoGalleryRotate =
+ (RotateLayout) sharePopup.findViewById(R.id.goto_gallery_button_rotate);
sharePopup.findViewById(R.id.goto_gallery_button).setOnClickListener(this);
mBitmapWidth = bitmap.getWidth();
@@ -157,31 +164,27 @@ public class SharePopup extends PopupWindow implements View.OnClickListener,
}
private void adjustThumbnailPosition() {
- RelativeLayout.LayoutParams lpOld =
- (RelativeLayout.LayoutParams) mThumbnailRotateLayout.getLayoutParams();
- RelativeLayout.LayoutParams lpNew =
- new RelativeLayout.LayoutParams(lpOld.width, lpOld.height);
+ FrameLayout.LayoutParams lpOld =
+ (FrameLayout.LayoutParams) mThumbnailRotateLayout.getLayoutParams();
+ FrameLayout.LayoutParams lpNew =
+ new FrameLayout.LayoutParams(lpOld.width, lpOld.height);
mRootView.setBackgroundDrawable(null);
if (mBitmapWidth > mBitmapHeight * 2 || mBitmapHeight > mBitmapWidth * 2) {
// panorama image
- lpNew.addRule(RelativeLayout.CENTER_HORIZONTAL);
- lpNew.addRule(RelativeLayout.CENTER_VERTICAL);
+ lpNew.gravity = Gravity.CENTER_HORIZONTAL | Gravity.CENTER_VERTICAL;
// panorama images block the preview from showing in the background
// use a special color here for that.
mRootView.setBackgroundColor(
mContext.getResources().getColor(R.color.share_popup_blackout));
- } else if (mBitmapWidth > mBitmapHeight) {
- // landscape image
- lpNew.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
- lpNew.addRule(RelativeLayout.ALIGN_PARENT_TOP);
- lpNew.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
} else {
- // portrait image
- lpNew.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
- lpNew.addRule(RelativeLayout.ALIGN_PARENT_TOP);
- lpNew.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
+ // landscape or portrait image
+ if (mActivityOrientation == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT) {
+ lpNew.gravity = Gravity.BOTTOM;
+ } else {
+ lpNew.gravity = Gravity.RIGHT;
+ }
}
mThumbnailRotateLayout.setLayoutParams(lpNew);
@@ -192,13 +195,11 @@ public class SharePopup extends PopupWindow implements View.OnClickListener,
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. Reserve the
// space for paddings.
- float maxWidth = mPreviewFrame.getWidth() - hPadding - hPaddingRootView;
- float maxHeight = mPreviewFrame.getHeight() - vPadding - vPaddingRootView;
+ float maxWidth = mPreviewFrame.getWidth() - hPaddingRootView;
+ float maxHeight = mPreviewFrame.getHeight() - vPaddingRootView;
// Swap the width and height if it is portrait mode.
if (orientation == 90 || orientation == 270) {
float temp = maxWidth;
@@ -209,10 +210,10 @@ public class SharePopup extends PopupWindow implements View.OnClickListener,
float desiredAspect = (float) mBitmapWidth / mBitmapHeight;
if (mMimeType.startsWith("video/")) {
- desiredAspect = 4F/3F;
+ desiredAspect = 4F / 3F;
mThumbnail.setScaleType(ImageView.ScaleType.CENTER_CROP);
} else {
- mThumbnail.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
+ mThumbnail.setScaleType(ImageView.ScaleType.FIT_CENTER);
}
LayoutParams params = mThumbnail.getLayoutParams();
@@ -250,7 +251,7 @@ public class SharePopup extends PopupWindow implements View.OnClickListener,
public void onClick(View v) {
switch (v.getId()) {
case R.id.goto_gallery_button:
- case R.id.share_view:
+ case R.id.thumbnail_image_frame:
Util.viewUri(mUri, mContext);
break;
}
@@ -271,7 +272,7 @@ public class SharePopup extends PopupWindow implements View.OnClickListener,
new Intent(Intent.ACTION_SEND).setType(mMimeType), 0);
ArrayList<HashMap<String, Object>> items = new ArrayList<HashMap<String, Object>>();
- for (ResolveInfo info: infos) {
+ for (ResolveInfo info : infos) {
ComponentName component = new ComponentName(
info.activityInfo.packageName, info.activityInfo.name);
HashMap<String, Object> map = new HashMap<String, Object>();
@@ -282,9 +283,10 @@ public class SharePopup extends PopupWindow implements View.OnClickListener,
// On phone UI, we have to know how many icons in the grid view before
// the view is measured.
- if (((Activity) mContext).getRequestedOrientation()
- == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT) {
+ if (mActivityOrientation == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT) {
mShareList.setNumColumns(items.size());
+ int width = mContext.getResources().getDimensionPixelSize(R.dimen.share_item_width);
+ mShareList.setColumnWidth(width);
}
SimpleAdapter listItemAdapter = new MySimpleAdapter(mContext, items,
diff --git a/src/com/android/camera/ui/StackLayout.java b/src/com/android/camera/ui/StackLayout.java
new file mode 100644
index 00000000..ab08d2f0
--- /dev/null
+++ b/src/com/android/camera/ui/StackLayout.java
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.camera.ui;
+
+import android.content.Context;
+import android.util.AttributeSet;
+import android.view.View;
+import android.view.ViewGroup;
+
+// A layout designed to make the children same size as the first child.
+public class StackLayout extends ViewGroup {
+ private static final String TAG = "StackLayout";
+
+ public StackLayout(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ }
+
+ @Override
+ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
+ final int count = getChildCount();
+
+ // Measure only the first child.
+ final View child = getChildAt(0);
+ measureChild(child, widthMeasureSpec, heightMeasureSpec);
+
+ // Ignore the paddings.
+ int width = child.getMeasuredWidth();
+ int height = child.getMeasuredHeight();
+
+ setMeasuredDimension(resolveSize(width, widthMeasureSpec),
+ resolveSize(height, heightMeasureSpec));
+ }
+
+ @Override
+ protected void onLayout(boolean changed, int l, int t, int r, int b) {
+ final int count = super.getChildCount();
+
+ for (int i = 0; i < count; i++) {
+ final View child = getChildAt(i);
+ if (child.getVisibility() != View.GONE) {
+ child.layout(0, 0, r - l, b - t);
+ }
+ }
+ }
+}