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

Implement SDL 0179 - Pixel density and Scale #1401

Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
6d00081
Adding new properties 'pixel', 'density' and 'scale' in 'SDLVideoStre…
lnafarrateluxoft Jul 23, 2019
addae68
Accessing SDLVideoStreamingCapability from SDLCarWindow, to apply cha…
lnafarrateluxoft Jul 23, 2019
a115a48
Calculating the correct coordinates by dividing the incoming coords w…
lnafarrateluxoft Jul 25, 2019
4e5b88c
Fixing tests for new changes in implementation for 'Pixel density and…
lnafarrateluxoft Jul 25, 2019
6f46e1e
Adding Unit Tests for Pixel density and Scale proposal.
lnafarrateluxoft Jul 25, 2019
e4a8547
Merge remote-tracking branch 'upstream/develop' into feature/pixel_de…
lnafarrateluxoft Jul 25, 2019
05ed747
Fixing unit tests.
lnafarrateluxoft Jul 25, 2019
f138bd5
Merge remote-tracking branch 'upstream/develop' into feature/0179_pix…
lnafarrateluxoft Aug 5, 2019
fcf51e3
Addressing comment in PR to copy OnTouchEvent before modification.
lnafarrateluxoft Aug 5, 2019
d499eff
Merge remote-tracking branch 'upstream/develop' into feature/0179_pix…
lnafarrateluxoft Aug 9, 2019
31d9165
Fixing video frame dimensions, applying scale. Now video frame and vi…
lnafarrateluxoft Aug 9, 2019
505ca7f
Merge remote-tracking branch 'upstream/develop' into feature/0179_pix…
lnafarrateluxoft Aug 26, 2019
4cd321e
Addressing comments in PR.
lnafarrateluxoft Aug 27, 2019
a0a3269
update Travis script (sdk-ios12.2)
yLeonid Sep 12, 2019
b04a22b
fixing warnings in Tests (wrong or incompatible data types)
yLeonid Sep 12, 2019
3b3d553
fixing 6 errors in Tests (expanded macro in SDLStreamingVideoLifecycl…
yLeonid Sep 12, 2019
eb85bd2
fixing warnings in Tests (wrong or incompatible data types)
yLeonid Sep 13, 2019
abcc998
hot fix SDLTouchManagerSpec (FIXIT: SDLTouchManager must unsubscribe …
yLeonid Sep 13, 2019
7e1ffcb
tmp: try to fix SDLTouchManagerSpec
yLeonid Sep 13, 2019
e55dfb0
tmp fixed SDLStreamingVideoLifecycleManagerSpec
yLeonid Sep 13, 2019
7600d81
update if statement using early return as proposed at:
yLeonid Sep 13, 2019
91b30ce
update CarWindow and TouchManager to use scale from StreamingVideoLif…
yLeonid Sep 13, 2019
8f0dca9
update private property of tested class in test to meet its declaration
yLeonid Sep 13, 2019
c551769
update scale in SDLVideoStreamingCapability.m, it can be nil
yLeonid Sep 13, 2019
046c0b9
update SDLVideoStreamingCapabilitySpec tests as requested
yLeonid Sep 13, 2019
9c94d3e
fixing warnings in Tests (wrong or incompatible data types)
yLeonid Sep 12, 2019
4e35c82
fixing warnings in Tests (wrong or incompatible data types)
yLeonid Sep 13, 2019
f26c4d8
update if statement using early return as proposed at:
yLeonid Sep 14, 2019
3aa7be8
hot fix SDLTouchManagerSpec (FIXIT: SDLTouchManager must unsubscribe …
yLeonid Sep 14, 2019
c8a9e5e
update SDLVideoStreamingCapabilitySpec tests as requested
yLeonid Sep 14, 2019
476234e
update scale in SDLVideoStreamingCapability.m, it can be nil
yLeonid Sep 14, 2019
ec2e1ba
Prepare merge into DEVELOP : Merge branch 'feature/0179_pixel_density…
yLeonid Sep 17, 2019
a8b54df
apply code review comments @NicoleYarroch :
yLeonid Sep 18, 2019
01262e2
fix test cases with test review comments @NicoleYarroch :
yLeonid Sep 18, 2019
4feb98d
fix review comments in SDLTouchManagerSpec
yLeonid Sep 19, 2019
17a73f9
fix a review comment @NicoleYarroch
yLeonid Sep 19, 2019
6bf3478
Replace Travis script with its version from develop branch 0e7d70b8
yLeonid Sep 20, 2019
53bf335
Merge branch '0179_pixel_density_and_scale' into develop, fix conflic…
yLeonid Sep 20, 2019
a32f571
Merge branch 'develop' of https://github.com/smartdevicelink/sdl_ios …
yLeonid Sep 23, 2019
e944477
Update SmartDeviceLink/SDLVideoStreamingCapability.h
yLeonid Sep 24, 2019
46ed0f0
0179_pixel_density_and_scale: handle haptic rectangles frames in Focu…
yLeonid Sep 24, 2019
47551a8
SDL 0179 - Pixel density and Scale : update SDLCarWindow and SDLFocus…
yLeonid Sep 27, 2019
8a4cdff
SDL 0179 - Pixel density and Scale : add scale property for SDLCarWin…
yLeonid Sep 27, 2019
9baffbb
0179_pixel_density_and_scale: add CGGeometry extensions for CGRect an…
yLeonid Sep 29, 2019
39dac48
0179_pixel_density_and_scale: fix FocusableItemLocator : scale the re…
yLeonid Sep 29, 2019
a86b539
0179_pixel_density_and_scale: update CGGeometry+SDL
yLeonid Sep 29, 2019
7ae5a2e
0179_pixel_density_and_scale : fix UI tests for HapticManager aka SDL…
yLeonid Sep 29, 2019
2fd9e09
0179_pixel_density_and_scale : discard fallen test
yLeonid Sep 29, 2019
710ad4f
0179_pixel_density_and_scale_v2 : minor update in CGGeometry+SDL
yLeonid Sep 30, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions SmartDeviceLink/SDLFocusableItemLocator.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
//

#import <Foundation/Foundation.h>
#import <simd/simd.h>
yLeonid marked this conversation as resolved.
Show resolved Hide resolved

#import "SDLFocusableItemLocator.h"
#import "SDLLogMacros.h"
Expand All @@ -28,17 +29,21 @@ @interface SDLFocusableItemLocator()
reference to SDLConnectionManager
*/
@property (nonatomic, weak) id<SDLConnectionManagerType> connectionManager;

@property (nonatomic, assign) float scale;

@end


@implementation SDLFocusableItemLocator

- (instancetype)initWithViewController:(UIViewController *)viewController connectionManager:(id<SDLConnectionManagerType>)connectionManager {
- (instancetype)initWithViewController:(UIViewController *)viewController connectionManager:(id<SDLConnectionManagerType>)connectionManager scale:(float)scale {
self = [super init];
if(!self) {
return nil;
}

_scale = simd_clamp(scale, 1.f, 10.f);
_viewController = viewController;
_connectionManager = connectionManager;
_enableHapticDataRequests = NO;
Expand Down Expand Up @@ -127,14 +132,15 @@ - (nullable UIView *)viewForPoint:(CGPoint)point {
for (UIView *view in self.focusableViews) {
//Convert the absolute location to local location and check if that falls within view boundary
CGPoint localPoint = [view convertPoint:point fromView:self.viewController.view];
localPoint.x /= self.scale;
yLeonid marked this conversation as resolved.
Show resolved Hide resolved
localPoint.y /= self.scale;
if ([view pointInside:localPoint withEvent:nil]) {
if (selectedView != nil) {
selectedView = nil;
break;
return nil;
//the point has been indentified in two views. We cannot identify which with confidence.
} else {
selectedView = view;
}

selectedView = view;
}
}

Expand Down
2 changes: 1 addition & 1 deletion SmartDeviceLink/SDLFocusableItemLocatorType.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ NS_ASSUME_NONNULL_BEGIN
@param viewController UIViewController to be checked for focusable views
@param connectionManager Object of a class that implements ConnectionManagerType. This is used for RPC communication.
*/
- (instancetype)initWithViewController:(UIViewController *)viewController connectionManager:(id<SDLConnectionManagerType>)connectionManager;
- (instancetype)initWithViewController:(UIViewController *)viewController connectionManager:(id<SDLConnectionManagerType>)connectionManager scale:(float)scale;

/**
updateInterfaceLayout crawls through the view hierarchy, updates and keep tracks of views to be reported through Haptic RPC. This function is automatically called when SDLDidUpdateProjectionView notification is sent by the application.
Expand Down
7 changes: 5 additions & 2 deletions SmartDeviceLink/SDLStreamingVideoLifecycleManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,10 @@ - (instancetype)initWithConnectionManager:(id<SDLConnectionManagerType>)connecti
NSAssert(configuration.streamingMediaConfig.enableForcedFramerateSync, @"When using CarWindow (rootViewController != nil), forceFrameRateSync must be YES");
if (@available(iOS 9.0, *)) {
SDLLogD(@"Initializing focusable item locator");
_focusableItemManager = [[SDLFocusableItemLocator alloc] initWithViewController:configuration.streamingMediaConfig.rootViewController connectionManager:_connectionManager];
_focusableItemManager = [[SDLFocusableItemLocator alloc]
initWithViewController:configuration.streamingMediaConfig.rootViewController
connectionManager:_connectionManager
scale:self.sdl_scale];
}

SDLLogD(@"Initializing CarWindow");
Expand Down Expand Up @@ -411,7 +414,7 @@ - (void)didEnterStateVideoStreamReady {

SDLLogD(@"Attempting to create video encoder");
const float scale = self.sdl_scale;
CGSize scaledScreenSize = CGSizeMake(self.screenSize.width / scale, self.screenSize.height / scale);
const CGSize scaledScreenSize = CGSizeMake(self.screenSize.width / scale, self.screenSize.height / scale);
self.videoEncoder = [[SDLH264VideoEncoder alloc] initWithProtocol:self.videoFormat.protocol dimensions:scaledScreenSize ssrc:self.ssrc properties:self.videoEncoderSettings delegate:self error:&error];

if (error || self.videoEncoder == nil) {
Expand Down
24 changes: 12 additions & 12 deletions SmartDeviceLinkTests/ProxySpecs/SDLHapticManagerSpec.m
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ BOOL compareRectangle(SDLRectangle *sdlRectangle, CGRect cgRect) {
UITextField *textField1 = [[UITextField alloc] initWithFrame:viewRect1];
[uiViewController.view addSubview:textField1];

hapticManager = [[SDLFocusableItemLocator alloc] initWithViewController:uiViewController connectionManager:sdlLifecycleManager];
hapticManager = [[SDLFocusableItemLocator alloc] initWithViewController:uiViewController connectionManager:sdlLifecycleManager scale:1.f];
hapticManager.enableHapticDataRequests = NO;
[hapticManager updateInterfaceLayout];
});
Expand All @@ -78,7 +78,7 @@ BOOL compareRectangle(SDLRectangle *sdlRectangle, CGRect cgRect) {

context(@"when initialized with no focusable view", ^{
beforeEach(^{
hapticManager = [[SDLFocusableItemLocator alloc] initWithViewController:uiViewController connectionManager:sdlLifecycleManager];
hapticManager = [[SDLFocusableItemLocator alloc] initWithViewController:uiViewController connectionManager:sdlLifecycleManager scale:1.f];
[hapticManager updateInterfaceLayout];
});

Expand All @@ -94,7 +94,7 @@ BOOL compareRectangle(SDLRectangle *sdlRectangle, CGRect cgRect) {
UITextField *textField1 = [[UITextField alloc] initWithFrame:viewRect1];
[uiViewController.view addSubview:textField1];

hapticManager = [[SDLFocusableItemLocator alloc] initWithViewController:uiViewController connectionManager:sdlLifecycleManager];
hapticManager = [[SDLFocusableItemLocator alloc] initWithViewController:uiViewController connectionManager:sdlLifecycleManager scale:1.f];
hapticManager.enableHapticDataRequests = YES;
[hapticManager updateInterfaceLayout];
});
Expand All @@ -121,7 +121,7 @@ BOOL compareRectangle(SDLRectangle *sdlRectangle, CGRect cgRect) {
UIButton *button = [[UIButton alloc] initWithFrame:viewRect1];
[uiViewController.view addSubview:button];

hapticManager = [[SDLFocusableItemLocator alloc] initWithViewController:uiViewController connectionManager:sdlLifecycleManager];
hapticManager = [[SDLFocusableItemLocator alloc] initWithViewController:uiViewController connectionManager:sdlLifecycleManager scale:1.f];
hapticManager.enableHapticDataRequests = YES;
[hapticManager updateInterfaceLayout];
});
Expand All @@ -144,7 +144,7 @@ BOOL compareRectangle(SDLRectangle *sdlRectangle, CGRect cgRect) {

context(@"when initialized with no views and then updated with two additional views", ^{
beforeEach(^{
hapticManager = [[SDLFocusableItemLocator alloc] initWithViewController:uiViewController connectionManager:sdlLifecycleManager];
hapticManager = [[SDLFocusableItemLocator alloc] initWithViewController:uiViewController connectionManager:sdlLifecycleManager scale:1.f];
hapticManager.enableHapticDataRequests = YES;
[hapticManager updateInterfaceLayout];

Expand Down Expand Up @@ -192,7 +192,7 @@ BOOL compareRectangle(SDLRectangle *sdlRectangle, CGRect cgRect) {
UITextField *textField2 = [[UITextField alloc] initWithFrame:viewRect2];
[textField addSubview:textField2];

hapticManager = [[SDLFocusableItemLocator alloc] initWithViewController:uiViewController connectionManager:sdlLifecycleManager];
hapticManager = [[SDLFocusableItemLocator alloc] initWithViewController:uiViewController connectionManager:sdlLifecycleManager scale:1.f];
hapticManager.enableHapticDataRequests = YES;
[hapticManager updateInterfaceLayout];
});
Expand Down Expand Up @@ -230,7 +230,7 @@ BOOL compareRectangle(SDLRectangle *sdlRectangle, CGRect cgRect) {
UITextField *textField2 = [[UITextField alloc] initWithFrame:viewRect2];
[button addSubview:textField2];

hapticManager = [[SDLFocusableItemLocator alloc] initWithViewController:uiViewController connectionManager:sdlLifecycleManager];
hapticManager = [[SDLFocusableItemLocator alloc] initWithViewController:uiViewController connectionManager:sdlLifecycleManager scale:1.f];
hapticManager.enableHapticDataRequests = YES;
[hapticManager updateInterfaceLayout];
});
Expand Down Expand Up @@ -265,7 +265,7 @@ BOOL compareRectangle(SDLRectangle *sdlRectangle, CGRect cgRect) {
UITextField *textField2 = [[UITextField alloc] initWithFrame:viewRect2];
[uiViewController.view addSubview:textField2];

hapticManager = [[SDLFocusableItemLocator alloc] initWithViewController:uiViewController connectionManager:sdlLifecycleManager];
hapticManager = [[SDLFocusableItemLocator alloc] initWithViewController:uiViewController connectionManager:sdlLifecycleManager scale:1.f];
hapticManager.enableHapticDataRequests = YES;
[hapticManager updateInterfaceLayout];

Expand Down Expand Up @@ -296,7 +296,7 @@ BOOL compareRectangle(SDLRectangle *sdlRectangle, CGRect cgRect) {
UITextField *textField1 = [[UITextField alloc] initWithFrame:viewRect1];
[uiViewController.view addSubview:textField1];

hapticManager = [[SDLFocusableItemLocator alloc] initWithViewController:uiViewController connectionManager:sdlLifecycleManager];
hapticManager = [[SDLFocusableItemLocator alloc] initWithViewController:uiViewController connectionManager:sdlLifecycleManager scale:1.f];
hapticManager.enableHapticDataRequests = YES;
[hapticManager updateInterfaceLayout];

Expand Down Expand Up @@ -335,7 +335,7 @@ BOOL compareRectangle(SDLRectangle *sdlRectangle, CGRect cgRect) {
UITextField *textField2 = [[UITextField alloc] initWithFrame:CGRectMake(201, 201, 50, 50)];
[uiViewController.view addSubview:textField2];

hapticManager = [[SDLFocusableItemLocator alloc] initWithViewController:uiViewController connectionManager:sdlLifecycleManager];
hapticManager = [[SDLFocusableItemLocator alloc] initWithViewController:uiViewController connectionManager:sdlLifecycleManager scale:1.f];
hapticManager.enableHapticDataRequests = YES;
[hapticManager updateInterfaceLayout];
});
Expand All @@ -357,7 +357,7 @@ BOOL compareRectangle(SDLRectangle *sdlRectangle, CGRect cgRect) {
UITextField *textField2 = [[UITextField alloc] initWithFrame:CGRectMake(126, 126, 50, 50)];
[uiViewController.view addSubview:textField2];

hapticManager = [[SDLFocusableItemLocator alloc] initWithViewController:uiViewController connectionManager:sdlLifecycleManager];
hapticManager = [[SDLFocusableItemLocator alloc] initWithViewController:uiViewController connectionManager:sdlLifecycleManager scale:1.f];
hapticManager.enableHapticDataRequests = YES;
[hapticManager updateInterfaceLayout];
});
Expand All @@ -373,7 +373,7 @@ BOOL compareRectangle(SDLRectangle *sdlRectangle, CGRect cgRect) {
UITextField *textField1 = [[UITextField alloc] initWithFrame:CGRectMake(101, 101, 50, 50)];
[uiWindow insertSubview:textField1 aboveSubview:uiWindow];

hapticManager = [[SDLFocusableItemLocator alloc] initWithViewController:uiViewController connectionManager:sdlLifecycleManager];
hapticManager = [[SDLFocusableItemLocator alloc] initWithViewController:uiViewController connectionManager:sdlLifecycleManager scale:1.f];
hapticManager.enableHapticDataRequests = YES;
[hapticManager updateInterfaceLayout];
});
Expand Down