diff options
author | Joel Fischer <joeljfischer@gmail.com> | 2022-09-22 10:07:49 -0400 |
---|---|---|
committer | Joel Fischer <joeljfischer@gmail.com> | 2022-09-22 10:07:49 -0400 |
commit | 69befcb68abb3226f39c627a9355eb8fda2ac1dd (patch) | |
tree | 4de6df22dbc32e15e74fcad495649ebdb6049336 | |
parent | b8219ba20f1ce524225c9a69a2f933e8ce40c1e4 (diff) | |
download | sdl_ios-69befcb68abb3226f39c627a9355eb8fda2ac1dd.tar.gz |
2109 - Only track alert icon upload status
* Soft buttons don't show the same bug
-rw-r--r-- | SmartDeviceLink/private/SDLPresentAlertOperation.m | 21 | ||||
-rw-r--r-- | SmartDeviceLinkTests/SDLPresentAlertOperationSpec.m | 6 |
2 files changed, 12 insertions, 15 deletions
diff --git a/SmartDeviceLink/private/SDLPresentAlertOperation.m b/SmartDeviceLink/private/SDLPresentAlertOperation.m index cb3cecde3..28ecec877 100644 --- a/SmartDeviceLink/private/SDLPresentAlertOperation.m +++ b/SmartDeviceLink/private/SDLPresentAlertOperation.m @@ -66,8 +66,7 @@ static const int SDLAlertSoftButtonCount = 4; @property (assign, nonatomic) UInt16 cancelId; @property (copy, nonatomic, nullable) NSError *internalError; @property (assign, atomic) BOOL isAlertPresented; - -@property (strong, nonatomic) NSMutableSet<NSString *> *uploadedImageNames; +@property (assign, nonatomic) BOOL alertIconUploaded; @end @@ -92,7 +91,7 @@ static const int SDLAlertSoftButtonCount = 4; _cancelId = cancelID; _operationId = [NSUUID UUID]; _currentWindowCapability = currentWindowCapability; - _uploadedImageNames = [NSMutableSet set]; + _alertIconUploaded = NO; return self; } @@ -202,19 +201,15 @@ static const int SDLAlertSoftButtonCount = 4; [artworksToBeUploaded addObject:self.alertView.icon]; } else if ([self.fileManager hasUploadedFile:self.alertView.icon] || self.alertView.icon.isStaticIcon) { // If the file is already uploaded, add it to the uploaded set so we can show it - [self.uploadedImageNames addObject:self.alertView.icon.name]; + self.alertIconUploaded = YES; } } // Don't upload artworks for buttons that will not be shown. for (NSUInteger i = 0; i < [self sdl_softButtonCount]; i++) { SDLSoftButtonObject *object = self.alertView.softButtons[i]; - if ([self sdl_supportsSoftButtonImages]) { - if ([self.fileManager fileNeedsUpload:object.currentState.artwork]) { - [artworksToBeUploaded addObject:object.currentState.artwork]; - } else if ([self.fileManager hasUploadedFile:object.currentState.artwork] || object.currentState.artwork.isStaticIcon) { - [self.uploadedImageNames addObject:object.currentState.artwork.name]; - } + if ([self sdl_supportsSoftButtonImages] && [self.fileManager fileNeedsUpload:object.currentState.artwork]) { + [artworksToBeUploaded addObject:object.currentState.artwork]; } } @@ -239,7 +234,9 @@ static const int SDLAlertSoftButtonCount = 4; SDLLogD(@"All alert images uploaded"); } - [strongself.uploadedImageNames addObjectsFromArray:artworkNames]; + if ([artworkNames containsObject:strongself.alertView.icon.name]) { + strongself.alertIconUploaded = YES; + } return handler(); }]; } @@ -308,7 +305,7 @@ static const int SDLAlertSoftButtonCount = 4; SDLAlert *alert = [[SDLAlert alloc] init]; [self sdl_assembleAlertText:alert]; alert.duration = @((NSUInteger)(self.alertView.timeout * 1000)); - alert.alertIcon = [self.uploadedImageNames containsObject:self.alertView.icon.name] ? self.alertView.icon.imageRPC : nil; + alert.alertIcon = self.alertIconUploaded ? self.alertView.icon.imageRPC : nil; alert.progressIndicator = @(self.alertView.showWaitIndicator); alert.cancelID = @(self.cancelId); diff --git a/SmartDeviceLinkTests/SDLPresentAlertOperationSpec.m b/SmartDeviceLinkTests/SDLPresentAlertOperationSpec.m index b464a37fd..06a3efbd7 100644 --- a/SmartDeviceLinkTests/SDLPresentAlertOperationSpec.m +++ b/SmartDeviceLinkTests/SDLPresentAlertOperationSpec.m @@ -42,7 +42,7 @@ @property (strong, nonatomic, readwrite) SDLAlertView *alertView; @property (assign, nonatomic) UInt16 cancelId; @property (copy, nonatomic, nullable) NSError *internalError; -@property (strong, nonatomic) NSSet<NSString *> *uploadedImageNames; +@property (assign, nonatomic) BOOL alertIconUploaded; - (nullable NSError *)sdl_isValidAlertViewData:(SDLAlertView *)alertView; - (SDLAlert *)alertRPC; @@ -372,7 +372,7 @@ describe(@"SDLPresentAlertOperation", ^{ }); it(@"should set the image if it is uploaded to the module", ^{ - testPresentAlertOperation.uploadedImageNames = [NSSet setWithObject:testAlertView.icon.name]; + testPresentAlertOperation.alertIconUploaded = YES; SDLAlert *testAlert = testPresentAlertOperation.alertRPC; expect(testAlert.alertIcon.value).to(equal(testAlertView.icon.name)); @@ -782,7 +782,7 @@ describe(@"SDLPresentAlertOperation", ^{ testAlertViewWithExtraSoftButtons = [[SDLAlertView alloc] initWithText:@"text" secondaryText:@"secondaryText" tertiaryText:@"tertiaryText" timeout:@(4) showWaitIndicator:@(YES) audioIndication:testAlertAudioData buttons:@[testAlertSoftButton1, testAlertSoftButton2, testAlertSoftButton3, testAlertSoftButton4, testAlertSoftButton5, testAlertSoftButton6] icon:testAlertIcon]; testPresentAlertOperation = [[SDLPresentAlertOperation alloc] initWithConnectionManager:mockConnectionManager fileManager:mockFileManager systemCapabilityManager:mockSystemCapabilityManager currentWindowCapability:mockCurrentWindowCapability alertView:testAlertViewWithExtraSoftButtons cancelID:testCancelID]; - testPresentAlertOperation.uploadedImageNames = [NSSet setWithObject:testAlertViewWithExtraSoftButtons.icon.name]; + testPresentAlertOperation.alertIconUploaded = YES; testPresentAlertOperation.completionBlock = ^{ hasCalledOperationCompletionHandler = YES; |