summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrank Elias <francois.elias@livio.io>2020-12-01 11:31:50 -0500
committerFrank Elias <francois.elias@livio.io>2020-12-01 11:31:50 -0500
commit597fd97eb847269d87369b5c106ce9f925ca86ef (patch)
tree4a675561ef1e91cbd2636661cdc064fa4e8b5206
parent0da5e1b9cb0ac3dee52deeb3f140aa787e09564d (diff)
downloadsdl_ios-597fd97eb847269d87369b5c106ce9f925ca86ef.tar.gz
Additional changes to make similar changes to android
-rw-r--r--SmartDeviceLink/private/SDLMenuManager.m13
-rw-r--r--SmartDeviceLink/private/SDLPreloadChoicesOperation.m4
-rw-r--r--SmartDeviceLink/private/SDLSoftButtonReplaceOperation.m6
-rw-r--r--SmartDeviceLink/private/SDLTextAndGraphicUpdateOperation.m4
-rw-r--r--SmartDeviceLink/public/SDLFileManager.h12
-rw-r--r--SmartDeviceLink/public/SDLFileManager.m6
6 files changed, 22 insertions, 23 deletions
diff --git a/SmartDeviceLink/private/SDLMenuManager.m b/SmartDeviceLink/private/SDLMenuManager.m
index b1406805c..5db143e70 100644
--- a/SmartDeviceLink/private/SDLMenuManager.m
+++ b/SmartDeviceLink/private/SDLMenuManager.m
@@ -539,7 +539,7 @@ UInt32 const MenuCellIdMin = 1;
NSMutableSet<SDLArtwork *> *mutableArtworks = [NSMutableSet set];
for (SDLMenuCell *cell in cells) {
- if (self.fileManager != nil && [self.fileManager sdl_artworkNeedsUpload:cell.icon]) {
+ if (self.fileManager != nil && [self.fileManager fileNeedsUpload:cell.icon]) {
[mutableArtworks addObject:cell.icon];
}
@@ -553,7 +553,8 @@ UInt32 const MenuCellIdMin = 1;
- (BOOL)sdl_areAllCellArtworksUploaded:(NSArray<SDLMenuCell *> *)cells {
for (SDLMenuCell *cell in cells) {
- if (![self sdl_isArtworkUploaded:cell.icon]) {
+ SDLArtwork *artwork = cell.icon;
+ if (artwork != nil && !artwork.isStaticIcon && self.fileManager != nil && ![self.fileManager hasUploadedFile:(artwork)]) {
return NO;
} else if (cell.subCells != nil && (cell.subCells.count) > 0) {
return [self sdl_areAllCellArtworksUploaded:cell.subCells];
@@ -563,14 +564,6 @@ UInt32 const MenuCellIdMin = 1;
return YES;
}
-- (BOOL)sdl_isArtworkUploaded:(nullable SDLArtwork *)artwork {
- if (artwork != nil) {
- return artwork.isStaticIcon || (self.fileManager != nil && [self.fileManager hasUploadedFile:artwork]);
- }
-
- return YES;
-}
-
#pragma mark IDs
- (void)sdl_updateIdsOnMenuCells:(NSArray<SDLMenuCell *> *)menuCells parentId:(UInt32)parentId {
diff --git a/SmartDeviceLink/private/SDLPreloadChoicesOperation.m b/SmartDeviceLink/private/SDLPreloadChoicesOperation.m
index 1a1ff6c03..ed7b85fee 100644
--- a/SmartDeviceLink/private/SDLPreloadChoicesOperation.m
+++ b/SmartDeviceLink/private/SDLPreloadChoicesOperation.m
@@ -87,10 +87,10 @@ NS_ASSUME_NONNULL_BEGIN
NSMutableArray<SDLArtwork *> *artworksToUpload = [NSMutableArray arrayWithCapacity:self.cellsToUpload.count];
for (SDLChoiceCell *cell in self.cellsToUpload) {
- if ([self sdl_shouldSendChoicePrimaryImage] && (self.fileManager != nil && [self.fileManager sdl_artworkNeedsUpload:cell.artwork])) {
+ if ([self sdl_shouldSendChoicePrimaryImage] && self.fileManager != nil && ([self.fileManager fileNeedsUpload:cell.artwork])) {
[artworksToUpload addObject:cell.artwork];
}
- if ([self sdl_shouldSendChoiceSecondaryImage] && (self.fileManager != nil && [self.fileManager sdl_artworkNeedsUpload:cell.secondaryArtwork])) {
+ if ([self sdl_shouldSendChoiceSecondaryImage] && self.fileManager != nil && ([self.fileManager fileNeedsUpload:cell.secondaryArtwork])) {
[artworksToUpload addObject:cell.secondaryArtwork];
}
}
diff --git a/SmartDeviceLink/private/SDLSoftButtonReplaceOperation.m b/SmartDeviceLink/private/SDLSoftButtonReplaceOperation.m
index 40656d9ce..b4fa5f169 100644
--- a/SmartDeviceLink/private/SDLSoftButtonReplaceOperation.m
+++ b/SmartDeviceLink/private/SDLSoftButtonReplaceOperation.m
@@ -103,7 +103,7 @@ NS_ASSUME_NONNULL_BEGIN
- (void)sdl_uploadInitialStateImagesWithCompletionHandler:(void (^)(void))handler {
NSMutableArray<SDLArtwork *> *initialStatesToBeUploaded = [NSMutableArray array];
for (SDLSoftButtonObject *object in self.softButtonObjects) {
- if (self.fileManager != nil && [self.fileManager sdl_artworkNeedsUpload:object.currentState.artwork]) {
+ if (self.fileManager != nil && [self.fileManager fileNeedsUpload:object.currentState.artwork] && self.softButtonCapabilities.imageSupported.boolValue) {
[initialStatesToBeUploaded addObject:object.currentState.artwork];
}
}
@@ -118,7 +118,7 @@ NS_ASSUME_NONNULL_BEGIN
for (SDLSoftButtonObject *object in self.softButtonObjects) {
for (SDLSoftButtonState *state in object.states) {
if ([state.name isEqualToString:object.currentState.name]) { continue; }
- if (self.fileManager != nil && [self.fileManager sdl_artworkNeedsUpload:state.artwork]) {
+ if (self.fileManager != nil && [self.fileManager fileNeedsUpload:state.artwork] && self.softButtonCapabilities.imageSupported.boolValue) {
[otherStatesToBeUploaded addObject:state.artwork];
}
}
@@ -233,7 +233,7 @@ NS_ASSUME_NONNULL_BEGIN
for (SDLSoftButtonObject *button in self.softButtonObjects) {
for (SDLSoftButtonState *state in button.states) {
SDLArtwork *artwork = state.artwork;
- if (self.fileManager != nil && ![self.fileManager sdl_artworkNeedsUpload:artwork]) { continue; }
+ if (self.fileManager != nil && ![self.fileManager fileNeedsUpload:artwork] && self.softButtonCapabilities.imageSupported.boolValue) { continue; }
return NO;
}
}
diff --git a/SmartDeviceLink/private/SDLTextAndGraphicUpdateOperation.m b/SmartDeviceLink/private/SDLTextAndGraphicUpdateOperation.m
index 2527148ec..4aaa75803 100644
--- a/SmartDeviceLink/private/SDLTextAndGraphicUpdateOperation.m
+++ b/SmartDeviceLink/private/SDLTextAndGraphicUpdateOperation.m
@@ -111,7 +111,7 @@ NS_ASSUME_NONNULL_BEGIN
}
[strongSelf finishOperation];
}];
- } else if (self.fileManager != nil && ![self.fileManager sdl_artworkNeedsUpload:self.updatedState.primaryGraphic] && ![self.fileManager sdl_artworkNeedsUpload:self.updatedState.secondaryGraphic]) {
+ } else if (self.fileManager != nil && ![self.fileManager fileNeedsUpload:self.updatedState.primaryGraphic] && ![self.fileManager fileNeedsUpload:self.updatedState.secondaryGraphic]) {
SDLLogV(@"Images already uploaded, sending full update");
// The files to be updated are already uploaded, send the full show immediately
[self sdl_sendShow:show withHandler:^(NSError * _Nullable error) {
@@ -520,7 +520,7 @@ NS_ASSUME_NONNULL_BEGIN
return artwork.isStaticIcon || (self.fileManager != nil && [self.fileManager hasUploadedFile:artwork]);
}
- return YES;
+ return NO;
}
- (BOOL)sdl_shouldUpdatePrimaryImage {
diff --git a/SmartDeviceLink/public/SDLFileManager.h b/SmartDeviceLink/public/SDLFileManager.h
index 5a5260ebe..5a6929fc7 100644
--- a/SmartDeviceLink/public/SDLFileManager.h
+++ b/SmartDeviceLink/public/SDLFileManager.h
@@ -137,11 +137,17 @@ typedef void (^SDLFileManagerStartupCompletionHandler)(BOOL success, NSError *__
- (void)uploadFiles:(NSArray<SDLFile *> *)files completionHandler:(nullable SDLFileManagerMultiUploadCompletionHandler)completionHandler NS_SWIFT_NAME(upload(files:completionHandler:));
/**
- * Check if artwork needs to be uploaded.
+ * Check if an SdlFile needs to be uploaded to Core or not.
+ * It is different from hasUploadedFile() because it takes isStaticIcon and overwrite properties into consideration.
+ * ie, if the file is static icon, the method always returns false.
+ * If the file is dynamic, it returns true in one of these situations:
+ * 1) the file has the overwrite property set to true
+ * 2) the file hasn't been uploaded to Core before.
*
- * @param artwork A SDLArwork containing an image to be sent
+ * @param file the SdlFile that needs to be checked
+ * @return boolean that tells whether file needs to be uploaded to Core or not
*/
-- (BOOL)sdl_artworkNeedsUpload:(SDLArtwork *)artwork;
+- (BOOL)fileNeedsUpload:(SDLArtwork *)file;
/**
* Uploads an artwork file to the remote file system and returns the name of the uploaded artwork once completed. If an artwork with the same name is already on the remote system, the artwork is not uploaded and the artwork name is simply returned.
diff --git a/SmartDeviceLink/public/SDLFileManager.m b/SmartDeviceLink/public/SDLFileManager.m
index 2503533ff..8bb29cc58 100644
--- a/SmartDeviceLink/public/SDLFileManager.m
+++ b/SmartDeviceLink/public/SDLFileManager.m
@@ -426,9 +426,9 @@ SDLFileManagerState *const SDLFileManagerStateStartupError = @"StartupError";
#pragma mark Artworks
-- (BOOL)sdl_artworkNeedsUpload:(SDLArtwork *)artwork {
- if (artwork != nil && !artwork.isStaticIcon) {
- return (artwork.overwrite || ![self hasUploadedFile:artwork]);
+- (BOOL)fileNeedsUpload:(SDLFile *)file {
+ if (file != nil && !file.isStaticIcon) {
+ return (file.overwrite || ![self hasUploadedFile:file]);
}
return NO;