summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicoleYarroch <nicole@livio.io>2019-10-04 16:36:17 -0400
committerNicoleYarroch <nicole@livio.io>2019-10-04 16:36:17 -0400
commit2141892df528029549db77c4e2179a4c9681a221 (patch)
tree1c18d044e61177b0ca279259e8c48530174169c8
parent6e8434c883887bdd905d3722bf0fe68fbfa25cb8 (diff)
downloadsdl_ios-2141892df528029549db77c4e2179a4c9681a221.tar.gz
Refactoring and cleanup
-rw-r--r--SmartDeviceLink/SDLFocusableItemLocator.m2
-rw-r--r--SmartDeviceLink/SDLStreamingVideoLifecycleManager.h2
-rw-r--r--SmartDeviceLink/SDLStreamingVideoLifecycleManager.m12
-rw-r--r--SmartDeviceLink/SDLStreamingVideoScaleManager.h2
-rw-r--r--SmartDeviceLink/SDLStreamingVideoScaleManager.m6
-rw-r--r--SmartDeviceLink/SDLTouchManager.m6
-rw-r--r--SmartDeviceLinkTests/SDLStreamingVideoScaleManagerSpec.m2
7 files changed, 14 insertions, 18 deletions
diff --git a/SmartDeviceLink/SDLFocusableItemLocator.m b/SmartDeviceLink/SDLFocusableItemLocator.m
index ef1300818..29da5b1af 100644
--- a/SmartDeviceLink/SDLFocusableItemLocator.m
+++ b/SmartDeviceLink/SDLFocusableItemLocator.m
@@ -39,7 +39,7 @@ NS_ASSUME_NONNULL_BEGIN
return nil;
}
- _viewController = streamManager.carWindow.rootViewController;
+ _viewController = viewController;
_connectionManager = connectionManager;
_streamManager = streamManager;
diff --git a/SmartDeviceLink/SDLStreamingVideoLifecycleManager.h b/SmartDeviceLink/SDLStreamingVideoLifecycleManager.h
index eed69a568..9a74f977a 100644
--- a/SmartDeviceLink/SDLStreamingVideoLifecycleManager.h
+++ b/SmartDeviceLink/SDLStreamingVideoLifecycleManager.h
@@ -45,7 +45,7 @@ NS_ASSUME_NONNULL_BEGIN
/**
* Touch Manager responsible for providing touch event notifications.
*/
-@property (nonatomic, strong, readonly, nullable) SDLTouchManager *touchManager;
+@property (nonatomic, strong, readonly) SDLTouchManager *touchManager;
@property (nonatomic, strong, nullable) UIViewController *rootViewController;
@property (strong, nonatomic, readonly, nullable) SDLCarWindow *carWindow;
diff --git a/SmartDeviceLink/SDLStreamingVideoLifecycleManager.m b/SmartDeviceLink/SDLStreamingVideoLifecycleManager.m
index 84dd1fcc6..2883105bf 100644
--- a/SmartDeviceLink/SDLStreamingVideoLifecycleManager.m
+++ b/SmartDeviceLink/SDLStreamingVideoLifecycleManager.m
@@ -283,9 +283,7 @@ typedef void(^SDLVideoCapabilityResponseHandler)(SDLVideoStreamingCapability *_N
if (_showVideoBackgroundDisplay) {
[self sdl_sendBackgroundFrames];
}
- if (self.touchManager != nil) {
- [self.touchManager cancelPendingTouches];
- }
+ [self.touchManager cancelPendingTouches];
if (self.isVideoConnected) {
[self.videoStreamStateMachine transitionToState:SDLVideoStreamManagerStateSuspended];
@@ -448,9 +446,7 @@ typedef void(^SDLVideoCapabilityResponseHandler)(SDLVideoStreamingCapability *_N
[self.displayLink addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSRunLoopCommonModes];
});
} else {
- if (self.touchManager != nil) {
- self.touchManager.enableSyncedPanning = NO;
- }
+ self.touchManager.enableSyncedPanning = NO;
}
}
@@ -700,9 +696,7 @@ typedef void(^SDLVideoCapabilityResponseHandler)(SDLVideoStreamingCapability *_N
SDLLogV(@"DisplayLink frame fired, duration: %f, last frame timestamp: %f, target timestamp: (not available)", displayLink.duration, displayLink.timestamp);
}
- if (self.touchManager != nil) {
- [self.touchManager syncFrame];
- }
+ [self.touchManager syncFrame];
[self.carWindow syncFrame];
}
diff --git a/SmartDeviceLink/SDLStreamingVideoScaleManager.h b/SmartDeviceLink/SDLStreamingVideoScaleManager.h
index 41ea3aea3..fd8a2285d 100644
--- a/SmartDeviceLink/SDLStreamingVideoScaleManager.h
+++ b/SmartDeviceLink/SDLStreamingVideoScaleManager.h
@@ -47,7 +47,7 @@ NS_ASSUME_NONNULL_BEGIN
@param screenSize The current screen size of the connected display
@return A SDLStreamingVideoScaleManager object
*/
-- (instancetype)initWithScale:(float)scale screenSize:(CGSize)screenSize;
+- (instancetype)initWithScale:(float)scale displayViewportResolution:(CGSize)displayViewportResolution;
/**
Scales the coordinates of the OnTouchEvent from the display's coordinate system to the view controller's coordinate system. If the scale value is less than 1.0, the touch events will be returned without being scaled.
diff --git a/SmartDeviceLink/SDLStreamingVideoScaleManager.m b/SmartDeviceLink/SDLStreamingVideoScaleManager.m
index 17cccbb22..094442cc2 100644
--- a/SmartDeviceLink/SDLStreamingVideoScaleManager.m
+++ b/SmartDeviceLink/SDLStreamingVideoScaleManager.m
@@ -29,21 +29,21 @@ const float DefaultScaleValue = 1.0;
CGSize const SDLDefaultDisplayViewportResolution = {0, 0};
- (instancetype)init {
- return [[self.class alloc] initWithScale:DefaultScaleValue screenSize:SDLDefaultDisplayViewportResolution];
+ return [[self.class alloc] initWithScale:DefaultScaleValue displayViewportResolution:SDLDefaultDisplayViewportResolution];
}
- (void)stop {
self.displayViewportResolution = SDLDefaultDisplayViewportResolution;
}
-- (instancetype)initWithScale:(float)scale screenSize:(CGSize)screenSize {
+- (instancetype)initWithScale:(float)scale displayViewportResolution:(CGSize)displayViewportResolution {
self = [super init];
if (!self) {
return nil;
}
_scale = [self.class validateScale:scale];
- _displayViewportResolution = screenSize;
+ _displayViewportResolution = displayViewportResolution;
return self;
}
diff --git a/SmartDeviceLink/SDLTouchManager.m b/SmartDeviceLink/SDLTouchManager.m
index 77d441c3b..f2d552ae6 100644
--- a/SmartDeviceLink/SDLTouchManager.m
+++ b/SmartDeviceLink/SDLTouchManager.m
@@ -7,8 +7,8 @@
//
#import "SDLTouchManager.h"
-#import "CGPoint_Util.h"
+#import "CGPoint_Util.h"
#import "SDLGlobals.h"
#import "SDLFocusableItemHitTester.h"
#import "SDLLogMacros.h"
@@ -111,9 +111,11 @@ static NSUInteger const MaximumNumberOfTouches = 2;
}
- (instancetype)initWithHitTester:(nullable id<SDLFocusableItemHitTester>)hitTester videoScaleManager:(SDLStreamingVideoScaleManager *)videoScaleManager {
- if (!(self = [super init])) {
+ self = [super init];
+ if (!self) {
return nil;
}
+
_hitTester = hitTester;
_videoScaleManager = videoScaleManager;
_movementTimeThreshold = 0.05f;
diff --git a/SmartDeviceLinkTests/SDLStreamingVideoScaleManagerSpec.m b/SmartDeviceLinkTests/SDLStreamingVideoScaleManagerSpec.m
index d44df5199..f948e98fe 100644
--- a/SmartDeviceLinkTests/SDLStreamingVideoScaleManagerSpec.m
+++ b/SmartDeviceLinkTests/SDLStreamingVideoScaleManagerSpec.m
@@ -31,7 +31,7 @@ describe(@"the streaming video scale manager", ^{
});
it(@"should properly init a default configuration", ^{
- videoScaleManager = [[SDLStreamingVideoScaleManager alloc] initWithScale:testScale screenSize:testScreenSize];
+ videoScaleManager = [[SDLStreamingVideoScaleManager alloc] initWithScale:testScale displayViewportResolution:testScreenSize];
expect(@(videoScaleManager.scale)).to(equal(testScale));
expect(CGSizeEqualToSize(videoScaleManager.displayViewportResolution, testScreenSize)).to(beTrue());