summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--res/layout/camera_controls.xml1
-rw-r--r--res/layout/capture_module.xml4
-rw-r--r--res/layout/photo_module.xml2
-rw-r--r--res/layout/review_module_control.xml (renamed from res/layout-port/review_module_control.xml)34
-rw-r--r--src/com/android/camera/CameraSettings.java2
-rw-r--r--src/com/android/camera/FocusOverlayManager.java2
-rw-r--r--src/com/android/camera/PhotoModule.java6
-rw-r--r--src/com/android/camera/PhotoUI.java19
-rw-r--r--src/com/android/camera/VideoModule.java32
-rw-r--r--src/com/android/camera/ui/AutoFitSurfaceView.java76
-rw-r--r--src/com/android/camera/ui/CameraControls.java28
-rw-r--r--src/com/android/camera/ui/ModuleSwitcher.java2
-rw-r--r--src/com/android/camera/ui/RotateImageView.java32
13 files changed, 193 insertions, 47 deletions
diff --git a/res/layout/camera_controls.xml b/res/layout/camera_controls.xml
index 66519d41c..c1def502f 100644
--- a/res/layout/camera_controls.xml
+++ b/res/layout/camera_controls.xml
@@ -50,6 +50,7 @@
style="@style/SwitcherButton"
android:layout_gravity="bottom|left"
android:layout_marginBottom="2dip"
+ android:scaleType="center"
android:contentDescription="@string/accessibility_mode_picker" />
<com.android.camera.ShutterButton
diff --git a/res/layout/capture_module.xml b/res/layout/capture_module.xml
index 02c32acab..a68af5e08 100644
--- a/res/layout/capture_module.xml
+++ b/res/layout/capture_module.xml
@@ -33,12 +33,12 @@
android:layout_height="match_parent"
android:layout_gravity="center_vertical|center_horizontal">
- <SurfaceView
+ <com.android.camera.ui.AutoFitSurfaceView
android:id="@+id/mdp_preview_content"
android:layout_width="match_parent"
android:layout_height="match_parent" />
- <SurfaceView
+ <com.android.camera.ui.AutoFitSurfaceView
android:id="@+id/mdp_preview_content2"
android:layout_width="300dp"
android:layout_height="300dp" />
diff --git a/res/layout/photo_module.xml b/res/layout/photo_module.xml
index 9c5b2c0d0..2e3fb8aa0 100644
--- a/res/layout/photo_module.xml
+++ b/res/layout/photo_module.xml
@@ -68,7 +68,7 @@
android:layout_marginTop="50dip"
android:layout_marginLeft="15dip" />
</RelativeLayout>
- <ImageView
+ <com.android.camera.ui.RotateImageView
android:id="@+id/review_image"
android:layout_width="match_parent"
android:layout_height="match_parent"
diff --git a/res/layout-port/review_module_control.xml b/res/layout/review_module_control.xml
index 3c4280ed2..8280b3101 100644
--- a/res/layout-port/review_module_control.xml
+++ b/res/layout/review_module_control.xml
@@ -18,16 +18,16 @@
style="@style/CameraControls"
android:layout_gravity="bottom|center_horizontal"
android:layout_marginBottom="2dip">
- <ImageView android:id="@+id/btn_done"
- style="@style/ReviewControlIcon"
- android:contentDescription="@string/accessibility_review_ok"
- android:visibility="gone"
- android:scaleType="center"
- android:layout_gravity="right|bottom"
- android:background="@drawable/bg_pressed"
- android:src="@drawable/ic_menu_done_holo_light" />
+ <com.android.camera.ui.RotateImageView android:id="@+id/btn_done"
+ style="@style/ReviewControlIcon"
+ android:contentDescription="@string/accessibility_review_ok"
+ android:visibility="gone"
+ android:scaleType="center"
+ android:layout_gravity="right|bottom"
+ android:background="@drawable/bg_pressed"
+ android:src="@drawable/ic_menu_done_holo_light" />
- <ImageView android:id="@+id/btn_retake"
+ <com.android.camera.ui.RotateImageView android:id="@+id/btn_retake"
style="@style/ReviewControlIcon"
android:contentDescription="@string/accessibility_review_retake"
android:layout_gravity="bottom|center_horizontal"
@@ -37,12 +37,12 @@
android:background="@drawable/bg_pressed"
android:src="@drawable/ic_btn_shutter_retake" />
- <ImageView android:id="@+id/btn_cancel"
- style="@style/ReviewControlIcon"
- android:contentDescription="@string/accessibility_review_cancel"
- android:visibility="gone"
- android:scaleType="center"
- android:layout_gravity="left|bottom"
- android:background="@drawable/bg_pressed"
- android:src="@drawable/ic_menu_cancel_holo_light" />
+ <com.android.camera.ui.RotateImageView android:id="@+id/btn_cancel"
+ style="@style/ReviewControlIcon"
+ android:contentDescription="@string/accessibility_review_cancel"
+ android:visibility="gone"
+ android:scaleType="center"
+ android:layout_gravity="left|bottom"
+ android:background="@drawable/bg_pressed"
+ android:src="@drawable/ic_menu_cancel_holo_light" />
</com.android.camera.ui.RotatableLayout>
diff --git a/src/com/android/camera/CameraSettings.java b/src/com/android/camera/CameraSettings.java
index 5ce385844..a12ce5de0 100644
--- a/src/com/android/camera/CameraSettings.java
+++ b/src/com/android/camera/CameraSettings.java
@@ -282,7 +282,7 @@ public class CameraSettings {
//video encoders
VIDEO_ENCODER_TABLE.put(MediaRecorder.VideoEncoder.H263, "h263");
VIDEO_ENCODER_TABLE.put(MediaRecorder.VideoEncoder.H264, "h264");
- VIDEO_ENCODER_TABLE.put(MediaRecorder.VideoEncoder.H265, "h265");
+ // VIDEO_ENCODER_TABLE.put(MediaRecorder.VideoEncoder.H265, "h265");
VIDEO_ENCODER_TABLE.put(MediaRecorder.VideoEncoder.MPEG_4_SP, "m4v");
//video qualities
diff --git a/src/com/android/camera/FocusOverlayManager.java b/src/com/android/camera/FocusOverlayManager.java
index c5ffef5c5..23b31b14d 100644
--- a/src/com/android/camera/FocusOverlayManager.java
+++ b/src/com/android/camera/FocusOverlayManager.java
@@ -373,7 +373,7 @@ public class FocusOverlayManager {
UsageStatistics.ACTION_TOUCH_FOCUS, x + "," + y);
// Let users be able to cancel previous touch focus.
- if ((mFocusArea != null) && (mState == STATE_FOCUSING ||
+ if ((mState == STATE_FOCUSING ||
mState == STATE_SUCCESS || mState == STATE_FAIL)) {
cancelAutoFocus();
}
diff --git a/src/com/android/camera/PhotoModule.java b/src/com/android/camera/PhotoModule.java
index 4d2ec6ad8..7324484ae 100644
--- a/src/com/android/camera/PhotoModule.java
+++ b/src/com/android/camera/PhotoModule.java
@@ -2360,7 +2360,11 @@ public class PhotoModule
mParameters = mCameraDevice.getParameters();
mCameraPreviewParamsReady = true;
mInitialParams = mParameters;
- if (mFocusManager == null) initializeFocusManager();
+ if (mFocusManager == null) {
+ initializeFocusManager();
+ } else {
+ mFocusManager.setParameters(mInitialParams);
+ }
initializeCapabilities();
mHandler.sendEmptyMessageDelayed(CAMERA_OPEN_DONE, 100);
return;
diff --git a/src/com/android/camera/PhotoUI.java b/src/com/android/camera/PhotoUI.java
index c8e01fea0..250f265b2 100644
--- a/src/com/android/camera/PhotoUI.java
+++ b/src/com/android/camera/PhotoUI.java
@@ -156,6 +156,7 @@ public class PhotoUI implements PieListener,
private int mScreenRatio = CameraUtil.RATIO_UNKNOWN;
private int mTopMargin = 0;
private int mBottomMargin = 0;
+ private boolean mIsLayoutInitializedAlready = false;
private int mOrientation;
private float mScreenBrightness = 0.0f;
@@ -260,7 +261,7 @@ public class PhotoUI implements PieListener,
}
if (mOrientationResize != mPrevOrientationResize
- || mAspectRatioResize) {
+ || mAspectRatioResize || !mIsLayoutInitializedAlready) {
layoutPreview(mAspectRatio);
mAspectRatioResize = false;
}
@@ -333,8 +334,10 @@ public class PhotoUI implements PieListener,
mMenuHelp.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
- mMenuHelp.setVisibility(View.GONE);
- mMenuHelp = null;
+ if (mMenuHelp != null) {
+ mMenuHelp.setVisibility(View.GONE);
+ mMenuHelp = null;
+ }
}
});
}
@@ -459,6 +462,7 @@ public class PhotoUI implements PieListener,
if (mFaceView != null) {
mFaceView.setLayoutParams(lp);
}
+ mIsLayoutInitializedAlready = true;
}
public void setSurfaceTextureSizeChangedListener(SurfaceTextureSizeChangedListener listener) {
@@ -984,7 +988,10 @@ public class PhotoUI implements PieListener,
}
public boolean sendTouchToPreviewMenu(MotionEvent ev) {
- return mPreviewMenuLayout.dispatchTouchEvent(ev);
+ if (mPreviewMenuLayout != null) {
+ return mPreviewMenuLayout.dispatchTouchEvent(ev);
+ }
+ return false;
}
public boolean sendTouchToMenu(MotionEvent ev) {
@@ -1400,6 +1407,10 @@ public class PhotoUI implements PieListener,
if (mZoomRenderer != null) {
mZoomRenderer.setOrientation(orientation);
}
+ if (mReviewImage != null) {
+ RotateImageView v = (RotateImageView) mReviewImage;
+ v.setOrientation(orientation, animation);
+ }
}
public void tryToCloseSubList() {
diff --git a/src/com/android/camera/VideoModule.java b/src/com/android/camera/VideoModule.java
index 31dd1e92c..f8d79ed00 100644
--- a/src/com/android/camera/VideoModule.java
+++ b/src/com/android/camera/VideoModule.java
@@ -315,7 +315,7 @@ public class VideoModule implements CameraModule,
VIDEO_ENCODER_TABLE.put("h263", MediaRecorder.VideoEncoder.H263);
VIDEO_ENCODER_TABLE.put("h264", MediaRecorder.VideoEncoder.H264);
- VIDEO_ENCODER_TABLE.put("h265", MediaRecorder.VideoEncoder.H265);
+ // VIDEO_ENCODER_TABLE.put("h265", MediaRecorder.VideoEncoder.H265);
VIDEO_ENCODER_TABLE.put("m4v", MediaRecorder.VideoEncoder.MPEG_4_SP);
VIDEO_ENCODER_TABLE.putDefault(MediaRecorder.VideoEncoder.DEFAULT);
@@ -1731,13 +1731,27 @@ public class VideoModule implements CameraModule,
* Make sure we're not recording music playing in the background, ask the
* MediaPlaybackService to pause playback.
*/
- private void pauseAudioPlayback() {
- // Shamelessly copied from MediaPlaybackService.java, which
- // should be public, but isn't.
- Intent i = new Intent("com.android.music.musicservicecommand");
- i.putExtra("command", "pause");
+ private void requestAudioFocus() {
+ AudioManager am = (AudioManager)mActivity.getSystemService(Context.AUDIO_SERVICE);
+
+ // Send request to obtain audio focus. This will stop other
+ // music stream.
+ int result = am.requestAudioFocus(null, AudioManager.STREAM_MUSIC,
+ AudioManager.AUDIOFOCUS_GAIN_TRANSIENT);
+
+ if (result == AudioManager.AUDIOFOCUS_REQUEST_FAILED) {
+ Log.v(TAG, "Audio focus request failed");
+ }
+ }
- mActivity.sendBroadcast(i);
+ private void releaseAudioFocus() {
+ AudioManager am = (AudioManager)mActivity.getSystemService(Context.AUDIO_SERVICE);
+
+ int result = am.abandonAudioFocus(null);
+
+ if (result == AudioManager.AUDIOFOCUS_REQUEST_FAILED) {
+ Log.v(TAG, "Audio focus release failed");
+ }
}
// For testing.
@@ -1805,13 +1819,14 @@ public class VideoModule implements CameraModule,
return false;
}
- pauseAudioPlayback();
+ requestAudioFocus();
try {
mMediaRecorder.start(); // Recording is now started
} catch (RuntimeException e) {
Toast.makeText(mActivity,"Could not start media recorder.\n Can't start video recording.", Toast.LENGTH_LONG).show();
releaseMediaRecorder();
+ releaseAudioFocus();
// If start fails, frameworks will not lock the camera for us.
mCameraDevice.lock();
mStartRecPending = false;
@@ -1962,6 +1977,7 @@ public class VideoModule implements CameraModule,
}
// release media recorder
releaseMediaRecorder();
+ releaseAudioFocus();
if (!mPaused) {
mCameraDevice.lock();
if (!ApiHelper.HAS_SURFACE_TEXTURE_RECORDING) {
diff --git a/src/com/android/camera/ui/AutoFitSurfaceView.java b/src/com/android/camera/ui/AutoFitSurfaceView.java
new file mode 100644
index 000000000..38be39cf9
--- /dev/null
+++ b/src/com/android/camera/ui/AutoFitSurfaceView.java
@@ -0,0 +1,76 @@
+/*
+ * Copyright 2014 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.SurfaceView;
+
+/**
+ * A {@link SurfaceView} that can be adjusted to a specified aspect ratio.
+ */
+public class AutoFitSurfaceView extends SurfaceView {
+
+ private int mRatioWidth = 0;
+ private int mRatioHeight = 0;
+
+ public AutoFitSurfaceView(Context context) {
+ this(context, null);
+ }
+
+ public AutoFitSurfaceView(Context context, AttributeSet attrs) {
+ this(context, attrs, 0);
+ }
+
+ public AutoFitSurfaceView(Context context, AttributeSet attrs, int defStyle) {
+ super(context, attrs, defStyle);
+ }
+
+ /**
+ * Sets the aspect ratio for this view. The size of the view will be measured based on the ratio
+ * calculated from the parameters. Note that the actual sizes of parameters don't matter, that
+ * is, calling setAspectRatio(2, 3) and setAspectRatio(4, 6) make the same result.
+ *
+ * @param width Relative horizontal size
+ * @param height Relative vertical size
+ */
+ public void setAspectRatio(int width, int height) {
+ if (width < 0 || height < 0) {
+ throw new IllegalArgumentException("Size cannot be negative.");
+ }
+ mRatioWidth = width;
+ mRatioHeight = height;
+ requestLayout();
+ }
+
+ @Override
+ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
+ super.onMeasure(widthMeasureSpec, heightMeasureSpec);
+ int width = MeasureSpec.getSize(widthMeasureSpec);
+ int height = MeasureSpec.getSize(heightMeasureSpec);
+ if (0 == mRatioWidth || 0 == mRatioHeight) {
+ setMeasuredDimension(width, height);
+ } else {
+ if (width < height * mRatioWidth / mRatioHeight) {
+ setMeasuredDimension(width, width * mRatioHeight / mRatioWidth);
+ } else {
+ setMeasuredDimension(height * mRatioWidth / mRatioHeight, height);
+ }
+ }
+ }
+
+}
diff --git a/src/com/android/camera/ui/CameraControls.java b/src/com/android/camera/ui/CameraControls.java
index 989568953..9f2a5ebb8 100644
--- a/src/com/android/camera/ui/CameraControls.java
+++ b/src/com/android/camera/ui/CameraControls.java
@@ -61,6 +61,9 @@ public class CameraControls extends RotatableLayout {
private View mPreview;
private View mSceneModeSwitcher;
private View mFilterModeSwitcher;
+ private View mReviewDoneButton;
+ private View mReviewCancelButton;
+ private View mReviewRetakeButton;
private ArrowTextView mRefocusToast;
private int mSize;
@@ -314,13 +317,18 @@ public class CameraControls extends RotatableLayout {
View retake = findViewById(R.id.btn_retake);
if (retake != null) {
- center(retake, shutter, rotation);
- View cancel = findViewById(R.id.btn_cancel);
- toLeft(cancel, shutter, rotation);
- View done = findViewById(R.id.btn_done);
- toRight(done, shutter, rotation);
- }
+ mReviewRetakeButton = retake;
+ mReviewCancelButton = findViewById(R.id.btn_cancel);
+ mReviewDoneButton = findViewById(R.id.btn_done);
+ center(mReviewRetakeButton, shutter, rotation);
+ toLeft(mReviewCancelButton, shutter, rotation);
+ toRight(mReviewDoneButton, shutter, rotation);
+ } else {
+ mReviewRetakeButton = null;
+ mReviewCancelButton = null;
+ mReviewDoneButton = null;
+ }
layoutRemaingPhotos();
}
@@ -972,10 +980,14 @@ public class CameraControls extends RotatableLayout {
View[] views = {
mSceneModeSwitcher, mFilterModeSwitcher, mFrontBackSwitcher,
TsMakeupManager.HAS_TS_MAKEUP ? mTsMakeupSwitcher : mHdrSwitcher,
- mMenu, mShutter, mPreview, mSwitcher, mMute
+ mMenu, mShutter, mPreview, mSwitcher, mMute, mReviewRetakeButton,
+ mReviewCancelButton, mReviewDoneButton
};
for (View v : views) {
- ((RotateImageView) v).setOrientation(orientation, animation);
+ if (v != null) {
+ ((RotateImageView) v).setOrientation(orientation,
+ animation);
+ }
}
layoutRemaingPhotos();
}
diff --git a/src/com/android/camera/ui/ModuleSwitcher.java b/src/com/android/camera/ui/ModuleSwitcher.java
index 189342a1b..603f81d4d 100644
--- a/src/com/android/camera/ui/ModuleSwitcher.java
+++ b/src/com/android/camera/ui/ModuleSwitcher.java
@@ -33,6 +33,7 @@ import android.view.View.OnTouchListener;
import android.view.ViewGroup;
import android.widget.FrameLayout.LayoutParams;
import android.widget.LinearLayout;
+import android.widget.ImageView;
import com.android.camera.util.CameraUtil;
import com.android.camera.util.GcamHelper;
@@ -203,6 +204,7 @@ public class ModuleSwitcher extends RotateImageView
for (int i = mDrawIds.length - 1; i >= 0; i--) {
RotateImageView item = new RotateImageView(getContext());
item.setImageResource(mDrawIds[i]);
+ item.setScaleType(ImageView.ScaleType.CENTER);
item.setBackgroundResource(R.drawable.bg_pressed);
final int index = i;
item.setOnClickListener(new OnClickListener() {
diff --git a/src/com/android/camera/ui/RotateImageView.java b/src/com/android/camera/ui/RotateImageView.java
index 05e1a7c5b..a8065c0a3 100644
--- a/src/com/android/camera/ui/RotateImageView.java
+++ b/src/com/android/camera/ui/RotateImageView.java
@@ -16,6 +16,7 @@
package com.android.camera.ui;
+import android.app.Activity;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
@@ -28,6 +29,7 @@ import android.util.AttributeSet;
import android.view.ViewGroup.LayoutParams;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;
+import com.android.camera.util.CameraUtil;
/**
* A @{code ImageView} which can rotate it's content.
@@ -47,6 +49,8 @@ public class RotateImageView extends TwoStateImageView implements Rotatable {
private long mAnimationStartTime = 0;
private long mAnimationEndTime = 0;
+ private boolean mNaturalPortrait = CameraUtil.isDefaultToPortrait(
+ (Activity) getContext());
public RotateImageView(Context context, AttributeSet attrs) {
super(context, attrs);
@@ -60,6 +64,19 @@ public class RotateImageView extends TwoStateImageView implements Rotatable {
return mTargetDegree;
}
+ private boolean isOrientationPortrait() {
+ int mapTo180Degree = (mCurrentDegree % 180);
+
+ // Assumging the devic's natural orientation is portrait and
+ // check if the current orienataion is within the landscape range
+ boolean isLandscape = ((mapTo180Degree > 45) &&
+ (mapTo180Degree < 135));
+ if (mNaturalPortrait)
+ return !isLandscape;
+ else
+ return isLandscape;
+ }
+
// Rotate the view counter-clockwise
@Override
public void setOrientation(int degree, boolean animation) {
@@ -124,10 +141,17 @@ public class RotateImageView extends TwoStateImageView implements Rotatable {
int saveCount = canvas.getSaveCount();
- // Scale down the image first if required.
- if ((getScaleType() == ImageView.ScaleType.FIT_CENTER) &&
- ((width < w) || (height < h))) {
- float ratio = Math.min((float) width / w, (float) height / h);
+ // Scale down or up the image first if required.
+ if (getScaleType() == ImageView.ScaleType.FIT_CENTER) {
+ float ratio;
+
+ // As camera layout is fixed to portrait, we need to
+ // swap canvas width and height when calculating the
+ // ratio for landscape mode.
+ if (isOrientationPortrait())
+ ratio = Math.min((float) width / w, (float) height / h);
+ else
+ ratio = Math.min((float) height / w, (float) width / h);
canvas.scale(ratio, ratio, width / 2.0f, height / 2.0f);
}
canvas.translate(left + width / 2, top + height / 2);