summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSatbir Tanda <satbirtanda@gmail.com>2019-07-18 15:38:24 -0700
committerSatbir Tanda <satbirtanda@gmail.com>2019-07-18 15:38:24 -0700
commit1b35cffe83561672063c895af5327cb73eaa2a7c (patch)
treeb34a605fbbf3eb895dd040db26c85898ade3c706
parent37a810c25bd0db744692e9d866dd8340e25987a1 (diff)
downloadsdl_ios-1b35cffe83561672063c895af5327cb73eaa2a7c.tar.gz
Make recommended fixes
-rw-r--r--SmartDeviceLink/SDLLockScreenManager.h2
-rw-r--r--SmartDeviceLink/SDLLockScreenManager.m37
-rw-r--r--SmartDeviceLink/SDLLockScreenViewController.h4
-rw-r--r--SmartDeviceLink/SDLLockScreenViewController.m14
-rw-r--r--SmartDeviceLink/SDLOnDriverDistraction.h8
5 files changed, 28 insertions, 37 deletions
diff --git a/SmartDeviceLink/SDLLockScreenManager.h b/SmartDeviceLink/SDLLockScreenManager.h
index 113c67846..a63e42234 100644
--- a/SmartDeviceLink/SDLLockScreenManager.h
+++ b/SmartDeviceLink/SDLLockScreenManager.h
@@ -25,7 +25,7 @@ NS_ASSUME_NONNULL_BEGIN
/**
* Whether or not the lock screen is currently dismissable
*/
-@property (assign, nonatomic, readonly, getter=isLockScreenDismissable) BOOL lockScreenDismissableEnabled;
+@property (assign, nonatomic, readonly, getter=isLockScreenDismissable) BOOL lockScreenDismissable;
/**
* The lock screen configuration used to set up the manager
diff --git a/SmartDeviceLink/SDLLockScreenManager.m b/SmartDeviceLink/SDLLockScreenManager.m
index 9876bed6b..083b6c136 100644
--- a/SmartDeviceLink/SDLLockScreenManager.m
+++ b/SmartDeviceLink/SDLLockScreenManager.m
@@ -30,7 +30,7 @@ NS_ASSUME_NONNULL_BEGIN
@property (strong, nonatomic) id<SDLViewControllerPresentable> presenter;
@property (strong, nonatomic, nullable) SDLOnLockScreenStatus *lastLockNotification;
@property (strong, nonatomic, nullable) SDLOnDriverDistraction *lastDriverDistractionNotification;
-@property (assign, nonatomic) BOOL lockScreenDismissableEnabled;
+@property (assign, nonatomic, readwrite, getter=isLockScreenDismissable) BOOL lockScreenDismissable;
@end
@@ -44,7 +44,7 @@ NS_ASSUME_NONNULL_BEGIN
}
_canPresent = NO;
- _lockScreenDismissableEnabled = NO;
+ _lockScreenDismissable = NO;
_config = config;
_presenter = presenter;
@@ -131,7 +131,7 @@ NS_ASSUME_NONNULL_BEGIN
}
self.lastDriverDistractionNotification = notification.notification;
- [self sdl_toggleLockscreenDismissalableState];
+ [self sdl_updateLockScreenDismissable];
}
#pragma mark - Private Helpers
@@ -160,42 +160,37 @@ NS_ASSUME_NONNULL_BEGIN
}
}
-- (void)sdl_toggleLockscreenDismissalableState {
+- (void)sdl_updateLockScreenDismissable {
BOOL lastLockScreenDismissableEnabled = [self.lastDriverDistractionNotification.lockScreenDismissalEnabled boolValue];
if (self.lastDriverDistractionNotification == nil || self.lastDriverDistractionNotification.lockScreenDismissalEnabled == nil ||
![self.lastDriverDistractionNotification.lockScreenDismissalEnabled boolValue]) {
- self.lockScreenDismissableEnabled = NO;
+ self.lockScreenDismissable = NO;
} else {
- self.lockScreenDismissableEnabled = YES;
+ self.lockScreenDismissable = YES;
}
- if (lastLockScreenDismissableEnabled != self.lockScreenDismissableEnabled) {
- [self sdl_updateLockscreenDismissalableWithState:self.lockScreenDismissableEnabled];
+ if (lastLockScreenDismissableEnabled != self.lockScreenDismissable) {
+ [self sdl_updateLockscreenViewControllerWithDismissableState:self.lockScreenDismissable];
}
}
-- (void)sdl_updateLockscreenDismissalableWithState:(BOOL)enabled {
+- (void)sdl_updateLockscreenViewControllerWithDismissableState:(BOOL)enabled {
if (![self.lockScreenViewController isKindOfClass:[SDLLockScreenViewController class]]) {
return;
}
__weak typeof(self) weakself = self;
dispatch_async(dispatch_get_main_queue(), ^{
- __strong typeof(self)strongSelf = weakself;
+ __strong typeof(self) strongSelf = weakself;
+ SDLLockScreenViewController *lockscreenViewController = (SDLLockScreenViewController *)strongSelf.lockScreenViewController;
if (enabled) {
- [(SDLLockScreenViewController *)strongSelf.lockScreenViewController addSwipeGestureWithCallback:^{
- [self.presenter dismiss];
+ [lockscreenViewController addDismissGestureWithCallback:^{
+ [strongSelf.presenter dismiss];
}];
-
- if ([self.lockScreenViewController isKindOfClass:[SDLLockScreenViewController class]]) {
- ((SDLLockScreenViewController *)self.lockScreenViewController).lockedLabelText = self.lastDriverDistractionNotification.lockScreenDismissalWarning;
- }
+ lockscreenViewController.lockedLabelText = strongSelf.lastDriverDistractionNotification.lockScreenDismissalWarning;
} else {
- [(SDLLockScreenViewController *)strongSelf.lockScreenViewController removeSwipeGesture];
-
- if ([self.lockScreenViewController isKindOfClass:[SDLLockScreenViewController class]]) {
- ((SDLLockScreenViewController *)self.lockScreenViewController).lockedLabelText = nil;
- }
+ [(SDLLockScreenViewController *)strongSelf.lockScreenViewController removeDismissGesture];
+ lockscreenViewController.lockedLabelText = nil;
}
});
}
diff --git a/SmartDeviceLink/SDLLockScreenViewController.h b/SmartDeviceLink/SDLLockScreenViewController.h
index 4db925b1a..2b19537b5 100644
--- a/SmartDeviceLink/SDLLockScreenViewController.h
+++ b/SmartDeviceLink/SDLLockScreenViewController.h
@@ -37,12 +37,12 @@ typedef void (^SwipeGestureCallbackBlock)(void);
/**
* Adds a swipe gesture to the lock screen view controller.
*/
-- (void)addSwipeGestureWithCallback:(SwipeGestureCallbackBlock)swipeGestureCallback;
+- (void)addDismissGestureWithCallback:(SwipeGestureCallbackBlock)swipeGestureCallback;
/**
* Remove swipe gesture to the lock screen view controller.
*/
-- (void)removeSwipeGesture;
+- (void)removeDismissGesture;
@end
diff --git a/SmartDeviceLink/SDLLockScreenViewController.m b/SmartDeviceLink/SDLLockScreenViewController.m
index 895e668f0..62de5f170 100644
--- a/SmartDeviceLink/SDLLockScreenViewController.m
+++ b/SmartDeviceLink/SDLLockScreenViewController.m
@@ -23,7 +23,7 @@ NS_ASSUME_NONNULL_BEGIN
@property (weak, nonatomic) IBOutlet UILabel *lockedLabel;
@property (weak, nonatomic) IBOutlet UIImageView *arrowUpImageView;
@property (weak, nonatomic) IBOutlet UIImageView *arrowDownImageView;
-@property (strong, nonatomic) SwipeGestureCallbackBlock swipeGestureCallback;
+@property (strong, nonatomic) SwipeGestureCallbackBlock dismissGestureCallback;
@end
@@ -78,19 +78,19 @@ NS_ASSUME_NONNULL_BEGIN
#pragma mark - Swipe Gesture
-- (void)addSwipeGestureWithCallback:(SwipeGestureCallbackBlock)swipeGestureCallback {
- self.swipeGestureCallback = swipeGestureCallback;
- UISwipeGestureRecognizer *swipeGesture = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(didSwipeDown:)];
+- (void)addDismissGestureWithCallback:(SwipeGestureCallbackBlock)swipeGestureCallback {
+ self.dismissGestureCallback = swipeGestureCallback;
+ UISwipeGestureRecognizer *swipeGesture = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(sdl_didSwipeToDismiss:)];
[swipeGesture setDirection: UISwipeGestureRecognizerDirectionDown];
[self.view addGestureRecognizer:swipeGesture];
}
-- (void)removeSwipeGesture {
+- (void)removeDismissGesture {
self.view.gestureRecognizers = [[NSArray alloc] init];
}
-- (void)didSwipeDown:(UISwipeGestureRecognizer *)gesture {
- self.swipeGestureCallback();
+- (void)sdl_didSwipeToDismiss:(UISwipeGestureRecognizer *)gesture {
+ self.dismissGestureCallback();
}
#pragma mark - Layout
diff --git a/SmartDeviceLink/SDLOnDriverDistraction.h b/SmartDeviceLink/SDLOnDriverDistraction.h
index 6c4010153..15ce73184 100644
--- a/SmartDeviceLink/SDLOnDriverDistraction.h
+++ b/SmartDeviceLink/SDLOnDriverDistraction.h
@@ -29,16 +29,12 @@ NS_ASSUME_NONNULL_BEGIN
@property (strong, nonatomic) SDLDriverDistractionState state;
/**
- If enabled, the lock screen will be able to be dismissed while connected to SDL, allowing users
- the ability to interact with the app.
+ If enabled, the lock screen will be able to be dismissed while connected to SDL, allowing users the ability to interact with the app.
*/
@property (strong, nonatomic) NSNumber<SDLBool> *lockScreenDismissalEnabled;
/**
- Warning message to be displayed on the lock screen when dismissal is enabled.
- This warning should be used to ensure that the user is not the driver of the vehicle,
- ex. `Swipe up to dismiss, acknowledging that you are not the driver.`.
- This parameter must be present if "lockScreenDismissalEnabled" is set to true.
+ Warning message to be displayed on the lock screen when dismissal is enabled. This warning should be used to ensure that the user is not the driver of the vehicle, ex. `Swipe up to dismiss, acknowledging that you are not the driver.`. This parameter must be present if "lockScreenDismissalEnabled" is set to true.
*/
@property (strong, nonatomic) NSString *lockScreenDismissalWarning;