From 76d1b9dad572c3313835fc58455f93f54ac530c0 Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Tue, 2 Jan 2018 15:56:06 -0600 Subject: [PATCH 1/3] proper title case --- Signal/translations/en.lproj/Localizable.strings | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Signal/translations/en.lproj/Localizable.strings b/Signal/translations/en.lproj/Localizable.strings index ec955a8c9..c6d182240 100644 --- a/Signal/translations/en.lproj/Localizable.strings +++ b/Signal/translations/en.lproj/Localizable.strings @@ -713,7 +713,7 @@ "FINGERPRINT_SCAN_VERIFY_BUTTON" = "Mark as Verified"; /* No comment provided by engineer. */ -"FINGERPRINT_SHRED_KEYMATERIAL_BUTTON" = "Reset this session"; +"FINGERPRINT_SHRED_KEYMATERIAL_BUTTON" = "Reset Session"; /* Accessibilty label for finishing new group */ "FINISH_GROUP_CREATION_LABEL" = "Finish creating group"; From 54f7c298b70cd8a725dc2d8f74a95915056773b1 Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Tue, 2 Jan 2018 17:29:38 -0600 Subject: [PATCH 2/3] Only initiate "show details" pan gesture when swiping back // FREEBIE --- .../ConversationView/Cells/OWSMessageCell.m | 2 +- .../DirectionalPanGestureRecognizer.swift | 44 ++++++++++++++++--- 2 files changed, 38 insertions(+), 8 deletions(-) diff --git a/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageCell.m b/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageCell.m index 4bb8f4c12..d06523d3d 100644 --- a/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageCell.m +++ b/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageCell.m @@ -283,7 +283,7 @@ const CGFloat OWSMessageCellCornerRadius = 17; [self.textBubbleImageView addGestureRecognizer:textLongPress]; PanDirectionGestureRecognizer *panGesture = - [[PanDirectionGestureRecognizer alloc] initWithDirection:PanDirectionHorizontal + [[PanDirectionGestureRecognizer alloc] initWithDirection:PanDirectionForward target:self action:@selector(handlePanGesture:)]; [self addGestureRecognizer:panGesture]; diff --git a/Signal/src/views/DirectionalPanGestureRecognizer.swift b/Signal/src/views/DirectionalPanGestureRecognizer.swift index 696a30a87..8e4b3b59d 100644 --- a/Signal/src/views/DirectionalPanGestureRecognizer.swift +++ b/Signal/src/views/DirectionalPanGestureRecognizer.swift @@ -1,13 +1,12 @@ // -// Copyright (c) 2017 Open Whisper Systems. All rights reserved. +// Copyright (c) 2018 Open Whisper Systems. All rights reserved. // import UIKit.UIGestureRecognizerSubclass @objc enum PanDirection: Int { - case vertical - case horizontal + case forward, backward, up, down, any } @objc @@ -17,19 +16,50 @@ class PanDirectionGestureRecognizer: UIPanGestureRecognizer { init(direction: PanDirection, target: AnyObject, action: Selector) { self.direction = direction + super.init(target: target, action: action) } override func touchesMoved(_ touches: Set, with event: UIEvent) { + // Only start gesture if it's initially in the specified direction. + if state == .possible { + guard let touch = touches.first else { + return + } + + let previousLocation = touch.previousLocation(in: view) + let location = touch.location(in: view) + let deltaY = previousLocation.y - location.y + let deltaX = previousLocation.x - location.x + + switch direction { + case .down where deltaY < 0: + return + case .up where deltaY > 0: + return + case .forward where deltaX < 0: + return + case .backward where deltaX > 0: + return + default: + break + } + } + + // Gesture was already started, or in the correct direction. super.touchesMoved(touches, with: event) if state == .began { let vel = velocity(in: view) switch direction { - case .horizontal where fabs(vel.y) > fabs(vel.x): - state = .cancelled - case .vertical where fabs(vel.x) > fabs(vel.y): - state = .cancelled + case .forward, .backward: + if fabs(vel.y) > fabs(vel.x) { + state = .cancelled + } + case .up, .down: + if fabs(vel.x) > fabs(vel.y) { + state = .cancelled + } default: break } From 7734958eecc702768659fde27bd457b67c6f28f5 Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Mon, 8 Jan 2018 11:24:50 -0500 Subject: [PATCH 3/3] Make "swipe for info" RTL compatible // FREEBIE --- .../ConversationView/Cells/OWSMessageCell.m | 2 +- .../src/views/DirectionalPanGestureRecognizer.swift | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageCell.m b/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageCell.m index d06523d3d..f4da0f6c3 100644 --- a/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageCell.m +++ b/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageCell.m @@ -283,7 +283,7 @@ const CGFloat OWSMessageCellCornerRadius = 17; [self.textBubbleImageView addGestureRecognizer:textLongPress]; PanDirectionGestureRecognizer *panGesture = - [[PanDirectionGestureRecognizer alloc] initWithDirection:PanDirectionForward + [[PanDirectionGestureRecognizer alloc] initWithDirection:(self.isRTL ? PanDirectionLeft : PanDirectionRight) target:self action:@selector(handlePanGesture:)]; [self addGestureRecognizer:panGesture]; diff --git a/Signal/src/views/DirectionalPanGestureRecognizer.swift b/Signal/src/views/DirectionalPanGestureRecognizer.swift index 8e4b3b59d..926158c51 100644 --- a/Signal/src/views/DirectionalPanGestureRecognizer.swift +++ b/Signal/src/views/DirectionalPanGestureRecognizer.swift @@ -6,7 +6,7 @@ import UIKit.UIGestureRecognizerSubclass @objc enum PanDirection: Int { - case forward, backward, up, down, any + case left, right, up, down, any } @objc @@ -33,13 +33,13 @@ class PanDirectionGestureRecognizer: UIPanGestureRecognizer { let deltaX = previousLocation.x - location.x switch direction { - case .down where deltaY < 0: - return case .up where deltaY > 0: return - case .forward where deltaX < 0: + case .down where deltaY < 0: + return + case .left where deltaX > 0: return - case .backward where deltaX > 0: + case .right where deltaX < 0: return default: break @@ -52,7 +52,7 @@ class PanDirectionGestureRecognizer: UIPanGestureRecognizer { if state == .began { let vel = velocity(in: view) switch direction { - case .forward, .backward: + case .left, .right: if fabs(vel.y) > fabs(vel.x) { state = .cancelled }