summaryrefslogtreecommitdiffstats
path: root/src/com/android/camera
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/camera')
-rw-r--r--src/com/android/camera/Camera.java30
-rw-r--r--src/com/android/camera/PreviewFrameLayout.java72
-rw-r--r--src/com/android/camera/Util.java17
-rw-r--r--src/com/android/camera/VideoCamera.java32
-rw-r--r--src/com/android/camera/panorama/PanoramaActivity.java13
-rw-r--r--src/com/android/camera/ui/IndicatorButton.java2
-rw-r--r--src/com/android/camera/ui/OtherSettingIndicatorButton.java2
-rw-r--r--src/com/android/camera/ui/SecondLevelIndicatorControlBar.java6
8 files changed, 78 insertions, 96 deletions
diff --git a/src/com/android/camera/Camera.java b/src/com/android/camera/Camera.java
index 345e9b2..5c645a4 100644
--- a/src/com/android/camera/Camera.java
+++ b/src/com/android/camera/Camera.java
@@ -105,10 +105,6 @@ public class Camera extends ActivityBase implements FocusManager.Listener,
// needed to be updated in mUpdateSet.
private int mUpdateSet;
- // The brightness settings used when it is set to automatic in the system.
- // The reason why it is set to 0.7 is just because 1.0 is too bright.
- private static final float DEFAULT_CAMERA_BRIGHTNESS = 0.7f;
-
private static final int SCREEN_DELAY = 2 * 60 * 1000;
private static final int ZOOM_STOPPED = 0;
@@ -145,6 +141,7 @@ public class Camera extends ActivityBase implements FocusManager.Listener,
private boolean mOpenCameraFail = false;
private boolean mCameraDisabled = false;
+ private View mPreviewPanel; // The container of PreviewFrameLayout.
private PreviewFrameLayout mPreviewFrameLayout;
private View mPreviewFrame; // Preview frame area.
@@ -365,7 +362,7 @@ public class Camera extends ActivityBase implements FocusManager.Listener,
mFocusIndicator = (RotateLayout) findViewById(R.id.focus_indicator_rotate_layout);
mFocusManager.initialize(mFocusIndicator, mPreviewFrame, mFaceView, this);
mFocusManager.initializeToneGenerator();
- initializeScreenBrightness();
+ Util.initializeScreenBrightness(getWindow(), getContentResolver());
installIntentFilter();
initializeZoom();
// Show the tap to focus toast if this is the first start.
@@ -1193,20 +1190,6 @@ public class Camera extends ActivityBase implements FocusManager.Listener,
mDidRegister = true;
}
- private void initializeScreenBrightness() {
- Window win = getWindow();
- // Overright the brightness settings if it is automatic
- int mode = Settings.System.getInt(
- getContentResolver(),
- Settings.System.SCREEN_BRIGHTNESS_MODE,
- Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL);
- if (mode == Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC) {
- WindowManager.LayoutParams winParams = win.getAttributes();
- winParams.screenBrightness = DEFAULT_CAMERA_BRIGHTNESS;
- win.setAttributes(winParams);
- }
- }
-
@Override
protected void onResume() {
super.onResume();
@@ -1343,7 +1326,8 @@ public class Camera extends ActivityBase implements FocusManager.Listener,
// Preview area is touched. Handle touch focus.
@Override
public boolean onTouch(View v, MotionEvent e) {
- if (mPausing || !mFirstTimeInitialized || mCameraState == SNAPSHOT_IN_PROGRESS) {
+ if (mPausing || mCameraDevice == null || !mFirstTimeInitialized
+ || mCameraState == SNAPSHOT_IN_PROGRESS) {
return false;
}
@@ -1606,7 +1590,8 @@ public class Camera extends ActivityBase implements FocusManager.Listener,
// Set the preview frame aspect ratio according to the picture size.
Size size = mParameters.getPictureSize();
- mPreviewFrameLayout = (PreviewFrameLayout) findViewById(R.id.frame_layout);
+ mPreviewPanel = findViewById(R.id.frame_layout);
+ mPreviewFrameLayout = (PreviewFrameLayout) findViewById(R.id.frame);
mPreviewFrameLayout.setAspectRatio((double) size.width / size.height);
// Set a preview size that is closest to the viewfinder height and has
@@ -1954,8 +1939,9 @@ public class Camera extends ActivityBase implements FocusManager.Listener,
private void showSharePopup() {
Uri uri = mThumbnail.getUri();
if (mSharePopup == null || !uri.equals(mSharePopup.getUri())) {
+ // SharePopup window takes the mPreviewPanel as its size reference.
mSharePopup = new SharePopup(this, uri, mThumbnail.getBitmap(),
- mOrientationCompensation, mPreviewFrameLayout);
+ mOrientationCompensation, mPreviewPanel);
}
mSharePopup.showAtLocation(mThumbnailView, Gravity.NO_GRAVITY, 0, 0);
}
diff --git a/src/com/android/camera/PreviewFrameLayout.java b/src/com/android/camera/PreviewFrameLayout.java
index d19ff6d..5d31e2b 100644
--- a/src/com/android/camera/PreviewFrameLayout.java
+++ b/src/com/android/camera/PreviewFrameLayout.java
@@ -16,13 +16,12 @@
package com.android.camera;
-import android.app.Activity;
+import com.android.camera.R;
+
import android.content.Context;
+import android.graphics.Rect;
import android.util.AttributeSet;
-import android.util.DisplayMetrics;
-import android.view.View;
import android.widget.RelativeLayout;
-
/**
* A layout which handles the preview aspect ratio.
*/
@@ -33,69 +32,48 @@ public class PreviewFrameLayout extends RelativeLayout {
}
private double mAspectRatio = 4.0 / 3.0;
- private View mFrame;
- private View mPreviewBorder;
- private final DisplayMetrics mMetrics = new DisplayMetrics();
public PreviewFrameLayout(Context context, AttributeSet attrs) {
super(context, attrs);
- ((Activity) context).getWindowManager()
- .getDefaultDisplay().getMetrics(mMetrics);
- }
-
- @Override
- protected void onFinishInflate() {
- super.onFinishInflate();
- mFrame = (View) findViewById(R.id.frame);
- mPreviewBorder = (View) findViewById(R.id.preview_border);
}
public void setAspectRatio(double ratio) {
if (ratio <= 0.0) throw new IllegalArgumentException();
-
if (mAspectRatio != ratio) {
mAspectRatio = ratio;
requestLayout();
}
}
+ public void showBorder(boolean enabled) {
+ setActivated(enabled);
+ }
+
+
@Override
- protected void onLayout(boolean changed, int l, int t, int r, int b) {
- // Calculate the width and the height of preview frame.
- int frameWidth = getWidth();
- int frameHeight = getHeight();
- int hPadding = 0;
- int vPadding = 0;
- if (mPreviewBorder != null) {
- hPadding = mPreviewBorder.getPaddingLeft() + mPreviewBorder.getPaddingRight();
- vPadding = mPreviewBorder.getPaddingBottom() + mPreviewBorder.getPaddingTop();
- }
- int previewHeight = frameHeight - vPadding;
- int previewWidth = frameWidth - hPadding;
+ protected void onMeasure(int widthSpec, int heightSpec) {
+ int previewWidth = MeasureSpec.getSize(widthSpec);
+ int previewHeight = MeasureSpec.getSize(heightSpec);
+
+ // Get the padding of the border background.
+ int hPadding = mPaddingLeft + mPaddingRight;
+ int vPadding = mPaddingTop + mPaddingBottom;
+
+ // Resize the preview frame with correct aspect ratio.
+ previewWidth -= hPadding;
+ previewHeight -= vPadding;
if (previewWidth > previewHeight * mAspectRatio) {
previewWidth = (int) (previewHeight * mAspectRatio + .5);
} else {
previewHeight = (int) (previewWidth / mAspectRatio + .5);
}
- // Measure and layout preview frame.
- int hSpace = ((r - l) - previewWidth) / 2;
- int vSpace = ((b - t) - previewHeight) / 2;
- mFrame.measure(
- MeasureSpec.makeMeasureSpec(previewWidth, MeasureSpec.EXACTLY),
- MeasureSpec.makeMeasureSpec(previewHeight, MeasureSpec.EXACTLY));
- mFrame.layout(hSpace, vSpace, frameWidth + hSpace, frameHeight + vSpace);
+ // Add the padding of the border.
+ previewWidth += hPadding;
+ previewHeight += vPadding;
- // Measure and layout the border of preview frame.
- if (mPreviewBorder != null) {
- frameWidth = previewWidth + hPadding;
- frameHeight = previewHeight + vPadding;
- hSpace = ((r - l) - frameWidth) / 2;
- vSpace = ((b - t) - frameHeight) / 2;
- mPreviewBorder.measure(
- MeasureSpec.makeMeasureSpec(frameWidth, MeasureSpec.EXACTLY),
- MeasureSpec.makeMeasureSpec(frameHeight, MeasureSpec.EXACTLY));
- mPreviewBorder.layout(hSpace, vSpace, frameWidth + hSpace, frameHeight + vSpace);
- }
+ // Ask children to follow the new preview dimension.
+ super.onMeasure(MeasureSpec.makeMeasureSpec(previewWidth, MeasureSpec.EXACTLY),
+ MeasureSpec.makeMeasureSpec(previewHeight, MeasureSpec.EXACTLY));
}
}
diff --git a/src/com/android/camera/Util.java b/src/com/android/camera/Util.java
index 906dc1e..c5bc79d 100644
--- a/src/com/android/camera/Util.java
+++ b/src/com/android/camera/Util.java
@@ -35,6 +35,7 @@ import android.location.Location;
import android.net.Uri;
import android.os.Build;
import android.os.ParcelFileDescriptor;
+import android.provider.Settings;
import android.telephony.TelephonyManager;
import android.util.DisplayMetrics;
import android.util.Log;
@@ -65,6 +66,11 @@ public class Util {
private static final int DIRECTION_UP = 2;
private static final int DIRECTION_DOWN = 3;
+ // The brightness setting used when it is set to automatic in the system.
+ // The reason why it is set to 0.7 is just because 1.0 is too bright.
+ // Use the same setting among the Camera, VideoCamera and Panorama modes.
+ private static final float DEFAULT_CAMERA_BRIGHTNESS = 0.7f;
+
public static final String REVIEW_ACTION = "com.android.camera.action.REVIEW";
// Private intent extras. Test only.
@@ -593,4 +599,15 @@ public class Util {
params.systemUiVisibility = View.SYSTEM_UI_FLAG_LOW_PROFILE;
window.setAttributes(params);
}
+
+ public static void initializeScreenBrightness(Window win, ContentResolver resolver) {
+ // Overright the brightness settings if it is automatic
+ int mode = Settings.System.getInt(resolver, Settings.System.SCREEN_BRIGHTNESS_MODE,
+ Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL);
+ if (mode == Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC) {
+ WindowManager.LayoutParams winParams = win.getAttributes();
+ winParams.screenBrightness = DEFAULT_CAMERA_BRIGHTNESS;
+ win.setAttributes(winParams);
+ }
+ }
}
diff --git a/src/com/android/camera/VideoCamera.java b/src/com/android/camera/VideoCamera.java
index a2d539f..e9c3133 100644
--- a/src/com/android/camera/VideoCamera.java
+++ b/src/com/android/camera/VideoCamera.java
@@ -111,6 +111,7 @@ public class VideoCamera extends ActivityBase
CamcorderProfile.QUALITY_TIME_LAPSE_720P,
CamcorderProfile.QUALITY_TIME_LAPSE_480P,
CamcorderProfile.QUALITY_TIME_LAPSE_CIF,
+ CamcorderProfile.QUALITY_TIME_LAPSE_QVGA,
CamcorderProfile.QUALITY_TIME_LAPSE_QCIF};
private static final int[] VIDEO_QUALITY = {
@@ -118,6 +119,7 @@ public class VideoCamera extends ActivityBase
CamcorderProfile.QUALITY_720P,
CamcorderProfile.QUALITY_480P,
CamcorderProfile.QUALITY_CIF,
+ CamcorderProfile.QUALITY_QVGA,
CamcorderProfile.QUALITY_QCIF};
/**
@@ -139,6 +141,7 @@ public class VideoCamera extends ActivityBase
private ComboPreferences mPreferences;
private PreferenceGroup mPreferenceGroup;
+ private View mPreviewPanel; // The container of PreviewFrameLayout.
private PreviewFrameLayout mPreviewFrameLayout;
private SurfaceHolder mSurfaceHolder = null;
private IndicatorControlContainer mIndicatorControlContainer;
@@ -207,7 +210,6 @@ public class VideoCamera extends ActivityBase
// Default 0. If it is larger than 0, the camcorder is in time lapse mode.
private int mTimeBetweenTimeLapseFrameCaptureMs = 0;
private View mTimeLapseLabel;
- private View mPreviewBorder;
private int mDesiredPreviewWidth;
private int mDesiredPreviewHeight;
@@ -336,18 +338,7 @@ public class VideoCamera extends ActivityBase
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
- Window win = getWindow();
-
- // Overright the brightness settings if it is automatic
- int mode = Settings.System.getInt(
- getContentResolver(),
- Settings.System.SCREEN_BRIGHTNESS_MODE,
- Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL);
- if (mode == Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC) {
- WindowManager.LayoutParams winParams = win.getAttributes();
- winParams.screenBrightness = DEFAULT_CAMERA_BRIGHTNESS;
- win.setAttributes(winParams);
- }
+ Util.initializeScreenBrightness(getWindow(), getContentResolver());
mPreferences = new ComboPreferences(this);
CameraSettings.upgradeGlobalPreferences(mPreferences.getGlobal());
@@ -399,8 +390,8 @@ public class VideoCamera extends ActivityBase
mModePicker.setOnModeChangeListener(this);
}
- mPreviewFrameLayout = (PreviewFrameLayout)
- findViewById(R.id.frame_layout);
+ mPreviewPanel = findViewById(R.id.frame_layout);
+ mPreviewFrameLayout = (PreviewFrameLayout) findViewById(R.id.frame);
mReviewImage = (ImageView) findViewById(R.id.review_image);
// don't set mSurfaceHolder here. We have it set ONLY within
@@ -421,7 +412,6 @@ public class VideoCamera extends ActivityBase
mRecordingTimeView = (TextView) findViewById(R.id.recording_time);
mOrientationListener = new MyOrientationEventListener(VideoCamera.this);
mTimeLapseLabel = findViewById(R.id.time_lapse_label);
- mPreviewBorder = findViewById(R.id.preview_border);
mBgLearningMessage = (TextView) findViewById(R.id.bg_replace_message);
@@ -448,7 +438,6 @@ public class VideoCamera extends ActivityBase
mBackCameraId = CameraHolder.instance().getBackCameraId();
mFrontCameraId = CameraHolder.instance().getFrontCameraId();
- initializeZoomControl();
initializeIndicatorControl();
}
@@ -822,6 +811,10 @@ public class VideoCamera extends ActivityBase
return;
}
}
+
+ // Initializing it here after the preview is started.
+ initializeZoomControl();
+
keepScreenOnAwhile();
// install an intent filter to receive SD card related events.
@@ -2048,7 +2041,7 @@ public class VideoCamera extends ActivityBase
Uri uri = mThumbnail.getUri();
if (mSharePopup == null || !uri.equals(mSharePopup.getUri())) {
mSharePopup = new SharePopup(this, uri, mThumbnail.getBitmap(),
- mOrientationCompensation, mPreviewFrameLayout);
+ mOrientationCompensation, mPreviewPanel);
}
mSharePopup.showAtLocation(mThumbnailView, Gravity.NO_GRAVITY, 0, 0);
}
@@ -2173,13 +2166,12 @@ public class VideoCamera extends ActivityBase
private void initializeVideoSnapshot() {
if (mParameters.isVideoSnapshotSupported() && !mIsVideoCaptureIntent) {
findViewById(R.id.camera_preview).setOnTouchListener(this);
- mPreviewBorder.setBackgroundResource(R.drawable.ic_snapshot_border);
}
}
void showVideoSnapshotUI(boolean enabled) {
if (mParameters.isVideoSnapshotSupported() && !mIsVideoCaptureIntent) {
- mPreviewBorder.setVisibility(enabled ? View.VISIBLE : View.INVISIBLE);
+ mPreviewFrameLayout.showBorder(enabled);
mIndicatorControlContainer.enableZoom(!enabled);
mShutterButton.setEnabled(!enabled);
}
diff --git a/src/com/android/camera/panorama/PanoramaActivity.java b/src/com/android/camera/panorama/PanoramaActivity.java
index d459740..8126a1b 100644
--- a/src/com/android/camera/panorama/PanoramaActivity.java
+++ b/src/com/android/camera/panorama/PanoramaActivity.java
@@ -62,6 +62,7 @@ import android.util.Log;
import android.view.Gravity;
import android.view.OrientationEventListener;
import android.view.View;
+import android.view.Window;
import android.view.WindowManager;
import android.view.animation.LinearInterpolator;
import android.widget.ImageView;
@@ -211,9 +212,11 @@ public class PanoramaActivity extends Activity implements
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
- getWindow().setFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON,
+ Window window = getWindow();
+ window.setFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON,
WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
- Util.enterLightsOutMode(getWindow());
+ Util.enterLightsOutMode(window);
+ Util.initializeScreenBrightness(window, getContentResolver());
createContentView();
@@ -252,7 +255,11 @@ public class PanoramaActivity extends Activity implements
break;
case MSG_GENERATE_FINAL_MOSAIC_ERROR:
onBackgroundThreadFinished();
- mAlertDialog.show();
+ if (mPausing) {
+ resetToPreview();
+ } else {
+ mAlertDialog.show();
+ }
break;
case MSG_RESET_TO_PREVIEW:
onBackgroundThreadFinished();
diff --git a/src/com/android/camera/ui/IndicatorButton.java b/src/com/android/camera/ui/IndicatorButton.java
index 6685358..880a650 100644
--- a/src/com/android/camera/ui/IndicatorButton.java
+++ b/src/com/android/camera/ui/IndicatorButton.java
@@ -100,7 +100,7 @@ public class IndicatorButton extends AbstractIndicatorButton implements BasicSet
protected void initializePopup() {
LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(
Context.LAYOUT_INFLATER_SERVICE);
- ViewGroup root = (ViewGroup) getRootView().findViewById(R.id.frame);
+ ViewGroup root = (ViewGroup) getRootView().findViewById(R.id.frame_layout);
BasicSettingPopup popup = (BasicSettingPopup) inflater.inflate(
R.layout.basic_setting_popup, root, false);
diff --git a/src/com/android/camera/ui/OtherSettingIndicatorButton.java b/src/com/android/camera/ui/OtherSettingIndicatorButton.java
index e020f94..69d627a 100644
--- a/src/com/android/camera/ui/OtherSettingIndicatorButton.java
+++ b/src/com/android/camera/ui/OtherSettingIndicatorButton.java
@@ -53,7 +53,7 @@ public class OtherSettingIndicatorButton extends AbstractIndicatorButton {
protected void initializePopup() {
LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(
Context.LAYOUT_INFLATER_SERVICE);
- ViewGroup root = (ViewGroup) getRootView().findViewById(R.id.frame);
+ ViewGroup root = (ViewGroup) getRootView().findViewById(R.id.frame_layout);
OtherSettingsPopup popup = (OtherSettingsPopup) inflater.inflate(
R.layout.other_setting_popup, root, false);
diff --git a/src/com/android/camera/ui/SecondLevelIndicatorControlBar.java b/src/com/android/camera/ui/SecondLevelIndicatorControlBar.java
index 4b87bdc..670bbb9 100644
--- a/src/com/android/camera/ui/SecondLevelIndicatorControlBar.java
+++ b/src/com/android/camera/ui/SecondLevelIndicatorControlBar.java
@@ -108,9 +108,11 @@ public class SecondLevelIndicatorControlBar extends IndicatorControl implements
int width = right - left;
int height = bottom - top;
int h = height / count;
+
+ // TODO: follow the redlines of UI design in next change. The icons are
+ // simply distributed on the bar equally with current implmentation.
for (int i = 0; i < count; i++) {
- getChildAt(i).layout(0, top + i * height / count, width,
- top + i * height / count + h);
+ getChildAt(i).layout(0, i * h, width, (i + 1) * h);
}
}