summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--[-rwxr-xr-x]src/com/android/camera/AndroidCameraManagerImpl.java26
-rw-r--r--src/com/android/camera/CameraActivity.java84
-rw-r--r--src/com/android/camera/CameraSettings.java4
-rwxr-xr-xsrc/com/android/camera/CaptureModule.java235
-rwxr-xr-x[-rw-r--r--]src/com/android/camera/CaptureUI.java70
-rw-r--r--src/com/android/camera/PhotoModule.java11
-rw-r--r--src/com/android/camera/PhotoUI.java2
-rw-r--r--src/com/android/camera/RecordLocationPreference.java11
-rw-r--r--src/com/android/camera/SettingsActivity.java37
-rw-r--r--src/com/android/camera/SettingsManager.java43
-rw-r--r--src/com/android/camera/VideoModule.java6
-rw-r--r--src/com/android/camera/VideoUI.java2
-rw-r--r--src/com/android/camera/WideAnglePanoramaModule.java3
-rwxr-xr-x[-rw-r--r--]src/com/android/camera/imageprocessor/FrameProcessor.java9
-rw-r--r--src/com/android/camera/ui/CameraControls.java1
-rwxr-xr-x[-rw-r--r--]src/com/android/camera/ui/CountDownView.java11
-rw-r--r--src/com/android/camera/ui/OneUICameraControls.java160
-rw-r--r--src/com/android/camera/ui/ProMode.java374
-rwxr-xr-x[-rw-r--r--]src/org/codeaurora/snapcam/filter/ClearSightImageProcessor.java29
19 files changed, 1004 insertions, 114 deletions
diff --git a/src/com/android/camera/AndroidCameraManagerImpl.java b/src/com/android/camera/AndroidCameraManagerImpl.java
index 486629895..438be2e90 100755..100644
--- a/src/com/android/camera/AndroidCameraManagerImpl.java
+++ b/src/com/android/camera/AndroidCameraManagerImpl.java
@@ -200,6 +200,30 @@ class AndroidCameraManagerImpl implements CameraManager {
return true;
}
+ public boolean waitDone(long timeout) {
+ final Object waitDoneLock = new Object();
+ final Runnable unlockRunnable = new Runnable() {
+ @Override
+ public void run() {
+ synchronized (waitDoneLock) {
+ waitDoneLock.notifyAll();
+ }
+ }
+ };
+
+ synchronized (waitDoneLock) {
+ mCameraHandler.post(unlockRunnable);
+ try {
+ waitDoneLock.wait(timeout);
+ mCameraHandler.removeCallbacks(unlockRunnable);
+ } catch (InterruptedException ex) {
+ Log.v(TAG, "waitDone interrupted");
+ return false;
+ }
+ }
+ return true;
+ }
+
/**
* This method does not deal with the API level check. Everyone should
* check first for supported operations before sending message to this handler.
@@ -499,7 +523,7 @@ class AndroidCameraManagerImpl implements CameraManager {
@Override
public void stopPreview() {
mCameraHandler.sendEmptyMessage(STOP_PREVIEW);
- mCameraHandler.waitDone();
+ mCameraHandler.waitDone(200);
}
@Override
diff --git a/src/com/android/camera/CameraActivity.java b/src/com/android/camera/CameraActivity.java
index 26e7ca933..d3c39793a 100644
--- a/src/com/android/camera/CameraActivity.java
+++ b/src/com/android/camera/CameraActivity.java
@@ -234,7 +234,6 @@ public class CameraActivity extends Activity
private View mPreviewCover;
private FrameLayout mPreviewContentLayout;
private boolean mPaused = true;
- private boolean mHasCriticalPermissions;
private boolean mForceReleaseCamera = false;
private Uri[] mNfcPushUris = new Uri[1];
@@ -310,7 +309,6 @@ public class CameraActivity extends Activity
public void onCameraDisabled(int cameraId) {
UsageStatistics.onEvent(UsageStatistics.COMPONENT_CAMERA,
UsageStatistics.ACTION_OPEN_FAIL, "security");
-
CameraUtil.showErrorAndFinish(CameraActivity.this,
R.string.camera_disabled);
}
@@ -319,27 +317,21 @@ public class CameraActivity extends Activity
public void onDeviceOpenFailure(int cameraId) {
UsageStatistics.onEvent(UsageStatistics.COMPONENT_CAMERA,
UsageStatistics.ACTION_OPEN_FAIL, "open");
-
- CameraUtil.showErrorAndFinish(CameraActivity.this,
- R.string.cannot_connect_camera);
+ showOpenCameraErrorDialog();
}
@Override
public void onReconnectionFailure(CameraManager mgr) {
UsageStatistics.onEvent(UsageStatistics.COMPONENT_CAMERA,
UsageStatistics.ACTION_OPEN_FAIL, "reconnect");
-
- CameraUtil.showErrorAndFinish(CameraActivity.this,
- R.string.cannot_connect_camera);
+ showOpenCameraErrorDialog();
}
@Override
public void onStartPreviewFailure(int cameraId) {
UsageStatistics.onEvent(UsageStatistics.COMPONENT_CAMERA,
UsageStatistics.ACTION_START_PREVIEW_FAIL, "startpreview");
-
- CameraUtil.showErrorAndFinish(CameraActivity.this,
- R.string.cannot_connect_camera);
+ showOpenCameraErrorDialog();
}
};
@@ -1448,11 +1440,6 @@ public class CameraActivity extends Activity
@Override
public void onCreate(Bundle state) {
super.onCreate(state);
- if (checkPermissions() || !mHasCriticalPermissions) {
- Log.v(TAG, "onCreate: Missing critical permissions.");
- finish();
- return;
- }
// Check if this is in the secure camera mode.
Intent intent = getIntent();
String action = intent.getAction();
@@ -1464,8 +1451,6 @@ public class CameraActivity extends Activity
mSecureCamera = intent.getBooleanExtra(SECURE_CAMERA_EXTRA, false);
}
- mCursor = getContentResolver().query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, null, null, null, null);
-
if (mSecureCamera) {
// Change the window flags so that secure camera can show when locked
Window win = getWindow();
@@ -1479,9 +1464,20 @@ public class CameraActivity extends Activity
Log.d(TAG, "acquire wake lock");
}
win.setAttributes(params);
+ }
+ if (mSecureCamera && !hasCriticalPermissions()) {
+ return;
+ }
+ if (isStartRequsetPermission()) {
+ Log.v(TAG, "onCreate: Missing critical permissions.");
+ finish();
+ return;
}
+
+ mCursor = getContentResolver().query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
+ null, null, null, null);
GcamHelper.init(getContentResolver());
getWindow().requestFeature(Window.FEATURE_ACTION_BAR);
@@ -1677,6 +1673,10 @@ public class CameraActivity extends Activity
@Override
public void onPause() {
+ if (mSecureCamera && !hasCriticalPermissions()) {
+ super.onPause();
+ return;
+ }
// Delete photos that are pending deletion
performDeletion();
mOrientationListener.disable();
@@ -1725,9 +1725,8 @@ public class CameraActivity extends Activity
* Critical permissions are: camera, microphone and storage. The app cannot run without them.
* Non-critical permission is location.
*/
- private boolean checkPermissions() {
- boolean requestPermission = false;
-
+ private boolean hasCriticalPermissions() {
+ boolean hasCriticalPermission = false;
if (checkSelfPermission(Manifest.permission.CAMERA) ==
PackageManager.PERMISSION_GRANTED &&
checkSelfPermission(Manifest.permission.RECORD_AUDIO) ==
@@ -1736,27 +1735,38 @@ public class CameraActivity extends Activity
PackageManager.PERMISSION_GRANTED &&
checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE) ==
PackageManager.PERMISSION_GRANTED) {
- mHasCriticalPermissions = true;
+ hasCriticalPermission = true;
} else {
- mHasCriticalPermissions = false;
+ hasCriticalPermission = false;
}
+ return hasCriticalPermission;
+ }
+
+ private boolean isStartRequsetPermission() {
+ boolean isStartPermissionActivity = false;
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
boolean isRequestShown = prefs.getBoolean(CameraSettings.KEY_REQUEST_PERMISSION, false);
- if(!isRequestShown || !mHasCriticalPermissions) {
- Log.v(TAG, "Request permission");
+
+ if(!mSecureCamera && (!isRequestShown || !hasCriticalPermissions())) {
+ Log.v(TAG, "Start Request Permission");
Intent intent = new Intent(this, PermissionsActivity.class);
startActivity(intent);
SharedPreferences.Editor editor = prefs.edit();
editor.putBoolean(CameraSettings.KEY_REQUEST_PERMISSION, true);
editor.apply();
- requestPermission = true;
- }
- return requestPermission;
+ isStartPermissionActivity = true;
+ }
+ return isStartPermissionActivity;
}
@Override
public void onResume() {
- if (checkPermissions() || !mHasCriticalPermissions) {
+ if (mSecureCamera && !hasCriticalPermissions()) {
+ super.onResume();
+ showOpenCameraErrorDialog();
+ return;
+ }
+ if (isStartRequsetPermission()) {
super.onResume();
Log.v(TAG, "onResume: Missing critical permissions.");
finish();
@@ -1814,6 +1824,9 @@ public class CameraActivity extends Activity
@Override
public void onStart() {
super.onStart();
+ if (mSecureCamera && !hasCriticalPermissions()) {
+ return;
+ }
bindMediaSaveService();
mPanoramaViewHelper.onStart();
}
@@ -1821,6 +1834,9 @@ public class CameraActivity extends Activity
@Override
protected void onStop() {
super.onStop();
+ if (mSecureCamera && !hasCriticalPermissions()) {
+ return;
+ }
mPanoramaViewHelper.onStop();
unbindMediaSaveService();
}
@@ -2352,4 +2368,14 @@ public class CameraActivity extends Activity
public CameraModule getCurrentModule() {
return mCurrentModule;
}
+
+ private void showOpenCameraErrorDialog() {
+ if (!hasCriticalPermissions()) {
+ CameraUtil.showErrorAndFinish(CameraActivity.this,
+ R.string.error_permissions);
+ } else {
+ CameraUtil.showErrorAndFinish(CameraActivity.this,
+ R.string.cannot_connect_camera);
+ }
+ }
}
diff --git a/src/com/android/camera/CameraSettings.java b/src/com/android/camera/CameraSettings.java
index 069fb8701..97c4eae0a 100644
--- a/src/com/android/camera/CameraSettings.java
+++ b/src/com/android/camera/CameraSettings.java
@@ -1027,6 +1027,10 @@ public class CameraSettings {
return;
}
+ if (numOfCameras > 2 ) {
+ numOfCameras = 2;
+ }
+
CharSequence[] entryValues = new CharSequence[numOfCameras];
for (int i = 0; i < numOfCameras; ++i) {
entryValues[i] = "" + i;
diff --git a/src/com/android/camera/CaptureModule.java b/src/com/android/camera/CaptureModule.java
index 6fedf48d0..de3f65c73 100755
--- a/src/com/android/camera/CaptureModule.java
+++ b/src/com/android/camera/CaptureModule.java
@@ -94,6 +94,7 @@ import com.android.camera.util.CameraUtil;
import com.android.camera.util.PersistUtil;
import com.android.camera.util.SettingTranslation;
import com.android.camera.util.ApiHelper;
+import com.android.camera.util.AccessibilityUtils;
import com.android.internal.util.MemInfoReader;
import org.codeaurora.snapcam.R;
@@ -104,7 +105,6 @@ import java.io.IOException;
import java.nio.ByteBuffer;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
-import java.util.Comparator;
import java.util.Date;
import java.util.LinkedList;
import java.util.List;
@@ -116,7 +116,7 @@ public class CaptureModule implements CameraModule, PhotoController,
MediaSaveService.Listener, ClearSightImageProcessor.Callback,
SettingsManager.Listener, LocationManager.Listener,
CountDownView.OnCountDownFinishedListener,
- MediaRecorder.OnInfoListener{
+ MediaRecorder.OnErrorListener, MediaRecorder.OnInfoListener {
public static final int DUAL_MODE = 0;
public static final int BAYER_MODE = 1;
public static final int MONO_MODE = 2;
@@ -193,6 +193,12 @@ public class CaptureModule implements CameraModule, PhotoController,
public static CameraCharacteristics.Key<Byte> MetaDataMonoOnlyKey =
new CameraCharacteristics.Key<>("org.codeaurora.qcamera3.sensor_meta_data.is_mono_only",
Byte.class);
+ public static CaptureRequest.Key<Integer> SELECT_PRIORITY =
+ new CaptureRequest.Key<>("org.codeaurora.qcamera3.iso_exp_priority.select_priority",
+ Integer.class);
+ public static CaptureRequest.Key<Long> ISO_EXP =
+ new CaptureRequest.Key<>("org.codeaurora.qcamera3.iso_exp_priority.use_iso_exp_priority",
+ Long.class);
private boolean[] mTakingPicture = new boolean[MAX_NUM_CAM];
private int mControlAFMode = CameraMetadata.CONTROL_AF_MODE_CONTINUOUS_PICTURE;
private int mLastResultAFState = -1;
@@ -206,7 +212,8 @@ public class CaptureModule implements CameraModule, PhotoController,
private boolean mIsLinked = false;
private long mCaptureStartTime;
private boolean mPaused = true;
- private boolean mSurfaceReady = false;
+ private Semaphore mSurfaceReadyLock = new Semaphore(1);
+ private boolean mSurfaceReady = true;
private boolean[] mCameraOpened = new boolean[MAX_NUM_CAM];
private CameraDevice[] mCameraDevice = new CameraDevice[MAX_NUM_CAM];
private String[] mCameraId = new String[MAX_NUM_CAM];
@@ -224,6 +231,7 @@ public class CaptureModule implements CameraModule, PhotoController,
private int mDisplayOrientation;
private boolean mIsRefocus = false;
private int mChosenImageFormat;
+ private Toast mToast;
/**
* A {@link CameraCaptureSession } for camera preview.
@@ -781,8 +789,15 @@ public class CaptureModule implements CameraModule, PhotoController,
}
}
+ private void applyFocusDistance(CaptureRequest.Builder builder, String value) {
+ if (value == null) return;
+ float valueF = Float.valueOf(value);
+ builder.set(CaptureRequest.CONTROL_AF_MODE, CaptureRequest.CONTROL_AF_MODE_OFF);
+ builder.set(CaptureRequest.LENS_FOCUS_DISTANCE, valueF);
+ }
+
private void createSessions() {
- if (mPaused || !mCamerasOpened || !mSurfaceReady) return;
+ if (mPaused || !mCamerasOpened ) return;
if (isBackCamera()) {
switch (getCameraMode()) {
case DUAL_MODE:
@@ -811,12 +826,42 @@ public class CaptureModule implements CameraModule, PhotoController,
return builder;
}
+ private void waitForPreviewSurfaceReady() {
+ try {
+ if (!mSurfaceReady) {
+ if (!mSurfaceReadyLock.tryAcquire(2000, TimeUnit.MILLISECONDS)) {
+ Log.d(TAG, "Time out waiting for surface.");
+ throw new RuntimeException("Time out waiting for surface.");
+ }
+ mSurfaceReadyLock.release();
+ }
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+
+ private void updatePreviewSurfaceReadyState(boolean rdy) {
+ if (rdy != mSurfaceReady) {
+ if (rdy) {
+ Log.i(TAG, "Preview Surface is ready!");
+ mSurfaceReadyLock.release();
+ mSurfaceReady = true;
+ } else {
+ try {
+ Log.i(TAG, "Preview Surface is not ready!");
+ mSurfaceReady = false;
+ mSurfaceReadyLock.acquire();
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ }
private void createSession(final int id) {
- if (mPaused || !mCameraOpened[id] || !mSurfaceReady) return;
+ if (mPaused || !mCameraOpened[id]) return;
Log.d(TAG, "createSession " + id);
List<Surface> list = new LinkedList<Surface>();
try {
- Surface surface = getPreviewSurfaceForSession(id);
// We set up a CaptureRequest.Builder with the output Surface.
mPreviewRequestBuilder[id] = getRequestBuilder(id);
mPreviewRequestBuilder[id].setTag(id);
@@ -867,6 +912,9 @@ public class CaptureModule implements CameraModule, PhotoController,
@Override
public void onConfigureFailed(CameraCaptureSession cameraCaptureSession) {
Log.e(TAG, "cameracapturesession - onConfigureFailed "+id);
+ if (mActivity.isFinishing()) {
+ return;
+ }
new AlertDialog.Builder(mActivity)
.setTitle("Camera Initialization Failed")
.setMessage("Closing SnapdragonCamera")
@@ -886,6 +934,8 @@ public class CaptureModule implements CameraModule, PhotoController,
Log.d(TAG, "cameracapturesession - onClosed");
}
};
+ waitForPreviewSurfaceReady();
+ Surface surface = getPreviewSurfaceForSession(id);
if(id == getMainCameraId()) {
mFrameProcessor.setOutputSurface(surface);
@@ -1009,8 +1059,6 @@ public class CaptureModule implements CameraModule, PhotoController,
mCameraOpened[i] = false;
mTakingPicture[i] = false;
}
- mSurfaceReady = false;
-
for (int i = 0; i < MAX_NUM_CAM; i++) {
mState[i] = STATE_PREVIEW;
}
@@ -1138,6 +1186,7 @@ public class CaptureModule implements CameraModule, PhotoController,
mCaptureSession[id].capture(builder.build(), mCaptureCallback, mCameraHandler);
setAFModeToPreview(id, mControlAFMode);
Message message = mCameraHandler.obtainMessage(CANCEL_TOUCH_FOCUS, mCameraId[id]);
+ message.arg1 = id;
mCameraHandler.sendMessageDelayed(message, CANCEL_TOUCH_FOCUS_DELAY);
} catch (CameraAccessException e) {
e.printStackTrace();
@@ -1213,10 +1262,12 @@ public class CaptureModule implements CameraModule, PhotoController,
Location location = mLocationManager.getCurrentLocation();
if(location != null) {
- Log.d(TAG, "captureStillPicture gps: " + location.toString());
+ // make copy so that we don't alter the saved location since we may re-use it
+ location = new Location(location);
// workaround for Google bug. Need to convert timestamp from ms -> sec
location.setTime(location.getTime()/1000);
captureBuilder.set(CaptureRequest.JPEG_GPS_LOCATION, location);
+ Log.d(TAG, "captureStillPicture gps: " + location.toString());
} else {
Log.d(TAG, "captureStillPicture no location - getRecordLocation: " + getRecordLocation());
}
@@ -1299,6 +1350,13 @@ public class CaptureModule implements CameraModule, PhotoController,
unlockFocus(id);
}
}, mCaptureCallbackHandler);
+ mActivity.runOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ mUI.enableVideo(false);
+ }
+ });
+
} else {
checkAndPlayShutterSound(id);
if(isMpoOn()) {
@@ -1555,6 +1613,7 @@ public class CaptureModule implements CameraModule, PhotoController,
public void run() {
mUI.stopSelfieFlash();
mUI.enableShutter(true);
+ mUI.enableVideo(true);
}
});
}
@@ -1828,6 +1887,7 @@ public class CaptureModule implements CameraModule, PhotoController,
@Override
public void onPauseBeforeSuper() {
mPaused = true;
+ mToast = null;
mUI.onPause();
if (mIsRecordingVideo) {
stopRecordingVideo(getMainCameraId());
@@ -1869,6 +1929,7 @@ public class CaptureModule implements CameraModule, PhotoController,
}
mLongshotActive = false;
mZoomValue = 1.0f;
+ updatePreviewSurfaceReadyState(false);
}
private ArrayList<Integer> getFrameProcFilterId() {
@@ -2025,7 +2086,6 @@ public class CaptureModule implements CameraModule, PhotoController,
Log.d(TAG, "onResume " + getCameraMode());
initializeValues();
updatePreviewSize();
- mUI.showSurfaceView();
mCameraIdList = new ArrayList<>();
if (mSound == null) {
@@ -2054,6 +2114,7 @@ public class CaptureModule implements CameraModule, PhotoController,
msg.arg1 = FRONT_ID;
mCameraHandler.sendMessage(msg);
}
+ mUI.showSurfaceView();
if (!mFirstTimeInitialized) {
initializeFirstTime();
} else {
@@ -2067,8 +2128,15 @@ public class CaptureModule implements CameraModule, PhotoController,
}
});
mUI.enableShutter(true);
-
+ mUI.enableVideo(true);
String scene = mSettingsManager.getValue(SettingsManager.KEY_SCENE_MODE);
+ boolean promode = false;
+ if (scene != null) {
+ int mode = Integer.parseInt(scene);
+ if (mode == SettingsManager.SCENE_MODE_PROMODE_INT) promode = true;
+ }
+ mUI.initializeProMode(promode);
+
if(isPanoSetting(scene)) {
mActivity.onModuleSelected(ModuleSwitcher.PANOCAPTURE_MODULE_INDEX);
}
@@ -2284,16 +2352,17 @@ public class CaptureModule implements CameraModule, PhotoController,
}
private boolean isTouchToFocusAllowed() {
- if (isTakingPicture() || mIsRecordingVideo || isSceneModeOn()) return false;
+ if (isTakingPicture() || mIsRecordingVideo || isTouchAfEnabledSceneMode()) return false;
return true;
}
- private boolean isSceneModeOn() {
+ private boolean isTouchAfEnabledSceneMode() {
String scene = mSettingsManager.getValue(SettingsManager.KEY_SCENE_MODE);
if (scene == null) return false;
int mode = Integer.parseInt(scene);
- if (mode != SettingsManager.SCENE_MODE_DUAL_INT && mode != CaptureRequest
- .CONTROL_SCENE_MODE_DISABLED) return true;
+ if (mode != CaptureRequest.CONTROL_SCENE_MODE_DISABLED
+ && mode < SettingsManager.SCENE_MODE_CUSTOM_START)
+ return true;
return false;
}
@@ -2372,17 +2441,16 @@ public class CaptureModule implements CameraModule, PhotoController,
@Override
public void onPreviewUIReady() {
+ updatePreviewSurfaceReadyState(true);
+
if (mPaused || mIsRecordingVideo) {
return;
}
- Log.d(TAG, "onPreviewUIReady");
- mSurfaceReady = true;
- createSessions();
}
@Override
public void onPreviewUIDestroyed() {
- mSurfaceReady = false;
+ updatePreviewSurfaceReadyState(false);
}
@Override
@@ -2532,7 +2600,7 @@ public class CaptureModule implements CameraModule, PhotoController,
}
}
- private void startRecordingVideo(int cameraId) {
+ private void startRecordingVideo(final int cameraId) {
if (null == mCameraDevice[cameraId]) {
return;
}
@@ -2559,7 +2627,7 @@ public class CaptureModule implements CameraModule, PhotoController,
createVideoSnapshotImageReader();
mVideoRequestBuilder = mCameraDevice[cameraId].createCaptureRequest(CameraDevice.TEMPLATE_RECORD);
mVideoRequestBuilder.setTag(cameraId);
-
+ mPreviewRequestBuilder[cameraId] = mVideoRequestBuilder;
List<Surface> surfaces = new ArrayList<>();
Surface surface = getPreviewSurfaceForSession(cameraId);
@@ -2585,6 +2653,7 @@ public class CaptureModule implements CameraModule, PhotoController,
@Override
public void onConfigured(CameraCaptureSession cameraCaptureSession) {
mCurrentSession = cameraCaptureSession;
+ mCaptureSession[cameraId] = cameraCaptureSession;
CameraConstrainedHighSpeedCaptureSession session =
(CameraConstrainedHighSpeedCaptureSession) mCurrentSession;
try {
@@ -2628,6 +2697,7 @@ public class CaptureModule implements CameraModule, PhotoController,
public void onConfigured(CameraCaptureSession cameraCaptureSession) {
Log.d(TAG, "StartRecordingVideo session onConfigured");
mCurrentSession = cameraCaptureSession;
+ mCaptureSession[cameraId] = cameraCaptureSession;
try {
setUpVideoCaptureRequestBuilder(mVideoRequestBuilder);
mCurrentSession.setRepeatingRequest(mVideoRequestBuilder.build(),
@@ -2828,14 +2898,30 @@ public class CaptureModule implements CameraModule, PhotoController,
private void stopRecordingVideo(int cameraId) {
Log.d(TAG, "stopRecordingVideo " + cameraId);
+ boolean shouldAddToMediaStoreNow = false;
// Stop recording
mFrameProcessor.setVideoOutputSurface(null);
mFrameProcessor.onClose();
closePreviewSession();
- mMediaRecorder.stop();
- mMediaRecorder.reset();
- mMediaRecorder.setOnInfoListener(null);
- saveVideo();
+ try {
+ mMediaRecorder.setOnErrorListener(null);
+ mMediaRecorder.setOnInfoListener(null);
+ mMediaRecorder.stop();
+ shouldAddToMediaStoreNow = true;
+ AccessibilityUtils.makeAnnouncement(mUI.getVideoButton(),
+ mActivity.getString(R.string.video_recording_stopped));
+ } catch (RuntimeException e) {
+ Log.e(TAG, "MediaRecoder stop fail", e);
+ if (mVideoFilename != null) deleteVideoFile(mVideoFilename);
+ }
+ if (shouldAddToMediaStoreNow) {
+ saveVideo();
+ }
+
+ // release media recorder
+ releaseMediaRecorder();
+ releaseAudioFocus();
+
mUI.showRecordingUI(false, false);
mUI.enableShutter(true);
@@ -2848,9 +2934,8 @@ public class CaptureModule implements CameraModule, PhotoController,
if (changed) {
mUI.hideSurfaceView();
mUI.showSurfaceView();
- } else {
- createSession(cameraId);
}
+ createSessions();
mUI.showUIafterRecording();
mUI.resetTrackingFocus();
}
@@ -2933,6 +3018,9 @@ public class CaptureModule implements CameraModule, PhotoController,
if (mCaptureTimeLapse) {
size = CameraSettings.getTimeLapseQualityFor(size);
}
+
+ if (mMediaRecorder == null) mMediaRecorder = new MediaRecorder();
+
updateHFRSetting();
boolean hfr = mHighSpeedCapture && !mHighSpeedRecordingMode;
mProfile = CamcorderProfile.get(cameraId, size);
@@ -3004,7 +3092,15 @@ public class CaptureModule implements CameraModule, PhotoController,
} else {
mMediaRecorder.setOrientationHint(rotation);
}
- mMediaRecorder.prepare();
+ try {
+ mMediaRecorder.prepare();
+ } catch (IOException e) {
+ Log.e(TAG, "prepare failed for " + mVideoFilename, e);
+ releaseMediaRecorder();
+ throw new RuntimeException(e);
+ }
+
+ mMediaRecorder.setOnErrorListener(this);
mMediaRecorder.setOnInfoListener(this);
}
@@ -3159,6 +3255,10 @@ public class CaptureModule implements CameraModule, PhotoController,
return true;
}
+ if ( mIsRecordingVideo ) {
+ Log.e(TAG, " cancel longshot:not supported when recording");
+ return true;
+ }
return false;
}
@@ -3228,6 +3328,9 @@ public class CaptureModule implements CameraModule, PhotoController,
updatePreview = true;
applyFaceDetection(mPreviewRequestBuilder[cameraId]);
break;
+ case SettingsManager.KEY_FOCUS_DISTANCE:
+ updatePreview = true;
+ applyFocusDistance(mPreviewRequestBuilder[cameraId], value);
}
return updatePreview;
}
@@ -3277,8 +3380,9 @@ public class CaptureModule implements CameraModule, PhotoController,
request.set(CaptureRequest.CONTROL_MODE, CaptureRequest.CONTROL_MODE_AUTO);
return;
}
- if (mode != CaptureRequest.CONTROL_SCENE_MODE_DISABLED && mode !=
- SettingsManager.SCENE_MODE_DUAL_INT) {
+ if (mode != CaptureRequest.CONTROL_SCENE_MODE_DISABLED
+ && mode != SettingsManager.SCENE_MODE_DUAL_INT
+ && mode != SettingsManager.SCENE_MODE_PROMODE_INT) {
request.set(CaptureRequest.CONTROL_SCENE_MODE, mode);
request.set(CaptureRequest.CONTROL_MODE, CaptureRequest.CONTROL_MODE_USE_SCENE_MODE);
} else {
@@ -3296,9 +3400,14 @@ public class CaptureModule implements CameraModule, PhotoController,
private void applyIso(CaptureRequest.Builder request) {
String value = mSettingsManager.getValue(SettingsManager.KEY_ISO);
if (value == null) return;
- if (value.equals("auto")) return;
- int intValue = Integer.parseInt(value);
- request.set(CaptureRequest.SENSOR_SENSITIVITY, intValue);
+ if (value.equals("auto")) {
+ request.set(SELECT_PRIORITY, null);
+ request.set(ISO_EXP, null);
+ } else {
+ long intValue = Integer.parseInt(value);
+ request.set(SELECT_PRIORITY, 0);
+ request.set(ISO_EXP, intValue);
+ }
}
private void applyColorEffect(CaptureRequest.Builder request) {
@@ -3542,6 +3651,9 @@ public class CaptureModule implements CameraModule, PhotoController,
case SettingsManager.KEY_FLASH_MODE:
if (count == 0) restartSession(false);
return;
+ case SettingsManager.KEY_SCENE_MODE:
+ restartAll();
+ return;
}
if (isBackCamera()) {
@@ -3835,6 +3947,18 @@ public class CaptureModule implements CameraModule, PhotoController,
enableRecordingLocation(false);
}
+ // from MediaRecorder.OnErrorListener
+ @Override
+ public void onError(MediaRecorder mr, int what, int extra) {
+ Log.e(TAG, "MediaRecorder error. what=" + what + ". extra=" + extra);
+ stopRecordingVideo(getMainCameraId());
+ mUI.showUIafterRecording();
+ if (what == MediaRecorder.MEDIA_RECORDER_ERROR_UNKNOWN) {
+ // We may have run out of space on the sdcard.
+ mActivity.updateStorageSpaceAndHint();
+ }
+ }
+
// from MediaRecorder.OnInfoListener
@Override
public void onInfo(MediaRecorder mr, int what, int extra) {
@@ -3863,4 +3987,49 @@ public class CaptureModule implements CameraModule, PhotoController,
Storage.setSaveSDCard(mSettingsManager.getValue(SettingsManager
.KEY_CAMERA_SAVEPATH).equals("1"));
}
+
+ private void deleteVideoFile(String fileName) {
+ Log.v(TAG, "Deleting video " + fileName);
+ File f = new File(fileName);
+ if (!f.delete()) {
+ Log.v(TAG, "Could not delete " + fileName);
+ }
+ }
+
+ private void releaseMediaRecorder() {
+ Log.v(TAG, "Releasing media recorder.");
+ if (mMediaRecorder != null) {
+ cleanupEmptyFile();
+ mMediaRecorder.reset();
+ mMediaRecorder.release();
+ mMediaRecorder = null;
+ }
+ mVideoFilename = null;
+ }
+
+ private void cleanupEmptyFile() {
+ if (mVideoFilename != null) {
+ File f = new File(mVideoFilename);
+ if (f.length() == 0 && f.delete()) {
+ Log.v(TAG, "Empty video file deleted: " + mVideoFilename);
+ mVideoFilename = null;
+ }
+ }
+ }
+
+ private void releaseAudioFocus() {
+ AudioManager am = (AudioManager)mActivity.getSystemService(Context.AUDIO_SERVICE);
+ int result = am.abandonAudioFocus(null);
+ if (result == AudioManager.AUDIOFOCUS_REQUEST_FAILED) {
+ Log.v(TAG, "Audio focus release failed");
+ }
+ }
+
+ private void showToast(String tips) {
+ if (mToast == null) {
+ mToast = Toast.makeText(mActivity, tips, Toast.LENGTH_LONG);
+ }
+ mToast.setText(tips);
+ mToast.show();
+ }
}
diff --git a/src/com/android/camera/CaptureUI.java b/src/com/android/camera/CaptureUI.java
index 88460b865..b026af892 100644..100755
--- a/src/com/android/camera/CaptureUI.java
+++ b/src/com/android/camera/CaptureUI.java
@@ -77,6 +77,7 @@ import org.codeaurora.snapcam.R;
import java.util.List;
import java.util.Locale;
+import java.util.Map;
public class CaptureUI implements FocusOverlayManager.FocusUI,
PreviewGestures.SingleTapListener,
@@ -184,6 +185,7 @@ public class CaptureUI implements FocusOverlayManager.FocusUI,
private PauseButton mPauseButton;
private RotateImageView mMuteButton;
private ImageView mSeekbarToggleButton;
+ private View mProModeCloseButton;
int mPreviewWidth;
int mPreviewHeight;
@@ -279,10 +281,18 @@ public class CaptureUI implements FocusOverlayManager.FocusUI,
@Override
public void onClick(View v) {
toggleMakeup();
+ updateMenus();
}
});
setMakeupButtonIcon();
mFlashButton = (FlashToggleButton) mRootView.findViewById(R.id.flash_button);
+ mProModeCloseButton = mRootView.findViewById(R.id.promode_close_button);
+ mProModeCloseButton.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ mSettingsManager.setValue(SettingsManager.KEY_SCENE_MODE, "" + SettingsManager.SCENE_MODE_AUTO_INT);
+ }
+ });
initFilterModeButton();
initSceneModeButton();
initSwitchCamera();
@@ -367,8 +377,8 @@ public class CaptureUI implements FocusOverlayManager.FocusUI,
String value = mSettingsManager.getValue(SettingsManager.KEY_MAKEUP);
if(value != null && !mIsVideoUI) {
if(value.equals("0")) {
- mSettingsManager.setValue(SettingsManager.KEY_MAKEUP, "10");
- mMakeupSeekBar.setProgress(10);
+ mSettingsManager.setValue(SettingsManager.KEY_MAKEUP, "50");
+ mMakeupSeekBar.setProgress(50);
mMakeupSeekBarLayout.setVisibility(View.VISIBLE);
mSeekbarBody.setVisibility(View.VISIBLE);
mSeekbarToggleButton.setImageResource(R.drawable.seekbar_hide);
@@ -425,6 +435,12 @@ public class CaptureUI implements FocusOverlayManager.FocusUI,
}
}
+ public void initializeProMode(boolean promode) {
+ mCameraControls.setProMode(promode);
+ if (promode) mVideoButton.setVisibility(View.INVISIBLE);
+ else mVideoButton.setVisibility(View.VISIBLE);
+ }
+
// called from onResume but only the first time
public void initializeFirstTime() {
// Initialize shutter button.
@@ -477,6 +493,7 @@ public class CaptureUI implements FocusOverlayManager.FocusUI,
mFilterLayout = null;
}
}
+ updateMenus();
}
public void openSettingsMenu() {
@@ -538,16 +555,26 @@ public class CaptureUI implements FocusOverlayManager.FocusUI,
String value = mSettingsManager.getValue(SettingsManager.KEY_COLOR_EFFECT);
if (value == null) return;
+ enableView(mFilterModeSwitcher, SettingsManager.KEY_COLOR_EFFECT);
+
mFilterModeSwitcher.setVisibility(View.VISIBLE);
mFilterModeSwitcher.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
addFilterMode();
adjustOrientation();
+ updateMenus();
}
});
}
+ private void enableView(View view, String key) {
+ Map<String, SettingsManager.Values> map = mSettingsManager.getValuesMap();
+ SettingsManager.Values values = map.get(key);
+ boolean enabled = values.overriddenValue == null;
+ view.setEnabled(enabled);
+ }
+
public void showTimeLapseUI(boolean enable) {
if (mTimeLapseLabel != null) {
mTimeLapseLabel.setVisibility(enable ? View.VISIBLE : View.GONE);
@@ -860,9 +887,28 @@ public class CaptureUI implements FocusOverlayManager.FocusUI,
public void cleanUpMenus() {
showUI();
+ updateMenus();
mActivity.setSystemBarsVisibility(false);
}
+ public void updateMenus() {
+ boolean enableMakeupMenu = true;
+ boolean enableFilterMenu = true;
+ boolean enableSceneMenu = true;
+ String makeupValue = mSettingsManager.getValue(SettingsManager.KEY_MAKEUP);
+ int colorEffect = mSettingsManager.getValueIndex(SettingsManager.KEY_COLOR_EFFECT);
+ if (makeupValue != null && !makeupValue.equals("0")) {
+ enableSceneMenu = false;
+ enableFilterMenu = false;
+ } else if (colorEffect != 0 || mFilterMenuStatus == FILTER_MENU_ON){
+ enableSceneMenu = false;
+ enableMakeupMenu = false;
+ }
+ mMakeupButton.setEnabled(enableMakeupMenu);
+ mFilterModeSwitcher.setEnabled(enableFilterMenu);
+ mSceneModeSwitcher.setEnabled(enableSceneMenu);
+ }
+
public boolean arePreviewControlsVisible() {
return !mUIhidden;
}
@@ -879,6 +925,15 @@ public class CaptureUI implements FocusOverlayManager.FocusUI,
}
}
+ /**
+ * Enables or disables the video button.
+ */
+ public void enableVideo(boolean enabled) {
+ if (mVideoButton != null) {
+ mVideoButton.setEnabled(enabled);
+ }
+ }
+
private boolean handleBackKeyOnMenu() {
if (mFilterMenuStatus == FILTER_MENU_ON) {
removeFilterMenu(true);
@@ -1282,6 +1337,12 @@ public class CaptureUI implements FocusOverlayManager.FocusUI,
@Override
public void onSettingsChanged(List<SettingsManager.SettingState> settings) {
+ for( SettingsManager.SettingState state : settings) {
+ if( state.key.equals(SettingsManager.KEY_COLOR_EFFECT) ) {
+ enableView(mFilterModeSwitcher, SettingsManager.KEY_COLOR_EFFECT);
+ break;
+ }
+ }
}
public void startSelfieFlash() {
@@ -1315,6 +1376,7 @@ public class CaptureUI implements FocusOverlayManager.FocusUI,
}
public void showSurfaceView() {
+ Log.d(TAG, "showSurfaceView");
mSurfaceView.getHolder().setFixedSize(mPreviewWidth, mPreviewHeight);
mSurfaceView.setAspectRatio(mPreviewHeight, mPreviewWidth);
mSurfaceView.setVisibility(View.VISIBLE);
@@ -1359,4 +1421,8 @@ public class CaptureUI implements FocusOverlayManager.FocusUI,
}
}
+
+ public ImageView getVideoButton() {
+ return mVideoButton;
+ }
}
diff --git a/src/com/android/camera/PhotoModule.java b/src/com/android/camera/PhotoModule.java
index cfdd8af12..884fe142e 100644
--- a/src/com/android/camera/PhotoModule.java
+++ b/src/com/android/camera/PhotoModule.java
@@ -629,7 +629,7 @@ public class PhotoModule
private void locationFirstRun() {
/* Do not prompt if the preference is already set, this is a secure
* camera session, or the prompt has already been triggered. */
- if (RecordLocationPreference.isSet(mPreferences) ||
+ if (RecordLocationPreference.isSet(mPreferences, CameraSettings.KEY_RECORD_LOCATION) ||
mActivity.isSecureCamera() || mLocationPromptTriggered) {
return;
}
@@ -912,7 +912,8 @@ public class PhotoModule
}
// Initialize location service.
- boolean recordLocation = RecordLocationPreference.get(mPreferences);
+ boolean recordLocation = RecordLocationPreference.get(mPreferences,
+ CameraSettings.KEY_RECORD_LOCATION);
mLocationManager.recordLocation(recordLocation);
mUI.initializeFirstTime();
@@ -943,7 +944,8 @@ public class PhotoModule
// onResume.
private void initializeSecondTime() {
// Start location update if needed.
- boolean recordLocation = RecordLocationPreference.get(mPreferences);
+ boolean recordLocation = RecordLocationPreference.get(mPreferences,
+ CameraSettings.KEY_RECORD_LOCATION);
mLocationManager.recordLocation(recordLocation);
MediaSaveService s = mActivity.getMediaSaveService();
if (s != null) {
@@ -4673,7 +4675,8 @@ public class PhotoModule
// ignore the events after "onPause()"
if (mPaused) return;
- boolean recordLocation = RecordLocationPreference.get(mPreferences);
+ boolean recordLocation = RecordLocationPreference.get(mPreferences,
+ CameraSettings.KEY_RECORD_LOCATION);
mLocationManager.recordLocation(recordLocation);
if(needRestart()){
Log.v(TAG, "Restarting Preview... Camera Mode Changed");
diff --git a/src/com/android/camera/PhotoUI.java b/src/com/android/camera/PhotoUI.java
index 250bfa603..442c65d94 100644
--- a/src/com/android/camera/PhotoUI.java
+++ b/src/com/android/camera/PhotoUI.java
@@ -728,7 +728,7 @@ public class PhotoUI implements PieListener,
// make sure the correct value was found
// otherwise use auto index
mOnScreenIndicators.updateWBIndicator(wbIndex < 0 ? 2 : wbIndex);
- boolean location = RecordLocationPreference.get(prefs);
+ boolean location = RecordLocationPreference.get(prefs, CameraSettings.KEY_RECORD_LOCATION);
mOnScreenIndicators.updateLocationIndicator(location);
}
diff --git a/src/com/android/camera/RecordLocationPreference.java b/src/com/android/camera/RecordLocationPreference.java
index b88f5e4ed..088ff663f 100644
--- a/src/com/android/camera/RecordLocationPreference.java
+++ b/src/com/android/camera/RecordLocationPreference.java
@@ -40,18 +40,17 @@ public class RecordLocationPreference extends IconListPreference {
@Override
public String getValue() {
- return get(getSharedPreferences()) ? VALUE_ON : VALUE_OFF;
+ return get(getSharedPreferences(), getKey()) ? VALUE_ON : VALUE_OFF;
}
- public static boolean get(SharedPreferences pref) {
- String value = pref.getString(
- CameraSettings.KEY_RECORD_LOCATION, VALUE_NONE);
+ public static boolean get(SharedPreferences pref, String key) {
+ String value = pref.getString(key, VALUE_NONE);
return VALUE_ON.equals(value);
}
- public static boolean isSet(SharedPreferences pref) {
+ public static boolean isSet(SharedPreferences pref, String key) {
String value = pref.getString(
- CameraSettings.KEY_RECORD_LOCATION, VALUE_NONE);
+ key, VALUE_NONE);
return !VALUE_NONE.equals(value);
}
}
diff --git a/src/com/android/camera/SettingsActivity.java b/src/com/android/camera/SettingsActivity.java
index 503927904..e97073f58 100644
--- a/src/com/android/camera/SettingsActivity.java
+++ b/src/com/android/camera/SettingsActivity.java
@@ -89,6 +89,20 @@ public class SettingsActivity extends PreferenceActivity {
}
};
+ private SettingsManager.Listener mListener = new SettingsManager.Listener(){
+ @Override
+ public void onSettingsChanged(List<SettingsManager.SettingState> settings){
+ Map<String, SettingsManager.Values> map = mSettingsManager.getValuesMap();
+ for( SettingsManager.SettingState state : settings) {
+ SettingsManager.Values values = map.get(state.key);
+ boolean enabled = values.overriddenValue == null;
+ Preference pref = findPreference(state.key);
+ if (pref != null) {
+ pref.setEnabled(enabled);
+ }
+ }
+ }
+ };
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -102,6 +116,7 @@ public class SettingsActivity extends PreferenceActivity {
finish();
return;
}
+ mSettingsManager.registerListener(mListener);
addPreferencesFromResource(R.xml.setting_menu_preferences);
mSharedPreferences = getPreferenceManager().getSharedPreferences();
@@ -207,12 +222,16 @@ public class SettingsActivity extends PreferenceActivity {
private void updatePreferenceButton(String key) {
Preference pref = findPreference(key);
- if (pref != null && pref instanceof ListPreference) {
- ListPreference pref2 = (ListPreference) pref;
- if (pref2.getEntryValues().length == 1) {
- pref2.setEnabled(false);
- } else {
- pref2.setEnabled(true);
+ if (pref != null ) {
+ if( pref instanceof ListPreference) {
+ ListPreference pref2 = (ListPreference) pref;
+ if (pref2.getEntryValues().length == 1) {
+ pref2.setEnabled(false);
+ } else {
+ pref2.setEnabled(true);
+ }
+ }else {
+ pref.setEnabled(false);
}
}
}
@@ -243,6 +262,12 @@ public class SettingsActivity extends PreferenceActivity {
finish();
}
+ @Override
+ protected void onDestroy() {
+ super.onDestroy();
+ mSettingsManager.unregisterListener(mListener);
+ }
+
private void setShowInLockScreen() {
// Change the window flags so that secure camera can show when locked
Window win = getWindow();
diff --git a/src/com/android/camera/SettingsManager.java b/src/com/android/camera/SettingsManager.java
index f64d64a01..520a247f6 100644
--- a/src/com/android/camera/SettingsManager.java
+++ b/src/com/android/camera/SettingsManager.java
@@ -86,15 +86,17 @@ public class SettingsManager implements ListMenu.SettingsListener {
public static final int SCENE_MODE_NIGHT_INT = 5;
// Custom-Scenemodes start from 100
- public static final int SCENE_MODE_DUAL_INT = 100;
- public static final int SCENE_MODE_OPTIZOOM_INT = 101;
- public static final int SCENE_MODE_UBIFOCUS_INT = 102;
- public static final int SCENE_MODE_BESTPICTURE_INT = 103;
- public static final int SCENE_MODE_PANORAMA_INT = 104;
- public static final int SCENE_MODE_CHROMAFLASH_INT = 105;
- public static final int SCENE_MODE_BLURBUSTER_INT = 106;
- public static final int SCENE_MODE_SHARPSHOOTER_INT = 107;
- public static final int SCENE_MODE_TRACKINGFOCUS_INT = 108;
+ public static final int SCENE_MODE_CUSTOM_START = 100;
+ public static final int SCENE_MODE_DUAL_INT = SCENE_MODE_CUSTOM_START;
+ public static final int SCENE_MODE_OPTIZOOM_INT = SCENE_MODE_CUSTOM_START + 1;
+ public static final int SCENE_MODE_UBIFOCUS_INT = SCENE_MODE_CUSTOM_START + 2;
+ public static final int SCENE_MODE_BESTPICTURE_INT = SCENE_MODE_CUSTOM_START + 3;
+ public static final int SCENE_MODE_PANORAMA_INT = SCENE_MODE_CUSTOM_START + 4;
+ public static final int SCENE_MODE_CHROMAFLASH_INT = SCENE_MODE_CUSTOM_START + 5;
+ public static final int SCENE_MODE_BLURBUSTER_INT = SCENE_MODE_CUSTOM_START + 6;
+ public static final int SCENE_MODE_SHARPSHOOTER_INT = SCENE_MODE_CUSTOM_START + 7;
+ public static final int SCENE_MODE_TRACKINGFOCUS_INT = SCENE_MODE_CUSTOM_START + 8;
+ public static final int SCENE_MODE_PROMODE_INT = SCENE_MODE_CUSTOM_START + 9;
public static final String SCENE_MODE_DUAL_STRING = "100";
public static final String KEY_CAMERA_SAVEPATH = "pref_camera2_savepath_key";
public static final String KEY_RECORD_LOCATION = "pref_camera2_recordlocation_key";
@@ -134,6 +136,7 @@ public class SettingsManager implements ListMenu.SettingsListener {
public static final String KEY_SHUTTER_SOUND = "pref_camera2_shutter_sound_key";
public static final String KEY_DEVELOPER_MENU = "pref_camera2_developer_menu_key";
public static final String KEY_RESTORE_DEFAULT = "pref_camera2_restore_default_key";
+ public static final String KEY_FOCUS_DISTANCE = "pref_camera2_focus_distance_key";
private static final String TAG = "SnapCam_SettingsManager";
private static SettingsManager sInstance;
@@ -419,12 +422,20 @@ public class SettingsManager implements ListMenu.SettingsListener {
mListeners.add(listener);
}
+ public void unregisterListener(Listener listener) {
+ mListeners.remove(listener);
+ }
+
private void notifyListeners(List<SettingState> changes) {
for (Listener listener : mListeners) {
listener.onSettingsChanged(changes);
}
}
+ public int getCurrentCameraId() {
+ return mCameraId;
+ }
+
public String getValue(String key) {
Values values = mValuesMap.get(key);
if (values == null) return null;
@@ -467,6 +478,14 @@ public class SettingsManager implements ListMenu.SettingsListener {
}
}
+ public void setFocusDistance(float value) {
+ List<SettingState> list = new ArrayList<>();
+ Values values = new Values("" + value, null);
+ SettingState ss = new SettingState(KEY_FOCUS_DISTANCE, values);
+ list.add(ss);
+ notifyListeners(list);
+ }
+
private void updateMapAndNotify(ListPreference pref) {
String key = pref.getKey();
List changed = checkDependencyAndUpdate(key);
@@ -996,6 +1015,11 @@ public class SettingsManager implements ListMenu.SettingsListener {
return modes;
}
+ public float getMinimumFocusDistance(int cameraId) {
+ return mCharacteristics.get(cameraId)
+ .get(CameraCharacteristics.LENS_INFO_MINIMUM_FOCUS_DISTANCE);
+ }
+
private List<String> getSupportedWhiteBalanceModes(int cameraId) {
int[] whiteBalanceModes = mCharacteristics.get(cameraId).get(CameraCharacteristics
.CONTROL_AWB_AVAILABLE_MODES);
@@ -1020,6 +1044,7 @@ public class SettingsManager implements ListMenu.SettingsListener {
if (BlurbusterFilter.isSupportedStatic()) modes.add(SCENE_MODE_BLURBUSTER_INT + "");
if (SharpshooterFilter.isSupportedStatic()) modes.add(SCENE_MODE_SHARPSHOOTER_INT + "");
if (TrackingFocusFrameListener.isSupportedStatic()) modes.add(SCENE_MODE_TRACKINGFOCUS_INT + "");
+ modes.add("" + SCENE_MODE_PROMODE_INT);
for (int mode : sceneModes) {
modes.add("" + mode);
}
diff --git a/src/com/android/camera/VideoModule.java b/src/com/android/camera/VideoModule.java
index 21ad36fcf..e420addcb 100644
--- a/src/com/android/camera/VideoModule.java
+++ b/src/com/android/camera/VideoModule.java
@@ -1158,7 +1158,8 @@ public class VideoModule implements CameraModule,
mOrientationManager.resume();
// Initialize location service.
- boolean recordLocation = RecordLocationPreference.get(mPreferences);
+ boolean recordLocation = RecordLocationPreference.get(mPreferences,
+ CameraSettings.KEY_RECORD_LOCATION);
mLocationManager.recordLocation(recordLocation);
if (mPreviewing) {
@@ -2798,7 +2799,8 @@ public class VideoModule implements CameraModule,
// startPreview().
if (mCameraDevice == null) return;
- boolean recordLocation = RecordLocationPreference.get(mPreferences);
+ boolean recordLocation = RecordLocationPreference.get(mPreferences,
+ CameraSettings.KEY_RECORD_LOCATION);
mLocationManager.recordLocation(recordLocation);
readVideoPreferences();
diff --git a/src/com/android/camera/VideoUI.java b/src/com/android/camera/VideoUI.java
index c68d895ea..e853783a6 100644
--- a/src/com/android/camera/VideoUI.java
+++ b/src/com/android/camera/VideoUI.java
@@ -721,7 +721,7 @@ public class VideoUI implements PieRenderer.PieListener,
public void updateOnScreenIndicators(Parameters param, ComboPreferences prefs) {
mOnScreenIndicators.updateFlashOnScreenIndicator(param.getFlashMode());
- boolean location = RecordLocationPreference.get(prefs);
+ boolean location = RecordLocationPreference.get(prefs, CameraSettings.KEY_RECORD_LOCATION);
mOnScreenIndicators.updateLocationIndicator(location);
}
diff --git a/src/com/android/camera/WideAnglePanoramaModule.java b/src/com/android/camera/WideAnglePanoramaModule.java
index 7a3b114d1..2d4ec1419 100644
--- a/src/com/android/camera/WideAnglePanoramaModule.java
+++ b/src/com/android/camera/WideAnglePanoramaModule.java
@@ -1046,7 +1046,8 @@ public class WideAnglePanoramaModule
mOrientationManager.resume();
// Initialize location service.
- boolean recordLocation = RecordLocationPreference.get(mPreferences);
+ boolean recordLocation = RecordLocationPreference.get(mPreferences,
+ CameraSettings.KEY_RECORD_LOCATION);
mLocationManager.recordLocation(recordLocation);
mUI.initDisplayChangeListener();
UsageStatistics.onContentViewChanged(
diff --git a/src/com/android/camera/imageprocessor/FrameProcessor.java b/src/com/android/camera/imageprocessor/FrameProcessor.java
index a2ae18c1c..5dc50c4e5 100644..100755
--- a/src/com/android/camera/imageprocessor/FrameProcessor.java
+++ b/src/com/android/camera/imageprocessor/FrameProcessor.java
@@ -40,6 +40,7 @@ import android.renderscript.Allocation;
import android.renderscript.Element;
import android.renderscript.RenderScript;
import android.renderscript.Type;
+import android.util.Log;
import android.util.Size;
import android.view.Surface;
import android.widget.Toast;
@@ -155,10 +156,12 @@ public class FrameProcessor {
mRsRotator.set_width(width);
mRsRotator.set_height(height);
mRsRotator.set_pad(stridePad);
- if(mModule.getMainCameraCharacteristics() != null &&
- mModule.getMainCameraCharacteristics().get(CameraCharacteristics.SENSOR_ORIENTATION) == 270) {
- mRsRotator.set_gFlip(true);
+ int degree = 90;
+ if(mModule.getMainCameraCharacteristics() != null) {
+ degree = mModule.getMainCameraCharacteristics().
+ get(CameraCharacteristics.SENSOR_ORIENTATION);
}
+ mRsRotator.set_degree(degree);
mRsYuvToRGB.set_gIn(mProcessAllocation);
mRsYuvToRGB.set_width(height);
mRsYuvToRGB.set_height(width);
diff --git a/src/com/android/camera/ui/CameraControls.java b/src/com/android/camera/ui/CameraControls.java
index 9039a9dce..b85d7f1ca 100644
--- a/src/com/android/camera/ui/CameraControls.java
+++ b/src/com/android/camera/ui/CameraControls.java
@@ -247,7 +247,6 @@ public class CameraControls extends RotatableLayout {
} else {
mHdrSwitcher.setEnabled(enable);
}
- mSceneModeSwitcher.setEnabled(enable);
mPreview.setEnabled(enable);
}
diff --git a/src/com/android/camera/ui/CountDownView.java b/src/com/android/camera/ui/CountDownView.java
index 6420fd2c3..7e1f28d52 100644..100755
--- a/src/com/android/camera/ui/CountDownView.java
+++ b/src/com/android/camera/ui/CountDownView.java
@@ -153,16 +153,21 @@ public class CountDownView extends FrameLayout {
public void setOrientation(int orientation) {
mRemainingSecondsView.setRotation(-orientation);
-
mCountDownTitle.setRotation(-orientation);
+ int width = getResources().getDisplayMetrics().widthPixels;
+ int height = mCountDownTitle.getMeasuredHeight();
+ if (height == 0) {
+ measure(MeasureSpec.UNSPECIFIED,MeasureSpec.UNSPECIFIED);
+ height = mCountDownTitle.getMeasuredHeight();
+ }
int dx = 0, dy = 0;
switch (orientation) {
case 90:
- dy = (mCountDownTitle.getWidth() - mCountDownTitle.getHeight()) / 2;
+ dy = (width - height) / 2;
dx = -dy;
break;
case 270:
- dx = dy = (mCountDownTitle.getWidth() - mCountDownTitle.getHeight()) / 2;
+ dx = dy = (width - height) / 2;
break;
case 180:
break;
diff --git a/src/com/android/camera/ui/OneUICameraControls.java b/src/com/android/camera/ui/OneUICameraControls.java
index 63e1b5b4d..413221211 100644
--- a/src/com/android/camera/ui/OneUICameraControls.java
+++ b/src/com/android/camera/ui/OneUICameraControls.java
@@ -27,15 +27,16 @@ import android.util.AttributeSet;
import android.util.TypedValue;
import android.view.View;
import android.view.ViewGroup;
+import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.SeekBar;
import android.widget.TextView;
-import org.codeaurora.snapcam.R;
-
import com.android.camera.Storage;
import com.android.camera.imageprocessor.filter.BeautificationFilter;
+import org.codeaurora.snapcam.R;
+
public class OneUICameraControls extends RotatableLayout {
private static final String TAG = "CAM_Controls";
@@ -53,6 +54,8 @@ public class OneUICameraControls extends RotatableLayout {
private View mMakeupSeekBarLowText;
private View mMakeupSeekBarHighText;
private View mMakeupSeekBarLayout;
+ private ViewGroup mProModeLayout;
+ private View mProModeCloseButton;
private ArrowTextView mRefocusToast;
@@ -76,9 +79,27 @@ public class OneUICameraControls extends RotatableLayout {
private int mHeight;
private boolean mVisible;
+ private ProMode mProMode;
+ private ImageView mExposureIcon;
+ private ImageView mManualIcon;
+ private ImageView mWhiteBalanceIcon;
+ private ImageView mIsoIcon;
+ private TextView mExposureText;
+ private TextView mManualText;
+ private TextView mWhiteBalanceText;
+ private TextView mIsoText;
+ private boolean mProModeOn = false;
+ private LinearLayout mExposureLayout;
+ private LinearLayout mManualLayout;
+ private LinearLayout mWhiteBalanceLayout;
+ private LinearLayout mIsoLayout;
+ private RotateLayout mExposureRotateLayout;
+ private RotateLayout mManualRotateLayout;
+ private RotateLayout mWhiteBalanceRotateLayout;
+ private RotateLayout mIsoRotateLayout;
+
public OneUICameraControls(Context context, AttributeSet attrs) {
super(context, attrs);
-
mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
setWillNotDraw(false);
@@ -117,6 +138,83 @@ public class OneUICameraControls extends RotatableLayout {
mFilterModeSwitcher = findViewById(R.id.filter_mode_switcher);
mRemainingPhotos = (LinearLayout) findViewById(R.id.remaining_photos);
mRemainingPhotosText = (TextView) findViewById(R.id.remaining_photos_text);
+ mProModeLayout = (ViewGroup) findViewById(R.id.pro_mode_layout);
+ mProModeCloseButton = findViewById(R.id.promode_close_button);
+
+ mExposureIcon = (ImageView) findViewById(R.id.exposure);
+ mManualIcon = (ImageView) findViewById(R.id.manual);
+ mWhiteBalanceIcon = (ImageView) findViewById(R.id.white_balance);
+ mIsoIcon = (ImageView) findViewById(R.id.iso);
+ mExposureText = (TextView) findViewById(R.id.exposure_value);
+ mManualText = (TextView) findViewById(R.id.manual_value);
+ mWhiteBalanceText = (TextView) findViewById(R.id.white_balance_value);
+ mIsoText = (TextView) findViewById(R.id.iso_value);
+ mProMode = (ProMode) findViewById(R.id.promode_slider);
+ mProMode.initialize(this);
+
+ mExposureLayout = (LinearLayout) findViewById(R.id.exposure_layout);
+ mManualLayout = (LinearLayout) findViewById(R.id.manual_layout);
+ mWhiteBalanceLayout = (LinearLayout) findViewById(R.id.white_balance_layout);
+ mIsoLayout = (LinearLayout) findViewById(R.id.iso_layout);
+
+ mExposureRotateLayout = (RotateLayout) findViewById(R.id.exposure_rotate_layout);
+ mManualRotateLayout = (RotateLayout) findViewById(R.id.manual_rotate_layout);
+ mWhiteBalanceRotateLayout = (RotateLayout) findViewById(R.id.white_balance_rotate_layout);
+ mIsoRotateLayout = (RotateLayout) findViewById(R.id.iso_rotate_layout);
+
+ mExposureLayout.setOnClickListener(new OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ resetProModeIcons();
+ int mode = mProMode.getMode();
+ if (mode == ProMode.EXPOSURE_MODE) {
+ mProMode.setMode(ProMode.NO_MODE);
+ } else {
+ mExposureIcon.setImageResource(R.drawable.icon_exposure_blue);
+ mProMode.setMode(ProMode.EXPOSURE_MODE);
+ }
+ }
+ });
+ mManualLayout.setOnClickListener(new OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ resetProModeIcons();
+ int mode = mProMode.getMode();
+ if (mode == ProMode.MANUAL_MODE) {
+ mProMode.setMode(ProMode.NO_MODE);
+ } else {
+ mManualIcon.setImageResource(R.drawable.icon_manual_blue);
+ mProMode.setMode(ProMode.MANUAL_MODE);
+ }
+ }
+ });
+ mWhiteBalanceLayout.setOnClickListener(new OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ resetProModeIcons();
+ int mode = mProMode.getMode();
+ if (mode == ProMode.WHITE_BALANCE_MODE) {
+ mProMode.setMode(ProMode.NO_MODE);
+ } else {
+ mWhiteBalanceIcon.setImageResource(R.drawable.icon_white_balance_blue);
+ mProMode.setMode(ProMode.WHITE_BALANCE_MODE);
+ }
+ }
+ });
+ mIsoLayout.setOnClickListener(new OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ resetProModeIcons();
+ int mode = mProMode.getMode();
+ if (mode == ProMode.ISO_MODE) {
+ mProMode.setMode(ProMode.NO_MODE);
+ } else {
+ mIsoIcon.setImageResource(R.drawable.icon_iso_blue);
+ mProMode.setMode(ProMode.ISO_MODE);
+ }
+ }
+ });
+
mViews = new View[]{
mSceneModeSwitcher, mFilterModeSwitcher, mFrontBackSwitcher,
mTsMakeupSwitcher, mFlashButton, mShutter, mPreview, mVideoShutter
@@ -142,6 +240,14 @@ public class OneUICameraControls extends RotatableLayout {
if(mMakeupSeekBar != null) {
mMakeupSeekBar.setMinimumWidth(mWidth/2);
}
+
+ LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(mWidth/ 4,mWidth/4);
+ mExposureLayout.setLayoutParams(lp);
+
+ mManualLayout.setLayoutParams(lp);
+ mWhiteBalanceLayout.setLayoutParams(lp);
+ mIsoLayout.setLayoutParams(lp);
+ initializeProMode(mProModeOn);
}
public boolean isControlRegion(int x, int y) {
@@ -212,6 +318,7 @@ public class OneUICameraControls extends RotatableLayout {
setLocation(mShutter, false, 2);
setLocation(mVideoShutter, false, 3.15f);
setLocationCustomBottom(mMakeupSeekBarLayout, 0, 1);
+ setLocation(mProModeCloseButton, false, 4);
layoutToast(mRefocusToast, w, h, rotation);
}
@@ -332,6 +439,11 @@ public class OneUICameraControls extends RotatableLayout {
((Rotatable) v).setOrientation(orientation, animation);
}
}
+ mExposureRotateLayout.setOrientation(orientation, animation);
+ mManualRotateLayout.setOrientation(orientation, animation);
+ mWhiteBalanceRotateLayout.setOrientation(orientation, animation);
+ mIsoRotateLayout.setOrientation(orientation, animation);
+ mProMode.setOrientation(orientation);
layoutRemaingPhotos();
}
@@ -377,4 +489,46 @@ public class OneUICameraControls extends RotatableLayout {
mPath.lineTo(x1, y1);
}
}
+
+ public void setProMode(boolean promode) {
+ mProModeOn = promode;
+ initializeProMode(mProModeOn);
+ resetProModeIcons();
+ }
+
+ private void resetProModeIcons() {
+ mExposureIcon.setImageResource(R.drawable.icon_exposure);
+ mManualIcon.setImageResource(R.drawable.icon_manual);
+ mWhiteBalanceIcon.setImageResource(R.drawable.icon_white_balance);
+ mIsoIcon.setImageResource(R.drawable.icon_iso);
+ }
+
+ public void initializeProMode(boolean promode) {
+ if (!promode) {
+ mProMode.setMode(ProMode.NO_MODE);
+ mProModeLayout.setVisibility(INVISIBLE);
+ mProModeCloseButton.setVisibility(INVISIBLE);
+ return;
+ }
+ mProModeLayout.setVisibility(VISIBLE);
+ mProModeCloseButton.setVisibility(VISIBLE);
+ mProModeLayout.setY(mHeight - mBottom - mProModeLayout.getHeight());
+ }
+
+ public void updateProModeText(int mode, String value) {
+ switch (mode) {
+ case ProMode.EXPOSURE_MODE:
+ mExposureText.setText(value);
+ break;
+ case ProMode.MANUAL_MODE:
+ mManualText.setText(value);
+ break;
+ case ProMode.WHITE_BALANCE_MODE:
+ mWhiteBalanceText.setText(value);
+ break;
+ case ProMode.ISO_MODE:
+ mIsoText.setText(value);
+ break;
+ }
+ }
}
diff --git a/src/com/android/camera/ui/ProMode.java b/src/com/android/camera/ui/ProMode.java
new file mode 100644
index 000000000..dbd89ec58
--- /dev/null
+++ b/src/com/android/camera/ui/ProMode.java
@@ -0,0 +1,374 @@
+/*
+ * Copyright (c) 2016, The Linux Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * * Neither the name of The Linux Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package com.android.camera.ui;
+
+import android.content.Context;
+import android.graphics.Canvas;
+import android.graphics.Color;
+import android.graphics.Paint;
+import android.graphics.Path;
+import android.graphics.PathMeasure;
+import android.graphics.Point;
+import android.util.AttributeSet;
+import android.view.MotionEvent;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ImageView;
+import android.widget.TextView;
+
+import com.android.camera.SettingsManager;
+
+import org.codeaurora.snapcam.R;
+
+import java.util.ArrayList;
+
+public class ProMode extends View {
+ public static final int NO_MODE = -1;
+ public static final int EXPOSURE_MODE = 0;
+ public static final int MANUAL_MODE = 1;
+ public static final int WHITE_BALANCE_MODE = 2;
+ public static final int ISO_MODE = 3;
+ private static final int DRAG_Y_THRESHOLD = 100;
+ private static final int DRAG_X_THRESHOLD = 30;
+ private static final int BLUE = 0xff4693fb;
+ private static final int SELECTED_DOT_SIZE = 20;
+ private static final int DOT_SIZE = 10;
+ private static final int[] wbIcons = {R.drawable.auto, R.drawable.incandecent,
+ R.drawable.fluorescent, R.drawable.sunlight, R.drawable.cloudy};
+ private static final int[] wbIconsBlue = {R.drawable.auto_blue, R.drawable.incandecent_blue,
+ R.drawable.fluorescent_blue, R.drawable.sunlight_blue, R.drawable.cloudy_blue};
+ private static final int WB_ICON_SIZE = 80;
+ private PathMeasure mCurveMeasure;
+ private int mCurveLeft;
+ private int mCurveRight;
+ private float mSlider = -1;
+ private Paint mPaint = new Paint();
+ private int mNums;
+ private int mIndex;
+ private Point[] mPoints;
+ private float mClickThreshold;
+ private int mStride;
+ private SettingsManager mSettingsManager;
+ private int mMode = NO_MODE;
+ private Context mContext;
+ private ViewGroup mParent;
+ private float minFocus;
+ private OneUICameraControls mUI;
+ private int mWidth;
+ private int mHeight;
+ private int mCurveY;
+ private ArrayList<View> mAddedViews;
+ private float curveCoordinate[] = new float[2];
+ private Path mCurvePath = new Path();
+ private int mCurveHeight;
+ private int mOrientation;
+
+ public ProMode(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ mContext = context;
+ mPaint.setStrokeWidth(7f);
+ mSettingsManager = SettingsManager.getInstance();
+ }
+
+ private void init() {
+ init(EXPOSURE_MODE);
+ init(WHITE_BALANCE_MODE);
+ init(ISO_MODE);
+ mUI.updateProModeText(MANUAL_MODE, "Manual");
+ }
+
+ private void init(int mode) {
+ String key = getKey(mode);
+ if (key == null) return;
+ int index = mSettingsManager.getValueIndex(key);
+ CharSequence[] cc = mSettingsManager.getEntries(key);
+ mUI.updateProModeText(mode, cc[index].toString());
+ }
+
+ @Override
+ protected void onDraw(Canvas canvas) {
+ super.onDraw(canvas);
+
+ if (mMode != NO_MODE) {
+ mPaint.setColor(Color.WHITE);
+ mPaint.setStyle(Paint.Style.STROKE);
+ canvas.drawPath(mCurvePath, mPaint);
+ }
+ mPaint.setStyle(Paint.Style.FILL);
+ if (mMode == MANUAL_MODE) {
+ mPaint.setColor(Color.WHITE);
+ canvas.drawCircle(mCurveLeft, mCurveY, DOT_SIZE, mPaint);
+ canvas.drawCircle(mCurveRight, mCurveY, DOT_SIZE, mPaint);
+ mPaint.setColor(BLUE);
+ if (mSlider >= 0f) {
+ mCurveMeasure.getPosTan(mCurveMeasure.getLength() * mSlider, curveCoordinate, null);
+ canvas.drawCircle(curveCoordinate[0], curveCoordinate[1], SELECTED_DOT_SIZE,
+ mPaint);
+ }
+ } else {
+ for (int i = 0; i < mNums; i++) {
+ if (i == mIndex) {
+ mPaint.setColor(BLUE);
+ canvas.drawCircle(mPoints[i].x, mPoints[i].y, SELECTED_DOT_SIZE, mPaint);
+ } else {
+ mPaint.setColor(Color.WHITE);
+ canvas.drawCircle(mPoints[i].x, mPoints[i].y, DOT_SIZE, mPaint);
+ }
+ }
+ }
+ }
+
+ public void initialize(OneUICameraControls ui) {
+ mParent = (ViewGroup) getParent();
+ mUI = ui;
+ init();
+ }
+
+ @Override
+ protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
+ super.onLayout(changed, left, top, right, bottom);
+ mWidth = right - left;
+ mHeight = bottom - top;
+
+ mCurveLeft = mWidth / 10;
+ mCurveRight = mWidth - mCurveLeft;
+ mCurveHeight = mWidth / 7;
+ mCurveY = (int) (mHeight * 0.67);
+
+ float cx = (mCurveLeft + mCurveRight) / 2;
+ mCurvePath.reset();
+ mCurvePath.moveTo(mCurveLeft, mCurveY);
+ mCurvePath.quadTo(cx, mCurveY - mCurveHeight, mCurveRight, mCurveY);
+ mCurveMeasure = new PathMeasure(mCurvePath, false);
+ }
+
+ public void setOrientation(int orientation) {
+ mOrientation = orientation;
+ if (mAddedViews != null) {
+ int rotation = mOrientation;
+ if (rotation == 90 || rotation == 270) rotation += 180;
+ rotation %= 360;
+ for (View v : mAddedViews) {
+ v.setRotation(rotation);
+ }
+ }
+ }
+
+ public int getMode() {
+ return mMode;
+ }
+
+ public void setMode(int mode) {
+ mMode = mode;
+ removeViews();
+ if (mMode == NO_MODE) {
+ setVisibility(INVISIBLE);
+ return;
+ } else {
+ setVisibility(VISIBLE);
+ }
+ mIndex = -1;
+ String key = currentKey();
+ if (mMode == MANUAL_MODE) {
+ minFocus = mSettingsManager
+ .getMinimumFocusDistance(mSettingsManager.getCurrentCameraId());
+ float value = 0.5f;
+ setSlider(value);
+ int stride = mCurveRight - mCurveLeft;
+ for (int i = 0; i < 2; i++) {
+ TextView v = new TextView(mContext);
+ String s = "infinity";
+ if (i == 1) s = "macro";
+ v.setText(s);
+ v.setTextColor(Color.WHITE);
+ v.measure(0, 0);
+ ViewGroup.LayoutParams lp = new ViewGroup.LayoutParams(v.getMeasuredWidth(),
+ v.getMeasuredHeight());
+ v.setLayoutParams(lp);
+ v.setX(mCurveLeft + i * stride - v.getMeasuredWidth() / 2);
+ v.setY(mCurveY - 2 * v.getMeasuredHeight());
+ mParent.addView(v);
+ mAddedViews.add(v);
+ }
+ } else {
+ if (key == null) return;
+ CharSequence[] cc = mSettingsManager.getEntries(key);
+ int length = mSettingsManager.getEntryValues(key).length;
+ int index = mSettingsManager.getValueIndex(key);
+ updateSlider(length);
+
+ for (int i = 0; i < length; i++) {
+ View v;
+ if (mMode == WHITE_BALANCE_MODE) {
+ v = new ImageView(mContext);
+ ((ImageView) v).setImageResource(wbIcons[i]);
+ ViewGroup.LayoutParams lp = new ViewGroup.LayoutParams(
+ WB_ICON_SIZE, WB_ICON_SIZE);
+ v.setLayoutParams(lp);
+ v.setX(mPoints[i].x - WB_ICON_SIZE / 2);
+ v.setY(mPoints[i].y - 2 * WB_ICON_SIZE);
+ } else {
+ v = new TextView(mContext);
+ ((TextView) v).setText(cc[i]);
+ ((TextView) v).setTextColor(Color.WHITE);
+ v.measure(0, 0);
+ ViewGroup.LayoutParams lp = new ViewGroup.LayoutParams(v.getMeasuredWidth(),
+ v.getMeasuredHeight());
+ v.setLayoutParams(lp);
+ v.setX(mPoints[i].x - v.getMeasuredWidth() / 2);
+ v.setY(mPoints[i].y - 2 * v.getMeasuredHeight());
+ }
+
+
+ mParent.addView(v);
+ mAddedViews.add(v);
+ }
+ setIndex(index, true);
+ }
+ setOrientation(mOrientation);
+ }
+
+ private String getKey(int mode) {
+ switch (mode) {
+ case EXPOSURE_MODE:
+ return SettingsManager.KEY_EXPOSURE;
+ case WHITE_BALANCE_MODE:
+ return SettingsManager.KEY_WHITE_BALANCE;
+ case ISO_MODE:
+ return SettingsManager.KEY_ISO;
+ }
+ return null;
+ }
+
+ private String currentKey() {
+ return getKey(mMode);
+ }
+
+ private void updateSlider(int n) {
+ mNums = n;
+ mStride = (mCurveRight - mCurveLeft) / (mNums - 1);
+ mClickThreshold = mStride * 0.45f;
+ mPoints = new Point[mNums];
+
+ float slide = 1f / (mNums - 1);
+ for (int i = 0; i < mNums; i++) {
+ mCurveMeasure.getPosTan(mCurveMeasure.getLength() * (slide * i), curveCoordinate, null);
+ mPoints[i] = new Point((int) curveCoordinate[0], (int) curveCoordinate[1]);
+ }
+
+ invalidate();
+ }
+
+ public void setSlider(float slider) {
+ mSlider = slider;
+ mSettingsManager.setFocusDistance(mSlider * minFocus);
+ mUI.updateProModeText(mMode, "Manual");
+ invalidate();
+ }
+
+ private void setIndex(int index, boolean force) {
+ if (mIndex == index && !force) return;
+ if (mIndex != -1) {
+ View v = mAddedViews.get(mIndex);
+ if (v instanceof TextView) {
+ ((TextView) v).setTextColor(Color.WHITE);
+ } else if (v instanceof ImageView) {
+ if (mMode == WHITE_BALANCE_MODE) {
+ ((ImageView) v).setImageResource(wbIcons[mIndex]);
+ }
+ }
+ }
+
+ mIndex = index;
+ String key = currentKey();
+ View v = mAddedViews.get(mIndex);
+ if (v instanceof TextView) {
+ ((TextView) v).setTextColor(BLUE);
+ } else if (v instanceof ImageView) {
+ if (mMode == WHITE_BALANCE_MODE) {
+ ((ImageView) v).setImageResource(wbIconsBlue[mIndex]);
+ }
+ }
+ if (key != null) mSettingsManager.setValueIndex(key, mIndex);
+ CharSequence[] cc = mSettingsManager.getEntries(key);
+ mUI.updateProModeText(mMode, cc[mIndex].toString());
+ invalidate();
+ }
+
+ private void removeViews() {
+ ViewGroup vg = (ViewGroup) getParent();
+ if (mAddedViews != null) {
+ for (int i = 0; i < mAddedViews.size(); i++) {
+ vg.removeView(mAddedViews.get(i));
+ }
+ }
+ mAddedViews = new ArrayList<View>();
+ }
+
+ @Override
+ public boolean onTouchEvent(MotionEvent event) {
+ if (mMode == MANUAL_MODE) {
+ float slider = getSlider(event.getX(), event.getY());
+ if (slider >= 0) {
+ setSlider(slider);
+ }
+ } else {
+ int idx = findButton(event.getX(), event.getY());
+ if (idx != -1) {
+ setIndex(idx, false);
+ }
+ return true;
+ }
+ return true;
+ }
+
+ private int findButton(float x, float y) {
+ for (int i = 0; i < mNums; i++) {
+ float xdiff = Math.abs(mPoints[i].x - x);
+ float ydiff = Math.abs(mPoints[i].y - y);
+ float dist = xdiff * xdiff + ydiff * ydiff;
+ if (dist < mClickThreshold * mClickThreshold) return i;
+ }
+ return -1;
+ }
+
+ private float getSlider(float x, float y) {
+ if (x > mCurveLeft - DRAG_X_THRESHOLD && x < mCurveRight + DRAG_X_THRESHOLD
+ && y > mCurveY - mCurveHeight - DRAG_Y_THRESHOLD
+ && y < mCurveY + DRAG_Y_THRESHOLD) {
+ if (x < mCurveLeft) x = mCurveLeft;
+ if (x > mCurveRight) x = mCurveRight;
+ return (x - mCurveLeft) / (mCurveRight - mCurveLeft);
+ } else {
+ return -1;
+ }
+ }
+
+}
diff --git a/src/org/codeaurora/snapcam/filter/ClearSightImageProcessor.java b/src/org/codeaurora/snapcam/filter/ClearSightImageProcessor.java
index 595df8122..bd54dc76a 100644..100755
--- a/src/org/codeaurora/snapcam/filter/ClearSightImageProcessor.java
+++ b/src/org/codeaurora/snapcam/filter/ClearSightImageProcessor.java
@@ -52,6 +52,7 @@ import android.hardware.camera2.CameraDevice;
import android.hardware.camera2.CameraManager;
import android.hardware.camera2.CaptureFailure;
import android.hardware.camera2.CaptureRequest;
+import android.hardware.camera2.CaptureResult;
import android.hardware.camera2.TotalCaptureResult;
import android.hardware.camera2.params.InputConfiguration;
import android.hardware.camera2.params.StreamConfigurationMap;
@@ -623,18 +624,26 @@ public class ClearSightImageProcessor {
ReprocessableImage bayer = mBayerFrames.peek();
ReprocessableImage mono = mMonoFrames.peek();
+ long bayerTsSOF = bayer.mCaptureResult.get(CaptureResult.SENSOR_TIMESTAMP);
+ long bayerTsEOF = bayerTsSOF + bayer.mCaptureResult.get(
+ CaptureResult.SENSOR_EXPOSURE_TIME);
+ long monoTsSOF = mono.mCaptureResult.get(CaptureResult.SENSOR_TIMESTAMP);
+ long monoTsEOF = monoTsSOF + mono.mCaptureResult.get(
+ CaptureResult.SENSOR_EXPOSURE_TIME);
+
+
Log.d(TAG,
- "checkForValidFramePair - bayer ts: "
- + bayer.mImage.getTimestamp() + " mono ts: "
- + mono.mImage.getTimestamp());
+ "checkForValidFramePair - bayer ts SOF: "
+ + bayerTsSOF + ", EOF: " + bayerTsEOF
+ + ", mono ts SOF: " + monoTsSOF + ", EOF: " + monoTsEOF);
Log.d(TAG,
- "checkForValidFramePair - difference: "
- + Math.abs(bayer.mImage.getTimestamp()
- - mono.mImage.getTimestamp()));
+ "checkForValidFramePair - difference SOF: "
+ + Math.abs(bayerTsSOF - monoTsSOF)
+ + ", EOF: " + Math.abs(bayerTsEOF - monoTsEOF));
// if timestamps are within threshold, keep frames
- if (Math.abs(bayer.mImage.getTimestamp()
- - mono.mImage.getTimestamp()) > mTimestampThresholdNs) {
- if(bayer.mImage.getTimestamp() > mono.mImage.getTimestamp()) {
+ if ((Math.abs(bayerTsSOF - monoTsSOF) > mTimestampThresholdNs) &&
+ (Math.abs(bayerTsEOF - monoTsEOF) > mTimestampThresholdNs)) {
+ if(bayerTsSOF > monoTsSOF) {
Log.d(TAG, "checkForValidFramePair - toss mono");
// no match, toss
mono = mMonoFrames.poll();
@@ -1028,6 +1037,8 @@ public class ClearSightImageProcessor {
}, null);
} catch (CameraAccessException e) {
e.printStackTrace();
+ } catch (IllegalStateException e1) {
+ e1.printStackTrace();
}
}
}