summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Fischer <joeljfischer@gmail.com>2020-08-28 11:09:27 -0400
committerJoel Fischer <joeljfischer@gmail.com>2020-08-28 11:09:27 -0400
commit2e0fec19ab24bfb39dc215ee509c2a7d925fbb9c (patch)
tree4f8d34d44288cc342731b21d8db94ae7f7d50fbe
parent865821d208d5fd7ddc6572e8674129925c24e02a (diff)
downloadsdl_ios-2e0fec19ab24bfb39dc215ee509c2a7d925fbb9c.tar.gz
Fix missing nullable annotations
* Fixes for secondary graphic on < 5.0
-rw-r--r--SmartDeviceLink/SDLTextAndGraphicState.m6
-rw-r--r--SmartDeviceLink/SDLTextAndGraphicUpdateOperation.m24
2 files changed, 17 insertions, 13 deletions
diff --git a/SmartDeviceLink/SDLTextAndGraphicState.m b/SmartDeviceLink/SDLTextAndGraphicState.m
index d91b4a6aa..a44b63810 100644
--- a/SmartDeviceLink/SDLTextAndGraphicState.m
+++ b/SmartDeviceLink/SDLTextAndGraphicState.m
@@ -10,9 +10,11 @@
#import "SDLArtwork.h"
+NS_ASSUME_NONNULL_BEGIN
+
@implementation SDLTextAndGraphicState
-- (instancetype)initWithTextField1:(NSString *)textField1 textField2:(NSString *)textField2 textField3:(NSString *)textField3 textField4:(NSString *)textField4 mediaText:(NSString *)mediaTrackTextField title:(NSString *)title primaryGraphic:(SDLArtwork *)primaryGraphic secondaryGraphic:(SDLArtwork *)secondaryGraphic alignment:(SDLTextAlignment)alignment textField1Type:(SDLMetadataType)textField1Type textField2Type:(SDLMetadataType)textField2Type textField3Type:(SDLMetadataType)textField3Type textField4Type:(SDLMetadataType)textField4Type {
+- (instancetype)initWithTextField1:(nullable NSString *)textField1 textField2:(nullable NSString *)textField2 textField3:(nullable NSString *)textField3 textField4:(nullable NSString *)textField4 mediaText:(nullable NSString *)mediaTrackTextField title:(nullable NSString *)title primaryGraphic:(nullable SDLArtwork *)primaryGraphic secondaryGraphic:(nullable SDLArtwork *)secondaryGraphic alignment:(nullable SDLTextAlignment)alignment textField1Type:(nullable SDLMetadataType)textField1Type textField2Type:(nullable SDLMetadataType)textField2Type textField3Type:(nullable SDLMetadataType)textField3Type textField4Type:(nullable SDLMetadataType)textField4Type {
self = [self init];
if (!self) { return nil; }
@@ -42,3 +44,5 @@
}
@end
+
+NS_ASSUME_NONNULL_END
diff --git a/SmartDeviceLink/SDLTextAndGraphicUpdateOperation.m b/SmartDeviceLink/SDLTextAndGraphicUpdateOperation.m
index 8cfd7906a..16267190c 100644
--- a/SmartDeviceLink/SDLTextAndGraphicUpdateOperation.m
+++ b/SmartDeviceLink/SDLTextAndGraphicUpdateOperation.m
@@ -12,14 +12,18 @@
#import "SDLConnectionManagerType.h"
#import "SDLError.h"
#import "SDLFileManager.h"
+#import "SDLGlobals.h"
#import "SDLImage.h"
#import "SDLLogMacros.h"
#import "SDLMetadataTags.h"
#import "SDLShow.h"
#import "SDLTextAndGraphicState.h"
+#import "SDLVersion.h"
#import "SDLWindowCapability.h"
#import "SDLWindowCapability+ScreenManagerExtensions.h"
+NS_ASSUME_NONNULL_BEGIN
+
@interface SDLTextAndGraphicUpdateOperation ()
@property (weak, nonatomic) id<SDLConnectionManagerType> connectionManager;
@@ -436,8 +440,12 @@
BOOL graphicMatchesExisting = [self.currentScreenData.secondaryGraphic.value isEqualToString:self.updatedState.secondaryGraphic.name];
BOOL graphicExists = (self.updatedState.secondaryGraphic != nil);
- // Cannot detect if there is a secondary image, so we'll just try to detect if there's a primary image and allow it if there is.
- return (templateSupportsSecondaryArtwork && !graphicMatchesExisting && graphicExists);
+ // Cannot detect if there is a secondary image below v5.0, so we'll just try to detect if the primary image is allowed and allow the secondary image if it is.
+ if ([[SDLGlobals sharedGlobals].rpcVersion isGreaterThanOrEqualToVersion:[SDLVersion versionWithMajor:5 minor:0 patch:0]]) {
+ return (templateSupportsSecondaryArtwork && !graphicMatchesExisting && graphicExists);
+ } else {
+ return [self.currentCapabilities hasImageFieldOfName:SDLImageFieldNameGraphic];
+ }
}
- (BOOL)sdl_shouldUpdateMediaTextField {
@@ -458,16 +466,6 @@
return [array copy];
}
-- (NSArray<SDLMetadataType> *)sdl_findNonNilMetadataFields {
- NSMutableArray *array = [NSMutableArray array];
- (self.updatedState.textField1Type.length) > 0 ? [array addObject:self.updatedState.textField1Type] : nil;
- (self.updatedState.textField2Type.length) > 0 ? [array addObject:self.updatedState.textField2Type] : nil;
- (self.updatedState.textField3Type.length) > 0 ? [array addObject:self.updatedState.textField3Type] : nil;
- (self.updatedState.textField4Type.length) > 0 ? [array addObject:self.updatedState.textField4Type] : nil;
-
- return [array copy];
-}
-
#pragma mark - Operation Overrides
- (void)finishOperation {
@@ -491,3 +489,5 @@
}
@end
+
+NS_ASSUME_NONNULL_END