summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore7
-rw-r--r--src/com/android/camera/PhotoModule.java4
-rw-r--r--src/com/android/camera/PhotoUI.java69
-rw-r--r--src/com/android/camera/VideoModule.java10
-rw-r--r--src/com/android/camera/VideoUI.java71
5 files changed, 75 insertions, 86 deletions
diff --git a/.gitignore b/.gitignore
index 871a664ce..a41c59eef 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,6 +1,11 @@
-# Eclipse project files and paths.
+# Project files and paths.
.classpath
.project
+*.iml
+**/*.iml
.settings/
bin/
libs/
+gen/
+.idea/
+.gitignore
diff --git a/src/com/android/camera/PhotoModule.java b/src/com/android/camera/PhotoModule.java
index a61c2676e..5c96592fe 100644
--- a/src/com/android/camera/PhotoModule.java
+++ b/src/com/android/camera/PhotoModule.java
@@ -1411,9 +1411,6 @@ public class PhotoModule
return;
}
- // Do not trigger touch focus if popup window is opened.
- if (mUI.removeTopLevelPopup()) return;
-
// Check if metering area or focus area is supported.
if (!mFocusAreaSupported && !mMeteringAreaSupported) return;
mFocusManager.onSingleTapUp(x, y);
@@ -1449,7 +1446,6 @@ public class PhotoModule
// Start auto-focus immediately to reduce shutter lag. After
// the shutter button gets the focus, onShutterButtonFocus()
// will be called again but it is fine.
- if (mUI.removeTopLevelPopup()) return true;
onShutterButtonFocus(true);
mUI.pressShutterButton();
}
diff --git a/src/com/android/camera/PhotoUI.java b/src/com/android/camera/PhotoUI.java
index a0e8b9b82..a1de60af2 100644
--- a/src/com/android/camera/PhotoUI.java
+++ b/src/com/android/camera/PhotoUI.java
@@ -22,8 +22,10 @@ import java.util.List;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.graphics.Bitmap;
+import android.graphics.Color;
import android.graphics.Matrix;
import android.graphics.SurfaceTexture;
+import android.graphics.drawable.ColorDrawable;
import android.hardware.Camera;
import android.hardware.Camera.Face;
import android.hardware.Camera.Size;
@@ -38,9 +40,9 @@ import android.view.View.OnClickListener;
import android.view.View.OnLayoutChangeListener;
import android.view.ViewGroup;
import android.view.ViewStub;
-import android.widget.FrameLayout;
import android.widget.FrameLayout.LayoutParams;
import android.widget.ImageView;
+import android.widget.PopupWindow;
import android.widget.Toast;
import com.android.camera.CameraPreference.OnPreferenceChangedListener;
@@ -78,7 +80,7 @@ public class PhotoUI implements PieListener,
private View mRootView;
private Object mSurfaceTexture;
- private AbstractSettingPopup mPopup;
+ private PopupWindow mPopup;
private ShutterButton mShutterButton;
private CountDownView mCountDownView;
@@ -89,7 +91,6 @@ public class PhotoUI implements PieListener,
private View mReviewRetakeButton;
private View mMenuButton;
- private View mBlocker;
private PhotoMenu mMenu;
private CameraSwitcher mSwitcher;
private CameraControls mCameraControls;
@@ -348,7 +349,6 @@ public class PhotoUI implements PieListener,
}
public void initializeControlByIntent() {
- mBlocker = mRootView.findViewById(R.id.blocker);
mPreviewThumb = (ImageView) mRootView.findViewById(R.id.preview_thumb);
mPreviewThumb.setOnClickListener(new OnClickListener() {
@Override
@@ -530,16 +530,13 @@ public class PhotoUI implements PieListener,
// 1) if there is any popup, dismiss them, 2) otherwise, get out of
// image capture
if (mController.isImageCaptureIntent()) {
- if (!removeTopLevelPopup()) {
- // no popup to dismiss, cancel image capture
- mController.onCaptureCancelled();
- }
+ mController.onCaptureCancelled();
return true;
} else if (!mController.isCameraIdle()) {
// ignore backs while we're taking a picture
return true;
} else {
- return removeTopLevelPopup();
+ return false;
}
}
@@ -552,9 +549,6 @@ public class PhotoUI implements PieListener,
if (mFaceView != null) {
mFaceView.setBlockDraw(!toCamera);
}
- if (mPopup != null) {
- dismissPopup(toCamera);
- }
if (mGestures != null) {
mGestures.setEnabled(toCamera);
}
@@ -569,42 +563,32 @@ public class PhotoUI implements PieListener,
if (!toCamera && mCountDownView != null) mCountDownView.cancelCountDown();
}
- public boolean removeTopLevelPopup() {
- // Remove the top level popup or dialog box and return true if there's any
- if (mPopup != null) {
- dismissPopup();
- return true;
- }
- return false;
- }
-
public void showPopup(AbstractSettingPopup popup) {
hideUI();
- mBlocker.setVisibility(View.INVISIBLE);
- setShowMenu(false);
- mPopup = popup;
- mPopup.setVisibility(View.VISIBLE);
- FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
- LayoutParams.WRAP_CONTENT);
- lp.gravity = Gravity.CENTER;
- ((FrameLayout) mRootView).addView(mPopup, lp);
- }
- public void dismissPopup() {
- dismissPopup(true);
+ if (mPopup == null) {
+ mPopup = new PopupWindow(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
+ mPopup.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
+ mPopup.setOutsideTouchable(true);
+ mPopup.setFocusable(true);
+ mPopup.setOnDismissListener(new PopupWindow.OnDismissListener() {
+ @Override
+ public void onDismiss() {
+ mPopup = null;
+ mMenu.popupDismissed();
+ showUI();
+ }
+ });
+ }
+ popup.setVisibility(View.VISIBLE);
+ mPopup.setContentView(popup);
+ mPopup.showAtLocation(mRootView, Gravity.CENTER, 0, 0);
}
- private void dismissPopup(boolean fullScreen) {
- if (fullScreen) {
- showUI();
- mBlocker.setVisibility(View.VISIBLE);
- }
- setShowMenu(fullScreen);
- if (mPopup != null) {
- ((FrameLayout) mRootView).removeView(mPopup);
- mPopup = null;
+ public void dismissPopup() {
+ if (mPopup != null && mPopup.isShowing()) {
+ mPopup.dismiss();
}
- mMenu.popupDismissed();
}
public void onShowSwitcherPopup() {
@@ -705,7 +689,6 @@ public class PhotoUI implements PieListener,
@Override
public void onPieOpened(int centerX, int centerY) {
setSwipingEnabled(false);
- dismissPopup();
if (mFaceView != null) {
mFaceView.setBlockDraw(true);
}
diff --git a/src/com/android/camera/VideoModule.java b/src/com/android/camera/VideoModule.java
index 1516cb5d0..80bbbca37 100644
--- a/src/com/android/camera/VideoModule.java
+++ b/src/com/android/camera/VideoModule.java
@@ -423,12 +423,6 @@ public class VideoModule implements CameraModule,
return;
}
- if (!mMediaRecorderRecording) {
- // check for dismissing popup
- mUI.dismissPopup(true);
- return;
- }
-
// Set rotation and gps data.
int rotation = Util.getJpegRotation(mCameraId, mOrientation);
mParameters.setRotation(rotation);
@@ -945,8 +939,8 @@ public class VideoModule implements CameraModule,
mPendingSwitchCameraId = -1;
mSwitchingCamera = false;
mPreferenceRead = false;
- // Call onPause after stopping video recording. So the camera can be
- // released as soon as possible.
+
+ mUI.collapseCameraControls();
}
@Override
diff --git a/src/com/android/camera/VideoUI.java b/src/com/android/camera/VideoUI.java
index 1f6505fcf..ee49277dc 100644
--- a/src/com/android/camera/VideoUI.java
+++ b/src/com/android/camera/VideoUI.java
@@ -19,8 +19,10 @@ package com.android.camera;
import java.util.List;
import android.graphics.Bitmap;
+import android.graphics.Color;
import android.graphics.Matrix;
import android.graphics.SurfaceTexture;
+import android.graphics.drawable.ColorDrawable;
import android.hardware.Camera.Parameters;
import android.os.Handler;
import android.os.Message;
@@ -38,6 +40,7 @@ import android.widget.FrameLayout;
import android.widget.FrameLayout.LayoutParams;
import android.widget.ImageView;
import android.widget.LinearLayout;
+import android.widget.PopupWindow;
import android.widget.TextView;
import com.android.camera.CameraPreference.OnPreferenceChangedListener;
@@ -78,11 +81,10 @@ public class VideoUI implements PieRenderer.PieListener,
private PieRenderer mPieRenderer;
private VideoMenu mVideoMenu;
private CameraControls mCameraControls;
- private AbstractSettingPopup mPopup;
+ private SettingsPopup mPopup;
private ZoomRenderer mZoomRenderer;
private PreviewGestures mGestures;
private View mMenuButton;
- private View mBlocker;
private OnScreenIndicators mOnScreenIndicators;
private RotateLayout mRecordingTimeRect;
private final Object mLock = new Object();
@@ -134,6 +136,31 @@ public class VideoUI implements PieRenderer.PieListener,
}
};
+ private class SettingsPopup extends PopupWindow {
+ public SettingsPopup(View popup) {
+ super(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
+ setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
+ setOutsideTouchable(true);
+ setFocusable(true);
+ popup.setVisibility(View.VISIBLE);
+ setContentView(popup);
+ showAtLocation(mRootView, Gravity.CENTER, 0, 0);
+ }
+
+ public void dismiss(boolean topLevelOnly) {
+ super.dismiss();
+ popupDismissed();
+ showUI();
+ mVideoMenu.popupDismissed(topLevelOnly);
+ }
+
+ @Override
+ public void dismiss() {
+ // Called by Framework when touch outside the popup or hit back key
+ dismiss(true);
+ }
+ }
+
public VideoUI(CameraActivity activity, VideoController controller, View parent) {
mActivity = activity;
mController = controller;
@@ -162,7 +189,6 @@ public class VideoUI implements PieRenderer.PieListener,
}
private void initializeControlByIntent() {
- mBlocker = mActivity.findViewById(R.id.blocker);
mMenuButton = mActivity.findViewById(R.id.menu);
mMenuButton.setOnClickListener(new OnClickListener() {
@Override
@@ -440,36 +466,25 @@ public class VideoUI implements PieRenderer.PieListener,
}
}
- public void showPopup(AbstractSettingPopup popup) {
- hideUI();
- mBlocker.setVisibility(View.INVISIBLE);
- setShowMenu(false);
- mPopup = popup;
- mPopup.setVisibility(View.VISIBLE);
- FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
- LayoutParams.WRAP_CONTENT);
- lp.gravity = Gravity.CENTER;
- ((FrameLayout) mRootView).addView(mPopup, lp);
+ public void dismissPopup(boolean topLevelOnly) {
+ // In review mode, we do not want to bring up the camera UI
+ if (mController.isInReviewMode()) return;
+ if (mPopup != null) {
+ mPopup.dismiss(topLevelOnly);
+ }
}
- public void dismissPopup(boolean topLevelOnly) {
- dismissPopup(topLevelOnly, true);
+ private void popupDismissed() {
+ mPopup = null;
}
- public void dismissPopup(boolean topLevelPopupOnly, boolean fullScreen) {
- // In review mode, we do not want to bring up the camera UI
- if (mController.isInReviewMode()) return;
+ public void showPopup(AbstractSettingPopup popup) {
+ hideUI();
- if (fullScreen) {
- showUI();
- mBlocker.setVisibility(View.VISIBLE);
- }
- setShowMenu(fullScreen);
if (mPopup != null) {
- ((FrameLayout) mRootView).removeView(mPopup);
- mPopup = null;
+ mPopup.dismiss(false);
}
- mVideoMenu.popupDismissed(topLevelPopupOnly);
+ mPopup = new SettingsPopup(popup);
}
public void onShowSwitcherPopup() {
@@ -500,7 +515,6 @@ public class VideoUI implements PieRenderer.PieListener,
@Override
public void onPieOpened(int centerX, int centerY) {
setSwipingEnabled(false);
- dismissPopup(false, true);
}
@Override
@@ -591,9 +605,6 @@ public class VideoUI implements PieRenderer.PieListener,
if (mGestures != null) {
mGestures.setEnabled(toCamera);
}
- if (mPopup != null) {
- dismissPopup(false, toCamera);
- }
if (mRenderOverlay != null) {
// this can not happen in capture mode
mRenderOverlay.setVisibility(toCamera ? View.VISIBLE : View.GONE);