CameraActivity.java revision 1ef76d4cbd73c02cb8d02cf4cde3f4cee81548d6
18872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb/* 28872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb * Copyright (C) 2012 The Android Open Source Project 38872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb * 48872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb * Licensed under the Apache License, Version 2.0 (the "License"); 58872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb * you may not use this file except in compliance with the License. 68872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb * You may obtain a copy of the License at 78872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb * 88872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb * http://www.apache.org/licenses/LICENSE-2.0 98872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb * 108872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb * Unless required by applicable law or agreed to in writing, software 118872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb * distributed under the License is distributed on an "AS IS" BASIS, 128872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 138872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb * See the License for the specific language governing permissions and 148872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb * limitations under the License. 158872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb */ 168872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb 178872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolbpackage com.android.camera; 188872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb 19fa9e2cc9ccbcd746f5765cb7a0afebcdb60e2973ztenghuiimport android.app.ActionBar; 206432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liuimport android.app.Activity; 21b84b9738c855a525dc1944165983cc3c342ce446Doris Liuimport android.content.BroadcastReceiver; 2286d36313d88fe96354f2cdd4f378e5ff8397c458Angus Kongimport android.content.ComponentName; 236432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liuimport android.content.ContentResolver; 2408650187c1f1a2d1ef7f754be0f479a29958daaaMichael Kolbimport android.content.Context; 258872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolbimport android.content.Intent; 26b84b9738c855a525dc1944165983cc3c342ce446Doris Liuimport android.content.IntentFilter; 2786d36313d88fe96354f2cdd4f378e5ff8397c458Angus Kongimport android.content.ServiceConnection; 282654dd9bb6a7d917dab1a48e2182c4f49fe71f11Sascha Haeberlingimport android.content.SharedPreferences; 293cf565c4242a9deab7da5eb84fc302c79d594f11Doris Liuimport android.content.pm.ActivityInfo; 308872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolbimport android.content.res.Configuration; 316432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liuimport android.graphics.drawable.ColorDrawable; 326432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liuimport android.net.Uri; 336f64b50db6565bc6454304fd20c0c4020b297bb7Sascha Haeberlingimport android.os.AsyncTask; 348872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolbimport android.os.Bundle; 356432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liuimport android.os.Handler; 3686d36313d88fe96354f2cdd4f378e5ff8397c458Angus Kongimport android.os.IBinder; 372654dd9bb6a7d917dab1a48e2182c4f49fe71f11Sascha Haeberlingimport android.preference.PreferenceManager; 382a7f44cac888de5683d05bef5708f846ee950f43Doris Liuimport android.provider.MediaStore; 393cf565c4242a9deab7da5eb84fc302c79d594f11Doris Liuimport android.provider.Settings; 4037f3611bbdc787c996a99894dcef7d8fb77e3f7cSascha Haeberlingimport android.util.Log; 418872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolbimport android.view.KeyEvent; 426432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liuimport android.view.LayoutInflater; 430353ca2e048543bd6e233b4c2110a1df1070cd3fztenghuiimport android.view.Menu; 440353ca2e048543bd6e233b4c2110a1df1070cd3fztenghuiimport android.view.MenuInflater; 450353ca2e048543bd6e233b4c2110a1df1070cd3fztenghuiimport android.view.MenuItem; 468872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolbimport android.view.OrientationEventListener; 478872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolbimport android.view.View; 486432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liuimport android.view.ViewGroup; 4908650187c1f1a2d1ef7f754be0f479a29958daaaMichael Kolbimport android.view.Window; 5008650187c1f1a2d1ef7f754be0f479a29958daaaMichael Kolbimport android.view.WindowManager; 51653c43be6e58be54cf2ac3c8efb2d65ac20bd03bAngus Kongimport android.widget.FrameLayout; 526432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liuimport android.widget.ImageView; 5337f3611bbdc787c996a99894dcef7d8fb77e3f7cSascha Haeberlingimport android.widget.ProgressBar; 54cd2eeb0efc4370f20e9836e20eb11cb974e3b00dMangesh Ghiwareimport android.widget.ShareActionProvider; 558872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb 566432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liuimport com.android.camera.data.CameraDataAdapter; 578e5e4eedb25a4589342660b928935acca4375fc7Angus Kongimport com.android.camera.data.CameraPreviewData; 588e5e4eedb25a4589342660b928935acca4375fc7Angus Kongimport com.android.camera.data.FixedFirstDataAdapter; 598e5e4eedb25a4589342660b928935acca4375fc7Angus Kongimport com.android.camera.data.FixedLastDataAdapter; 606432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liuimport com.android.camera.data.LocalData; 618e5e4eedb25a4589342660b928935acca4375fc7Angus Kongimport com.android.camera.data.LocalDataAdapter; 626f64b50db6565bc6454304fd20c0c4020b297bb7Sascha Haeberlingimport com.android.camera.data.MediaDetails; 63bd26069d391830856c57c2141cd2efbc8423d871Angus Kongimport com.android.camera.data.SimpleViewData; 64147e26ab7075f0acd3978f0cd0541cd1da4b50e1Doris Liuimport com.android.camera.ui.CameraSwitcher; 656432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liuimport com.android.camera.ui.CameraSwitcher.CameraSwitchListener; 666f64b50db6565bc6454304fd20c0c4020b297bb7Sascha Haeberlingimport com.android.camera.ui.DetailsDialog; 676432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liuimport com.android.camera.ui.FilmStripView; 6888ef7664ba6a888fa5da8693091674e152b56192Sascha Haeberlingimport com.android.camera.util.ApiHelper; 69b50b5cbfbc0a67db6fc43373363b10381c9c61a3Angus Kongimport com.android.camera.util.CameraUtil; 7037f3611bbdc787c996a99894dcef7d8fb77e3f7cSascha Haeberlingimport com.android.camera.util.PhotoSphereHelper; 7188ef7664ba6a888fa5da8693091674e152b56192Sascha Haeberlingimport com.android.camera.util.PhotoSphereHelper.PanoramaViewHelper; 728e963a5a6016d246184ed65906f9d103e92b17e2Sascha Haeberlingimport com.android.camera2.R; 738872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb 746432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liupublic class CameraActivity extends Activity 756432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu implements CameraSwitchListener { 766432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu 776432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu private static final String TAG = "CAM_Activity"; 786432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu 796432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu private static final String INTENT_ACTION_STILL_IMAGE_CAMERA_SECURE = 806432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu "android.media.action.STILL_IMAGE_CAMERA_SECURE"; 816432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu public static final String ACTION_IMAGE_CAPTURE_SECURE = 826432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu "android.media.action.IMAGE_CAPTURE_SECURE"; 836b9203214d828d72758943aca55adceab684a862ztenghui public static final String ACTION_TRIM_VIDEO = 846b9203214d828d72758943aca55adceab684a862ztenghui "com.android.camera.action.TRIM"; 856b9203214d828d72758943aca55adceab684a862ztenghui public static final String MEDIA_ITEM_PATH = "media-item-path"; 866432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu 872654dd9bb6a7d917dab1a48e2182c4f49fe71f11Sascha Haeberling private static final String PREF_STARTUP_MODULE_INDEX = "camera.startup_module"; 882654dd9bb6a7d917dab1a48e2182c4f49fe71f11Sascha Haeberling 896432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu // The intent extra for camera from secure lock screen. True if the gallery 906432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu // should only show newly captured pictures. sSecureAlbumId does not 916432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu // increment. This is used when switching between camera, camcorder, and 926432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu // panorama. If the extra is not set, it is in the normal camera mode. 936432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu public static final String SECURE_CAMERA_EXTRA = "secure_camera"; 946432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu 950353ca2e048543bd6e233b4c2110a1df1070cd3fztenghui // Supported operations at FilmStripView. Different data has different 960353ca2e048543bd6e233b4c2110a1df1070cd3fztenghui // set of supported operations. 970353ca2e048543bd6e233b4c2110a1df1070cd3fztenghui private static final int SUPPORT_DELETE = 1 << 0; 980353ca2e048543bd6e233b4c2110a1df1070cd3fztenghui private static final int SUPPORT_ROTATE = 1 << 1; 990353ca2e048543bd6e233b4c2110a1df1070cd3fztenghui private static final int SUPPORT_INFO = 1 << 2; 1000353ca2e048543bd6e233b4c2110a1df1070cd3fztenghui private static final int SUPPORT_CROP = 1 << 3; 1010353ca2e048543bd6e233b4c2110a1df1070cd3fztenghui private static final int SUPPORT_SETAS = 1 << 4; 1020353ca2e048543bd6e233b4c2110a1df1070cd3fztenghui private static final int SUPPORT_EDIT = 1 << 5; 1030353ca2e048543bd6e233b4c2110a1df1070cd3fztenghui private static final int SUPPORT_TRIM = 1 << 6; 104cd2eeb0efc4370f20e9836e20eb11cb974e3b00dMangesh Ghiware private static final int SUPPORT_SHARE = 1 << 7; 105cd2eeb0efc4370f20e9836e20eb11cb974e3b00dMangesh Ghiware private static final int SUPPORT_SHARE_PANORAMA360 = 1 << 8; 106cd2eeb0efc4370f20e9836e20eb11cb974e3b00dMangesh Ghiware private static final int SUPPORT_SHOW_ON_MAP = 1 << 9; 1070353ca2e048543bd6e233b4c2110a1df1070cd3fztenghui private static final int SUPPORT_ALL = 0xffffffff; 1080353ca2e048543bd6e233b4c2110a1df1070cd3fztenghui 1096f64b50db6565bc6454304fd20c0c4020b297bb7Sascha Haeberling /** This data adapter is used by FilmStripView. */ 1108e5e4eedb25a4589342660b928935acca4375fc7Angus Kong private LocalDataAdapter mDataAdapter; 1118e5e4eedb25a4589342660b928935acca4375fc7Angus Kong /** This data adapter represents the real local camera data. */ 1128e5e4eedb25a4589342660b928935acca4375fc7Angus Kong private LocalDataAdapter mWrappedDataAdapter; 1138e5e4eedb25a4589342660b928935acca4375fc7Angus Kong 1146798c34ddb5248f038f351674c6a6c7a20992c8cAngus Kong private PanoramaStitchingManager mPanoramaManager; 1158872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb private int mCurrentModuleIndex; 1166432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu private CameraModule mCurrentModule; 117653c43be6e58be54cf2ac3c8efb2d65ac20bd03bAngus Kong private FrameLayout mLayoutRoot; 118653c43be6e58be54cf2ac3c8efb2d65ac20bd03bAngus Kong private FrameLayout mAboveFilmstripControlLayout; 119653c43be6e58be54cf2ac3c8efb2d65ac20bd03bAngus Kong private View mCameraModuleRootView; 1206432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu private FilmStripView mFilmStripView; 12137f3611bbdc787c996a99894dcef7d8fb77e3f7cSascha Haeberling private ProgressBar mBottomProgress; 12237f3611bbdc787c996a99894dcef7d8fb77e3f7cSascha Haeberling private View mPanoStitchingPanel; 1236432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu private int mResultCodeForTesting; 1246432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu private Intent mResultDataForTesting; 1256432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu private OnScreenHint mStorageHint; 1266432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu private long mStorageSpace = Storage.LOW_STORAGE_THRESHOLD; 1273cf565c4242a9deab7da5eb84fc302c79d594f11Doris Liu private boolean mAutoRotateScreen; 1286432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu private boolean mSecureCamera; 1296a8e8a1a0f3e8e62cd350733e275047475380d6bAngus Kong // This is a hack to speed up the start of SecureCamera. 1306a8e8a1a0f3e8e62cd350733e275047475380d6bAngus Kong private static boolean sFirstStartAfterScreenOn = true; 1316432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu private boolean mShowCameraPreview; 1326432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu private int mLastRawOrientation; 1338872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb private MyOrientationEventListener mOrientationListener; 1346432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu private Handler mMainHandler; 135f1f5186f7d3fd8bf35009d9e65a43914c664d82bSascha Haeberling private PanoramaViewHelper mPanoramaViewHelper; 1368e5e4eedb25a4589342660b928935acca4375fc7Angus Kong private CameraPreviewData mCameraPreviewData; 137fa9e2cc9ccbcd746f5765cb7a0afebcdb60e2973ztenghui private ActionBar mActionBar; 1380353ca2e048543bd6e233b4c2110a1df1070cd3fztenghui private Menu mActionBarMenu; 139653c43be6e58be54cf2ac3c8efb2d65ac20bd03bAngus Kong private ViewGroup mUndoDeletionBar; 1403cf565c4242a9deab7da5eb84fc302c79d594f11Doris Liu 141cd2eeb0efc4370f20e9836e20eb11cb974e3b00dMangesh Ghiware private ShareActionProvider mStandardShareActionProvider; 142cd2eeb0efc4370f20e9836e20eb11cb974e3b00dMangesh Ghiware private Intent mStandardShareIntent; 143cd2eeb0efc4370f20e9836e20eb11cb974e3b00dMangesh Ghiware private ShareActionProvider mPanoramaShareActionProvider; 144cd2eeb0efc4370f20e9836e20eb11cb974e3b00dMangesh Ghiware private Intent mPanoramaShareIntent; 145cd2eeb0efc4370f20e9836e20eb11cb974e3b00dMangesh Ghiware 146734598c39e6a9d809982dae2907dc7d10e0b0e9fAngus Kong public void gotoGallery() { 147734598c39e6a9d809982dae2907dc7d10e0b0e9fAngus Kong mFilmStripView.getController().goToNextItem(); 148734598c39e6a9d809982dae2907dc7d10e0b0e9fAngus Kong } 149734598c39e6a9d809982dae2907dc7d10e0b0e9fAngus Kong 1508872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb private class MyOrientationEventListener 1516432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu extends OrientationEventListener { 1528872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb public MyOrientationEventListener(Context context) { 1538872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb super(context); 1548872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb } 1558872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb 1568872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb @Override 1578872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb public void onOrientationChanged(int orientation) { 1588872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb // We keep the last known orientation. So if the user first orient 1598872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb // the camera then point the camera to floor or sky, we still have 1608872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb // the correct orientation. 1618872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb if (orientation == ORIENTATION_UNKNOWN) return; 1628872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb mLastRawOrientation = orientation; 1638872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb mCurrentModule.onOrientationChanged(orientation); 1648872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb } 1658872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb } 1668872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb 1676432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu private MediaSaveService mMediaSaveService; 1686432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu private ServiceConnection mConnection = new ServiceConnection() { 1696432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu @Override 1706432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu public void onServiceConnected(ComponentName className, IBinder b) { 1716432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu mMediaSaveService = ((MediaSaveService.LocalBinder) b).getService(); 1726432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu mCurrentModule.onMediaSaveServiceConnected(mMediaSaveService); 1738872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb } 1746432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu @Override 1756432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu public void onServiceDisconnected(ComponentName className) { 1767e374eb0a450ed2689b556ab42a0a88c8f74df2eAngus Kong if (mMediaSaveService != null) { 1777e374eb0a450ed2689b556ab42a0a88c8f74df2eAngus Kong mMediaSaveService.setListener(null); 1787e374eb0a450ed2689b556ab42a0a88c8f74df2eAngus Kong mMediaSaveService = null; 1797e374eb0a450ed2689b556ab42a0a88c8f74df2eAngus Kong } 1806432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu }}; 181e319aeabdc825f221df5af8a6ec080c6f5d41a94John Reck 182b84b9738c855a525dc1944165983cc3c342ce446Doris Liu // close activity when screen turns off 183b84b9738c855a525dc1944165983cc3c342ce446Doris Liu private BroadcastReceiver mScreenOffReceiver = new BroadcastReceiver() { 184b84b9738c855a525dc1944165983cc3c342ce446Doris Liu @Override 185b84b9738c855a525dc1944165983cc3c342ce446Doris Liu public void onReceive(Context context, Intent intent) { 186b84b9738c855a525dc1944165983cc3c342ce446Doris Liu finish(); 187b84b9738c855a525dc1944165983cc3c342ce446Doris Liu } 188b84b9738c855a525dc1944165983cc3c342ce446Doris Liu }; 189b84b9738c855a525dc1944165983cc3c342ce446Doris Liu 1906a8e8a1a0f3e8e62cd350733e275047475380d6bAngus Kong private static BroadcastReceiver sScreenOffReceiver; 1916a8e8a1a0f3e8e62cd350733e275047475380d6bAngus Kong private static class ScreenOffReceiver extends BroadcastReceiver { 1926a8e8a1a0f3e8e62cd350733e275047475380d6bAngus Kong @Override 1936a8e8a1a0f3e8e62cd350733e275047475380d6bAngus Kong public void onReceive(Context context, Intent intent) { 1946a8e8a1a0f3e8e62cd350733e275047475380d6bAngus Kong sFirstStartAfterScreenOn = true; 1956a8e8a1a0f3e8e62cd350733e275047475380d6bAngus Kong } 1966a8e8a1a0f3e8e62cd350733e275047475380d6bAngus Kong } 1976a8e8a1a0f3e8e62cd350733e275047475380d6bAngus Kong 1986a8e8a1a0f3e8e62cd350733e275047475380d6bAngus Kong public static boolean isFirstStartAfterScreenOn() { 1996a8e8a1a0f3e8e62cd350733e275047475380d6bAngus Kong return sFirstStartAfterScreenOn; 2006a8e8a1a0f3e8e62cd350733e275047475380d6bAngus Kong } 2016a8e8a1a0f3e8e62cd350733e275047475380d6bAngus Kong 2026a8e8a1a0f3e8e62cd350733e275047475380d6bAngus Kong public static void resetFirstStartAfterScreenOn() { 2036a8e8a1a0f3e8e62cd350733e275047475380d6bAngus Kong sFirstStartAfterScreenOn = false; 2046a8e8a1a0f3e8e62cd350733e275047475380d6bAngus Kong } 2056a8e8a1a0f3e8e62cd350733e275047475380d6bAngus Kong 20637f3611bbdc787c996a99894dcef7d8fb77e3f7cSascha Haeberling private FilmStripView.Listener mFilmStripListener = 20737f3611bbdc787c996a99894dcef7d8fb77e3f7cSascha Haeberling new FilmStripView.Listener() { 20837f3611bbdc787c996a99894dcef7d8fb77e3f7cSascha Haeberling @Override 20937f3611bbdc787c996a99894dcef7d8fb77e3f7cSascha Haeberling public void onDataPromoted(int dataID) { 21037f3611bbdc787c996a99894dcef7d8fb77e3f7cSascha Haeberling removeData(dataID); 21137f3611bbdc787c996a99894dcef7d8fb77e3f7cSascha Haeberling } 212e319aeabdc825f221df5af8a6ec080c6f5d41a94John Reck 21337f3611bbdc787c996a99894dcef7d8fb77e3f7cSascha Haeberling @Override 21437f3611bbdc787c996a99894dcef7d8fb77e3f7cSascha Haeberling public void onDataDemoted(int dataID) { 21537f3611bbdc787c996a99894dcef7d8fb77e3f7cSascha Haeberling removeData(dataID); 21637f3611bbdc787c996a99894dcef7d8fb77e3f7cSascha Haeberling } 217e319aeabdc825f221df5af8a6ec080c6f5d41a94John Reck 21837f3611bbdc787c996a99894dcef7d8fb77e3f7cSascha Haeberling @Override 21937f3611bbdc787c996a99894dcef7d8fb77e3f7cSascha Haeberling public void onDataFullScreenChange(int dataID, boolean full) { 22037f3611bbdc787c996a99894dcef7d8fb77e3f7cSascha Haeberling } 221e319aeabdc825f221df5af8a6ec080c6f5d41a94John Reck 22237f3611bbdc787c996a99894dcef7d8fb77e3f7cSascha Haeberling @Override 22337f3611bbdc787c996a99894dcef7d8fb77e3f7cSascha Haeberling public void onSwitchMode(boolean toCamera) { 22437f3611bbdc787c996a99894dcef7d8fb77e3f7cSascha Haeberling mCurrentModule.onSwitchMode(toCamera); 225fa9e2cc9ccbcd746f5765cb7a0afebcdb60e2973ztenghui if (toCamera) { 226fa9e2cc9ccbcd746f5765cb7a0afebcdb60e2973ztenghui mActionBar.hide(); 227fa9e2cc9ccbcd746f5765cb7a0afebcdb60e2973ztenghui } else { 228fa9e2cc9ccbcd746f5765cb7a0afebcdb60e2973ztenghui mActionBar.show(); 229fa9e2cc9ccbcd746f5765cb7a0afebcdb60e2973ztenghui } 23037f3611bbdc787c996a99894dcef7d8fb77e3f7cSascha Haeberling } 23137f3611bbdc787c996a99894dcef7d8fb77e3f7cSascha Haeberling 23237f3611bbdc787c996a99894dcef7d8fb77e3f7cSascha Haeberling @Override 23333035c19cc47adfb738c20cef66652ae451c8e10Mangesh Ghiware public void onCurrentDataChanged(final int dataID, final boolean current) { 23433035c19cc47adfb738c20cef66652ae451c8e10Mangesh Ghiware runOnUiThread(new Runnable() { 23533035c19cc47adfb738c20cef66652ae451c8e10Mangesh Ghiware @Override 23633035c19cc47adfb738c20cef66652ae451c8e10Mangesh Ghiware public void run() { 23733035c19cc47adfb738c20cef66652ae451c8e10Mangesh Ghiware if (!current) { 23833035c19cc47adfb738c20cef66652ae451c8e10Mangesh Ghiware hidePanoStitchingProgress(); 23933035c19cc47adfb738c20cef66652ae451c8e10Mangesh Ghiware } else { 24033035c19cc47adfb738c20cef66652ae451c8e10Mangesh Ghiware LocalData currentData = mDataAdapter.getLocalData(dataID); 24133035c19cc47adfb738c20cef66652ae451c8e10Mangesh Ghiware if (currentData == null) { 24233035c19cc47adfb738c20cef66652ae451c8e10Mangesh Ghiware Log.w(TAG, "Current data ID not found."); 24333035c19cc47adfb738c20cef66652ae451c8e10Mangesh Ghiware hidePanoStitchingProgress(); 24433035c19cc47adfb738c20cef66652ae451c8e10Mangesh Ghiware return; 24533035c19cc47adfb738c20cef66652ae451c8e10Mangesh Ghiware } 2461ef76d4cbd73c02cb8d02cf4cde3f4cee81548d6Alan Newberger 2471ef76d4cbd73c02cb8d02cf4cde3f4cee81548d6Alan Newberger if (currentData.getLocalDataType() == 2481ef76d4cbd73c02cb8d02cf4cde3f4cee81548d6Alan Newberger LocalData.LOCAL_CAMERA_PREVIEW) { 2491ef76d4cbd73c02cb8d02cf4cde3f4cee81548d6Alan Newberger // Don't show the action bar in Camera preview. 2501ef76d4cbd73c02cb8d02cf4cde3f4cee81548d6Alan Newberger mActionBar.hide(); 2511ef76d4cbd73c02cb8d02cf4cde3f4cee81548d6Alan Newberger } else { 2521ef76d4cbd73c02cb8d02cf4cde3f4cee81548d6Alan Newberger updateActionBarMenu(dataID); 2531ef76d4cbd73c02cb8d02cf4cde3f4cee81548d6Alan Newberger } 25433035c19cc47adfb738c20cef66652ae451c8e10Mangesh Ghiware 25533035c19cc47adfb738c20cef66652ae451c8e10Mangesh Ghiware Uri contentUri = currentData.getContentUri(); 25633035c19cc47adfb738c20cef66652ae451c8e10Mangesh Ghiware if (contentUri == null) { 25733035c19cc47adfb738c20cef66652ae451c8e10Mangesh Ghiware hidePanoStitchingProgress(); 25833035c19cc47adfb738c20cef66652ae451c8e10Mangesh Ghiware return; 25933035c19cc47adfb738c20cef66652ae451c8e10Mangesh Ghiware } 26033035c19cc47adfb738c20cef66652ae451c8e10Mangesh Ghiware int panoStitchingProgress = mPanoramaManager.getTaskProgress( 26133035c19cc47adfb738c20cef66652ae451c8e10Mangesh Ghiware contentUri); 26233035c19cc47adfb738c20cef66652ae451c8e10Mangesh Ghiware if (panoStitchingProgress < 0) { 26333035c19cc47adfb738c20cef66652ae451c8e10Mangesh Ghiware hidePanoStitchingProgress(); 26433035c19cc47adfb738c20cef66652ae451c8e10Mangesh Ghiware return; 26533035c19cc47adfb738c20cef66652ae451c8e10Mangesh Ghiware } 26633035c19cc47adfb738c20cef66652ae451c8e10Mangesh Ghiware showPanoStitchingProgress(); 26733035c19cc47adfb738c20cef66652ae451c8e10Mangesh Ghiware updateStitchingProgress(panoStitchingProgress); 26833035c19cc47adfb738c20cef66652ae451c8e10Mangesh Ghiware } 26937f3611bbdc787c996a99894dcef7d8fb77e3f7cSascha Haeberling } 27033035c19cc47adfb738c20cef66652ae451c8e10Mangesh Ghiware }); 27137f3611bbdc787c996a99894dcef7d8fb77e3f7cSascha Haeberling } 272394023fb7e3c8d07d4aeafc30bf4b66ed481ebb7Sascha Haeberling 273394023fb7e3c8d07d4aeafc30bf4b66ed481ebb7Sascha Haeberling @Override 27488ef7664ba6a888fa5da8693091674e152b56192Sascha Haeberling public boolean onToggleActionBarVisibility() { 275394023fb7e3c8d07d4aeafc30bf4b66ed481ebb7Sascha Haeberling if (mActionBar.isShowing()) { 276394023fb7e3c8d07d4aeafc30bf4b66ed481ebb7Sascha Haeberling mActionBar.hide(); 277394023fb7e3c8d07d4aeafc30bf4b66ed481ebb7Sascha Haeberling } else { 278fd43e3be3d69f48a97bdd9084e9549f41e963cc2ztenghui // In the preview, don't show the action bar if that is 279fd43e3be3d69f48a97bdd9084e9549f41e963cc2ztenghui // a capture intent. 280fd43e3be3d69f48a97bdd9084e9549f41e963cc2ztenghui if (!isCaptureIntent()) { 281fd43e3be3d69f48a97bdd9084e9549f41e963cc2ztenghui mActionBar.show(); 282fd43e3be3d69f48a97bdd9084e9549f41e963cc2ztenghui } 283394023fb7e3c8d07d4aeafc30bf4b66ed481ebb7Sascha Haeberling } 28488ef7664ba6a888fa5da8693091674e152b56192Sascha Haeberling return mActionBar.isShowing(); 285394023fb7e3c8d07d4aeafc30bf4b66ed481ebb7Sascha Haeberling } 28637f3611bbdc787c996a99894dcef7d8fb77e3f7cSascha Haeberling }; 28737f3611bbdc787c996a99894dcef7d8fb77e3f7cSascha Haeberling 28837f3611bbdc787c996a99894dcef7d8fb77e3f7cSascha Haeberling private void hidePanoStitchingProgress() { 28937f3611bbdc787c996a99894dcef7d8fb77e3f7cSascha Haeberling mPanoStitchingPanel.setVisibility(View.GONE); 29037f3611bbdc787c996a99894dcef7d8fb77e3f7cSascha Haeberling } 29137f3611bbdc787c996a99894dcef7d8fb77e3f7cSascha Haeberling 29237f3611bbdc787c996a99894dcef7d8fb77e3f7cSascha Haeberling private void showPanoStitchingProgress() { 29337f3611bbdc787c996a99894dcef7d8fb77e3f7cSascha Haeberling mPanoStitchingPanel.setVisibility(View.VISIBLE); 29437f3611bbdc787c996a99894dcef7d8fb77e3f7cSascha Haeberling } 29537f3611bbdc787c996a99894dcef7d8fb77e3f7cSascha Haeberling 29637f3611bbdc787c996a99894dcef7d8fb77e3f7cSascha Haeberling private void updateStitchingProgress(int progress) { 29737f3611bbdc787c996a99894dcef7d8fb77e3f7cSascha Haeberling mBottomProgress.setProgress(progress); 29837f3611bbdc787c996a99894dcef7d8fb77e3f7cSascha Haeberling } 2998872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb 300cd2eeb0efc4370f20e9836e20eb11cb974e3b00dMangesh Ghiware private void setStandardShareIntent(Uri contentUri, String mimeType) { 301cd2eeb0efc4370f20e9836e20eb11cb974e3b00dMangesh Ghiware if (mStandardShareIntent == null) { 302cd2eeb0efc4370f20e9836e20eb11cb974e3b00dMangesh Ghiware mStandardShareIntent = new Intent(Intent.ACTION_SEND); 303cd2eeb0efc4370f20e9836e20eb11cb974e3b00dMangesh Ghiware } 304cd2eeb0efc4370f20e9836e20eb11cb974e3b00dMangesh Ghiware mStandardShareIntent.setType(mimeType); 305cd2eeb0efc4370f20e9836e20eb11cb974e3b00dMangesh Ghiware mStandardShareIntent.putExtra(Intent.EXTRA_STREAM, contentUri); 306cd2eeb0efc4370f20e9836e20eb11cb974e3b00dMangesh Ghiware if (mStandardShareActionProvider != null) { 307cd2eeb0efc4370f20e9836e20eb11cb974e3b00dMangesh Ghiware mStandardShareActionProvider.setShareIntent(mStandardShareIntent); 308cd2eeb0efc4370f20e9836e20eb11cb974e3b00dMangesh Ghiware } 309cd2eeb0efc4370f20e9836e20eb11cb974e3b00dMangesh Ghiware } 310cd2eeb0efc4370f20e9836e20eb11cb974e3b00dMangesh Ghiware 311cd2eeb0efc4370f20e9836e20eb11cb974e3b00dMangesh Ghiware private void setPanoramaShareIntent(Uri contentUri) { 312cd2eeb0efc4370f20e9836e20eb11cb974e3b00dMangesh Ghiware if (mPanoramaShareIntent == null) { 313cd2eeb0efc4370f20e9836e20eb11cb974e3b00dMangesh Ghiware mPanoramaShareIntent = new Intent(Intent.ACTION_SEND); 314cd2eeb0efc4370f20e9836e20eb11cb974e3b00dMangesh Ghiware } 315cd2eeb0efc4370f20e9836e20eb11cb974e3b00dMangesh Ghiware mPanoramaShareIntent.setType("application/vnd.google.panorama360+jpg"); 316cd2eeb0efc4370f20e9836e20eb11cb974e3b00dMangesh Ghiware mPanoramaShareIntent.putExtra(Intent.EXTRA_STREAM, contentUri); 317cd2eeb0efc4370f20e9836e20eb11cb974e3b00dMangesh Ghiware if (mPanoramaShareActionProvider != null) { 318cd2eeb0efc4370f20e9836e20eb11cb974e3b00dMangesh Ghiware mPanoramaShareActionProvider.setShareIntent(mPanoramaShareIntent); 319cd2eeb0efc4370f20e9836e20eb11cb974e3b00dMangesh Ghiware } 320cd2eeb0efc4370f20e9836e20eb11cb974e3b00dMangesh Ghiware } 321cd2eeb0efc4370f20e9836e20eb11cb974e3b00dMangesh Ghiware 3220353ca2e048543bd6e233b4c2110a1df1070cd3fztenghui /** 3230353ca2e048543bd6e233b4c2110a1df1070cd3fztenghui * According to the data type, make the menu items for supported operations 3240353ca2e048543bd6e233b4c2110a1df1070cd3fztenghui * visible. 325fae11a165e344a38811770c7d348eda214683edcSascha Haeberling * @param dataID the data ID of the current item. 3260353ca2e048543bd6e233b4c2110a1df1070cd3fztenghui */ 327fae11a165e344a38811770c7d348eda214683edcSascha Haeberling private void updateActionBarMenu(int dataID) { 328fae11a165e344a38811770c7d348eda214683edcSascha Haeberling LocalData currentData = mDataAdapter.getLocalData(dataID); 329fae11a165e344a38811770c7d348eda214683edcSascha Haeberling int type = currentData.getLocalDataType(); 330fae11a165e344a38811770c7d348eda214683edcSascha Haeberling 3310353ca2e048543bd6e233b4c2110a1df1070cd3fztenghui if (mActionBarMenu == null) { 3320353ca2e048543bd6e233b4c2110a1df1070cd3fztenghui return; 3330353ca2e048543bd6e233b4c2110a1df1070cd3fztenghui } 3340353ca2e048543bd6e233b4c2110a1df1070cd3fztenghui 3350353ca2e048543bd6e233b4c2110a1df1070cd3fztenghui int supported = 0; 3360353ca2e048543bd6e233b4c2110a1df1070cd3fztenghui switch (type) { 3370353ca2e048543bd6e233b4c2110a1df1070cd3fztenghui case LocalData.LOCAL_IMAGE: 3380353ca2e048543bd6e233b4c2110a1df1070cd3fztenghui supported |= SUPPORT_DELETE | SUPPORT_ROTATE | SUPPORT_INFO 3390353ca2e048543bd6e233b4c2110a1df1070cd3fztenghui | SUPPORT_CROP | SUPPORT_SETAS | SUPPORT_EDIT 340cd2eeb0efc4370f20e9836e20eb11cb974e3b00dMangesh Ghiware | SUPPORT_SHARE | SUPPORT_SHOW_ON_MAP; 3410353ca2e048543bd6e233b4c2110a1df1070cd3fztenghui break; 3420353ca2e048543bd6e233b4c2110a1df1070cd3fztenghui case LocalData.LOCAL_VIDEO: 343cd2eeb0efc4370f20e9836e20eb11cb974e3b00dMangesh Ghiware supported |= SUPPORT_DELETE | SUPPORT_INFO | SUPPORT_TRIM 344cd2eeb0efc4370f20e9836e20eb11cb974e3b00dMangesh Ghiware | SUPPORT_SHARE; 3450353ca2e048543bd6e233b4c2110a1df1070cd3fztenghui break; 3460353ca2e048543bd6e233b4c2110a1df1070cd3fztenghui case LocalData.LOCAL_PHOTO_SPHERE: 3470353ca2e048543bd6e233b4c2110a1df1070cd3fztenghui supported |= SUPPORT_DELETE | SUPPORT_ROTATE | SUPPORT_INFO 3480353ca2e048543bd6e233b4c2110a1df1070cd3fztenghui | SUPPORT_CROP | SUPPORT_SETAS | SUPPORT_EDIT 349cd2eeb0efc4370f20e9836e20eb11cb974e3b00dMangesh Ghiware | SUPPORT_SHARE | SUPPORT_SHOW_ON_MAP; 350cd2eeb0efc4370f20e9836e20eb11cb974e3b00dMangesh Ghiware break; 351cd2eeb0efc4370f20e9836e20eb11cb974e3b00dMangesh Ghiware case LocalData.LOCAL_360_PHOTO_SPHERE: 352cd2eeb0efc4370f20e9836e20eb11cb974e3b00dMangesh Ghiware supported |= SUPPORT_DELETE | SUPPORT_ROTATE | SUPPORT_INFO 353cd2eeb0efc4370f20e9836e20eb11cb974e3b00dMangesh Ghiware | SUPPORT_CROP | SUPPORT_SETAS | SUPPORT_EDIT 354cd2eeb0efc4370f20e9836e20eb11cb974e3b00dMangesh Ghiware | SUPPORT_SHARE | SUPPORT_SHARE_PANORAMA360 3550353ca2e048543bd6e233b4c2110a1df1070cd3fztenghui | SUPPORT_SHOW_ON_MAP; 3560353ca2e048543bd6e233b4c2110a1df1070cd3fztenghui break; 3570353ca2e048543bd6e233b4c2110a1df1070cd3fztenghui default: 3580353ca2e048543bd6e233b4c2110a1df1070cd3fztenghui break; 3590353ca2e048543bd6e233b4c2110a1df1070cd3fztenghui } 3600353ca2e048543bd6e233b4c2110a1df1070cd3fztenghui 3610353ca2e048543bd6e233b4c2110a1df1070cd3fztenghui setMenuItemVisible(mActionBarMenu, R.id.action_delete, 3620353ca2e048543bd6e233b4c2110a1df1070cd3fztenghui (supported & SUPPORT_DELETE) != 0); 3630353ca2e048543bd6e233b4c2110a1df1070cd3fztenghui setMenuItemVisible(mActionBarMenu, R.id.action_rotate_ccw, 3640353ca2e048543bd6e233b4c2110a1df1070cd3fztenghui (supported & SUPPORT_ROTATE) != 0); 3650353ca2e048543bd6e233b4c2110a1df1070cd3fztenghui setMenuItemVisible(mActionBarMenu, R.id.action_rotate_cw, 3660353ca2e048543bd6e233b4c2110a1df1070cd3fztenghui (supported & SUPPORT_ROTATE) != 0); 367cd2eeb0efc4370f20e9836e20eb11cb974e3b00dMangesh Ghiware setMenuItemVisible(mActionBarMenu, R.id.action_details, 368cd2eeb0efc4370f20e9836e20eb11cb974e3b00dMangesh Ghiware (supported & SUPPORT_INFO) != 0); 3690353ca2e048543bd6e233b4c2110a1df1070cd3fztenghui setMenuItemVisible(mActionBarMenu, R.id.action_crop, 3700353ca2e048543bd6e233b4c2110a1df1070cd3fztenghui (supported & SUPPORT_CROP) != 0); 3710353ca2e048543bd6e233b4c2110a1df1070cd3fztenghui setMenuItemVisible(mActionBarMenu, R.id.action_setas, 3720353ca2e048543bd6e233b4c2110a1df1070cd3fztenghui (supported & SUPPORT_SETAS) != 0); 3730353ca2e048543bd6e233b4c2110a1df1070cd3fztenghui setMenuItemVisible(mActionBarMenu, R.id.action_edit, 3740353ca2e048543bd6e233b4c2110a1df1070cd3fztenghui (supported & SUPPORT_EDIT) != 0); 375cd2eeb0efc4370f20e9836e20eb11cb974e3b00dMangesh Ghiware setMenuItemVisible(mActionBarMenu, R.id.action_trim, 376cd2eeb0efc4370f20e9836e20eb11cb974e3b00dMangesh Ghiware (supported & SUPPORT_TRIM) != 0); 377cd2eeb0efc4370f20e9836e20eb11cb974e3b00dMangesh Ghiware 37833035c19cc47adfb738c20cef66652ae451c8e10Mangesh Ghiware boolean standardShare = (supported & SUPPORT_SHARE) != 0; 37933035c19cc47adfb738c20cef66652ae451c8e10Mangesh Ghiware boolean panoramaShare = (supported & SUPPORT_SHARE_PANORAMA360) != 0; 38033035c19cc47adfb738c20cef66652ae451c8e10Mangesh Ghiware setMenuItemVisible(mActionBarMenu, R.id.action_share, standardShare); 38133035c19cc47adfb738c20cef66652ae451c8e10Mangesh Ghiware setMenuItemVisible(mActionBarMenu, R.id.action_share_panorama, panoramaShare); 38233035c19cc47adfb738c20cef66652ae451c8e10Mangesh Ghiware 38333035c19cc47adfb738c20cef66652ae451c8e10Mangesh Ghiware if (panoramaShare) { 38433035c19cc47adfb738c20cef66652ae451c8e10Mangesh Ghiware // For 360 PhotoSphere, relegate standard share to the overflow menu 38533035c19cc47adfb738c20cef66652ae451c8e10Mangesh Ghiware MenuItem item = mActionBarMenu.findItem(R.id.action_share); 38633035c19cc47adfb738c20cef66652ae451c8e10Mangesh Ghiware if (item != null) { 38733035c19cc47adfb738c20cef66652ae451c8e10Mangesh Ghiware item.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); 38833035c19cc47adfb738c20cef66652ae451c8e10Mangesh Ghiware item.setTitle(getResources().getString(R.string.share_as_photo)); 38933035c19cc47adfb738c20cef66652ae451c8e10Mangesh Ghiware } 39033035c19cc47adfb738c20cef66652ae451c8e10Mangesh Ghiware // And, promote "share as panorama" to action bar 39133035c19cc47adfb738c20cef66652ae451c8e10Mangesh Ghiware item = mActionBarMenu.findItem(R.id.action_share_panorama); 39233035c19cc47adfb738c20cef66652ae451c8e10Mangesh Ghiware if (item != null) { 39333035c19cc47adfb738c20cef66652ae451c8e10Mangesh Ghiware item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); 39433035c19cc47adfb738c20cef66652ae451c8e10Mangesh Ghiware } 395cd2eeb0efc4370f20e9836e20eb11cb974e3b00dMangesh Ghiware setPanoramaShareIntent(currentData.getContentUri()); 396cd2eeb0efc4370f20e9836e20eb11cb974e3b00dMangesh Ghiware } 39733035c19cc47adfb738c20cef66652ae451c8e10Mangesh Ghiware if (standardShare) { 39833035c19cc47adfb738c20cef66652ae451c8e10Mangesh Ghiware if (!panoramaShare) { 39933035c19cc47adfb738c20cef66652ae451c8e10Mangesh Ghiware MenuItem item = mActionBarMenu.findItem(R.id.action_share); 40033035c19cc47adfb738c20cef66652ae451c8e10Mangesh Ghiware if (item != null) { 40133035c19cc47adfb738c20cef66652ae451c8e10Mangesh Ghiware item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); 40233035c19cc47adfb738c20cef66652ae451c8e10Mangesh Ghiware item.setTitle(getResources().getString(R.string.share)); 40333035c19cc47adfb738c20cef66652ae451c8e10Mangesh Ghiware } 40433035c19cc47adfb738c20cef66652ae451c8e10Mangesh Ghiware } 40533035c19cc47adfb738c20cef66652ae451c8e10Mangesh Ghiware setStandardShareIntent(currentData.getContentUri(), currentData.getMimeType()); 40633035c19cc47adfb738c20cef66652ae451c8e10Mangesh Ghiware } 407fae11a165e344a38811770c7d348eda214683edcSascha Haeberling 408fae11a165e344a38811770c7d348eda214683edcSascha Haeberling boolean itemHasLocation = currentData.getLatLong() != null; 409fae11a165e344a38811770c7d348eda214683edcSascha Haeberling setMenuItemVisible(mActionBarMenu, R.id.action_show_on_map, 410fae11a165e344a38811770c7d348eda214683edcSascha Haeberling itemHasLocation && (supported & SUPPORT_SHOW_ON_MAP) != 0); 4110353ca2e048543bd6e233b4c2110a1df1070cd3fztenghui } 4120353ca2e048543bd6e233b4c2110a1df1070cd3fztenghui 4130353ca2e048543bd6e233b4c2110a1df1070cd3fztenghui private void setMenuItemVisible(Menu menu, int itemId, boolean visible) { 4140353ca2e048543bd6e233b4c2110a1df1070cd3fztenghui MenuItem item = menu.findItem(itemId); 4150353ca2e048543bd6e233b4c2110a1df1070cd3fztenghui if (item != null) 4160353ca2e048543bd6e233b4c2110a1df1070cd3fztenghui item.setVisible(visible); 4170353ca2e048543bd6e233b4c2110a1df1070cd3fztenghui } 4180353ca2e048543bd6e233b4c2110a1df1070cd3fztenghui 4196432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu private Runnable mDeletionRunnable = new Runnable() { 4206432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu @Override 4216432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu public void run() { 422653c43be6e58be54cf2ac3c8efb2d65ac20bd03bAngus Kong hideUndoDeletionBar(); 4236432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu mDataAdapter.executeDeletion(CameraActivity.this); 4246432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu } 4256432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu }; 4268872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb 4276798c34ddb5248f038f351674c6a6c7a20992c8cAngus Kong private ImageTaskManager.TaskListener mStitchingListener = 4286798c34ddb5248f038f351674c6a6c7a20992c8cAngus Kong new ImageTaskManager.TaskListener() { 4296798c34ddb5248f038f351674c6a6c7a20992c8cAngus Kong @Override 43037f3611bbdc787c996a99894dcef7d8fb77e3f7cSascha Haeberling public void onTaskQueued(String filePath, final Uri imageUri) { 43137f3611bbdc787c996a99894dcef7d8fb77e3f7cSascha Haeberling mMainHandler.post(new Runnable() { 43237f3611bbdc787c996a99894dcef7d8fb77e3f7cSascha Haeberling @Override 43337f3611bbdc787c996a99894dcef7d8fb77e3f7cSascha Haeberling public void run() { 43437f3611bbdc787c996a99894dcef7d8fb77e3f7cSascha Haeberling notifyNewMedia(imageUri); 43537f3611bbdc787c996a99894dcef7d8fb77e3f7cSascha Haeberling } 43637f3611bbdc787c996a99894dcef7d8fb77e3f7cSascha Haeberling }); 4376798c34ddb5248f038f351674c6a6c7a20992c8cAngus Kong } 4386798c34ddb5248f038f351674c6a6c7a20992c8cAngus Kong 4396798c34ddb5248f038f351674c6a6c7a20992c8cAngus Kong @Override 44037f3611bbdc787c996a99894dcef7d8fb77e3f7cSascha Haeberling public void onTaskDone(String filePath, final Uri imageUri) { 44137f3611bbdc787c996a99894dcef7d8fb77e3f7cSascha Haeberling Log.v(TAG, "onTaskDone:" + filePath); 44237f3611bbdc787c996a99894dcef7d8fb77e3f7cSascha Haeberling mMainHandler.post(new Runnable() { 44337f3611bbdc787c996a99894dcef7d8fb77e3f7cSascha Haeberling @Override 44437f3611bbdc787c996a99894dcef7d8fb77e3f7cSascha Haeberling public void run() { 44537f3611bbdc787c996a99894dcef7d8fb77e3f7cSascha Haeberling int doneID = mDataAdapter.findDataByContentUri(imageUri); 44637f3611bbdc787c996a99894dcef7d8fb77e3f7cSascha Haeberling int currentDataId = mFilmStripView.getCurrentId(); 44737f3611bbdc787c996a99894dcef7d8fb77e3f7cSascha Haeberling 44837f3611bbdc787c996a99894dcef7d8fb77e3f7cSascha Haeberling if (currentDataId == doneID) { 44937f3611bbdc787c996a99894dcef7d8fb77e3f7cSascha Haeberling hidePanoStitchingProgress(); 45037f3611bbdc787c996a99894dcef7d8fb77e3f7cSascha Haeberling updateStitchingProgress(0); 45137f3611bbdc787c996a99894dcef7d8fb77e3f7cSascha Haeberling } 45237f3611bbdc787c996a99894dcef7d8fb77e3f7cSascha Haeberling 45337f3611bbdc787c996a99894dcef7d8fb77e3f7cSascha Haeberling mDataAdapter.refresh(getContentResolver(), imageUri); 45437f3611bbdc787c996a99894dcef7d8fb77e3f7cSascha Haeberling } 45537f3611bbdc787c996a99894dcef7d8fb77e3f7cSascha Haeberling }); 4566798c34ddb5248f038f351674c6a6c7a20992c8cAngus Kong } 4576798c34ddb5248f038f351674c6a6c7a20992c8cAngus Kong 4586798c34ddb5248f038f351674c6a6c7a20992c8cAngus Kong @Override 4596798c34ddb5248f038f351674c6a6c7a20992c8cAngus Kong public void onTaskProgress( 46037f3611bbdc787c996a99894dcef7d8fb77e3f7cSascha Haeberling String filePath, final Uri imageUri, final int progress) { 46137f3611bbdc787c996a99894dcef7d8fb77e3f7cSascha Haeberling mMainHandler.post(new Runnable() { 46237f3611bbdc787c996a99894dcef7d8fb77e3f7cSascha Haeberling @Override 46337f3611bbdc787c996a99894dcef7d8fb77e3f7cSascha Haeberling public void run() { 46437f3611bbdc787c996a99894dcef7d8fb77e3f7cSascha Haeberling int currentDataId = mFilmStripView.getCurrentId(); 46537f3611bbdc787c996a99894dcef7d8fb77e3f7cSascha Haeberling if (currentDataId == -1) { 46637f3611bbdc787c996a99894dcef7d8fb77e3f7cSascha Haeberling return; 46737f3611bbdc787c996a99894dcef7d8fb77e3f7cSascha Haeberling } 46837f3611bbdc787c996a99894dcef7d8fb77e3f7cSascha Haeberling if (imageUri.equals( 46937f3611bbdc787c996a99894dcef7d8fb77e3f7cSascha Haeberling mDataAdapter.getLocalData(currentDataId).getContentUri())) { 47037f3611bbdc787c996a99894dcef7d8fb77e3f7cSascha Haeberling updateStitchingProgress(progress); 47137f3611bbdc787c996a99894dcef7d8fb77e3f7cSascha Haeberling } 47237f3611bbdc787c996a99894dcef7d8fb77e3f7cSascha Haeberling } 47337f3611bbdc787c996a99894dcef7d8fb77e3f7cSascha Haeberling }); 4746798c34ddb5248f038f351674c6a6c7a20992c8cAngus Kong } 4756798c34ddb5248f038f351674c6a6c7a20992c8cAngus Kong }; 4766798c34ddb5248f038f351674c6a6c7a20992c8cAngus Kong 4776432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu public MediaSaveService getMediaSaveService() { 4786432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu return mMediaSaveService; 4798872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb } 4808872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb 4816432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu public void notifyNewMedia(Uri uri) { 4826432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu ContentResolver cr = getContentResolver(); 4836432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu String mimeType = cr.getType(uri); 4846432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu if (mimeType.startsWith("video/")) { 485b50b5cbfbc0a67db6fc43373363b10381c9c61a3Angus Kong sendBroadcast(new Intent(CameraUtil.ACTION_NEW_VIDEO, uri)); 4866432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu mDataAdapter.addNewVideo(cr, uri); 4876432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu } else if (mimeType.startsWith("image/")) { 488b50b5cbfbc0a67db6fc43373363b10381c9c61a3Angus Kong CameraUtil.broadcastNewPicture(this, uri); 4896432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu mDataAdapter.addNewPhoto(cr, uri); 49037f3611bbdc787c996a99894dcef7d8fb77e3f7cSascha Haeberling } else if (mimeType.startsWith("application/stitching-preview")) { 49137f3611bbdc787c996a99894dcef7d8fb77e3f7cSascha Haeberling mDataAdapter.addNewPhoto(cr, uri); 4926432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu } else { 4936432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu android.util.Log.w(TAG, "Unknown new media with MIME type:" 4946432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu + mimeType + ", uri:" + uri); 4956432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu } 4968872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb } 4978872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb 4986432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu private void removeData(int dataID) { 4996432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu mDataAdapter.removeData(CameraActivity.this, dataID); 500653c43be6e58be54cf2ac3c8efb2d65ac20bd03bAngus Kong showUndoDeletionBar(); 5016432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu mMainHandler.removeCallbacks(mDeletionRunnable); 5026432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu mMainHandler.postDelayed(mDeletionRunnable, 3000); 5038872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb } 5048872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb 5056432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu private void bindMediaSaveService() { 5066432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu Intent intent = new Intent(this, MediaSaveService.class); 5076432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu bindService(intent, mConnection, Context.BIND_AUTO_CREATE); 5088872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb } 5098872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb 5106432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu private void unbindMediaSaveService() { 5116432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu if (mConnection != null) { 5126432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu unbindService(mConnection); 5136432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu } 5148872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb } 5158872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb 5166432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu @Override 5170353ca2e048543bd6e233b4c2110a1df1070cd3fztenghui public boolean onCreateOptionsMenu(Menu menu) { 5180353ca2e048543bd6e233b4c2110a1df1070cd3fztenghui // Inflate the menu items for use in the action bar 5190353ca2e048543bd6e233b4c2110a1df1070cd3fztenghui MenuInflater inflater = getMenuInflater(); 5200353ca2e048543bd6e233b4c2110a1df1070cd3fztenghui inflater.inflate(R.menu.operations, menu); 5210353ca2e048543bd6e233b4c2110a1df1070cd3fztenghui mActionBarMenu = menu; 522cd2eeb0efc4370f20e9836e20eb11cb974e3b00dMangesh Ghiware 523cd2eeb0efc4370f20e9836e20eb11cb974e3b00dMangesh Ghiware // Configure the standard share action provider 524cd2eeb0efc4370f20e9836e20eb11cb974e3b00dMangesh Ghiware MenuItem item = menu.findItem(R.id.action_share); 525cd2eeb0efc4370f20e9836e20eb11cb974e3b00dMangesh Ghiware mStandardShareActionProvider = (ShareActionProvider) item.getActionProvider(); 52633035c19cc47adfb738c20cef66652ae451c8e10Mangesh Ghiware mStandardShareActionProvider.setShareHistoryFileName("standard_share_history.xml"); 527cd2eeb0efc4370f20e9836e20eb11cb974e3b00dMangesh Ghiware if (mStandardShareIntent != null) { 528cd2eeb0efc4370f20e9836e20eb11cb974e3b00dMangesh Ghiware mStandardShareActionProvider.setShareIntent(mStandardShareIntent); 529cd2eeb0efc4370f20e9836e20eb11cb974e3b00dMangesh Ghiware } 530cd2eeb0efc4370f20e9836e20eb11cb974e3b00dMangesh Ghiware 531cd2eeb0efc4370f20e9836e20eb11cb974e3b00dMangesh Ghiware // Configure the panorama share action provider 532cd2eeb0efc4370f20e9836e20eb11cb974e3b00dMangesh Ghiware item = menu.findItem(R.id.action_share_panorama); 533cd2eeb0efc4370f20e9836e20eb11cb974e3b00dMangesh Ghiware mPanoramaShareActionProvider = (ShareActionProvider) item.getActionProvider(); 53433035c19cc47adfb738c20cef66652ae451c8e10Mangesh Ghiware mPanoramaShareActionProvider.setShareHistoryFileName("panorama_share_history.xml"); 535cd2eeb0efc4370f20e9836e20eb11cb974e3b00dMangesh Ghiware if (mPanoramaShareIntent != null) { 536cd2eeb0efc4370f20e9836e20eb11cb974e3b00dMangesh Ghiware mPanoramaShareActionProvider.setShareIntent(mPanoramaShareIntent); 537cd2eeb0efc4370f20e9836e20eb11cb974e3b00dMangesh Ghiware } 538cd2eeb0efc4370f20e9836e20eb11cb974e3b00dMangesh Ghiware 5390353ca2e048543bd6e233b4c2110a1df1070cd3fztenghui return super.onCreateOptionsMenu(menu); 5400353ca2e048543bd6e233b4c2110a1df1070cd3fztenghui } 5410353ca2e048543bd6e233b4c2110a1df1070cd3fztenghui 5420353ca2e048543bd6e233b4c2110a1df1070cd3fztenghui @Override 5430353ca2e048543bd6e233b4c2110a1df1070cd3fztenghui public boolean onOptionsItemSelected(MenuItem item) { 5446f64b50db6565bc6454304fd20c0c4020b297bb7Sascha Haeberling int currentDataId = mFilmStripView.getCurrentId(); 5456f64b50db6565bc6454304fd20c0c4020b297bb7Sascha Haeberling if (currentDataId < 0) { 5466f64b50db6565bc6454304fd20c0c4020b297bb7Sascha Haeberling return false; 5476f64b50db6565bc6454304fd20c0c4020b297bb7Sascha Haeberling } 5486f64b50db6565bc6454304fd20c0c4020b297bb7Sascha Haeberling final LocalData localData = mDataAdapter.getLocalData(currentDataId); 5496f64b50db6565bc6454304fd20c0c4020b297bb7Sascha Haeberling 5500353ca2e048543bd6e233b4c2110a1df1070cd3fztenghui // Handle presses on the action bar items 5510353ca2e048543bd6e233b4c2110a1df1070cd3fztenghui switch (item.getItemId()) { 5523f969c1735e2636bf22dfe44104d0e99924cca97Alan Newberger case android.R.id.home: 5533f969c1735e2636bf22dfe44104d0e99924cca97Alan Newberger // ActionBar's Up/Home button was clicked 5543f969c1735e2636bf22dfe44104d0e99924cca97Alan Newberger mFilmStripView.getController().goToFirstItem(); 5553f969c1735e2636bf22dfe44104d0e99924cca97Alan Newberger return true; 5560353ca2e048543bd6e233b4c2110a1df1070cd3fztenghui case R.id.action_delete: 557e857cc90a98e280e2008beb03e2446bd642d2ec4Angus Kong removeData(currentDataId); 5580353ca2e048543bd6e233b4c2110a1df1070cd3fztenghui return true; 5590353ca2e048543bd6e233b4c2110a1df1070cd3fztenghui case R.id.action_edit: 56088ef7664ba6a888fa5da8693091674e152b56192Sascha Haeberling launchEditor(localData); 5610353ca2e048543bd6e233b4c2110a1df1070cd3fztenghui return true; 5620819304bc06ffd3498d9fd0d8a148c50f0903c46nicolasroard case R.id.action_trim: { 5636b9203214d828d72758943aca55adceab684a862ztenghui // This is going to be handled by the Gallery app. 5646b9203214d828d72758943aca55adceab684a862ztenghui Intent intent = new Intent(ACTION_TRIM_VIDEO); 5656b9203214d828d72758943aca55adceab684a862ztenghui LocalData currentData = mDataAdapter.getLocalData( 5666b9203214d828d72758943aca55adceab684a862ztenghui mFilmStripView.getCurrentId()); 5676b9203214d828d72758943aca55adceab684a862ztenghui intent.setData(currentData.getContentUri()); 5686b9203214d828d72758943aca55adceab684a862ztenghui // We need the file path to wrap this into a RandomAccessFile. 5696b9203214d828d72758943aca55adceab684a862ztenghui intent.putExtra(MEDIA_ITEM_PATH, currentData.getPath()); 5706b9203214d828d72758943aca55adceab684a862ztenghui startActivity(intent); 5710353ca2e048543bd6e233b4c2110a1df1070cd3fztenghui return true; 5720819304bc06ffd3498d9fd0d8a148c50f0903c46nicolasroard } 5730353ca2e048543bd6e233b4c2110a1df1070cd3fztenghui case R.id.action_rotate_ccw: 574a16e7b50f3148f581439509279f242092e254309ztenghui localData.rotate90Degrees(this, mDataAdapter, currentDataId, false); 5750353ca2e048543bd6e233b4c2110a1df1070cd3fztenghui return true; 5760353ca2e048543bd6e233b4c2110a1df1070cd3fztenghui case R.id.action_rotate_cw: 577a16e7b50f3148f581439509279f242092e254309ztenghui localData.rotate90Degrees(this, mDataAdapter, currentDataId, true); 5780353ca2e048543bd6e233b4c2110a1df1070cd3fztenghui return true; 5790353ca2e048543bd6e233b4c2110a1df1070cd3fztenghui case R.id.action_crop: 5800353ca2e048543bd6e233b4c2110a1df1070cd3fztenghui // TODO: add the functionality. 5810353ca2e048543bd6e233b4c2110a1df1070cd3fztenghui return true; 5820819304bc06ffd3498d9fd0d8a148c50f0903c46nicolasroard case R.id.action_setas: { 5830819304bc06ffd3498d9fd0d8a148c50f0903c46nicolasroard Intent intent = new Intent(Intent.ACTION_ATTACH_DATA) 5840819304bc06ffd3498d9fd0d8a148c50f0903c46nicolasroard .setDataAndType(localData.getContentUri(), 5850819304bc06ffd3498d9fd0d8a148c50f0903c46nicolasroard localData.getMimeType()) 5860819304bc06ffd3498d9fd0d8a148c50f0903c46nicolasroard .setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); 5870819304bc06ffd3498d9fd0d8a148c50f0903c46nicolasroard intent.putExtra("mimeType", intent.getType()); 5880819304bc06ffd3498d9fd0d8a148c50f0903c46nicolasroard startActivity(Intent.createChooser( 5890819304bc06ffd3498d9fd0d8a148c50f0903c46nicolasroard intent, getString(R.string.set_as))); 5900353ca2e048543bd6e233b4c2110a1df1070cd3fztenghui return true; 5910819304bc06ffd3498d9fd0d8a148c50f0903c46nicolasroard } 5920353ca2e048543bd6e233b4c2110a1df1070cd3fztenghui case R.id.action_details: 5936f64b50db6565bc6454304fd20c0c4020b297bb7Sascha Haeberling (new AsyncTask<Void, Void, MediaDetails>() { 5946f64b50db6565bc6454304fd20c0c4020b297bb7Sascha Haeberling @Override 5956f64b50db6565bc6454304fd20c0c4020b297bb7Sascha Haeberling protected MediaDetails doInBackground(Void... params) { 5966f64b50db6565bc6454304fd20c0c4020b297bb7Sascha Haeberling return localData.getMediaDetails(CameraActivity.this); 5976f64b50db6565bc6454304fd20c0c4020b297bb7Sascha Haeberling } 5986f64b50db6565bc6454304fd20c0c4020b297bb7Sascha Haeberling 5996f64b50db6565bc6454304fd20c0c4020b297bb7Sascha Haeberling @Override 6006f64b50db6565bc6454304fd20c0c4020b297bb7Sascha Haeberling protected void onPostExecute(MediaDetails mediaDetails) { 6016f64b50db6565bc6454304fd20c0c4020b297bb7Sascha Haeberling DetailsDialog.create(CameraActivity.this, mediaDetails).show(); 6026f64b50db6565bc6454304fd20c0c4020b297bb7Sascha Haeberling } 6036f64b50db6565bc6454304fd20c0c4020b297bb7Sascha Haeberling }).execute(); 6040353ca2e048543bd6e233b4c2110a1df1070cd3fztenghui return true; 6050353ca2e048543bd6e233b4c2110a1df1070cd3fztenghui case R.id.action_show_on_map: 606fae11a165e344a38811770c7d348eda214683edcSascha Haeberling double[] latLong = localData.getLatLong(); 607fae11a165e344a38811770c7d348eda214683edcSascha Haeberling if (latLong != null) { 608fae11a165e344a38811770c7d348eda214683edcSascha Haeberling CameraUtil.showOnMap(this, latLong); 609fae11a165e344a38811770c7d348eda214683edcSascha Haeberling } 6100353ca2e048543bd6e233b4c2110a1df1070cd3fztenghui return true; 6110353ca2e048543bd6e233b4c2110a1df1070cd3fztenghui default: 6120353ca2e048543bd6e233b4c2110a1df1070cd3fztenghui return super.onOptionsItemSelected(item); 6130353ca2e048543bd6e233b4c2110a1df1070cd3fztenghui } 6140353ca2e048543bd6e233b4c2110a1df1070cd3fztenghui } 6150353ca2e048543bd6e233b4c2110a1df1070cd3fztenghui 616fd43e3be3d69f48a97bdd9084e9549f41e963cc2ztenghui private boolean isCaptureIntent() { 617fd43e3be3d69f48a97bdd9084e9549f41e963cc2ztenghui if (MediaStore.ACTION_VIDEO_CAPTURE.equals(getIntent().getAction()) 618fd43e3be3d69f48a97bdd9084e9549f41e963cc2ztenghui || MediaStore.ACTION_IMAGE_CAPTURE.equals(getIntent().getAction()) 619fd43e3be3d69f48a97bdd9084e9549f41e963cc2ztenghui || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(getIntent().getAction())) { 620fd43e3be3d69f48a97bdd9084e9549f41e963cc2ztenghui return true; 621fd43e3be3d69f48a97bdd9084e9549f41e963cc2ztenghui } else { 622fd43e3be3d69f48a97bdd9084e9549f41e963cc2ztenghui return false; 623fd43e3be3d69f48a97bdd9084e9549f41e963cc2ztenghui } 624fd43e3be3d69f48a97bdd9084e9549f41e963cc2ztenghui } 625fd43e3be3d69f48a97bdd9084e9549f41e963cc2ztenghui 6260353ca2e048543bd6e233b4c2110a1df1070cd3fztenghui @Override 6276432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu public void onCreate(Bundle state) { 6286432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu super.onCreate(state); 62950df47071c776703a36dbc4cb90ec8d1df3c0f6eztenghui getWindow().requestFeature(Window.FEATURE_ACTION_BAR); 6306432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu setContentView(R.layout.camera_filmstrip); 631fa9e2cc9ccbcd746f5765cb7a0afebcdb60e2973ztenghui mActionBar = getActionBar(); 632fa9e2cc9ccbcd746f5765cb7a0afebcdb60e2973ztenghui // Hide action bar first since we are in full screen mode first. 633fa9e2cc9ccbcd746f5765cb7a0afebcdb60e2973ztenghui mActionBar.hide(); 634fa9e2cc9ccbcd746f5765cb7a0afebcdb60e2973ztenghui 6356432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu if (ApiHelper.HAS_ROTATION_ANIMATION) { 6366432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu setRotationAnimation(); 6376432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu } 6386432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu // Check if this is in the secure camera mode. 6396432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu Intent intent = getIntent(); 6406432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu String action = intent.getAction(); 641b84b9738c855a525dc1944165983cc3c342ce446Doris Liu if (INTENT_ACTION_STILL_IMAGE_CAMERA_SECURE.equals(action) 642b84b9738c855a525dc1944165983cc3c342ce446Doris Liu || ACTION_IMAGE_CAPTURE_SECURE.equals(action)) { 6436432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu mSecureCamera = true; 6446432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu } else { 6456432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu mSecureCamera = intent.getBooleanExtra(SECURE_CAMERA_EXTRA, false); 6468872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb } 647b84b9738c855a525dc1944165983cc3c342ce446Doris Liu 648b84b9738c855a525dc1944165983cc3c342ce446Doris Liu if (mSecureCamera) { 649b84b9738c855a525dc1944165983cc3c342ce446Doris Liu // Change the window flags so that secure camera can show when locked 650b84b9738c855a525dc1944165983cc3c342ce446Doris Liu Window win = getWindow(); 651b84b9738c855a525dc1944165983cc3c342ce446Doris Liu WindowManager.LayoutParams params = win.getAttributes(); 652b84b9738c855a525dc1944165983cc3c342ce446Doris Liu params.flags |= WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED; 653b84b9738c855a525dc1944165983cc3c342ce446Doris Liu win.setAttributes(params); 654b84b9738c855a525dc1944165983cc3c342ce446Doris Liu 655b84b9738c855a525dc1944165983cc3c342ce446Doris Liu // Filter for screen off so that we can finish secure camera activity 656b84b9738c855a525dc1944165983cc3c342ce446Doris Liu // when screen is off. 6576432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu IntentFilter filter = new IntentFilter(Intent.ACTION_SCREEN_OFF); 6586432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu registerReceiver(mScreenOffReceiver, filter); 6596a8e8a1a0f3e8e62cd350733e275047475380d6bAngus Kong // TODO: This static screen off event receiver is a workaround to the 6606a8e8a1a0f3e8e62cd350733e275047475380d6bAngus Kong // double onResume() invocation (onResume->onPause->onResume). We should 6616a8e8a1a0f3e8e62cd350733e275047475380d6bAngus Kong // find a better solution to this. 6626a8e8a1a0f3e8e62cd350733e275047475380d6bAngus Kong if (sScreenOffReceiver == null) { 6636a8e8a1a0f3e8e62cd350733e275047475380d6bAngus Kong sScreenOffReceiver = new ScreenOffReceiver(); 6646a8e8a1a0f3e8e62cd350733e275047475380d6bAngus Kong registerReceiver(sScreenOffReceiver, filter); 6656a8e8a1a0f3e8e62cd350733e275047475380d6bAngus Kong } 666b84b9738c855a525dc1944165983cc3c342ce446Doris Liu } 667653c43be6e58be54cf2ac3c8efb2d65ac20bd03bAngus Kong mLayoutRoot = (FrameLayout) findViewById(R.id.camera_layout_root); 668653c43be6e58be54cf2ac3c8efb2d65ac20bd03bAngus Kong 669653c43be6e58be54cf2ac3c8efb2d65ac20bd03bAngus Kong mAboveFilmstripControlLayout = 670653c43be6e58be54cf2ac3c8efb2d65ac20bd03bAngus Kong (FrameLayout) findViewById(R.id.camera_above_filmstrip_layout); 671653c43be6e58be54cf2ac3c8efb2d65ac20bd03bAngus Kong mAboveFilmstripControlLayout.setFitsSystemWindows(true); 672653c43be6e58be54cf2ac3c8efb2d65ac20bd03bAngus Kong mAboveFilmstripControlLayout.setSystemUiVisibility( 673653c43be6e58be54cf2ac3c8efb2d65ac20bd03bAngus Kong View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN 674653c43be6e58be54cf2ac3c8efb2d65ac20bd03bAngus Kong | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION); 6756798c34ddb5248f038f351674c6a6c7a20992c8cAngus Kong mPanoramaManager = new PanoramaStitchingManager(CameraActivity.this); 6766798c34ddb5248f038f351674c6a6c7a20992c8cAngus Kong mPanoramaManager.addTaskListener(mStitchingListener); 6776432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu LayoutInflater inflater = getLayoutInflater(); 6786432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu View rootLayout = inflater.inflate(R.layout.camera, null, false); 679653c43be6e58be54cf2ac3c8efb2d65ac20bd03bAngus Kong mCameraModuleRootView = rootLayout.findViewById(R.id.camera_app_root); 680fa9e2cc9ccbcd746f5765cb7a0afebcdb60e2973ztenghui mPanoStitchingPanel = findViewById(R.id.pano_stitching_progress_panel); 68137f3611bbdc787c996a99894dcef7d8fb77e3f7cSascha Haeberling mBottomProgress = (ProgressBar) findViewById(R.id.pano_stitching_progress_bar); 6828e5e4eedb25a4589342660b928935acca4375fc7Angus Kong mCameraPreviewData = new CameraPreviewData(rootLayout, 6838e5e4eedb25a4589342660b928935acca4375fc7Angus Kong FilmStripView.ImageData.SIZE_FULL, 6848e5e4eedb25a4589342660b928935acca4375fc7Angus Kong FilmStripView.ImageData.SIZE_FULL); 68537f3611bbdc787c996a99894dcef7d8fb77e3f7cSascha Haeberling // Put a CameraPreviewData at the first position. 6868e5e4eedb25a4589342660b928935acca4375fc7Angus Kong mWrappedDataAdapter = new FixedFirstDataAdapter( 6878e5e4eedb25a4589342660b928935acca4375fc7Angus Kong new CameraDataAdapter(new ColorDrawable( 6888e5e4eedb25a4589342660b928935acca4375fc7Angus Kong getResources().getColor(R.color.photo_placeholder))), 6898e5e4eedb25a4589342660b928935acca4375fc7Angus Kong mCameraPreviewData); 6906432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu mFilmStripView = (FilmStripView) findViewById(R.id.filmstrip_view); 6916432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu mFilmStripView.setViewGap( 6926432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu getResources().getDimensionPixelSize(R.dimen.camera_film_strip_gap)); 693f1f5186f7d3fd8bf35009d9e65a43914c664d82bSascha Haeberling mPanoramaViewHelper = new PanoramaViewHelper(this); 694f1f5186f7d3fd8bf35009d9e65a43914c664d82bSascha Haeberling mPanoramaViewHelper.onCreate(); 695f1f5186f7d3fd8bf35009d9e65a43914c664d82bSascha Haeberling mFilmStripView.setPanoramaViewHelper(mPanoramaViewHelper); 6966432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu // Set up the camera preview first so the preview shows up ASAP. 6976432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu mFilmStripView.setListener(mFilmStripListener); 6982654dd9bb6a7d917dab1a48e2182c4f49fe71f11Sascha Haeberling 6992654dd9bb6a7d917dab1a48e2182c4f49fe71f11Sascha Haeberling int moduleIndex = -1; 7002a7f44cac888de5683d05bef5708f846ee950f43Doris Liu if (MediaStore.INTENT_ACTION_VIDEO_CAMERA.equals(getIntent().getAction()) 7012a7f44cac888de5683d05bef5708f846ee950f43Doris Liu || MediaStore.ACTION_VIDEO_CAPTURE.equals(getIntent().getAction())) { 7022654dd9bb6a7d917dab1a48e2182c4f49fe71f11Sascha Haeberling moduleIndex = CameraSwitcher.VIDEO_MODULE_INDEX; 7032654dd9bb6a7d917dab1a48e2182c4f49fe71f11Sascha Haeberling } else if (MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA.equals(getIntent().getAction()) 7042654dd9bb6a7d917dab1a48e2182c4f49fe71f11Sascha Haeberling || MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA_SECURE.equals(getIntent() 7052654dd9bb6a7d917dab1a48e2182c4f49fe71f11Sascha Haeberling .getAction()) 7062654dd9bb6a7d917dab1a48e2182c4f49fe71f11Sascha Haeberling || MediaStore.ACTION_IMAGE_CAPTURE.equals(getIntent().getAction()) 7072654dd9bb6a7d917dab1a48e2182c4f49fe71f11Sascha Haeberling || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(getIntent().getAction())) { 7082654dd9bb6a7d917dab1a48e2182c4f49fe71f11Sascha Haeberling moduleIndex = CameraSwitcher.PHOTO_MODULE_INDEX; 7092a7f44cac888de5683d05bef5708f846ee950f43Doris Liu } else { 7102654dd9bb6a7d917dab1a48e2182c4f49fe71f11Sascha Haeberling // If the activity has not been started using an explicit intent, 7112654dd9bb6a7d917dab1a48e2182c4f49fe71f11Sascha Haeberling // read the module index from the last time the user changed modes 7122654dd9bb6a7d917dab1a48e2182c4f49fe71f11Sascha Haeberling SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); 7132654dd9bb6a7d917dab1a48e2182c4f49fe71f11Sascha Haeberling moduleIndex = prefs.getInt(PREF_STARTUP_MODULE_INDEX, -1); 7142654dd9bb6a7d917dab1a48e2182c4f49fe71f11Sascha Haeberling if (moduleIndex < 0) { 7152654dd9bb6a7d917dab1a48e2182c4f49fe71f11Sascha Haeberling moduleIndex = CameraSwitcher.PHOTO_MODULE_INDEX; 7162654dd9bb6a7d917dab1a48e2182c4f49fe71f11Sascha Haeberling } 7172a7f44cac888de5683d05bef5708f846ee950f43Doris Liu } 7182654dd9bb6a7d917dab1a48e2182c4f49fe71f11Sascha Haeberling setModuleFromIndex(moduleIndex); 7192654dd9bb6a7d917dab1a48e2182c4f49fe71f11Sascha Haeberling 720653c43be6e58be54cf2ac3c8efb2d65ac20bd03bAngus Kong mCurrentModule.init(this, mCameraModuleRootView); 7216432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu mOrientationListener = new MyOrientationEventListener(this); 7226432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu mMainHandler = new Handler(getMainLooper()); 72337f3611bbdc787c996a99894dcef7d8fb77e3f7cSascha Haeberling 72437f3611bbdc787c996a99894dcef7d8fb77e3f7cSascha Haeberling if (!mSecureCamera) { 72537f3611bbdc787c996a99894dcef7d8fb77e3f7cSascha Haeberling mDataAdapter = mWrappedDataAdapter; 726dcccc510652b835fdbd39310a07849af8203052aAngus Kong mFilmStripView.setDataAdapter(mDataAdapter); 72737f3611bbdc787c996a99894dcef7d8fb77e3f7cSascha Haeberling mDataAdapter.requestLoad(getContentResolver()); 72837f3611bbdc787c996a99894dcef7d8fb77e3f7cSascha Haeberling } else { 72937f3611bbdc787c996a99894dcef7d8fb77e3f7cSascha Haeberling // Put a lock placeholder as the last image by setting its date to 0. 73037f3611bbdc787c996a99894dcef7d8fb77e3f7cSascha Haeberling ImageView v = (ImageView) getLayoutInflater().inflate( 73137f3611bbdc787c996a99894dcef7d8fb77e3f7cSascha Haeberling R.layout.secure_album_placeholder, null); 73237f3611bbdc787c996a99894dcef7d8fb77e3f7cSascha Haeberling mDataAdapter = new FixedLastDataAdapter( 73337f3611bbdc787c996a99894dcef7d8fb77e3f7cSascha Haeberling mWrappedDataAdapter, 734bd26069d391830856c57c2141cd2efbc8423d871Angus Kong new SimpleViewData( 73537f3611bbdc787c996a99894dcef7d8fb77e3f7cSascha Haeberling v, 73637f3611bbdc787c996a99894dcef7d8fb77e3f7cSascha Haeberling v.getDrawable().getIntrinsicWidth(), 73737f3611bbdc787c996a99894dcef7d8fb77e3f7cSascha Haeberling v.getDrawable().getIntrinsicHeight(), 73837f3611bbdc787c996a99894dcef7d8fb77e3f7cSascha Haeberling 0, 0)); 73937f3611bbdc787c996a99894dcef7d8fb77e3f7cSascha Haeberling // Flush out all the original data. 74037f3611bbdc787c996a99894dcef7d8fb77e3f7cSascha Haeberling mDataAdapter.flush(); 741dcccc510652b835fdbd39310a07849af8203052aAngus Kong mFilmStripView.setDataAdapter(mDataAdapter); 74237f3611bbdc787c996a99894dcef7d8fb77e3f7cSascha Haeberling } 7438872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb } 7448872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb 7456432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu private void setRotationAnimation() { 7466432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu int rotationAnimation = WindowManager.LayoutParams.ROTATION_ANIMATION_ROTATE; 7476432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu rotationAnimation = WindowManager.LayoutParams.ROTATION_ANIMATION_CROSSFADE; 7486432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu Window win = getWindow(); 7496432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu WindowManager.LayoutParams winParams = win.getAttributes(); 7506432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu winParams.rotationAnimation = rotationAnimation; 7516432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu win.setAttributes(winParams); 7528872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb } 7538872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb 7548872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb @Override 7556432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu public void onUserInteraction() { 7566432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu super.onUserInteraction(); 7576432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu mCurrentModule.onUserInteraction(); 75809106a41ee6acc6b20553662cb9b730702a8f08aDoris Liu } 7598872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb 7608872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb @Override 7618872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb public void onPause() { 7628872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb mOrientationListener.disable(); 7638872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb mCurrentModule.onPauseBeforeSuper(); 7648872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb super.onPause(); 7658872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb mCurrentModule.onPauseAfterSuper(); 7668872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb } 7678872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb 7688872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb @Override 7698872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb public void onResume() { 7703cf565c4242a9deab7da5eb84fc302c79d594f11Doris Liu if (Settings.System.getInt(getContentResolver(), 7713cf565c4242a9deab7da5eb84fc302c79d594f11Doris Liu Settings.System.ACCELEROMETER_ROTATION, 0) == 0) {// auto-rotate off 7723cf565c4242a9deab7da5eb84fc302c79d594f11Doris Liu setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED); 7733cf565c4242a9deab7da5eb84fc302c79d594f11Doris Liu mAutoRotateScreen = false; 7743cf565c4242a9deab7da5eb84fc302c79d594f11Doris Liu } else { 7753cf565c4242a9deab7da5eb84fc302c79d594f11Doris Liu setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR); 7763cf565c4242a9deab7da5eb84fc302c79d594f11Doris Liu mAutoRotateScreen = true; 7773cf565c4242a9deab7da5eb84fc302c79d594f11Doris Liu } 7788872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb mOrientationListener.enable(); 7798872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb mCurrentModule.onResumeBeforeSuper(); 7808872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb super.onResume(); 7818872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb mCurrentModule.onResumeAfterSuper(); 7828872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb 7836798c34ddb5248f038f351674c6a6c7a20992c8cAngus Kong setSwipingEnabled(true); 7846798c34ddb5248f038f351674c6a6c7a20992c8cAngus Kong } 7856798c34ddb5248f038f351674c6a6c7a20992c8cAngus Kong 7866798c34ddb5248f038f351674c6a6c7a20992c8cAngus Kong @Override 7876798c34ddb5248f038f351674c6a6c7a20992c8cAngus Kong public void onStart() { 7886798c34ddb5248f038f351674c6a6c7a20992c8cAngus Kong super.onStart(); 7897e374eb0a450ed2689b556ab42a0a88c8f74df2eAngus Kong bindMediaSaveService(); 790f1f5186f7d3fd8bf35009d9e65a43914c664d82bSascha Haeberling mPanoramaViewHelper.onStart(); 791f1f5186f7d3fd8bf35009d9e65a43914c664d82bSascha Haeberling } 792f1f5186f7d3fd8bf35009d9e65a43914c664d82bSascha Haeberling 793f1f5186f7d3fd8bf35009d9e65a43914c664d82bSascha Haeberling @Override 794f1f5186f7d3fd8bf35009d9e65a43914c664d82bSascha Haeberling protected void onStop() { 795f1f5186f7d3fd8bf35009d9e65a43914c664d82bSascha Haeberling super.onStop(); 796f1f5186f7d3fd8bf35009d9e65a43914c664d82bSascha Haeberling mPanoramaViewHelper.onStop(); 7977e374eb0a450ed2689b556ab42a0a88c8f74df2eAngus Kong unbindMediaSaveService(); 79808650187c1f1a2d1ef7f754be0f479a29958daaaMichael Kolb } 79908650187c1f1a2d1ef7f754be0f479a29958daaaMichael Kolb 8008872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb @Override 8016432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu public void onDestroy() { 802b84b9738c855a525dc1944165983cc3c342ce446Doris Liu if (mSecureCamera) unregisterReceiver(mScreenOffReceiver); 8036432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu super.onDestroy(); 8048872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb } 8058872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb 8068872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb @Override 8076432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu public void onConfigurationChanged(Configuration config) { 8086432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu super.onConfigurationChanged(config); 8096432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu mCurrentModule.onConfigurationChanged(config); 8108872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb } 8118872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb 8128872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb @Override 8136432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu public boolean onKeyDown(int keyCode, KeyEvent event) { 8146432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu if (mCurrentModule.onKeyDown(keyCode, event)) return true; 8156432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu // Prevent software keyboard or voice search from showing up. 8166432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu if (keyCode == KeyEvent.KEYCODE_SEARCH 8176432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu || keyCode == KeyEvent.KEYCODE_MENU) { 8186432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu if (event.isLongPress()) return true; 8196432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu } 8206432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu if (keyCode == KeyEvent.KEYCODE_MENU && mShowCameraPreview) { 8216432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu return true; 8226432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu } 8236432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu 8246432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu return super.onKeyDown(keyCode, event); 8258872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb } 8268872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb 8278872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb @Override 8286432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu public boolean onKeyUp(int keyCode, KeyEvent event) { 8296432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu if (mCurrentModule.onKeyUp(keyCode, event)) return true; 8306432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu if (keyCode == KeyEvent.KEYCODE_MENU && mShowCameraPreview) { 8316432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu return true; 8328872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb } 8336432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu return super.onKeyUp(keyCode, event); 8348872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb } 8358872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb 8365f6b50deaf46fb546ebf6d0d6244ebf7fb79c7caAlan Newberger @Override 8375f6b50deaf46fb546ebf6d0d6244ebf7fb79c7caAlan Newberger public void onBackPressed() { 8385f6b50deaf46fb546ebf6d0d6244ebf7fb79c7caAlan Newberger if (!mFilmStripView.inCameraFullscreen()) { 8395f6b50deaf46fb546ebf6d0d6244ebf7fb79c7caAlan Newberger mFilmStripView.getController().goToFirstItem(); 8405f6b50deaf46fb546ebf6d0d6244ebf7fb79c7caAlan Newberger } else if (!mCurrentModule.onBackPressed()) { 8415f6b50deaf46fb546ebf6d0d6244ebf7fb79c7caAlan Newberger super.onBackPressed(); 8425f6b50deaf46fb546ebf6d0d6244ebf7fb79c7caAlan Newberger } 8435f6b50deaf46fb546ebf6d0d6244ebf7fb79c7caAlan Newberger } 8445f6b50deaf46fb546ebf6d0d6244ebf7fb79c7caAlan Newberger 8456432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu public boolean isAutoRotateScreen() { 8466432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu return mAutoRotateScreen; 8478872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb } 8488872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb 8496432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu protected void updateStorageSpace() { 8506432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu mStorageSpace = Storage.getAvailableSpace(); 8518872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb } 8528872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb 8536432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu protected long getStorageSpace() { 8546432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu return mStorageSpace; 8558872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb } 8568872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb 8576432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu protected void updateStorageSpaceAndHint() { 8586432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu updateStorageSpace(); 8596432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu updateStorageHint(mStorageSpace); 8608872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb } 8618872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb 8626432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu protected void updateStorageHint() { 8636432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu updateStorageHint(mStorageSpace); 8648872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb } 8658872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb 8666432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu protected boolean updateStorageHintOnResume() { 8676432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu return true; 8686432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu } 8696432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu 8706432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu protected void updateStorageHint(long storageSpace) { 8716432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu String message = null; 8726432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu if (storageSpace == Storage.UNAVAILABLE) { 8736432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu message = getString(R.string.no_storage); 8746432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu } else if (storageSpace == Storage.PREPARING) { 8756432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu message = getString(R.string.preparing_sd); 8766432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu } else if (storageSpace == Storage.UNKNOWN_SIZE) { 8776432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu message = getString(R.string.access_sd_fail); 8786432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu } else if (storageSpace <= Storage.LOW_STORAGE_THRESHOLD) { 8796432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu message = getString(R.string.spaceIsLow_content); 8808872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb } 8816432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu 8826432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu if (message != null) { 8836432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu if (mStorageHint == null) { 8846432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu mStorageHint = OnScreenHint.makeText(this, message); 8856432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu } else { 8866432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu mStorageHint.setText(message); 8876432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu } 8886432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu mStorageHint.show(); 8896432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu } else if (mStorageHint != null) { 8906432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu mStorageHint.cancel(); 8916432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu mStorageHint = null; 8928872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb } 8938872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb } 8948872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb 8956432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu protected void setResultEx(int resultCode) { 8966432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu mResultCodeForTesting = resultCode; 8976432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu setResult(resultCode); 8988872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb } 8998872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb 9006432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu protected void setResultEx(int resultCode, Intent data) { 9016432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu mResultCodeForTesting = resultCode; 9026432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu mResultDataForTesting = data; 9036432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu setResult(resultCode, data); 9048872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb } 9058872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb 9066432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu public int getResultCode() { 9076432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu return mResultCodeForTesting; 9088872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb } 9098872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb 9106432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu public Intent getResultData() { 9116432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu return mResultDataForTesting; 9128872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb } 9138872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb 9146432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu public boolean isSecureCamera() { 9156432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu return mSecureCamera; 9168872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb } 9178872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb 9188872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb @Override 9192654dd9bb6a7d917dab1a48e2182c4f49fe71f11Sascha Haeberling public void onCameraSelected(int moduleIndex) { 9202654dd9bb6a7d917dab1a48e2182c4f49fe71f11Sascha Haeberling if (mCurrentModuleIndex == moduleIndex) return; 9216432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu 9226432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu CameraHolder.instance().keep(); 9236432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu closeModule(mCurrentModule); 9242654dd9bb6a7d917dab1a48e2182c4f49fe71f11Sascha Haeberling setModuleFromIndex(moduleIndex); 9252654dd9bb6a7d917dab1a48e2182c4f49fe71f11Sascha Haeberling 9262654dd9bb6a7d917dab1a48e2182c4f49fe71f11Sascha Haeberling openModule(mCurrentModule); 9272654dd9bb6a7d917dab1a48e2182c4f49fe71f11Sascha Haeberling mCurrentModule.onOrientationChanged(mLastRawOrientation); 9282654dd9bb6a7d917dab1a48e2182c4f49fe71f11Sascha Haeberling if (mMediaSaveService != null) { 9292654dd9bb6a7d917dab1a48e2182c4f49fe71f11Sascha Haeberling mCurrentModule.onMediaSaveServiceConnected(mMediaSaveService); 9302654dd9bb6a7d917dab1a48e2182c4f49fe71f11Sascha Haeberling } 9312654dd9bb6a7d917dab1a48e2182c4f49fe71f11Sascha Haeberling 9322654dd9bb6a7d917dab1a48e2182c4f49fe71f11Sascha Haeberling // Store the module index so we can use it the next time the Camera 9332654dd9bb6a7d917dab1a48e2182c4f49fe71f11Sascha Haeberling // starts up. 9342654dd9bb6a7d917dab1a48e2182c4f49fe71f11Sascha Haeberling SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); 9352654dd9bb6a7d917dab1a48e2182c4f49fe71f11Sascha Haeberling prefs.edit().putInt(PREF_STARTUP_MODULE_INDEX, moduleIndex).apply(); 9362654dd9bb6a7d917dab1a48e2182c4f49fe71f11Sascha Haeberling } 9372654dd9bb6a7d917dab1a48e2182c4f49fe71f11Sascha Haeberling 9382654dd9bb6a7d917dab1a48e2182c4f49fe71f11Sascha Haeberling /** 9392654dd9bb6a7d917dab1a48e2182c4f49fe71f11Sascha Haeberling * Sets the mCurrentModuleIndex, creates a new module instance for the 9402654dd9bb6a7d917dab1a48e2182c4f49fe71f11Sascha Haeberling * given index an sets it as mCurrentModule. 9412654dd9bb6a7d917dab1a48e2182c4f49fe71f11Sascha Haeberling */ 9422654dd9bb6a7d917dab1a48e2182c4f49fe71f11Sascha Haeberling private void setModuleFromIndex(int moduleIndex) { 9432654dd9bb6a7d917dab1a48e2182c4f49fe71f11Sascha Haeberling mCurrentModuleIndex = moduleIndex; 9442654dd9bb6a7d917dab1a48e2182c4f49fe71f11Sascha Haeberling switch (moduleIndex) { 945147e26ab7075f0acd3978f0cd0541cd1da4b50e1Doris Liu case CameraSwitcher.VIDEO_MODULE_INDEX: 9466432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu mCurrentModule = new VideoModule(); 9476432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu break; 948147e26ab7075f0acd3978f0cd0541cd1da4b50e1Doris Liu case CameraSwitcher.PHOTO_MODULE_INDEX: 9496432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu mCurrentModule = new PhotoModule(); 9506432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu break; 951147e26ab7075f0acd3978f0cd0541cd1da4b50e1Doris Liu case CameraSwitcher.LIGHTCYCLE_MODULE_INDEX: 9528e963a5a6016d246184ed65906f9d103e92b17e2Sascha Haeberling mCurrentModule = PhotoSphereHelper.createPanoramaModule(); 9536432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu break; 9542654dd9bb6a7d917dab1a48e2182c4f49fe71f11Sascha Haeberling default: 9552654dd9bb6a7d917dab1a48e2182c4f49fe71f11Sascha Haeberling break; 9566432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu } 9578872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb } 9588872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb 95988ef7664ba6a888fa5da8693091674e152b56192Sascha Haeberling /** 96088ef7664ba6a888fa5da8693091674e152b56192Sascha Haeberling * Launches an ACTION_EDIT intent for the given local data item. 96188ef7664ba6a888fa5da8693091674e152b56192Sascha Haeberling */ 96288ef7664ba6a888fa5da8693091674e152b56192Sascha Haeberling public void launchEditor(LocalData data) { 96388ef7664ba6a888fa5da8693091674e152b56192Sascha Haeberling Intent intent = new Intent(Intent.ACTION_EDIT) 96488ef7664ba6a888fa5da8693091674e152b56192Sascha Haeberling .setDataAndType(data.getContentUri(), data.getMimeType()) 96588ef7664ba6a888fa5da8693091674e152b56192Sascha Haeberling .setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); 96688ef7664ba6a888fa5da8693091674e152b56192Sascha Haeberling startActivity(Intent.createChooser(intent, null)); 96788ef7664ba6a888fa5da8693091674e152b56192Sascha Haeberling } 96888ef7664ba6a888fa5da8693091674e152b56192Sascha Haeberling 9696432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu private void openModule(CameraModule module) { 970653c43be6e58be54cf2ac3c8efb2d65ac20bd03bAngus Kong module.init(this, mCameraModuleRootView); 9716432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu module.onResumeBeforeSuper(); 9726432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu module.onResumeAfterSuper(); 9738872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb } 9748872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb 9756432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu private void closeModule(CameraModule module) { 9766432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu module.onPauseBeforeSuper(); 9776432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu module.onPauseAfterSuper(); 978653c43be6e58be54cf2ac3c8efb2d65ac20bd03bAngus Kong ((ViewGroup) mCameraModuleRootView).removeAllViews(); 979653c43be6e58be54cf2ac3c8efb2d65ac20bd03bAngus Kong } 980653c43be6e58be54cf2ac3c8efb2d65ac20bd03bAngus Kong 981653c43be6e58be54cf2ac3c8efb2d65ac20bd03bAngus Kong private void showUndoDeletionBar() { 982653c43be6e58be54cf2ac3c8efb2d65ac20bd03bAngus Kong if (mUndoDeletionBar == null) { 983653c43be6e58be54cf2ac3c8efb2d65ac20bd03bAngus Kong Log.v(TAG, "showing undo bar"); 984653c43be6e58be54cf2ac3c8efb2d65ac20bd03bAngus Kong ViewGroup v = (ViewGroup) getLayoutInflater().inflate( 985653c43be6e58be54cf2ac3c8efb2d65ac20bd03bAngus Kong R.layout.undo_bar, mAboveFilmstripControlLayout, true); 986653c43be6e58be54cf2ac3c8efb2d65ac20bd03bAngus Kong mUndoDeletionBar = (ViewGroup) v.findViewById(R.id.camera_undo_deletion_bar); 987653c43be6e58be54cf2ac3c8efb2d65ac20bd03bAngus Kong View button = mUndoDeletionBar.findViewById(R.id.camera_undo_deletion_button); 988653c43be6e58be54cf2ac3c8efb2d65ac20bd03bAngus Kong button.setOnClickListener(new View.OnClickListener() { 989653c43be6e58be54cf2ac3c8efb2d65ac20bd03bAngus Kong @Override 990653c43be6e58be54cf2ac3c8efb2d65ac20bd03bAngus Kong public void onClick(View view) { 991653c43be6e58be54cf2ac3c8efb2d65ac20bd03bAngus Kong mDataAdapter.undoDataRemoval(); 992653c43be6e58be54cf2ac3c8efb2d65ac20bd03bAngus Kong mMainHandler.removeCallbacks(mDeletionRunnable); 993653c43be6e58be54cf2ac3c8efb2d65ac20bd03bAngus Kong hideUndoDeletionBar(); 994653c43be6e58be54cf2ac3c8efb2d65ac20bd03bAngus Kong } 995653c43be6e58be54cf2ac3c8efb2d65ac20bd03bAngus Kong }); 996653c43be6e58be54cf2ac3c8efb2d65ac20bd03bAngus Kong } 997653c43be6e58be54cf2ac3c8efb2d65ac20bd03bAngus Kong mUndoDeletionBar.setAlpha(0f); 998653c43be6e58be54cf2ac3c8efb2d65ac20bd03bAngus Kong mUndoDeletionBar.setVisibility(View.VISIBLE); 999653c43be6e58be54cf2ac3c8efb2d65ac20bd03bAngus Kong mUndoDeletionBar.animate().setDuration(200).alpha(1f).start(); 1000653c43be6e58be54cf2ac3c8efb2d65ac20bd03bAngus Kong } 1001653c43be6e58be54cf2ac3c8efb2d65ac20bd03bAngus Kong 1002653c43be6e58be54cf2ac3c8efb2d65ac20bd03bAngus Kong private void hideUndoDeletionBar() { 1003653c43be6e58be54cf2ac3c8efb2d65ac20bd03bAngus Kong Log.v(TAG, "Hiding undo deletion bar"); 1004653c43be6e58be54cf2ac3c8efb2d65ac20bd03bAngus Kong if (mUndoDeletionBar != null) { 1005653c43be6e58be54cf2ac3c8efb2d65ac20bd03bAngus Kong mUndoDeletionBar.animate() 1006653c43be6e58be54cf2ac3c8efb2d65ac20bd03bAngus Kong .setDuration(200) 1007653c43be6e58be54cf2ac3c8efb2d65ac20bd03bAngus Kong .alpha(0f) 1008653c43be6e58be54cf2ac3c8efb2d65ac20bd03bAngus Kong .withEndAction(new Runnable() { 1009653c43be6e58be54cf2ac3c8efb2d65ac20bd03bAngus Kong @Override 1010653c43be6e58be54cf2ac3c8efb2d65ac20bd03bAngus Kong public void run() { 1011653c43be6e58be54cf2ac3c8efb2d65ac20bd03bAngus Kong mUndoDeletionBar.setVisibility(View.GONE); 1012653c43be6e58be54cf2ac3c8efb2d65ac20bd03bAngus Kong } 1013653c43be6e58be54cf2ac3c8efb2d65ac20bd03bAngus Kong }) 1014653c43be6e58be54cf2ac3c8efb2d65ac20bd03bAngus Kong .start(); 1015653c43be6e58be54cf2ac3c8efb2d65ac20bd03bAngus Kong } 10168872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb } 10178872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb 10188872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb @Override 10196432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu public void onShowSwitcherPopup() { 10206432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu } 10216432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu 10226432cd65159731a28d9239426b0f0f4d7c44fa98Doris Liu public void setSwipingEnabled(boolean enable) { 10238e5e4eedb25a4589342660b928935acca4375fc7Angus Kong mCameraPreviewData.lockPreview(!enable); 10248872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb } 10258872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb 10268872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb // Accessor methods for getting latency times used in performance testing 10278872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb public long getAutoFocusTime() { 10288872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb return (mCurrentModule instanceof PhotoModule) ? 10298872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb ((PhotoModule) mCurrentModule).mAutoFocusTime : -1; 10308872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb } 10318872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb 10328872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb public long getShutterLag() { 10338872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb return (mCurrentModule instanceof PhotoModule) ? 10348872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb ((PhotoModule) mCurrentModule).mShutterLag : -1; 10358872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb } 10368872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb 10378872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb public long getShutterToPictureDisplayedTime() { 10388872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb return (mCurrentModule instanceof PhotoModule) ? 10398872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb ((PhotoModule) mCurrentModule).mShutterToPictureDisplayedTime : -1; 10408872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb } 10418872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb 10428872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb public long getPictureDisplayedToJpegCallbackTime() { 10438872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb return (mCurrentModule instanceof PhotoModule) ? 10448872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb ((PhotoModule) mCurrentModule).mPictureDisplayedToJpegCallbackTime : -1; 10458872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb } 10468872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb 10478872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb public long getJpegCallbackFinishTime() { 10488872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb return (mCurrentModule instanceof PhotoModule) ? 10498872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb ((PhotoModule) mCurrentModule).mJpegCallbackFinishTime : -1; 10508872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb } 10518872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb 10528872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb public long getCaptureStartTime() { 10538872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb return (mCurrentModule instanceof PhotoModule) ? 10548872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb ((PhotoModule) mCurrentModule).mCaptureStartTime : -1; 10558872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb } 10568872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb 10578872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb public boolean isRecording() { 10588872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb return (mCurrentModule instanceof VideoModule) ? 10598872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb ((VideoModule) mCurrentModule).isRecording() : false; 10608872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb } 10618872c23e739de38d74f04a8c852ebb5199c905f6Michael Kolb} 1062