Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Touch Manager #423

Merged
merged 48 commits into from Jul 29, 2016
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
ef3fe39
Initial support for a touch manager for interpreting onTouchEvent not…
asm09fsu Jun 15, 2016
80ba013
Updated SDLTouchManager's header to public
asm09fsu Jun 15, 2016
17337c4
Added touch manager to SmartDeviceLink.h
asm09fsu Jun 15, 2016
3ca1d55
Fixed issue relating to using C files in cocoapods.
asm09fsu Jun 15, 2016
e704ce7
Using ULONG_MAX instead of 0 for our unsigned longs in const struct v…
asm09fsu Jun 15, 2016
4e3c613
Updated the tapTimeThreshold to be seconds instead of milliseconds to…
asm09fsu Jun 15, 2016
0debf95
Fixed function mistype.
asm09fsu Jun 15, 2016
ca030ed
Added missing header for ULONG_MAX.
asm09fsu Jun 16, 2016
e39aeaa
Added spec tests for CGPoint_Util.
asm09fsu Jun 17, 2016
5338b68
Updated SDLTouch to use a signed long for identifier, so we may use -…
asm09fsu Jun 17, 2016
d26d4f9
Added SDLTouch spec tests.
asm09fsu Jun 17, 2016
23281cb
Removed public exposure of SDLTouchEqualToTouch
asm09fsu Jun 17, 2016
de8db6e
Added SDLPinchGesture spec tests.
asm09fsu Jun 17, 2016
4564749
Fixed SDLPinchGesture tests.
asm09fsu Jun 17, 2016
ef754ee
Added dispatch_timer spec tests.
asm09fsu Jun 17, 2016
116008b
removed unecessary @class
asm09fsu Jun 18, 2016
8199fcf
Reduced pan time threshold to a lower value to improve panning delay.
asm09fsu Jun 24, 2016
ef7d601
Adding check in the event we receive an invalid timestamp object from…
asm09fsu Jun 24, 2016
301f21f
Made performingTouchType internal because necessity of it for develop…
asm09fsu Jun 28, 2016
565d10f
Added multiple structs/notifications to be visible to testing target.
asm09fsu Jun 28, 2016
b11680b
Added tests for all touch events.
asm09fsu Jun 28, 2016
c8d0846
Moved all helper class tests to separate files.
asm09fsu Jul 1, 2016
ac2dcf5
Using NSSelectorFromString instead of @selector to silence warning.
asm09fsu Jul 1, 2016
1ff49f6
Rewrote SDLTouchManager tests to extract variables out of the tests a…
asm09fsu Jul 2, 2016
0baeebb
Replaced structs for SDLTouch & SDLPinchGesture in favor of classes.
asm09fsu Jul 17, 2016
bb4adcb
Merge remote-tracking branch 'origin/develop' into feature/touch_manager
asm09fsu Jul 17, 2016
83d93f6
Removed "k" from internal constant.
asm09fsu Jul 17, 2016
a4dc92e
Updated panTimeThreshold to seconds instead of milliseconds. Also ren…
asm09fsu Jul 17, 2016
e7b9481
Updated inits to avoid right shift.
asm09fsu Jul 17, 2016
c3dfc98
Fixed issue causing Panning tests to sometimes fail.
asm09fsu Jul 17, 2016
1ed1b8e
Added missing non-null audited regions. Updated all properties to con…
asm09fsu Jul 17, 2016
4c7fc67
Removed duplicate function.
asm09fsu Jul 17, 2016
4696481
Removed unneeded function.
asm09fsu Jul 17, 2016
f822b52
Added documentation
asm09fsu Jul 17, 2016
34e4441
Renamed SDLTouchManagerListener to SDLTouchManagerDelegate
asm09fsu Jul 17, 2016
37c3351
Updated variable from "Listener" to "Delegate.
asm09fsu Jul 19, 2016
adaa29e
Renamed touchEventListener to touchEventDelegate.
asm09fsu Jul 19, 2016
7dd3744
Fixed issue with default movementTimeThreshold being off by a tenth r…
asm09fsu Jul 25, 2016
32506bc
Merge branch 'develop' into feature/touch_manager
joeljfischer Jul 28, 2016
a353f96
Renamed internal methods to make them more readable.
asm09fsu Jul 28, 2016
977f7f4
Added observation of when an application enters an invalidate state s…
asm09fsu Jul 28, 2016
3dc4d5c
Updated SDLPinchGesture's touches from having copy to strong.
asm09fsu Jul 28, 2016
e6b44e8
Moved Touch Manager to be a property of the Streaming Media Manager i…
asm09fsu Jul 28, 2016
9f0a635
Moved the observing of application state changes to Streaming Media M…
asm09fsu Jul 28, 2016
8d4b1b8
Added check for singleTapTimer nullability when canceling.
asm09fsu Jul 29, 2016
e17cda8
Fixed spec issues relating to changed protocol property name.
asm09fsu Jul 29, 2016
10b8220
Fixed spec issue relating to changed default movementTimeThreshold.
asm09fsu Jul 29, 2016
ca91918
Merge branch 'develop' into feature/touch_manager
joeljfischer Jul 29, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
72 changes: 72 additions & 0 deletions SmartDeviceLink-iOS.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

20 changes: 20 additions & 0 deletions SmartDeviceLink/CGPoint_Util.h
@@ -0,0 +1,20 @@
//
// CGPoint_Util.h
// SmartDeviceLink-iOS
//
// Created by Muller, Alexander (A.) on 6/14/16.
// Copyright © 2016 smartdevicelink. All rights reserved.
//

#ifndef CGPoint_Util_h
#define CGPoint_Util_h

#include <stdio.h>
#include <CoreGraphics/CGGeometry.h>

CGPoint CGPointAverageOfPoints(CGPoint point1, CGPoint point2);
CGPoint CGPointCenterOfPoints(CGPoint point1, CGPoint point2);
CGPoint CGPointDisplacementOfPoints(CGPoint point1, CGPoint point2);
CGFloat CGPointDistanceBetweenPoints(CGPoint point1, CGPoint point2);

#endif /* CGPoint_Util_h */
32 changes: 32 additions & 0 deletions SmartDeviceLink/CGPoint_Util.m
@@ -0,0 +1,32 @@
//
// CGPoint_Util.c
// SmartDeviceLink-iOS
//
// Created by Muller, Alexander (A.) on 6/14/16.
// Copyright © 2016 smartdevicelink. All rights reserved.
//

#include "CGPoint_Util.h"
#include "math.h"

CGPoint CGPointAverageOfPoints(CGPoint point1, CGPoint point2) {
CGFloat xAverage = (point1.x + point2.x)/2.0f;
CGFloat yAverage = (point1.y + point2.y)/2.0f;
return CGPointMake(xAverage, yAverage);
}

CGPoint CGPointCenterOfPoints(CGPoint point1, CGPoint point2) {
CGFloat xCenter = (point1.x + point2.x) / 2.0f;
CGFloat yCenter = (point1.y + point2.y) / 2.0f;
return CGPointMake(xCenter, yCenter);
}

CGPoint CGPointDisplacementOfPoints(CGPoint point1, CGPoint point2) {
CGFloat xDisplacement = point1.x - point2.x;
CGFloat yDisplacement = point1.y - point2.y;
return CGPointMake(xDisplacement, yDisplacement);
}

CGFloat CGPointDistanceBetweenPoints(CGPoint point1, CGPoint point2) {
return hypotf(point1.x - point2.x, point1.y - point2.y);
}
31 changes: 31 additions & 0 deletions SmartDeviceLink/SDLPinchGesture.h
@@ -0,0 +1,31 @@
//
// SDLPinchGesture.h
// SmartDeviceLink-iOS
//
// Created by Muller, Alexander (A.) on 6/14/16.
// Copyright © 2016 smartdevicelink. All rights reserved.
//

#ifndef SDLPinchGesture_h
#define SDLPinchGesture_h

#include <stdio.h>
#include "SDLTouch.h"
#include "CGPoint_Util.h"

typedef struct {
SDLTouch firstTouch;
SDLTouch secondTouch;
CGFloat distance;
CGPoint center;
} SDLPinchGesture;

extern const SDLPinchGesture SDLPinchGestureZero;

SDLPinchGesture SDLPinchGestureMake(SDLTouch firstTouch, SDLTouch secondTouch);

SDLPinchGesture SDLPinchGestureUpdateFromTouch(SDLPinchGesture pinch, SDLTouch touch);

bool SDLPinchGestureIsValid(SDLPinchGesture pinch);

#endif /* SDLPinchGesture_h */
38 changes: 38 additions & 0 deletions SmartDeviceLink/SDLPinchGesture.m
@@ -0,0 +1,38 @@
//
// SDLPinchGesture.c
// SmartDeviceLink-iOS
//
// Created by Muller, Alexander (A.) on 6/14/16.
// Copyright © 2016 smartdevicelink. All rights reserved.
//

#include "SDLPinchGesture.h"

SDLPinchGesture SDLPinchGestureMake(SDLTouch firstTouch, SDLTouch secondTouch) {
SDLPinchGesture pinchGesture;
pinchGesture.firstTouch = firstTouch;
pinchGesture.secondTouch = secondTouch;
pinchGesture.center = CGPointCenterOfPoints(firstTouch.location, secondTouch.location);
pinchGesture.distance = CGPointDistanceBetweenPoints(firstTouch.location, secondTouch.location);
return pinchGesture;
}

const SDLPinchGesture SDLPinchGestureZero = {{-1, {0, 0}, 0}, {-1, {0, 0}, 0}, 0, {0, 0}};

SDLPinchGesture SDLPinchGestureUpdateFromTouch(SDLPinchGesture pinch, SDLTouch touch) {
switch (touch.identifier) {
case SDLTouchIdentifierFirstFinger:
return SDLPinchGestureMake(touch, pinch.secondTouch);
break;
case SDLTouchIdentifierSecondFinger:
return SDLPinchGestureMake(pinch.firstTouch, touch);
break;
default:
return SDLPinchGestureZero;
break;
}
}

bool SDLPinchGestureIsValid(SDLPinchGesture pinch) {
return SDLTouchIsValid(pinch.firstTouch) && SDLTouchIsValid(pinch.secondTouch);
}
2 changes: 2 additions & 0 deletions SmartDeviceLink/SDLProxy.h
Expand Up @@ -9,6 +9,7 @@
@class SDLRPCRequestFactory;
@class SDLStreamingMediaManager;
@class SDLTimer;
@class SDLTouchManager;

#import "SDLProtocolListener.h"
#import "SDLProxyListener.h"
Expand All @@ -28,6 +29,7 @@
@property (copy) NSString *debugConsoleGroupName;
@property (readonly, copy) NSString *proxyVersion;
@property (nonatomic, strong, readonly) SDLStreamingMediaManager *streamingMediaManager;
@property (nonatomic, strong, readonly) SDLTouchManager* touchManager;

- (id)initWithTransport:(SDLAbstractTransport *)transport
protocol:(SDLAbstractProtocol *)protocol
Expand Down
12 changes: 12 additions & 0 deletions SmartDeviceLink/SDLProxy.m
Expand Up @@ -39,6 +39,7 @@
#import "SDLSystemContext.h"
#import "SDLSystemRequest.h"
#import "SDLTimer.h"
#import "SDLTouchManager.h"
#import "SDLURLSession.h"


Expand All @@ -57,6 +58,7 @@ @interface SDLProxy () {

@property (strong, nonatomic) NSMutableSet *mutableProxyListeners;
@property (nonatomic, strong, readwrite) SDLStreamingMediaManager *streamingMediaManager;
@property (nonatomic, strong, readwrite) SDLTouchManager *touchManager;

@end

Expand Down Expand Up @@ -98,6 +100,7 @@ - (void)destructObjects {
[self.protocol dispose];
[self.transport dispose];

_touchManager = nil;
_transport = nil;
_protocol = nil;
_mutableProxyListeners = nil;
Expand Down Expand Up @@ -173,6 +176,15 @@ - (SDLStreamingMediaManager *)streamingMediaManager {
return _streamingMediaManager;
}

- (SDLTouchManager*)touchManager {
if (_touchManager == nil) {
_touchManager = [[SDLTouchManager alloc] init];
[self.mutableProxyListeners addObject:_touchManager];
}

return _touchManager;
}


#pragma mark - SDLProtocolListener Implementation
- (void)onProtocolOpened {
Expand Down
36 changes: 36 additions & 0 deletions SmartDeviceLink/SDLTouch.h
@@ -0,0 +1,36 @@
//
// SDLTouch.h
// SmartDeviceLink-iOS
//
// Created by Muller, Alexander (A.) on 6/14/16.
// Copyright © 2016 smartdevicelink. All rights reserved.
//

#ifndef SDLTouch_h
#define SDLTouch_h

#include <stdio.h>
#include <CoreGraphics/CGGeometry.h>

typedef struct SDLTouch {
long identifier;
CGPoint location;
unsigned long timeStamp;
} SDLTouch;

typedef enum {
SDLTouchIdentifierFirstFinger = 0,
SDLTouchIdentifierSecondFinger = 1
} SDLTouchIdentifier;

extern const SDLTouch SDLTouchZero;

SDLTouch SDLTouchMake(unsigned long identifier, float x, float y, unsigned long timeStamp);

// Checks if SDLTouch is equal to SDLTouchZero.
bool SDLTouchIsValid(SDLTouch touch);

bool SDLTouchIsFirstFinger(SDLTouch touch);
bool SDLTouchIsSecondFinger(SDLTouch touch);

#endif /* SDLTouch_h */
38 changes: 38 additions & 0 deletions SmartDeviceLink/SDLTouch.m
@@ -0,0 +1,38 @@
//
// SDLTouch.c
// SmartDeviceLink-iOS
//
// Created by Muller, Alexander (A.) on 6/14/16.
// Copyright © 2016 smartdevicelink. All rights reserved.
//

#include "SDLTouch.h"

SDLTouch const SDLTouchZero = {-1, {0, 0}, 0};

SDLTouch SDLTouchMake(unsigned long identifier, float x, float y, unsigned long timeStamp) {
SDLTouch touch;
touch.identifier = identifier;
touch.location = CGPointMake(x, y);
touch.timeStamp = timeStamp;
return touch;
}

bool SDLTouchEqualToTouch(SDLTouch touch1, SDLTouch touch2) {
bool isEqual = (touch1.identifier == touch2.identifier);
isEqual = (isEqual && CGPointEqualToPoint(touch1.location, touch2.location));
isEqual = (isEqual && touch1.timeStamp == touch2.timeStamp);
return isEqual;
}

bool SDLTouchIsValid(SDLTouch touch) {
return SDLTouchEqualToTouch(touch, SDLTouchZero) ? false : true;
}

bool SDLTouchIsFirstFinger(SDLTouch touch) {
return touch.identifier == SDLTouchIdentifierFirstFinger ? true : false;
}

bool SDLTouchIsSecondFinger(SDLTouch touch) {
return touch.identifier == SDLTouchIdentifierSecondFinger ? true : false;
}
33 changes: 33 additions & 0 deletions SmartDeviceLink/SDLTouchManager.h
@@ -0,0 +1,33 @@
//
// SDLTouchManager.h
// SmartDeviceLink-iOS
//
// Created by Muller, Alexander (A.) on 6/14/16.
// Copyright © 2016 smartdevicelink. All rights reserved.
//

#import <UIKit/UIKit.h>
#import "SDLTouchManagerListener.h"

@interface SDLTouchManager : NSObject

@property (nonatomic, weak) id<SDLTouchManagerListener> touchEventListener;

/*
* Distance between taps.
*/
@property (nonatomic) CGFloat tapDistanceThreshold;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Explicitly specify as assign(?), even though it's obvious, just for consistency. Atomicity and strong/weak/assign/copy should be on every property.


/*
* Duration between taps (in seconds).
*/
@property (nonatomic) CGFloat tapTimeThreshold;

/*
* Time between pan events (in milliseconds).
*/
@property (nonatomic) CGFloat panTimeThreshold;

@property (nonatomic, getter=isTouchEnabled) BOOL touchEnabled;

@end