blob: 5e5d353c46b80509e698f95c661ff8227b3e7144 [file] [log] [blame]
Michael Kolbd6954f32013-03-08 20:43:01 -08001/*
Doris Liu6432cd62013-06-13 17:20:31 -07002 * Copyright (C) 2012 The Android Open Source Project
Michael Kolbd6954f32013-03-08 20:43:01 -08003 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
Michael Kolbd6954f32013-03-08 20:43:01 -080017package com.android.camera;
18
Doris Liudb8f9752014-05-12 15:25:13 -070019import android.app.Dialog;
20import android.content.DialogInterface;
Sascha Haeberling37f36112013-08-06 14:31:52 -070021import android.graphics.Bitmap;
Doris Liu6c751642014-05-05 18:43:26 -070022import android.graphics.RectF;
Doris Liu6432cd62013-06-13 17:20:31 -070023import android.graphics.SurfaceTexture;
Michael Kolbd6954f32013-03-08 20:43:01 -080024import android.hardware.Camera.Face;
Sascha Haeberling37f36112013-08-06 14:31:52 -070025import android.os.AsyncTask;
Doris Liuf9e4f8f2013-12-04 18:04:22 -080026import android.view.GestureDetector;
27import android.view.MotionEvent;
Michael Kolbd6954f32013-03-08 20:43:01 -080028import android.view.View;
Michael Kolbd6954f32013-03-08 20:43:01 -080029import android.view.ViewGroup;
Spike Spragueb4a22222014-05-22 14:40:53 -070030import android.widget.FrameLayout;
31import android.widget.ImageView;
Michael Kolbd6954f32013-03-08 20:43:01 -080032
Senpo Hu00a764a2015-02-19 16:13:40 -080033import com.android.camera.captureintent.PictureDecoder;
Andy Huibers62b4c3c2014-08-25 15:01:25 -070034import com.android.camera.debug.DebugPropertyHelper;
Angus Kong5596b4c2014-03-11 16:27:30 -070035import com.android.camera.debug.Log;
Doris Liu6c751642014-05-05 18:43:26 -070036import com.android.camera.ui.CountDownView;
Michael Kolbd6954f32013-03-08 20:43:01 -080037import com.android.camera.ui.FaceView;
Doris Liuf9e4f8f2013-12-04 18:04:22 -080038import com.android.camera.ui.PreviewOverlay;
Doris Liu06db7422013-12-09 19:36:25 -080039import com.android.camera.ui.PreviewStatusListener;
Paul Rohde987ee642014-12-05 12:17:15 -080040import com.android.camera.ui.focus.FocusRing;
Sascha Haeberling8e963a52013-08-06 11:43:02 -070041import com.android.camera2.R;
Sol Boucher5a344962014-06-17 14:05:08 -070042import com.android.ex.camera2.portability.CameraAgent;
Sascha Haeberling4c1bffe2014-08-21 10:01:00 -070043import com.android.ex.camera2.portability.CameraCapabilities;
Sol Boucher5a344962014-06-17 14:05:08 -070044import com.android.ex.camera2.portability.CameraSettings;
Angus Kongb50b5cb2013-08-09 14:55:20 -070045
Doris Liu482de022013-12-18 19:18:16 -080046public class PhotoUI implements PreviewStatusListener,
Sol Boucher5a344962014-06-17 14:05:08 -070047 CameraAgent.CameraFaceDetectionCallback, PreviewStatusListener.PreviewAreaChangedListener {
Michael Kolbd6954f32013-03-08 20:43:01 -080048
Angus Kong5596b4c2014-03-11 16:27:30 -070049 private static final Log.Tag TAG = new Log.Tag("PhotoUI");
Sascha Haeberling37f36112013-08-06 14:31:52 -070050 private static final int DOWN_SAMPLE_FACTOR = 4;
Doris Liu70da9182013-12-17 18:41:15 -080051 private static final float UNSET = 0f;
Spike Sprague0f3c4b42013-12-10 19:50:17 -080052
Doris Liuf9e4f8f2013-12-04 18:04:22 -080053 private final PreviewOverlay mPreviewOverlay;
Paul Rohde987ee642014-12-05 12:17:15 -080054 private final FocusRing mFocusRing;
Sascha Haeberlinge2914fd2014-01-17 19:03:52 -080055 private final CameraActivity mActivity;
56 private final PhotoController mController;
Michael Kolbd6954f32013-03-08 20:43:01 -080057
Sascha Haeberlinge2914fd2014-01-17 19:03:52 -080058 private final View mRootView;
Doris Liudb8f9752014-05-12 15:25:13 -070059 private Dialog mDialog = null;
Michael Kolbd6954f32013-03-08 20:43:01 -080060
Doris Liud27ea7b2014-02-25 11:46:11 -080061 // TODO: Remove face view logic if UX does not bring it back within a month.
Andy Huibers62b4c3c2014-08-25 15:01:25 -070062 private final FaceView mFaceView;
Doris Liu36e56fb2013-09-11 17:38:08 -070063 private DecodeImageForReview mDecodeTaskForReview = null;
Michael Kolbd6954f32013-03-08 20:43:01 -080064
Sol Boucher2192fba2014-08-19 17:24:07 -070065 private float mZoomMax;
Michael Kolbd6954f32013-03-08 20:43:01 -080066
67 private int mPreviewWidth = 0;
68 private int mPreviewHeight = 0;
Doris Liu70da9182013-12-17 18:41:15 -080069 private float mAspectRatio = UNSET;
Marco Nelissen0744e4a2013-11-22 01:47:37 +000070
Spike Spragueb4a22222014-05-22 14:40:53 -070071 private ImageView mIntentReviewImageView;
72
Doris Liu06db7422013-12-09 19:36:25 -080073 private final GestureDetector.OnGestureListener mPreviewGestureListener
74 = new GestureDetector.SimpleOnGestureListener() {
75 @Override
76 public boolean onSingleTapUp(MotionEvent ev) {
77 mController.onSingleTapUp(null, (int) ev.getX(), (int) ev.getY());
78 return true;
79 }
80 };
Doris Liudb8f9752014-05-12 15:25:13 -070081 private final DialogInterface.OnDismissListener mOnDismissListener
82 = new DialogInterface.OnDismissListener() {
83 @Override
84 public void onDismiss(DialogInterface dialog) {
85 mDialog = null;
86 }
87 };
Sascha Haeberling4c1bffe2014-08-21 10:01:00 -070088 private final CountDownView mCountdownView;
Marco Nelissen0744e4a2013-11-22 01:47:37 +000089
Doris Liu06db7422013-12-09 19:36:25 -080090 @Override
91 public GestureDetector.OnGestureListener getGestureListener() {
92 return mPreviewGestureListener;
93 }
94
Doris Liu4a010db2013-12-16 18:44:49 -080095 @Override
Erin Dahlgrend8de0772014-02-03 10:12:27 -080096 public View.OnTouchListener getTouchListener() {
97 return null;
98 }
99
100 @Override
Doris Liu4a010db2013-12-16 18:44:49 -0800101 public void onPreviewLayoutChanged(View v, int left, int top, int right,
102 int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
103 int width = right - left;
104 int height = bottom - top;
105 if (mPreviewWidth != width || mPreviewHeight != height) {
106 mPreviewWidth = width;
107 mPreviewHeight = height;
Michael Kolbd6954f32013-03-08 20:43:01 -0800108 }
Doris Liu4a010db2013-12-16 18:44:49 -0800109 }
Michael Kolbd6954f32013-03-08 20:43:01 -0800110
Doris Liu70da9182013-12-17 18:41:15 -0800111 @Override
112 public boolean shouldAutoAdjustTransformMatrixOnLayout() {
113 return true;
114 }
115
116 @Override
Doris Liu11ddd732014-01-07 10:52:11 -0800117 public void onPreviewFlipped() {
118 mController.updateCameraOrientation();
119 }
120
Doris Liu08b0cdd2014-05-13 19:19:55 -0700121 /**
Doris Liu6c751642014-05-05 18:43:26 -0700122 * Starts the countdown timer.
123 *
124 * @param sec seconds to countdown
125 */
126 public void startCountdown(int sec) {
127 mCountdownView.startCountDown(sec);
128 }
129
130 /**
131 * Sets a listener that gets notified when the countdown is finished.
132 */
133 public void setCountdownFinishedListener(CountDownView.OnCountDownStatusListener listener) {
134 mCountdownView.setCountDownStatusListener(listener);
135 }
136
137 /**
138 * Returns whether the countdown is on-going.
139 */
140 public boolean isCountingDown() {
141 return mCountdownView.isCountingDown();
142 }
143
144 /**
145 * Cancels the on-going countdown, if any.
146 */
147 public void cancelCountDown() {
148 mCountdownView.cancelCountDown();
149 }
150
151 @Override
152 public void onPreviewAreaChanged(RectF previewArea) {
153 if (mFaceView != null) {
154 mFaceView.onPreviewAreaChanged(previewArea);
155 }
156 mCountdownView.onPreviewAreaChanged(previewArea);
157 }
158
Doris Liu36e56fb2013-09-11 17:38:08 -0700159 private class DecodeTask extends AsyncTask<Void, Void, Bitmap> {
Sascha Haeberling37f36112013-08-06 14:31:52 -0700160 private final byte [] mData;
Sascha Haeberlinge2914fd2014-01-17 19:03:52 -0800161 private final int mOrientation;
162 private final boolean mMirror;
Doris Liuc2e9abd2013-06-19 14:20:51 -0700163
Doris Liu29da2db2013-08-28 14:28:45 -0700164 public DecodeTask(byte[] data, int orientation, boolean mirror) {
Sascha Haeberling37f36112013-08-06 14:31:52 -0700165 mData = data;
Doris Liuce2acbc2013-08-21 18:45:29 -0700166 mOrientation = orientation;
Doris Liu29da2db2013-08-28 14:28:45 -0700167 mMirror = mirror;
Doris Liuc2e9abd2013-06-19 14:20:51 -0700168 }
169
170 @Override
Doris Liu36e56fb2013-09-11 17:38:08 -0700171 protected Bitmap doInBackground(Void... params) {
Sascha Haeberling37f36112013-08-06 14:31:52 -0700172 // Decode image in background.
Senpo Hu00a764a2015-02-19 16:13:40 -0800173 return PictureDecoder.decode(mData, DOWN_SAMPLE_FACTOR, mOrientation, mMirror);
Sascha Haeberling37f36112013-08-06 14:31:52 -0700174 }
Sascha Haeberling37f36112013-08-06 14:31:52 -0700175 }
Doris Liuc2e9abd2013-06-19 14:20:51 -0700176
Doris Liu36e56fb2013-09-11 17:38:08 -0700177 private class DecodeImageForReview extends DecodeTask {
178 public DecodeImageForReview(byte[] data, int orientation, boolean mirror) {
179 super(data, orientation, mirror);
180 }
181
182 @Override
183 protected void onPostExecute(Bitmap bitmap) {
184 if (isCancelled()) {
185 return;
186 }
Spike Spragueb4a22222014-05-22 14:40:53 -0700187
188 mIntentReviewImageView.setImageBitmap(bitmap);
189 showIntentReviewImageView();
190
Doris Liu36e56fb2013-09-11 17:38:08 -0700191 mDecodeTaskForReview = null;
192 }
193 }
194
Michael Kolbd6954f32013-03-08 20:43:01 -0800195 public PhotoUI(CameraActivity activity, PhotoController controller, View parent) {
196 mActivity = activity;
197 mController = controller;
198 mRootView = parent;
199
Doris Liuf55f3c42013-11-20 00:24:46 -0800200 ViewGroup moduleRoot = (ViewGroup) mRootView.findViewById(R.id.module_layout);
Michael Kolbd6954f32013-03-08 20:43:01 -0800201 mActivity.getLayoutInflater().inflate(R.layout.photo_module,
Sascha Haeberlinge2914fd2014-01-17 19:03:52 -0800202 moduleRoot, true);
Michael Kolbd6954f32013-03-08 20:43:01 -0800203 initIndicators();
Paul Rohde987ee642014-12-05 12:17:15 -0800204 mFocusRing = (FocusRing) mRootView.findViewById(R.id.focus_ring);
Doris Liuf9e4f8f2013-12-04 18:04:22 -0800205 mPreviewOverlay = (PreviewOverlay) mRootView.findViewById(R.id.preview_overlay);
Doris Liu6c751642014-05-05 18:43:26 -0700206 mCountdownView = (CountDownView) mRootView.findViewById(R.id.count_down_view);
Andy Huibers62b4c3c2014-08-25 15:01:25 -0700207 // Show faces if we are in debug mode.
208 if (DebugPropertyHelper.showCaptureDebugUI()) {
209 mFaceView = (FaceView) mRootView.findViewById(R.id.face_view);
210 } else {
211 mFaceView = null;
212 }
Spike Spragueb4a22222014-05-22 14:40:53 -0700213
214 if (mController.isImageCaptureIntent()) {
Spike Sprague02b9b9a2014-07-02 11:26:28 -0700215 initIntentReviewImageView();
Spike Spragueb4a22222014-05-22 14:40:53 -0700216 }
Doris Liu6432cd62013-06-13 17:20:31 -0700217 }
Michael Kolbd6954f32013-03-08 20:43:01 -0800218
Spike Sprague02b9b9a2014-07-02 11:26:28 -0700219 private void initIntentReviewImageView() {
220 mIntentReviewImageView = (ImageView) mRootView.findViewById(R.id.intent_review_imageview);
Spike Spragueb4a22222014-05-22 14:40:53 -0700221 mActivity.getCameraAppUI().addPreviewAreaChangedListener(
222 new PreviewStatusListener.PreviewAreaChangedListener() {
223 @Override
224 public void onPreviewAreaChanged(RectF previewArea) {
225 FrameLayout.LayoutParams params =
226 (FrameLayout.LayoutParams) mIntentReviewImageView.getLayoutParams();
227 params.width = (int) previewArea.width();
228 params.height = (int) previewArea.height();
229 params.setMargins((int) previewArea.left, (int) previewArea.top, 0, 0);
230 mIntentReviewImageView.setLayoutParams(params);
231 }
232 });
233 }
234
235 /**
236 * Show the image review over the live preview for intent captures.
237 */
238 public void showIntentReviewImageView() {
239 if (mIntentReviewImageView != null) {
240 mIntentReviewImageView.setVisibility(View.VISIBLE);
241 }
242 }
243
244 /**
245 * Hide the image review over the live preview for intent captures.
246 */
247 public void hideIntentReviewImageView() {
248 if (mIntentReviewImageView != null) {
249 mIntentReviewImageView.setVisibility(View.INVISIBLE);
250 }
251 }
252
253
Paul Rohde987ee642014-12-05 12:17:15 -0800254 public FocusRing getFocusRing() {
255 return mFocusRing;
Doris Liu482de022013-12-18 19:18:16 -0800256 }
257
Doris Liud053a5b2013-10-25 20:20:43 -0700258 public void updatePreviewAspectRatio(float aspectRatio) {
259 if (aspectRatio <= 0) {
260 Log.e(TAG, "Invalid aspect ratio: " + aspectRatio);
261 return;
262 }
263 if (aspectRatio < 1f) {
264 aspectRatio = 1f / aspectRatio;
265 }
266
267 if (mAspectRatio != aspectRatio) {
268 mAspectRatio = aspectRatio;
269 // Update transform matrix with the new aspect ratio.
Doris Liu70da9182013-12-17 18:41:15 -0800270 mController.updatePreviewAspectRatio(mAspectRatio);
Doris Liud053a5b2013-10-25 20:20:43 -0700271 }
272 }
273
Angus Kongdcccc512013-08-08 17:06:03 -0700274 @Override
Doris Liu6432cd62013-06-13 17:20:31 -0700275 public void onSurfaceTextureAvailable(SurfaceTexture surface, int width, int height) {
Erin Dahlgrend8de0772014-02-03 10:12:27 -0800276 mController.onPreviewUIReady();
Doris Liu6432cd62013-06-13 17:20:31 -0700277 }
278
Angus Kongdcccc512013-08-08 17:06:03 -0700279 @Override
Doris Liu6432cd62013-06-13 17:20:31 -0700280 public void onSurfaceTextureSizeChanged(SurfaceTexture surface, int width, int height) {
281 // Ignored, Camera does all the work for us
282 }
283
Angus Kongdcccc512013-08-08 17:06:03 -0700284 @Override
Doris Liu6432cd62013-06-13 17:20:31 -0700285 public boolean onSurfaceTextureDestroyed(SurfaceTexture surface) {
Erin Dahlgrend8de0772014-02-03 10:12:27 -0800286 mController.onPreviewUIDestroyed();
287 return true;
Doris Liu6432cd62013-06-13 17:20:31 -0700288 }
289
ztenghui7b265a62013-09-09 14:58:44 -0700290 @Override
Doris Liu6432cd62013-06-13 17:20:31 -0700291 public void onSurfaceTextureUpdated(SurfaceTexture surface) {
Michael Kolbd6954f32013-03-08 20:43:01 -0800292 }
293
294 private void initIndicators() {
Marco Nelissen0744e4a2013-11-22 01:47:37 +0000295 // TODO init toggle buttons on bottom bar here
Michael Kolbd6954f32013-03-08 20:43:01 -0800296 }
297
Angus Kong6607dae2014-06-10 16:07:45 -0700298 public void onCameraOpened(CameraCapabilities capabilities, CameraSettings settings) {
299 initializeZoom(capabilities, settings);
Michael Kolbd6954f32013-03-08 20:43:01 -0800300 }
301
Erin Dahlgren0a6a8d82014-01-09 22:17:38 -0800302 public void animateCapture(final byte[] jpegData, int orientation, boolean mirror) {
303 // Decode jpeg byte array and then animate the jpeg
304 DecodeTask task = new DecodeTask(jpegData, orientation, mirror);
305 task.execute();
Spike Spragueeb3134f2013-12-12 11:14:27 -0800306 }
307
Michael Kolbd6954f32013-03-08 20:43:01 -0800308 // called from onResume but only the first time
Kevin Gabayanffbc43c2013-12-09 11:41:50 -0800309 public void initializeFirstTime() {
Marco Nelissen0744e4a2013-11-22 01:47:37 +0000310
Michael Kolbd6954f32013-03-08 20:43:01 -0800311 }
312
313 // called from onResume every other time
Angus Kong6607dae2014-06-10 16:07:45 -0700314 public void initializeSecondTime(CameraCapabilities capabilities, CameraSettings settings) {
315 initializeZoom(capabilities, settings);
Michael Kolbd6954f32013-03-08 20:43:01 -0800316 if (mController.isImageCaptureIntent()) {
317 hidePostCaptureAlert();
318 }
Michael Kolbd6954f32013-03-08 20:43:01 -0800319 }
320
Angus Kong6607dae2014-06-10 16:07:45 -0700321 public void initializeZoom(CameraCapabilities capabilities, CameraSettings settings) {
322 if ((capabilities == null) || settings == null ||
323 !capabilities.supports(CameraCapabilities.Feature.ZOOM)) {
Sascha Haeberling1d943642014-05-19 11:56:53 -0700324 return;
325 }
Sol Boucher2192fba2014-08-19 17:24:07 -0700326 mZoomMax = capabilities.getMaxZoomRatio();
Michael Kolbd6954f32013-03-08 20:43:01 -0800327 // Currently we use immediate zoom for fast zooming to get better UX and
328 // there is no plan to take advantage of the smooth zoom.
Doris Liuf9e4f8f2013-12-04 18:04:22 -0800329 // TODO: Need to setup a path to AppUI to do this
Sol Boucher2192fba2014-08-19 17:24:07 -0700330 mPreviewOverlay.setupZoom(mZoomMax, settings.getCurrentZoomRatio(),
Angus Kong6607dae2014-06-10 16:07:45 -0700331 new ZoomChangeListener());
Michael Kolbd6954f32013-03-08 20:43:01 -0800332 }
333
Doris Liuc2e9abd2013-06-19 14:20:51 -0700334 public void animateFlash() {
Doris Liu1dfe7822013-12-12 00:02:08 -0800335 mController.startPreCaptureAnimation();
Doris Liuc2e9abd2013-06-19 14:20:51 -0700336 }
337
Michael Kolbd6954f32013-03-08 20:43:01 -0800338 public boolean onBackPressed() {
Michael Kolbd6954f32013-03-08 20:43:01 -0800339 // In image capture mode, back button should:
340 // 1) if there is any popup, dismiss them, 2) otherwise, get out of
341 // image capture
342 if (mController.isImageCaptureIntent()) {
Doris Liuc3679c02013-08-08 18:08:43 -0700343 mController.onCaptureCancelled();
Michael Kolbd6954f32013-03-08 20:43:01 -0800344 return true;
345 } else if (!mController.isCameraIdle()) {
346 // ignore backs while we're taking a picture
347 return true;
348 } else {
Doris Liuc3679c02013-08-08 18:08:43 -0700349 return false;
Michael Kolbd6954f32013-03-08 20:43:01 -0800350 }
351 }
352
Doris Liu36e56fb2013-09-11 17:38:08 -0700353 protected void showCapturedImageForReview(byte[] jpegData, int orientation, boolean mirror) {
354 mDecodeTaskForReview = new DecodeImageForReview(jpegData, orientation, mirror);
355 mDecodeTaskForReview.execute();
Erin Dahlgren4efa8b52013-12-17 18:31:35 -0800356
Erin Dahlgren4efa8b52013-12-17 18:31:35 -0800357 mActivity.getCameraAppUI().transitionToIntentReviewLayout();
Doris Liud31cdfe2013-05-14 11:31:19 -0700358 pauseFaceDetection();
Michael Kolbd6954f32013-03-08 20:43:01 -0800359 }
360
361 protected void hidePostCaptureAlert() {
Doris Liu36e56fb2013-09-11 17:38:08 -0700362 if (mDecodeTaskForReview != null) {
363 mDecodeTaskForReview.cancel(true);
364 }
Doris Liud31cdfe2013-05-14 11:31:19 -0700365 resumeFaceDetection();
Michael Kolbd6954f32013-03-08 20:43:01 -0800366 }
367
368 public void setDisplayOrientation(int orientation) {
369 if (mFaceView != null) {
370 mFaceView.setDisplayOrientation(orientation);
371 }
372 }
373
Doris Liuf9e4f8f2013-12-04 18:04:22 -0800374 private class ZoomChangeListener implements PreviewOverlay.OnZoomChangedListener {
Michael Kolbd6954f32013-03-08 20:43:01 -0800375 @Override
Sol Boucher2192fba2014-08-19 17:24:07 -0700376 public void onZoomValueChanged(float ratio) {
377 mController.onZoomChanged(ratio);
Michael Kolbd6954f32013-03-08 20:43:01 -0800378 }
379
380 @Override
381 public void onZoomStart() {
Michael Kolbd6954f32013-03-08 20:43:01 -0800382 }
383
384 @Override
385 public void onZoomEnd() {
Michael Kolbd6954f32013-03-08 20:43:01 -0800386 }
387 }
388
Doris Liu6432cd62013-06-13 17:20:31 -0700389 public void setSwipingEnabled(boolean enable) {
390 mActivity.setSwipingEnabled(enable);
Michael Kolbd6954f32013-03-08 20:43:01 -0800391 }
392
Michael Kolbd6954f32013-03-08 20:43:01 -0800393 public void onPause() {
Sascha Haeberling1d943642014-05-19 11:56:53 -0700394 if (mFaceView != null) {
395 mFaceView.clear();
396 }
Doris Liudb8f9752014-05-12 15:25:13 -0700397 if (mDialog != null) {
398 mDialog.dismiss();
399 }
Alan Newberger73514152014-09-10 15:03:27 -0700400 // recalculate aspect ratio when restarting.
401 mAspectRatio = 0.0f;
Michael Kolbd6954f32013-03-08 20:43:01 -0800402 }
403
Michael Kolbd6954f32013-03-08 20:43:01 -0800404 public void clearFaces() {
Marco Nelissen0744e4a2013-11-22 01:47:37 +0000405 if (mFaceView != null) {
406 mFaceView.clear();
407 }
Michael Kolbd6954f32013-03-08 20:43:01 -0800408 }
409
Michael Kolbd6954f32013-03-08 20:43:01 -0800410 public void pauseFaceDetection() {
Sascha Haeberling1d943642014-05-19 11:56:53 -0700411 if (mFaceView != null) {
412 mFaceView.pause();
413 }
Michael Kolbd6954f32013-03-08 20:43:01 -0800414 }
415
Michael Kolbd6954f32013-03-08 20:43:01 -0800416 public void resumeFaceDetection() {
Sascha Haeberling1d943642014-05-19 11:56:53 -0700417 if (mFaceView != null) {
418 mFaceView.resume();
419 }
Michael Kolbd6954f32013-03-08 20:43:01 -0800420 }
421
422 public void onStartFaceDetection(int orientation, boolean mirror) {
Doris Liud27ea7b2014-02-25 11:46:11 -0800423 if (mFaceView != null) {
424 mFaceView.clear();
425 mFaceView.setVisibility(View.VISIBLE);
426 mFaceView.setDisplayOrientation(orientation);
427 mFaceView.setMirror(mirror);
428 mFaceView.resume();
429 }
Michael Kolbd6954f32013-03-08 20:43:01 -0800430 }
431
432 @Override
Sol Boucher5a344962014-06-17 14:05:08 -0700433 public void onFaceDetection(Face[] faces, CameraAgent.CameraProxy camera) {
Doris Liud27ea7b2014-02-25 11:46:11 -0800434 if (mFaceView != null) {
435 mFaceView.setFaces(faces);
436 }
Michael Kolbd6954f32013-03-08 20:43:01 -0800437 }
438
Michael Kolbd6954f32013-03-08 20:43:01 -0800439}