diff --git a/Signal/Signal-Info.plist b/Signal/Signal-Info.plist index bbc073f5d..4fe947497 100644 --- a/Signal/Signal-Info.plist +++ b/Signal/Signal-Info.plist @@ -6,10 +6,14 @@ CarthageVersion 0.31.2 + DateTime + Wed Feb 13 22:13:11 UTC 2019 OSXVersion 10.14.3 WebRTCCommit 55de5593cc261fa9368c5ccde98884ed1e278ba0 M72 + XCodeVersion + 1000.1010 CFBundleDevelopmentRegion en diff --git a/Signal/test/views/ImageEditor/ImageEditorModelTest.swift b/Signal/test/views/ImageEditor/ImageEditorModelTest.swift index 29cb2ab39..1d7f62f72 100644 --- a/Signal/test/views/ImageEditor/ImageEditorModelTest.swift +++ b/Signal/test/views/ImageEditor/ImageEditorModelTest.swift @@ -49,23 +49,34 @@ class ImageEditorModelTest: SignalBaseTest { } func testAffineTransformComposition() { + // Documents how classic SRT (scale-rotate-translate) ordering is specified + // in _reverse_ order using CGAffineTransform. + + // The transformed origin should reflect ONLY the translation, not scaling or rotation. XCTAssertEqual(+20.0, CGPoint.zero.applying(CGAffineTransform.translate(CGPoint(x: 20, y: 30)).scale(5)).x, accuracy: 0.1) XCTAssertEqual(+30.0, CGPoint.zero.applying(CGAffineTransform.translate(CGPoint(x: 20, y: 30)).scale(5)).y, accuracy: 0.1) + // WRONG: the translation is being scaled. XCTAssertEqual(+100.0, CGPoint.zero.applying(CGAffineTransform.scale(5).translate(CGPoint(x: 20, y: 30))).x, accuracy: 0.1) XCTAssertEqual(+150.0, CGPoint.zero.applying(CGAffineTransform.scale(5).translate(CGPoint(x: 20, y: 30))).y, accuracy: 0.1) + // The transformed origin should reflect ONLY the translation, not scaling or rotation. XCTAssertEqual(+20.0, CGPoint.zero.applying(CGAffineTransform.translate(CGPoint(x: 20, y: 30)).rotate(CGFloat.halfPi).scale(5)).x, accuracy: 0.1) XCTAssertEqual(+30.0, CGPoint.zero.applying(CGAffineTransform.translate(CGPoint(x: 20, y: 30)).rotate(CGFloat.halfPi).scale(5)).y, accuracy: 0.1) + // WRONG: the translation is being scaled. XCTAssertEqual(-150.0, CGPoint.zero.applying(CGAffineTransform.scale(5).rotate(CGFloat.halfPi).translate(CGPoint(x: 20, y: 30))).x, accuracy: 0.1) XCTAssertEqual(+100.0, CGPoint.zero.applying(CGAffineTransform.scale(5).rotate(CGFloat.halfPi).translate(CGPoint(x: 20, y: 30))).y, accuracy: 0.1) + // An arbitrary point one "unit" away from the origin should be end up scaled (unit x scaling) + translation. XCTAssertEqual(+25.0, CGPoint.unit.applying(CGAffineTransform.translate(CGPoint(x: 20, y: 30)).scale(5)).x, accuracy: 0.1) XCTAssertEqual(+35.0, CGPoint.unit.applying(CGAffineTransform.translate(CGPoint(x: 20, y: 30)).scale(5)).y, accuracy: 0.1) + // WRONG: the translation is being scaled. XCTAssertEqual(+105.0, CGPoint.unit.applying(CGAffineTransform.scale(5).translate(CGPoint(x: 20, y: 30))).x, accuracy: 0.1) XCTAssertEqual(+155.0, CGPoint.unit.applying(CGAffineTransform.scale(5).translate(CGPoint(x: 20, y: 30))).y, accuracy: 0.1) + // An arbitrary point one "unit" away from the origin should be end up scaled (unit x scaling ... rotated about the origin) + translation. XCTAssertEqual(+15.0, CGPoint.unit.applying(CGAffineTransform.translate(CGPoint(x: 20, y: 30)).rotate(CGFloat.halfPi).scale(5)).x, accuracy: 0.1) XCTAssertEqual(+35.0, CGPoint.unit.applying(CGAffineTransform.translate(CGPoint(x: 20, y: 30)).rotate(CGFloat.halfPi).scale(5)).y, accuracy: 0.1) + // WRONG: the translation is being scaled. XCTAssertEqual(-155.0, CGPoint.unit.applying(CGAffineTransform.scale(5).rotate(CGFloat.halfPi).translate(CGPoint(x: 20, y: 30))).x, accuracy: 0.1) XCTAssertEqual(+105.0, CGPoint.unit.applying(CGAffineTransform.scale(5).rotate(CGFloat.halfPi).translate(CGPoint(x: 20, y: 30))).y, accuracy: 0.1) } diff --git a/SignalMessaging/Views/ImageEditor/ImageEditorCanvasView.swift b/SignalMessaging/Views/ImageEditor/ImageEditorCanvasView.swift index c3529bb55..ce696a272 100644 --- a/SignalMessaging/Views/ImageEditor/ImageEditorCanvasView.swift +++ b/SignalMessaging/Views/ImageEditor/ImageEditorCanvasView.swift @@ -143,10 +143,12 @@ public class ImageEditorCanvasView: UIView { let srcImageUrl = URL(fileURLWithPath: srcImagePath) srcImageData = try Data(contentsOf: srcImageUrl) } catch { - Logger.error("Couldn't parse srcImageUrl") + owsFailDebug("Couldn't parse srcImageUrl") return nil } // We use this constructor so that we can specify the scale. + // + // UIImage(contentsOfFile:) will sometimes use device scale. guard let srcImage = UIImage(data: srcImageData, scale: 1.0) else { owsFailDebug("Couldn't load background image.") return nil @@ -605,9 +607,9 @@ public class ImageEditorCanvasView: UIView { for item in model.items() { guard let layer = layerForItem(item: item, - model: model, + model: model, viewSize: viewSize) else { - Logger.error("Couldn't create layer for item.") + owsFailDebug("Couldn't create layer for item.") continue } layer.contentsScale = dstScale * transform.scaling * item.outputScale() diff --git a/SignalMessaging/Views/ImageEditor/ImageEditorCropViewController.swift b/SignalMessaging/Views/ImageEditor/ImageEditorCropViewController.swift index 264505c1f..26653ddca 100644 --- a/SignalMessaging/Views/ImageEditor/ImageEditorCropViewController.swift +++ b/SignalMessaging/Views/ImageEditor/ImageEditorCropViewController.swift @@ -296,18 +296,6 @@ class ImageEditorCropViewController: OWSViewController { return true } - override func viewWillAppear(_ animated: Bool) { - super.viewWillAppear(animated) - - _ = self.becomeFirstResponder() - } - - override func viewDidAppear(_ animated: Bool) { - super.viewDidAppear(animated) - - _ = self.becomeFirstResponder() - } - // MARK: - Pinch Gesture @objc @@ -368,6 +356,7 @@ class ImageEditorCropViewController: OWSViewController { // We could undo an in-progress pinch if the gesture is cancelled, but it seems gratuitous. + // Handle the GR if necessary. switch gestureRecognizer.state { case .began: Logger.verbose("began: \(transform.unitTranslation)") @@ -385,6 +374,7 @@ class ImageEditorCropViewController: OWSViewController { break } + // Reset the GR if necessary. switch gestureRecognizer.state { case .ended, .failed, .cancelled, .possible: if panCropRegion != nil { diff --git a/SignalMessaging/Views/ImageEditor/ImageEditorView.swift b/SignalMessaging/Views/ImageEditor/ImageEditorView.swift index 989ab212e..2bf841fd0 100644 --- a/SignalMessaging/Views/ImageEditor/ImageEditorView.swift +++ b/SignalMessaging/Views/ImageEditor/ImageEditorView.swift @@ -100,10 +100,6 @@ public class ImageEditorView: UIView { updateGestureState() - DispatchQueue.main.async { - self.presentCropTool() - } - return true }