diff options
Diffstat (limited to 'src/com/android/camera/PhotoUI.java')
-rw-r--r-- | src/com/android/camera/PhotoUI.java | 187 |
1 files changed, 175 insertions, 12 deletions
diff --git a/src/com/android/camera/PhotoUI.java b/src/com/android/camera/PhotoUI.java index eb077c3b2..238be864a 100644 --- a/src/com/android/camera/PhotoUI.java +++ b/src/com/android/camera/PhotoUI.java @@ -17,6 +17,8 @@ package com.android.camera; +import java.util.List; + import android.app.AlertDialog; import android.content.DialogInterface; import android.content.res.Configuration; @@ -32,15 +34,20 @@ import android.os.AsyncTask; import android.util.Log; import android.view.Gravity; import android.view.TextureView; +import android.view.MotionEvent; import android.view.View; import android.view.View.OnClickListener; import android.view.View.OnLayoutChangeListener; import android.view.ViewGroup; +import android.view.ViewPropertyAnimator; import android.view.ViewStub; import android.widget.FrameLayout.LayoutParams; import android.widget.ImageView; +import android.widget.LinearLayout; +import android.widget.ListView; import android.widget.PopupWindow; import android.widget.Toast; +import android.graphics.drawable.AnimationDrawable; import com.android.camera.CameraPreference.OnPreferenceChangedListener; import com.android.camera.FocusOverlayManager.FocusUI; @@ -59,8 +66,6 @@ import com.android.camera.ui.ZoomRenderer; import com.android.camera.util.CameraUtil; import org.codeaurora.snapcam.R; -import java.util.List; - public class PhotoUI implements PieListener, PreviewGestures.SingleTapListener, FocusUI, TextureView.SurfaceTextureListener, @@ -91,6 +96,7 @@ public class PhotoUI implements PieListener, private View mMenuButton; private PhotoMenu mMenu; + private CustomPhotoMenu mCustomPhotoMenu; private ModuleSwitcher mSwitcher; private CameraControls mCameraControls; private AlertDialog mLocationDialog; @@ -108,6 +114,7 @@ public class PhotoUI implements PieListener, private int mPreviewWidth = 0; private int mPreviewHeight = 0; public boolean mMenuInitialized = false; + public boolean mCustomPhotoMenuInitialized = false; private float mSurfaceTextureUncroppedWidth; private float mSurfaceTextureUncroppedHeight; @@ -124,6 +131,11 @@ public class PhotoUI implements PieListener, private boolean mPrevOrientationResize; private View mPreviewCover; private final Object mSurfaceTextureLock = new Object(); + private LinearLayout mMenuLayout; + private LinearLayout mSubMenuLayout; + private LinearLayout mPreviewMenuLayout; + private boolean mUIhidden = false; + private int mPreviewOrientation = -1; public interface SurfaceTextureSizeChangedListener { public void onSurfaceTextureSizeChanged(int uncroppedWidth, int uncroppedHeight); @@ -145,6 +157,9 @@ public class PhotoUI implements PieListener, (int) mSurfaceTextureUncroppedHeight); mAspectRatioResize = false; } + + if (mCustomPhotoMenu != null) + mCustomPhotoMenu.tryToCloseSubList(); } }; @@ -371,6 +386,13 @@ public class PhotoUI implements PieListener, mMenu.initialize(prefGroup); mMenuInitialized = true; + if (mCustomPhotoMenu == null) { + mCustomPhotoMenu = new CustomPhotoMenu(mActivity, this); + mCustomPhotoMenu.setListener(listener); + } + mCustomPhotoMenu.initialize(prefGroup); + mCustomPhotoMenuInitialized = true; + if (mZoomRenderer == null) { mZoomRenderer = new ZoomRenderer(mActivity); mRenderOverlay.addRenderer(mZoomRenderer); @@ -381,12 +403,15 @@ public class PhotoUI implements PieListener, mGestures = new PreviewGestures(mActivity, this, mZoomRenderer, mPieRenderer); mRenderOverlay.setGestures(mGestures); } + mGestures.setCustomPhotoMenu(mCustomPhotoMenu); + mGestures.setZoomEnabled(params.isZoomSupported()); mGestures.setRenderOverlay(mRenderOverlay); mRenderOverlay.requestLayout(); initializeZoom(params); updateOnScreenIndicators(params, prefGroup, prefs); + mActivity.setPreviewGestures(mGestures); } public void animateCapture(final byte[] jpegData, int orientation, boolean mirror) { @@ -411,14 +436,15 @@ public class PhotoUI implements PieListener, mPreviewThumb.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { - mActivity.gotoGallery(); + if (!CameraControls.isAnimating()) + mActivity.gotoGallery(); } }); mMenuButton = mRootView.findViewById(R.id.menu); mMenuButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { - openMenu(); + mCustomPhotoMenu.openFirstLevel(); } }); if (mController.isImageCaptureIntent()) { @@ -455,16 +481,22 @@ public class PhotoUI implements PieListener, } public void hideUI() { - mCameraControls.setVisibility(View.INVISIBLE); mSwitcher.closePopup(); + if (mUIhidden) + return; + mUIhidden = true; + mCameraControls.hideUI(); } public void showUI() { - mCameraControls.setVisibility(View.VISIBLE); + if (!mUIhidden || (mCustomPhotoMenu != null && mCustomPhotoMenu.isMenuBeingShown())) + return; + mUIhidden = false; + mCameraControls.showUI(); } public boolean arePreviewControlsVisible() { - return (mCameraControls.getVisibility() == View.VISIBLE); + return !mUIhidden; } public void hideSwitcher() { @@ -478,11 +510,27 @@ public class PhotoUI implements PieListener, // called from onResume but only the first time public void initializeFirstTime() { // Initialize shutter button. - mShutterButton.setImageResource(R.drawable.btn_new_shutter); + mShutterButton.setImageBitmap(null); + mShutterButton.setBackgroundResource(R.drawable.shutter_button_anim); + mShutterButton.setOnClickListener(new OnClickListener() + { + @Override + public void onClick(View v) { + if (!CameraControls.isAnimating()) + doShutterAnimation(); + } + }); + mShutterButton.setOnShutterButtonListener(mController); mShutterButton.setVisibility(View.VISIBLE); } + public void doShutterAnimation() { + AnimationDrawable frameAnimation = (AnimationDrawable) mShutterButton.getBackground(); + frameAnimation.stop(); + frameAnimation.start(); + } + // called from onResume every other time public void initializeSecondTime(Camera.Parameters params) { initializeZoom(params); @@ -492,6 +540,9 @@ public class PhotoUI implements PieListener, if (mMenu != null) { mMenu.reloadPreferences(); } + if (mCustomPhotoMenu != null) { + mCustomPhotoMenu.reloadPreferences(); + } } public void showLocationDialog() { @@ -545,7 +596,10 @@ public class PhotoUI implements PieListener, public void hideGpsOnScreenIndicator() { } public void overrideSettings(final String ... keyvalues) { - if (mMenu == null) return; + if (mCustomPhotoMenu != null) + mCustomPhotoMenu.overrideSettings(keyvalues); + if (mMenu == null) + return; mMenu.overrideSettings(keyvalues); } @@ -593,6 +647,10 @@ public class PhotoUI implements PieListener, } public boolean onBackPressed() { + if (mCustomPhotoMenu != null && mCustomPhotoMenu.handleBackKey()) { + return true; + } + if (mPieRenderer != null && mPieRenderer.showsItems()) { mPieRenderer.hide(); return true; @@ -606,6 +664,9 @@ public class PhotoUI implements PieListener, } else if (!mController.isCameraIdle()) { // ignore backs while we're taking a picture return true; + } if (mSwitcher != null && mSwitcher.showsPopup()) { + mSwitcher.closePopup(); + return true; } else { return false; } @@ -634,6 +695,59 @@ public class PhotoUI implements PieListener, if (!previewFocused && mCountDownView != null) mCountDownView.cancelCountDown(); } + public ViewGroup getMenuLayout() { + return mMenuLayout; + } + + public void setPreviewMenuLayout(LinearLayout layout) { + mPreviewMenuLayout = layout; + } + + public ViewGroup getPreviewMenuLayout() { + return mPreviewMenuLayout; + } + + public void showPopup(ListView popup, int level, boolean animate) { + hideUI(); + + popup.setVisibility(View.VISIBLE); + if (level == 1) { + if (mMenuLayout == null) { + mMenuLayout = new LinearLayout(mActivity); + ViewGroup.LayoutParams params = new ViewGroup.LayoutParams( + CameraActivity.SETTING_LIST_WIDTH_1, LayoutParams.WRAP_CONTENT); + mMenuLayout.setLayoutParams(params); + ((ViewGroup) mRootView).addView(mMenuLayout); + } + mMenuLayout.addView(popup); + } + if (level == 2) { + if (mSubMenuLayout == null) { + mSubMenuLayout = new LinearLayout(mActivity); + ViewGroup.LayoutParams params = new ViewGroup.LayoutParams( + CameraActivity.SETTING_LIST_WIDTH_2, LayoutParams.WRAP_CONTENT); + mSubMenuLayout.setLayoutParams(params); + ((ViewGroup) mRootView).addView(mSubMenuLayout); + } + mSubMenuLayout.addView(popup); + mSubMenuLayout.setX(CameraActivity.SETTING_LIST_WIDTH_1); + } + if (animate) { + if (level == 1) + mCustomPhotoMenu.animateSlideIn(popup, CameraActivity.SETTING_LIST_WIDTH_1, true); + if (level == 2) + mCustomPhotoMenu.animateFadeIn(popup); + } else + popup.setAlpha(0.85f); + } + + public void removeLevel2() { + if (mSubMenuLayout != null) { + View v = mSubMenuLayout.getChildAt(0); + mSubMenuLayout.removeView(v); + } + } + public void showPopup(AbstractSettingPopup popup) { hideUI(); @@ -661,6 +775,11 @@ public class PhotoUI implements PieListener, mPopup.showAtLocation(mRootView, Gravity.CENTER, 0, 0); } + public void cleanupListview() { + showUI(); + mActivity.setSystemBarsVisibility(false); + } + public void dismissPopup() { if (mPopup != null && mPopup.isShowing()) { mPopup.dismiss(); @@ -675,6 +794,44 @@ public class PhotoUI implements PieListener, } } + public void dismissLevel1() { + if (mMenuLayout != null) { + ((ViewGroup) mRootView).removeView(mMenuLayout); + mMenuLayout = null; + } + } + + public void dismissLevel2() { + if (mSubMenuLayout != null) { + ((ViewGroup) mRootView).removeView(mSubMenuLayout); + mSubMenuLayout = null; + } + } + + public boolean sendTouchToPreviewMenu(MotionEvent ev) { + return mPreviewMenuLayout.dispatchTouchEvent(ev); + } + + public boolean sendTouchToMenu(MotionEvent ev) { + View v = mMenuLayout.getChildAt(0); + return v.dispatchTouchEvent(ev); + } + + public void dismissSceneModeMenu() { + if (mPreviewMenuLayout != null) { + ((ViewGroup) mRootView).removeView(mPreviewMenuLayout); + mPreviewMenuLayout = null; + } + } + + public void removeSceneModeMenu() { + if (mPreviewMenuLayout != null) { + ((ViewGroup) mRootView).removeView(mPreviewMenuLayout); + mPreviewMenuLayout = null; + } + cleanupListview(); + } + public void onShowSwitcherPopup() { if (mPieRenderer != null && mPieRenderer.showsItems()) { mPieRenderer.hide(); @@ -685,9 +842,6 @@ public class PhotoUI implements PieListener, if (mOnScreenIndicators != null) { mOnScreenIndicators.setVisibility(show ? View.VISIBLE : View.GONE); } - if (mMenuButton != null) { - mMenuButton.setVisibility(show ? View.VISIBLE : View.GONE); - } } public boolean collapseCameraControls() { @@ -696,6 +850,9 @@ public class PhotoUI implements PieListener, mSwitcher.closePopup(); // Remove all the popups/dialog boxes boolean ret = false; + if (mCustomPhotoMenu != null) { + mCustomPhotoMenu.closeAllView(); + } if (mPopup != null) { dismissAllPopup(); ret = true; @@ -732,6 +889,12 @@ public class PhotoUI implements PieListener, if (mFaceView != null) { mFaceView.setDisplayOrientation(orientation); } + if ((mPreviewOrientation == -1 || mPreviewOrientation != orientation) + && mCustomPhotoMenu != null && mCustomPhotoMenu.isPreviewMenuBeingShown()) { + dismissSceneModeMenu(); + mCustomPhotoMenu.addModeBack(); + } + mPreviewOrientation = orientation; } // shutter button handling |