Doris Liu | 6827ce2 | 2013-03-12 19:24:28 -0700 | [diff] [blame] | 1 | /* |
Doris Liu | 6432cd6 | 2013-06-13 17:20:31 -0700 | [diff] [blame] | 2 | * Copyright (C) 2012 The Android Open Source Project |
Doris Liu | 6827ce2 | 2013-03-12 19:24:28 -0700 | [diff] [blame] | 3 | * |
| 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 | |
| 17 | package com.android.camera; |
| 18 | |
| 19 | import android.graphics.Bitmap; |
Angus Kong | 5f8c30e | 2014-03-06 17:15:08 -0800 | [diff] [blame] | 20 | import android.graphics.Point; |
Doris Liu | 6432cd6 | 2013-06-13 17:20:31 -0700 | [diff] [blame] | 21 | import android.graphics.SurfaceTexture; |
Doris Liu | f9e4f8f | 2013-12-04 18:04:22 -0800 | [diff] [blame] | 22 | import android.view.GestureDetector; |
Doris Liu | f9e4f8f | 2013-12-04 18:04:22 -0800 | [diff] [blame] | 23 | import android.view.MotionEvent; |
Doris Liu | 6827ce2 | 2013-03-12 19:24:28 -0700 | [diff] [blame] | 24 | import android.view.View; |
Doris Liu | 6827ce2 | 2013-03-12 19:24:28 -0700 | [diff] [blame] | 25 | import android.view.ViewGroup; |
Doris Liu | 6827ce2 | 2013-03-12 19:24:28 -0700 | [diff] [blame] | 26 | import android.widget.ImageView; |
| 27 | import android.widget.LinearLayout; |
| 28 | import android.widget.TextView; |
| 29 | |
Senpo Hu | 0bdc4b5 | 2014-11-17 22:56:31 -0800 | [diff] [blame] | 30 | import com.android.camera.app.OrientationManager; |
Angus Kong | 5596b4c | 2014-03-11 16:27:30 -0700 | [diff] [blame] | 31 | import com.android.camera.debug.Log; |
Doris Liu | f9e4f8f | 2013-12-04 18:04:22 -0800 | [diff] [blame] | 32 | import com.android.camera.ui.PreviewOverlay; |
Doris Liu | 06db742 | 2013-12-09 19:36:25 -0800 | [diff] [blame] | 33 | import com.android.camera.ui.PreviewStatusListener; |
Doris Liu | 6827ce2 | 2013-03-12 19:24:28 -0700 | [diff] [blame] | 34 | import com.android.camera.ui.RotateLayout; |
Paul Rohde | 987ee64 | 2014-12-05 12:17:15 -0800 | [diff] [blame] | 35 | import com.android.camera.ui.focus.FocusRing; |
Doris Liu | 8dc878f | 2014-05-05 14:10:34 -0700 | [diff] [blame] | 36 | import com.android.camera.widget.VideoRecordingHints; |
Sascha Haeberling | 8e963a5 | 2013-08-06 11:43:02 -0700 | [diff] [blame] | 37 | import com.android.camera2.R; |
Sol Boucher | 5a34496 | 2014-06-17 14:05:08 -0700 | [diff] [blame] | 38 | import com.android.ex.camera2.portability.CameraCapabilities; |
| 39 | import com.android.ex.camera2.portability.CameraSettings; |
Sascha Haeberling | 638e6f0 | 2013-09-18 14:28:51 -0700 | [diff] [blame] | 40 | |
Erin Dahlgren | d8de077 | 2014-02-03 10:12:27 -0800 | [diff] [blame] | 41 | public class VideoUI implements PreviewStatusListener { |
Angus Kong | 5596b4c | 2014-03-11 16:27:30 -0700 | [diff] [blame] | 42 | private static final Log.Tag TAG = new Log.Tag("VideoUI"); |
Doris Liu | e038c16 | 2013-12-13 23:06:11 -0800 | [diff] [blame] | 43 | |
Doris Liu | 70da918 | 2013-12-17 18:41:15 -0800 | [diff] [blame] | 44 | private final static float UNSET = 0f; |
Doris Liu | f9e4f8f | 2013-12-04 18:04:22 -0800 | [diff] [blame] | 45 | private final PreviewOverlay mPreviewOverlay; |
Doris Liu | 6827ce2 | 2013-03-12 19:24:28 -0700 | [diff] [blame] | 46 | // module fields |
Sascha Haeberling | 67019c7 | 2013-12-14 01:08:38 -0800 | [diff] [blame] | 47 | private final CameraActivity mActivity; |
| 48 | private final View mRootView; |
Paul Rohde | 987ee64 | 2014-12-05 12:17:15 -0800 | [diff] [blame] | 49 | private final FocusRing mFocusRing; |
Doris Liu | 6827ce2 | 2013-03-12 19:24:28 -0700 | [diff] [blame] | 50 | // An review image having same size as preview. It is displayed when |
| 51 | // recording is stopped in capture intent. |
| 52 | private ImageView mReviewImage; |
Doris Liu | 8dc878f | 2014-05-05 14:10:34 -0700 | [diff] [blame] | 53 | private VideoRecordingHints mVideoHints; |
Doris Liu | 6827ce2 | 2013-03-12 19:24:28 -0700 | [diff] [blame] | 54 | private TextView mRecordingTimeView; |
| 55 | private LinearLayout mLabelsLinearLayout; |
Doris Liu | 6827ce2 | 2013-03-12 19:24:28 -0700 | [diff] [blame] | 56 | private RotateLayout mRecordingTimeRect; |
Doris Liu | fe6596c | 2013-10-08 11:03:37 -0700 | [diff] [blame] | 57 | private boolean mRecordingStarted = false; |
Sascha Haeberling | 67019c7 | 2013-12-14 01:08:38 -0800 | [diff] [blame] | 58 | private final VideoController mController; |
Sol Boucher | 2192fba | 2014-08-19 17:24:07 -0700 | [diff] [blame] | 59 | private float mZoomMax; |
Doris Liu | 6827ce2 | 2013-03-12 19:24:28 -0700 | [diff] [blame] | 60 | |
Doris Liu | 70da918 | 2013-12-17 18:41:15 -0800 | [diff] [blame] | 61 | private float mAspectRatio = UNSET; |
Sascha Haeberling | 37f3611 | 2013-08-06 14:31:52 -0700 | [diff] [blame] | 62 | private final AnimationManager mAnimationManager; |
Doris Liu | e038c16 | 2013-12-13 23:06:11 -0800 | [diff] [blame] | 63 | |
Doris Liu | 4a010db | 2013-12-16 18:44:49 -0800 | [diff] [blame] | 64 | @Override |
| 65 | public void onPreviewLayoutChanged(View v, int left, int top, int right, |
| 66 | int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) { |
Doris Liu | 70da918 | 2013-12-17 18:41:15 -0800 | [diff] [blame] | 67 | } |
| 68 | |
| 69 | @Override |
| 70 | public boolean shouldAutoAdjustTransformMatrixOnLayout() { |
| 71 | return true; |
| 72 | } |
| 73 | |
| 74 | @Override |
| 75 | public boolean shouldAutoAdjustBottomBar() { |
| 76 | return true; |
Doris Liu | 4a010db | 2013-12-16 18:44:49 -0800 | [diff] [blame] | 77 | } |
Doris Liu | 6432cd6 | 2013-06-13 17:20:31 -0700 | [diff] [blame] | 78 | |
Doris Liu | 11ddd73 | 2014-01-07 10:52:11 -0800 | [diff] [blame] | 79 | @Override |
| 80 | public void onPreviewFlipped() { |
| 81 | mController.updateCameraOrientation(); |
| 82 | } |
| 83 | |
Doris Liu | 06db742 | 2013-12-09 19:36:25 -0800 | [diff] [blame] | 84 | private final GestureDetector.OnGestureListener mPreviewGestureListener |
| 85 | = new GestureDetector.SimpleOnGestureListener() { |
| 86 | @Override |
| 87 | public boolean onSingleTapUp(MotionEvent ev) { |
Doris Liu | d6487c9 | 2014-02-28 10:35:45 -0800 | [diff] [blame] | 88 | if (mVideoHints.getVisibility() == View.VISIBLE) { |
| 89 | mVideoHints.setVisibility(View.INVISIBLE); |
| 90 | } else { |
| 91 | mController.onSingleTapUp(null, (int) ev.getX(), (int) ev.getY()); |
| 92 | } |
Doris Liu | 06db742 | 2013-12-09 19:36:25 -0800 | [diff] [blame] | 93 | return true; |
| 94 | } |
| 95 | }; |
Doris Liu | 3a45c33 | 2013-10-15 19:10:28 -0700 | [diff] [blame] | 96 | |
Doris Liu | 6827ce2 | 2013-03-12 19:24:28 -0700 | [diff] [blame] | 97 | public VideoUI(CameraActivity activity, VideoController controller, View parent) { |
| 98 | mActivity = activity; |
| 99 | mController = controller; |
| 100 | mRootView = parent; |
Doris Liu | f55f3c4 | 2013-11-20 00:24:46 -0800 | [diff] [blame] | 101 | ViewGroup moduleRoot = (ViewGroup) mRootView.findViewById(R.id.module_layout); |
| 102 | mActivity.getLayoutInflater().inflate(R.layout.video_module, |
Sascha Haeberling | 67019c7 | 2013-12-14 01:08:38 -0800 | [diff] [blame] | 103 | moduleRoot, true); |
Marco Nelissen | 0744e4a | 2013-11-22 01:47:37 +0000 | [diff] [blame] | 104 | |
Doris Liu | f9e4f8f | 2013-12-04 18:04:22 -0800 | [diff] [blame] | 105 | mPreviewOverlay = (PreviewOverlay) mRootView.findViewById(R.id.preview_overlay); |
Doris Liu | e038c16 | 2013-12-13 23:06:11 -0800 | [diff] [blame] | 106 | |
Doris Liu | 6827ce2 | 2013-03-12 19:24:28 -0700 | [diff] [blame] | 107 | initializeMiscControls(); |
Sascha Haeberling | 37f3611 | 2013-08-06 14:31:52 -0700 | [diff] [blame] | 108 | mAnimationManager = new AnimationManager(); |
Paul Rohde | 987ee64 | 2014-12-05 12:17:15 -0800 | [diff] [blame] | 109 | mFocusRing = (FocusRing) mRootView.findViewById(R.id.focus_ring); |
Doris Liu | 8dc878f | 2014-05-05 14:10:34 -0700 | [diff] [blame] | 110 | mVideoHints = (VideoRecordingHints) mRootView.findViewById(R.id.video_shooting_hints); |
Doris Liu | 6827ce2 | 2013-03-12 19:24:28 -0700 | [diff] [blame] | 111 | } |
| 112 | |
Doris Liu | 6432cd6 | 2013-06-13 17:20:31 -0700 | [diff] [blame] | 113 | public void setPreviewSize(int width, int height) { |
| 114 | if (width == 0 || height == 0) { |
| 115 | Log.w(TAG, "Preview size should not be 0."); |
| 116 | return; |
| 117 | } |
Doris Liu | e038c16 | 2013-12-13 23:06:11 -0800 | [diff] [blame] | 118 | float aspectRatio; |
Doris Liu | 6432cd6 | 2013-06-13 17:20:31 -0700 | [diff] [blame] | 119 | if (width > height) { |
Doris Liu | e038c16 | 2013-12-13 23:06:11 -0800 | [diff] [blame] | 120 | aspectRatio = (float) width / height; |
Doris Liu | 6432cd6 | 2013-06-13 17:20:31 -0700 | [diff] [blame] | 121 | } else { |
Doris Liu | e038c16 | 2013-12-13 23:06:11 -0800 | [diff] [blame] | 122 | aspectRatio = (float) height / width; |
Doris Liu | 6432cd6 | 2013-06-13 17:20:31 -0700 | [diff] [blame] | 123 | } |
Doris Liu | e038c16 | 2013-12-13 23:06:11 -0800 | [diff] [blame] | 124 | setAspectRatio(aspectRatio); |
Doris Liu | 6432cd6 | 2013-06-13 17:20:31 -0700 | [diff] [blame] | 125 | } |
| 126 | |
Paul Rohde | 987ee64 | 2014-12-05 12:17:15 -0800 | [diff] [blame] | 127 | public FocusRing getFocusRing() { |
| 128 | return mFocusRing; |
Doris Liu | a1ec04a | 2014-01-13 17:29:40 -0800 | [diff] [blame] | 129 | } |
| 130 | |
Sascha Haeberling | 37f3611 | 2013-08-06 14:31:52 -0700 | [diff] [blame] | 131 | /** |
Sascha Haeberling | 37f3611 | 2013-08-06 14:31:52 -0700 | [diff] [blame] | 132 | * Cancels on-going animations |
| 133 | */ |
| 134 | public void cancelAnimations() { |
| 135 | mAnimationManager.cancelAnimations(); |
| 136 | } |
| 137 | |
Doris Liu | 6827ce2 | 2013-03-12 19:24:28 -0700 | [diff] [blame] | 138 | public void setOrientationIndicator(int orientation, boolean animation) { |
Doris Liu | 6827ce2 | 2013-03-12 19:24:28 -0700 | [diff] [blame] | 139 | // We change the orientation of the linearlayout only for phone UI |
| 140 | // because when in portrait the width is not enough. |
| 141 | if (mLabelsLinearLayout != null) { |
| 142 | if (((orientation / 90) & 1) == 0) { |
| 143 | mLabelsLinearLayout.setOrientation(LinearLayout.VERTICAL); |
| 144 | } else { |
| 145 | mLabelsLinearLayout.setOrientation(LinearLayout.HORIZONTAL); |
| 146 | } |
| 147 | } |
| 148 | mRecordingTimeRect.setOrientation(0, animation); |
| 149 | } |
| 150 | |
Doris Liu | 6827ce2 | 2013-03-12 19:24:28 -0700 | [diff] [blame] | 151 | private void initializeMiscControls() { |
Doris Liu | 6827ce2 | 2013-03-12 19:24:28 -0700 | [diff] [blame] | 152 | mReviewImage = (ImageView) mRootView.findViewById(R.id.review_image); |
Doris Liu | 6827ce2 | 2013-03-12 19:24:28 -0700 | [diff] [blame] | 153 | mRecordingTimeView = (TextView) mRootView.findViewById(R.id.recording_time); |
| 154 | mRecordingTimeRect = (RotateLayout) mRootView.findViewById(R.id.recording_time_rect); |
Doris Liu | 6827ce2 | 2013-03-12 19:24:28 -0700 | [diff] [blame] | 155 | // The R.id.labels can only be found in phone layout. |
| 156 | // That is, mLabelsLinearLayout should be null in tablet layout. |
| 157 | mLabelsLinearLayout = (LinearLayout) mRootView.findViewById(R.id.labels); |
| 158 | } |
| 159 | |
Angus Kong | 6607dae | 2014-06-10 16:07:45 -0700 | [diff] [blame] | 160 | public void updateOnScreenIndicators(CameraSettings settings) { |
Doris Liu | 6827ce2 | 2013-03-12 19:24:28 -0700 | [diff] [blame] | 161 | } |
| 162 | |
Doris Liu | e038c16 | 2013-12-13 23:06:11 -0800 | [diff] [blame] | 163 | public void setAspectRatio(float ratio) { |
| 164 | if (ratio <= 0) { |
| 165 | return; |
| 166 | } |
| 167 | float aspectRatio = ratio > 1 ? ratio : 1 / ratio; |
| 168 | if (aspectRatio != mAspectRatio) { |
| 169 | mAspectRatio = aspectRatio; |
Doris Liu | 70da918 | 2013-12-17 18:41:15 -0800 | [diff] [blame] | 170 | mController.updatePreviewAspectRatio(mAspectRatio); |
Doris Liu | e038c16 | 2013-12-13 23:06:11 -0800 | [diff] [blame] | 171 | } |
Doris Liu | 6827ce2 | 2013-03-12 19:24:28 -0700 | [diff] [blame] | 172 | } |
| 173 | |
Doris Liu | 6432cd6 | 2013-06-13 17:20:31 -0700 | [diff] [blame] | 174 | public void setSwipingEnabled(boolean enable) { |
| 175 | mActivity.setSwipingEnabled(enable); |
Doris Liu | 6827ce2 | 2013-03-12 19:24:28 -0700 | [diff] [blame] | 176 | } |
| 177 | |
| 178 | public void showPreviewBorder(boolean enable) { |
Doris Liu | 6432cd6 | 2013-06-13 17:20:31 -0700 | [diff] [blame] | 179 | // TODO: mPreviewFrameLayout.showBorder(enable); |
Doris Liu | 6827ce2 | 2013-03-12 19:24:28 -0700 | [diff] [blame] | 180 | } |
| 181 | |
Doris Liu | fe6596c | 2013-10-08 11:03:37 -0700 | [diff] [blame] | 182 | public void showRecordingUI(boolean recording) { |
| 183 | mRecordingStarted = recording; |
Doris Liu | 6827ce2 | 2013-03-12 19:24:28 -0700 | [diff] [blame] | 184 | if (recording) { |
Doris Liu | 6827ce2 | 2013-03-12 19:24:28 -0700 | [diff] [blame] | 185 | mRecordingTimeView.setText(""); |
| 186 | mRecordingTimeView.setVisibility(View.VISIBLE); |
Alan Newberger | f271192 | 2014-03-26 11:28:50 -0700 | [diff] [blame] | 187 | mRecordingTimeView.announceForAccessibility( |
| 188 | mActivity.getResources().getString(R.string.video_recording_started)); |
Doris Liu | 6827ce2 | 2013-03-12 19:24:28 -0700 | [diff] [blame] | 189 | } else { |
Alan Newberger | f271192 | 2014-03-26 11:28:50 -0700 | [diff] [blame] | 190 | mRecordingTimeView.announceForAccessibility( |
| 191 | mActivity.getResources().getString(R.string.video_recording_stopped)); |
Doris Liu | 6827ce2 | 2013-03-12 19:24:28 -0700 | [diff] [blame] | 192 | mRecordingTimeView.setVisibility(View.GONE); |
Doris Liu | 6827ce2 | 2013-03-12 19:24:28 -0700 | [diff] [blame] | 193 | } |
| 194 | } |
| 195 | |
| 196 | public void showReviewImage(Bitmap bitmap) { |
| 197 | mReviewImage.setImageBitmap(bitmap); |
| 198 | mReviewImage.setVisibility(View.VISIBLE); |
| 199 | } |
| 200 | |
| 201 | public void showReviewControls() { |
Erin Dahlgren | 4efa8b5 | 2013-12-17 18:31:35 -0800 | [diff] [blame] | 202 | mActivity.getCameraAppUI().transitionToIntentReviewLayout(); |
Doris Liu | 6827ce2 | 2013-03-12 19:24:28 -0700 | [diff] [blame] | 203 | mReviewImage.setVisibility(View.VISIBLE); |
Doris Liu | 6827ce2 | 2013-03-12 19:24:28 -0700 | [diff] [blame] | 204 | } |
| 205 | |
Angus Kong | 6607dae | 2014-06-10 16:07:45 -0700 | [diff] [blame] | 206 | public void initializeZoom(CameraSettings settings, CameraCapabilities capabilities) { |
Sol Boucher | 2192fba | 2014-08-19 17:24:07 -0700 | [diff] [blame] | 207 | mZoomMax = capabilities.getMaxZoomRatio(); |
Doris Liu | 6827ce2 | 2013-03-12 19:24:28 -0700 | [diff] [blame] | 208 | // Currently we use immediate zoom for fast zooming to get better UX and |
| 209 | // there is no plan to take advantage of the smooth zoom. |
Doris Liu | f9e4f8f | 2013-12-04 18:04:22 -0800 | [diff] [blame] | 210 | // TODO: setup zoom through App UI. |
Sol Boucher | 2192fba | 2014-08-19 17:24:07 -0700 | [diff] [blame] | 211 | mPreviewOverlay.setupZoom(mZoomMax, settings.getCurrentZoomRatio(), |
Angus Kong | 6607dae | 2014-06-10 16:07:45 -0700 | [diff] [blame] | 212 | new ZoomChangeListener()); |
Doris Liu | 6827ce2 | 2013-03-12 19:24:28 -0700 | [diff] [blame] | 213 | } |
| 214 | |
Doris Liu | 6827ce2 | 2013-03-12 19:24:28 -0700 | [diff] [blame] | 215 | public void setRecordingTime(String text) { |
| 216 | mRecordingTimeView.setText(text); |
| 217 | } |
| 218 | |
| 219 | public void setRecordingTimeTextColor(int color) { |
| 220 | mRecordingTimeView.setTextColor(color); |
| 221 | } |
| 222 | |
Doris Liu | 6432cd6 | 2013-06-13 17:20:31 -0700 | [diff] [blame] | 223 | public boolean isVisible() { |
Marco Nelissen | 0744e4a | 2013-11-22 01:47:37 +0000 | [diff] [blame] | 224 | return false; |
Doris Liu | 6432cd6 | 2013-06-13 17:20:31 -0700 | [diff] [blame] | 225 | } |
| 226 | |
Doris Liu | 06db742 | 2013-12-09 19:36:25 -0800 | [diff] [blame] | 227 | @Override |
| 228 | public GestureDetector.OnGestureListener getGestureListener() { |
| 229 | return mPreviewGestureListener; |
| 230 | } |
| 231 | |
Erin Dahlgren | d8de077 | 2014-02-03 10:12:27 -0800 | [diff] [blame] | 232 | @Override |
| 233 | public View.OnTouchListener getTouchListener() { |
| 234 | return null; |
| 235 | } |
| 236 | |
Doris Liu | 38c6bc3 | 2014-01-16 18:03:18 -0800 | [diff] [blame] | 237 | /** |
Paul Rohde | 987ee64 | 2014-12-05 12:17:15 -0800 | [diff] [blame] | 238 | * Hide the focus indicator. |
Doris Liu | 38c6bc3 | 2014-01-16 18:03:18 -0800 | [diff] [blame] | 239 | */ |
Paul Rohde | 987ee64 | 2014-12-05 12:17:15 -0800 | [diff] [blame] | 240 | public void hidePassiveFocusIndicator() { |
| 241 | if (mFocusRing != null) { |
| 242 | Log.v(TAG, "mFocusRing.stopFocusAnimations()"); |
| 243 | mFocusRing.stopFocusAnimations(); |
Doris Liu | 38c6bc3 | 2014-01-16 18:03:18 -0800 | [diff] [blame] | 244 | } |
| 245 | } |
| 246 | |
Doris Liu | d6487c9 | 2014-02-28 10:35:45 -0800 | [diff] [blame] | 247 | /** |
Paul Rohde | 987ee64 | 2014-12-05 12:17:15 -0800 | [diff] [blame] | 248 | * Show the passive focus indicator. |
| 249 | */ |
| 250 | public void showPassiveFocusIndicator() { |
| 251 | if (mFocusRing != null) { |
| 252 | mFocusRing.startPassiveFocus(); |
| 253 | } |
| 254 | } |
| 255 | |
| 256 | |
| 257 | /** |
Doris Liu | d6487c9 | 2014-02-28 10:35:45 -0800 | [diff] [blame] | 258 | * Shows or hides video recording hints. |
| 259 | * |
| 260 | * @param show shows video recording hints when true, hides it otherwise. |
| 261 | */ |
| 262 | public void showVideoRecordingHints(boolean show) { |
| 263 | mVideoHints.setVisibility(show ? View.VISIBLE : View.INVISIBLE); |
| 264 | } |
| 265 | |
Angus Kong | 5f8c30e | 2014-03-06 17:15:08 -0800 | [diff] [blame] | 266 | /** |
| 267 | * @return The size of the available preview area. |
| 268 | */ |
| 269 | public Point getPreviewScreenSize() { |
| 270 | return new Point(mRootView.getMeasuredWidth(), mRootView.getMeasuredHeight()); |
| 271 | } |
| 272 | |
Senpo Hu | 0bdc4b5 | 2014-11-17 22:56:31 -0800 | [diff] [blame] | 273 | public void onOrientationChanged(OrientationManager orientationManager, |
| 274 | OrientationManager.DeviceOrientation deviceOrientation) { |
| 275 | mVideoHints.onOrientationChanged(orientationManager, deviceOrientation); |
Doris Liu | 8dc878f | 2014-05-05 14:10:34 -0700 | [diff] [blame] | 276 | } |
| 277 | |
Doris Liu | f9e4f8f | 2013-12-04 18:04:22 -0800 | [diff] [blame] | 278 | private class ZoomChangeListener implements PreviewOverlay.OnZoomChangedListener { |
Doris Liu | 6827ce2 | 2013-03-12 19:24:28 -0700 | [diff] [blame] | 279 | @Override |
Sol Boucher | 2192fba | 2014-08-19 17:24:07 -0700 | [diff] [blame] | 280 | public void onZoomValueChanged(float ratio) { |
| 281 | mController.onZoomChanged(ratio); |
Doris Liu | 6827ce2 | 2013-03-12 19:24:28 -0700 | [diff] [blame] | 282 | } |
| 283 | |
| 284 | @Override |
| 285 | public void onZoomStart() { |
| 286 | } |
| 287 | |
| 288 | @Override |
| 289 | public void onZoomEnd() { |
| 290 | } |
| 291 | } |
Michael Kolb | 3bc96b2 | 2013-03-12 10:24:42 -0700 | [diff] [blame] | 292 | |
Doris Liu | 6432cd6 | 2013-06-13 17:20:31 -0700 | [diff] [blame] | 293 | // SurfaceTexture callbacks |
Michael Kolb | 3bc96b2 | 2013-03-12 10:24:42 -0700 | [diff] [blame] | 294 | @Override |
Doris Liu | 6432cd6 | 2013-06-13 17:20:31 -0700 | [diff] [blame] | 295 | public void onSurfaceTextureAvailable(SurfaceTexture surface, int width, int height) { |
Angus Kong | 395ee2d | 2013-07-15 12:42:41 -0700 | [diff] [blame] | 296 | mController.onPreviewUIReady(); |
Michael Kolb | 3bc96b2 | 2013-03-12 10:24:42 -0700 | [diff] [blame] | 297 | } |
| 298 | |
Doris Liu | 6432cd6 | 2013-06-13 17:20:31 -0700 | [diff] [blame] | 299 | @Override |
| 300 | public boolean onSurfaceTextureDestroyed(SurfaceTexture surface) { |
Angus Kong | 395ee2d | 2013-07-15 12:42:41 -0700 | [diff] [blame] | 301 | mController.onPreviewUIDestroyed(); |
Doris Liu | 6432cd6 | 2013-06-13 17:20:31 -0700 | [diff] [blame] | 302 | Log.d(TAG, "surfaceTexture is destroyed"); |
| 303 | return true; |
| 304 | } |
| 305 | |
| 306 | @Override |
| 307 | public void onSurfaceTextureSizeChanged(SurfaceTexture surface, int width, int height) { |
| 308 | } |
| 309 | |
| 310 | @Override |
| 311 | public void onSurfaceTextureUpdated(SurfaceTexture surface) { |
| 312 | } |
Alan Newberger | 7351415 | 2014-09-10 15:03:27 -0700 | [diff] [blame] | 313 | |
| 314 | public void onPause() { |
| 315 | // recalculate aspect ratio when restarting. |
| 316 | mAspectRatio = 0.0f; |
| 317 | } |
Doris Liu | 6827ce2 | 2013-03-12 19:24:28 -0700 | [diff] [blame] | 318 | } |