diff options
author | Muller, Alexander (A.) <amulle19@ford.com> | 2016-07-17 13:07:17 -0700 |
---|---|---|
committer | Muller, Alexander (A.) <amulle19@ford.com> | 2016-07-17 13:07:17 -0700 |
commit | a4dc92e83cb73ff0b9e2408ccae5caa47ae8706c (patch) | |
tree | 71ccf0500c5809bd48b374e60c0dcf1ab5fcedc2 | |
parent | 83d93f65cf0f4efcd5fabafda631d221f053f99a (diff) | |
download | sdl_ios-a4dc92e83cb73ff0b9e2408ccae5caa47ae8706c.tar.gz |
Updated panTimeThreshold to seconds instead of milliseconds. Also renamed to movementTimeThreshold.
-rw-r--r-- | SmartDeviceLink/SDLTouchManager.h | 4 | ||||
-rw-r--r-- | SmartDeviceLink/SDLTouchManager.m | 4 | ||||
-rw-r--r-- | SmartDeviceLinkTests/UtilitiesSpecs/Touches/SDLTouchManagerSpec.m | 14 |
3 files changed, 11 insertions, 11 deletions
diff --git a/SmartDeviceLink/SDLTouchManager.h b/SmartDeviceLink/SDLTouchManager.h index 78bbca3cb..f476b3314 100644 --- a/SmartDeviceLink/SDLTouchManager.h +++ b/SmartDeviceLink/SDLTouchManager.h @@ -24,9 +24,9 @@ @property (nonatomic) CGFloat tapTimeThreshold; /* - * Time between pan events (in milliseconds). + * Time between pan events (in seconds). */ -@property (nonatomic) CGFloat panTimeThreshold; +@property (nonatomic) CGFloat movementTimeThreshold; @property (nonatomic, getter=isTouchEnabled) BOOL touchEnabled; diff --git a/SmartDeviceLink/SDLTouchManager.m b/SmartDeviceLink/SDLTouchManager.m index e733dc5f3..e86b6fff2 100644 --- a/SmartDeviceLink/SDLTouchManager.m +++ b/SmartDeviceLink/SDLTouchManager.m @@ -51,7 +51,7 @@ static NSUInteger const MaximumNumberOfTouches = 2; - (instancetype)init { if (self = [super init]) { - _panTimeThreshold = 50.0f; + _movementTimeThreshold = 0.5f; _tapTimeThreshold = 0.4f; _tapDistanceThreshold = 50.0f; _touchEnabled = YES; @@ -114,7 +114,7 @@ static NSUInteger const MaximumNumberOfTouches = 2; } - (void)sdl_handleMovedTouch:(SDLTouch*)touch { - if ((touch.timeStamp - self.previousTouch.timeStamp) <= self.panTimeThreshold + if ((touch.timeStamp - self.previousTouch.timeStamp) <= (self.movementTimeThreshold * NSEC_PER_USEC) || !self.isTouchEnabled) { return; // no-op } diff --git a/SmartDeviceLinkTests/UtilitiesSpecs/Touches/SDLTouchManagerSpec.m b/SmartDeviceLinkTests/UtilitiesSpecs/Touches/SDLTouchManagerSpec.m index e7125fca1..d00b3768c 100644 --- a/SmartDeviceLinkTests/UtilitiesSpecs/Touches/SDLTouchManagerSpec.m +++ b/SmartDeviceLinkTests/UtilitiesSpecs/Touches/SDLTouchManagerSpec.m @@ -31,7 +31,7 @@ describe(@"SDLTouchManager Tests", ^{ expect(touchManager.touchEventListener).to(beNil()); expect(@(touchManager.tapDistanceThreshold)).to(equal(@50)); expect(@(touchManager.tapTimeThreshold)).to(beCloseTo(@0.4).within(0.0001)); - expect(@(touchManager.panTimeThreshold)).to(equal(@50)); + expect(@(touchManager.movementTimeThreshold)).to(beCloseTo(@0.5).within(0.0001)); expect(@(touchManager.isTouchEnabled)).to(beTruthy()); }); @@ -337,7 +337,7 @@ describe(@"SDLTouchManager Tests", ^{ panStartTouchCoord.x = @(panStartPoint.x); panStartTouchCoord.y = @(panStartPoint.y); - NSUInteger panStartTimeStamp = ([[NSDate date] timeIntervalSince1970] + touchManager.panTimeThreshold) * 1000; + NSUInteger panStartTimeStamp = ([[NSDate date] timeIntervalSince1970] + ((touchManager.movementTimeThreshold + .1) * 1000)) * 1000; SDLTouchEvent* panStartTouchEvent = [[SDLTouchEvent alloc] init]; panStartTouchEvent.coord = [NSMutableArray arrayWithObject:panStartTouchCoord]; @@ -354,7 +354,7 @@ describe(@"SDLTouchManager Tests", ^{ panMoveTouchCoord.x = @(panMovePoint.x); panMoveTouchCoord.y = @(panMovePoint.y); - NSUInteger panMoveTimeStamp = panStartTimeStamp + (touchManager.panTimeThreshold * 1000); + NSUInteger panMoveTimeStamp = panStartTimeStamp + (touchManager.movementTimeThreshold * 1000); SDLTouchEvent* panMoveTouchEvent = [[SDLTouchEvent alloc] init]; panMoveTouchEvent.coord = [NSMutableArray arrayWithObject:panMoveTouchCoord]; @@ -371,7 +371,7 @@ describe(@"SDLTouchManager Tests", ^{ panSecondMoveTouchCoord.x = @(panSecondMovePoint.x); panSecondMoveTouchCoord.y = @(panSecondMovePoint.y); - NSUInteger panSecondMoveTimeStamp = panMoveTimeStamp + (touchManager.panTimeThreshold * 1000); + NSUInteger panSecondMoveTimeStamp = panMoveTimeStamp + (touchManager.movementTimeThreshold * 1000); SDLTouchEvent* panSecondMoveTouchEvent = [[SDLTouchEvent alloc] init]; panSecondMoveTouchEvent.coord = [NSMutableArray arrayWithObject:panSecondMoveTouchCoord]; @@ -388,7 +388,7 @@ describe(@"SDLTouchManager Tests", ^{ panEndTouchCoord.x = @(panEndPoint.x); panEndTouchCoord.y = @(panEndPoint.y); - NSUInteger panEndTimeStamp = panSecondMoveTimeStamp + (touchManager.panTimeThreshold * 1000); + NSUInteger panEndTimeStamp = panSecondMoveTimeStamp + (touchManager.movementTimeThreshold * 1000); SDLTouchEvent* panEndTouchEvent = [[SDLTouchEvent alloc] init]; panEndTouchEvent.coord = [NSMutableArray arrayWithObject:panEndTouchCoord]; @@ -510,7 +510,7 @@ describe(@"SDLTouchManager Tests", ^{ secondFingerMoveTouchCoord.x = @(secondFingerTouchCoord.x.floatValue - 50); secondFingerMoveTouchCoord.y = @(secondFingerTouchCoord.y.floatValue - 40); - NSUInteger secondFingerMoveTimeStamp = secondFingerTimeStamp + (touchManager.panTimeThreshold * 1000); + NSUInteger secondFingerMoveTimeStamp = secondFingerTimeStamp + ((touchManager.movementTimeThreshold + 0.1) * 1000); SDLTouchEvent* secondFingerMoveTouchEvent = [[SDLTouchEvent alloc] init]; secondFingerMoveTouchEvent.touchEventId = @1; @@ -532,7 +532,7 @@ describe(@"SDLTouchManager Tests", ^{ // Second finger end SDLTouchCoord* secondFingerEndTouchCoord = secondFingerMoveTouchCoord; - NSUInteger secondFingerEndTimeStamp = secondFingerMoveTimeStamp + (touchManager.panTimeThreshold * 1000); + NSUInteger secondFingerEndTimeStamp = secondFingerMoveTimeStamp + ((touchManager.movementTimeThreshold + 0.1) * 1000); SDLTouchEvent* secondFingerEndTouchEvent = [[SDLTouchEvent alloc] init]; secondFingerEndTouchEvent.touchEventId = @1; |