summaryrefslogtreecommitdiffstats
path: root/src/com/android/camera/PhotoUI.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/camera/PhotoUI.java')
-rwxr-xr-xsrc/com/android/camera/PhotoUI.java192
1 files changed, 31 insertions, 161 deletions
diff --git a/src/com/android/camera/PhotoUI.java b/src/com/android/camera/PhotoUI.java
index 50b5f64fe..806a68bad 100755
--- a/src/com/android/camera/PhotoUI.java
+++ b/src/com/android/camera/PhotoUI.java
@@ -58,7 +58,6 @@ import android.widget.PopupWindow;
import android.widget.Toast;
import com.android.camera.CameraPreference.OnPreferenceChangedListener;
-import com.android.camera.FocusOverlayManager.FocusUI;
import com.android.camera.TsMakeupManager.MakeupLevelListener;
import com.android.camera.ui.AbstractSettingPopup;
import com.android.camera.ui.CameraControls;
@@ -66,10 +65,8 @@ import com.android.camera.ui.CameraRootView;
import com.android.camera.ui.CountDownView;
import com.android.camera.ui.CountDownView.OnCountDownFinishedListener;
import com.android.camera.ui.FaceView;
-import com.android.camera.ui.FocusIndicator;
import com.android.camera.ui.ListSubMenu;
import com.android.camera.ui.ModuleSwitcher;
-import com.android.camera.ui.MenuHelp;
import com.android.camera.ui.PieRenderer;
import com.android.camera.ui.PieRenderer.PieListener;
import com.android.camera.ui.RenderOverlay;
@@ -78,11 +75,11 @@ import com.android.camera.ui.RotateLayout;
import com.android.camera.ui.RotateTextToast;
import com.android.camera.ui.SelfieFlashView;
import com.android.camera.ui.ZoomRenderer;
+import com.android.camera.ui.focus.FocusRing;
import com.android.camera.util.CameraUtil;
public class PhotoUI implements PieListener,
PreviewGestures.SingleTapListener,
- FocusUI,
SurfaceHolder.Callback,
CameraRootView.MyDisplayListener,
CameraManager.CameraFaceDetectionCallback {
@@ -90,6 +87,7 @@ public class PhotoUI implements PieListener,
private static final String TAG = "CAM_UI";
private int mDownSampleFactor = 4;
private final AnimationManager mAnimationManager;
+ private final FocusRing mFocusRing;
private CameraActivity mActivity;
private PhotoController mController;
private PreviewGestures mGestures;
@@ -114,12 +112,8 @@ public class PhotoUI implements PieListener,
private PhotoMenu mMenu;
private ModuleSwitcher mSwitcher;
private CameraControls mCameraControls;
- private MenuHelp mMenuHelp;
private AlertDialog mLocationDialog;
- // Small indicators which show the camera settings in the viewfinder.
- private OnScreenIndicators mOnScreenIndicators;
-
private PieRenderer mPieRenderer;
private ZoomRenderer mZoomRenderer;
private RotateTextToast mNotSelectableToast;
@@ -296,17 +290,16 @@ public class PhotoUI implements PieListener,
mFaceView = (FaceView) mRootView.findViewById(R.id.face_view);
setSurfaceTextureSizeChangedListener(mFaceView);
}
- initIndicators();
+ mFocusRing = (FocusRing) mRootView.findViewById(R.id.focus_ring);
mAnimationManager = new AnimationManager();
mOrientationResize = false;
mPrevOrientationResize = false;
Point size = new Point();
- mActivity.getWindowManager().getDefaultDisplay().getSize(size);
+ mActivity.getWindowManager().getDefaultDisplay().getRealSize(size);
mScreenRatio = CameraUtil.determineRatio(size.x, size.y);
calculateMargins(size);
mCameraControls.setMargins(mTopMargin, mBottomMargin);
- showFirstTimeHelp();
}
private void calculateMargins(Point size) {
@@ -326,27 +319,10 @@ public class PhotoUI implements PieListener,
mOrientationResize = orientation;
}
- private void showFirstTimeHelp(int topMargin, int bottomMargin) {
- mMenuHelp = (MenuHelp) mRootView.findViewById(R.id.menu_help);
- mMenuHelp.setVisibility(View.VISIBLE);
- mMenuHelp.setMargins(topMargin, bottomMargin);
- mMenuHelp.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- if (mMenuHelp != null) {
- mMenuHelp.setVisibility(View.GONE);
- mMenuHelp = null;
- }
- }
- });
- }
-
public void setAspectRatio(float ratio) {
if (ratio <= 0.0) throw new IllegalArgumentException();
- if (mOrientationResize &&
- mActivity.getResources().getConfiguration().orientation
- != Configuration.ORIENTATION_PORTRAIT) {
+ if (mOrientationResize && CameraUtil.isScreenRotated(mActivity)) {
ratio = 1 / ratio;
}
@@ -363,6 +339,9 @@ public class PhotoUI implements PieListener,
FrameLayout.LayoutParams lp;
float scaledTextureWidth, scaledTextureHeight;
int rotation = CameraUtil.getDisplayRotation(mActivity);
+ if (!CameraUtil.isDefaultToPortrait(mActivity)) {
+ rotation = (rotation - 90) % 360;
+ }
mScreenRatio = CameraUtil.determineRatio(ratio);
if (mScreenRatio == CameraUtil.RATIO_16_9
&& CameraUtil.determinCloseRatio(ratio) == CameraUtil.RATIO_4_3) {
@@ -397,8 +376,13 @@ public class PhotoUI implements PieListener,
} else {
float width = mMaxPreviewWidth, height = mMaxPreviewHeight;
if (width == 0 || height == 0) return;
- if(mScreenRatio == CameraUtil.RATIO_4_3)
- height -= (mTopMargin + mBottomMargin);
+ if (mScreenRatio == CameraUtil.RATIO_4_3) {
+ if (height > width) {
+ height -= (mTopMargin + mBottomMargin);
+ } else {
+ width -= (mTopMargin + mBottomMargin);
+ }
+ }
if (mOrientationResize) {
scaledTextureWidth = height * mAspectRatio;
if (scaledTextureWidth > width) {
@@ -497,11 +481,6 @@ public class PhotoUI implements PieListener,
return mRootView;
}
- private void initIndicators() {
- mOnScreenIndicators = new OnScreenIndicators(mActivity,
- mRootView.findViewById(R.id.on_screen_indicators));
- }
-
public void onCameraOpened(PreferenceGroup prefGroup, ComboPreferences prefs,
Camera.Parameters params, OnPreferenceChangedListener listener, MakeupLevelListener makeupListener) {
if (mPieRenderer == null) {
@@ -534,7 +513,6 @@ public class PhotoUI implements PieListener,
mRenderOverlay.requestLayout();
initializeZoom(params);
- updateOnScreenIndicators(params, prefGroup, prefs);
mActivity.setPreviewGestures(mGestures);
}
@@ -565,8 +543,9 @@ public class PhotoUI implements PieListener,
@Override
public void onClick(View v) {
if (!CameraControls.isAnimating()
- && mController.getCameraState() != PhotoController.SNAPSHOT_IN_PROGRESS)
+ && mController.getCameraState() != PhotoController.SNAPSHOT_IN_PROGRESS) {
mActivity.gotoGallery();
+ }
}
});
}
@@ -652,29 +631,11 @@ public class PhotoUI implements PieListener,
// called from onResume but only the first time
public void initializeFirstTime() {
// Initialize shutter button.
- mShutterButton.setImageResource(R.drawable.shutter_button_anim);
- mShutterButton.setOnClickListener(new OnClickListener()
- {
- @Override
- public void onClick(View v) {
- if (!CameraControls.isAnimating())
- doShutterAnimation();
- if (mController.isImageCaptureIntent()) {
- mCameraControls.setTitleBarVisibility(View.VISIBLE);
- }
- }
- });
-
+ mShutterButton.setImageResource(R.drawable.btn_new_shutter);
mShutterButton.setOnShutterButtonListener(mController);
mShutterButton.setVisibility(View.VISIBLE);
}
- public void doShutterAnimation() {
- AnimationDrawable frameAnimation = (AnimationDrawable) mShutterButton.getDrawable();
- frameAnimation.stop();
- frameAnimation.start();
- }
-
// called from onResume every other time
public void initializeSecondTime(Camera.Parameters params) {
initializeZoom(params);
@@ -709,29 +670,6 @@ public class PhotoUI implements PieListener,
mMenu.overrideSettings(keyvalues);
}
- public void updateOnScreenIndicators(Camera.Parameters params,
- PreferenceGroup group, ComboPreferences prefs) {
- if (params == null || group == null) return;
- mOnScreenIndicators.updateSceneOnScreenIndicator(params.getSceneMode());
- mOnScreenIndicators.updateExposureOnScreenIndicator(params,
- CameraSettings.readExposure(prefs));
- mOnScreenIndicators.updateFlashOnScreenIndicator(params.getFlashMode());
- int wbIndex = -1;
- String wb = Camera.Parameters.WHITE_BALANCE_AUTO;
- if (Camera.Parameters.SCENE_MODE_AUTO.equals(params.getSceneMode())) {
- wb = params.getWhiteBalance();
- }
- ListPreference pref = group.findPreference(CameraSettings.KEY_WHITE_BALANCE);
- if (pref != null) {
- wbIndex = pref.findIndexOfValue(wb);
- }
- // make sure the correct value was found
- // otherwise use auto index
- mOnScreenIndicators.updateWBIndicator(wbIndex < 0 ? 2 : wbIndex);
- boolean location = RecordLocationPreference.get(prefs, CameraSettings.KEY_RECORD_LOCATION);
- mOnScreenIndicators.updateLocationIndicator(location);
- }
-
public void setCameraState(int state) {
}
@@ -796,7 +734,6 @@ public class PhotoUI implements PieListener,
if (mPieRenderer != null) {
mPieRenderer.setBlockFocus(!previewFocused);
}
- setShowMenu(previewFocused);
if (!previewFocused && mCountDownView != null) mCountDownView.cancelCountDown();
}
@@ -876,8 +813,9 @@ public class PhotoUI implements PieListener,
mMenu.animateSlideIn(mMenuLayout, CameraActivity.SETTING_LIST_WIDTH_1, true);
if (level == 2)
mMenu.animateFadeIn(popup);
- } else
- popup.setAlpha(0.85f);
+ } else {
+ popup.setAlpha(1f);
+ }
}
public void removeLevel2() {
@@ -983,12 +921,6 @@ public class PhotoUI implements PieListener,
}
}
- private void setShowMenu(boolean show) {
- if (mOnScreenIndicators != null) {
- mOnScreenIndicators.setVisibility(show ? View.VISIBLE : View.GONE);
- }
- }
-
public boolean collapseCameraControls() {
// TODO: Mode switcher should behave like a popup and should hide itself when there
// is a touch outside of it.
@@ -1011,14 +943,12 @@ public class PhotoUI implements PieListener,
mCameraControls.hideCameraSettings();
mDecodeTaskForReview = new DecodeImageForReview(jpegData, orientation, mirror);
mDecodeTaskForReview.execute();
- mOnScreenIndicators.setVisibility(View.GONE);
mMenuButton.setVisibility(View.GONE);
CameraUtil.fadeIn(mReviewDoneButton);
mShutterButton.setVisibility(View.INVISIBLE);
CameraUtil.fadeIn(mReviewRetakeButton);
setOrientation(mOrientation, true);
mMenu.hideTopMenu(true);
- pauseFaceDetection();
}
protected void hidePostCaptureAlert() {
@@ -1027,7 +957,6 @@ public class PhotoUI implements PieListener,
mDecodeTaskForReview.cancel(true);
}
mReviewImage.setVisibility(View.GONE);
- mOnScreenIndicators.setVisibility(View.VISIBLE);
mMenuButton.setVisibility(View.VISIBLE);
if (mMenu != null) {
mMenu.hideTopMenu(false);
@@ -1035,7 +964,6 @@ public class PhotoUI implements PieListener,
CameraUtil.fadeOut(mReviewDoneButton);
mShutterButton.setVisibility(View.VISIBLE);
CameraUtil.fadeOut(mReviewRetakeButton);
- resumeFaceDetection();
}
public void setDisplayOrientation(int orientation) {
@@ -1242,61 +1170,8 @@ public class PhotoUI implements PieListener,
((CameraRootView) mRootView).removeDisplayChangeListener();
}
- // focus UI implementation
-
- private FocusIndicator getFocusIndicator() {
- return (mFaceView != null && mFaceView.faceExists()) ? mFaceView : mPieRenderer;
- }
-
- @Override
- public boolean hasFaces() {
- return (mFaceView != null && mFaceView.faceExists());
- }
-
- public void clearFaces() {
- if (mFaceView != null) mFaceView.clear();
- }
-
- @Override
- public void clearFocus() {
- FocusIndicator indicator = mPieRenderer;
- if (hasFaces()) {
- mFaceView.showStart();
- }
- if (indicator != null) indicator.clear();
- }
-
- @Override
- public void setFocusPosition(int x, int y) {
- mPieRenderer.setFocus(x, y);
- }
-
- @Override
- public void onFocusStarted() {
- FocusIndicator indicator = getFocusIndicator();
- if (indicator != null) indicator.showStart();
- }
-
- @Override
- public void onFocusSucceeded(boolean timeout) {
- FocusIndicator indicator = getFocusIndicator();
- if (indicator != null) indicator.showSuccess(timeout);
- }
-
- @Override
- public void onFocusFailed(boolean timeout) {
- FocusIndicator indicator = getFocusIndicator();
- if (indicator != null) indicator.showFail(timeout);
- }
-
- @Override
- public void pauseFaceDetection() {
- if (mFaceView != null) mFaceView.pause();
- }
-
- @Override
- public void resumeFaceDetection() {
- if (mFaceView != null) mFaceView.resume();
+ public FocusRing getFocusRing() {
+ return mFocusRing;
}
public void onStartFaceDetection(int orientation, boolean mirror) {
@@ -1320,6 +1195,13 @@ public class PhotoUI implements PieListener,
mFaceView.setFaces(faces);
}
+ public boolean onScaleStepResize(boolean direction) {
+ if (mGestures != null) {
+ return mGestures.onScaleStepResize(direction);
+ }
+ return false;
+ }
+
@Override
public void onDisplayChanged() {
Log.d(TAG, "Device flip detected.");
@@ -1338,8 +1220,6 @@ public class PhotoUI implements PieListener,
public void setOrientation(int orientation, boolean animation) {
mOrientation = orientation;
mCameraControls.setOrientation(orientation, animation);
- if (mMenuHelp != null)
- mMenuHelp.setOrientation(orientation, animation);
if (mMenuLayout != null)
mMenuLayout.setOrientation(orientation, animation);
if (mSubMenuLayout != null)
@@ -1389,6 +1269,7 @@ public class PhotoUI implements PieListener,
RotateImageView v = (RotateImageView) mReviewImage;
v.setOrientation(orientation, animation);
}
+ mOrientation = orientation;
}
public void tryToCloseSubList() {
@@ -1404,17 +1285,6 @@ public class PhotoUI implements PieListener,
setOrientation(mOrientation, true);
}
- public void showFirstTimeHelp() {
- final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(mActivity);
- boolean isMenuShown = prefs.getBoolean(CameraSettings.KEY_SHOW_MENU_HELP, false);
- if(!isMenuShown) {
- showFirstTimeHelp(mTopMargin, mBottomMargin);
- SharedPreferences.Editor editor = prefs.edit();
- editor.putBoolean(CameraSettings.KEY_SHOW_MENU_HELP, true);
- editor.apply();
- }
- }
-
public void showRefocusDialog() {
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(mActivity);
int prompt = prefs.getInt(CameraSettings.KEY_REFOCUS_PROMPT, 1);