mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-19 08:09:12 +01:00
Preserve user zoom level when starting video recording.
Remove the unconditional zoom reset to 1x at the start of video recording so that any pinch-to-zoom the user applied before recording is maintained.
This commit is contained in:
committed by
Cody Henthorne
parent
177ef8a555
commit
4ed0056d2a
@@ -257,14 +257,20 @@ public class CameraButtonView extends View {
|
||||
startAnimation(shrinkAnimation);
|
||||
}
|
||||
case MotionEvent.ACTION_MOVE:
|
||||
if (isRecordingVideo && eventIsNotInsideDeadzone(event)) {
|
||||
if (isRecordingVideo) {
|
||||
float maxRange = getHeight() * DRAG_DISTANCE_MULTIPLIER;
|
||||
|
||||
float maxRange = getHeight() * DRAG_DISTANCE_MULTIPLIER;
|
||||
float deltaY = Math.abs(event.getY() - deadzoneRect.top);
|
||||
float increment = Math.min(1f, deltaY / maxRange);
|
||||
|
||||
notifyZoomPercent(ZOOM_INTERPOLATOR.getInterpolation(increment));
|
||||
invalidate();
|
||||
if (eventIsAboveDeadzone(event)) {
|
||||
float deltaY = Math.abs(event.getY() - deadzoneRect.top);
|
||||
float increment = Math.min(1f, deltaY / maxRange);
|
||||
notifyZoomPercent(ZOOM_INTERPOLATOR.getInterpolation(increment));
|
||||
invalidate();
|
||||
} else if (eventIsBelowDeadzone(event)) {
|
||||
float deltaY = Math.abs(event.getY() - deadzoneRect.bottom);
|
||||
float increment = Math.min(1f, deltaY / maxRange);
|
||||
notifyZoomPercent(-ZOOM_INTERPOLATOR.getInterpolation(increment));
|
||||
invalidate();
|
||||
}
|
||||
}
|
||||
break;
|
||||
case MotionEvent.ACTION_CANCEL:
|
||||
@@ -279,10 +285,14 @@ public class CameraButtonView extends View {
|
||||
return super.onTouchEvent(event);
|
||||
}
|
||||
|
||||
private boolean eventIsNotInsideDeadzone(MotionEvent event) {
|
||||
private boolean eventIsAboveDeadzone(MotionEvent event) {
|
||||
return Math.round(event.getY()) < deadzoneRect.top;
|
||||
}
|
||||
|
||||
private boolean eventIsBelowDeadzone(MotionEvent event) {
|
||||
return Math.round(event.getY()) > deadzoneRect.bottom;
|
||||
}
|
||||
|
||||
private void notifyVideoCaptureStarted() {
|
||||
if (!isRecordingVideo && videoCaptureListener != null) {
|
||||
videoCaptureListener.onVideoCaptureStarted();
|
||||
|
||||
@@ -238,8 +238,15 @@ class CameraXVideoCaptureHelper implements CameraButtonView.VideoCaptureListener
|
||||
@Override
|
||||
public void onZoomIncremented(float increment) {
|
||||
ZoomState zoomState = Objects.requireNonNull(cameraController.getZoomState().getValue());
|
||||
float range = zoomState.getMaxZoomRatio() - getDefaultVideoZoomRatio();
|
||||
cameraController.setZoomRatio((range * increment) + getDefaultVideoZoomRatio());
|
||||
float base = getDefaultVideoZoomRatio();
|
||||
|
||||
if (increment >= 0f) {
|
||||
float range = zoomState.getMaxZoomRatio() - base;
|
||||
cameraController.setZoomRatio(base + range * increment);
|
||||
} else {
|
||||
float range = base - zoomState.getMinZoomRatio();
|
||||
cameraController.setZoomRatio(base + range * increment);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user