summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrank Elias <francois.elias@livio.io>2020-12-02 17:24:19 -0500
committerFrank Elias <francois.elias@livio.io>2020-12-02 17:24:19 -0500
commitede6d2e81fee8a036a0e85ad8e9c86866c6ef82b (patch)
treecf621318718b93efdeec183be3640c95c5c825b5
parent3837dc23952a306b29aef27bc9239b74f3eb5d59 (diff)
downloadsdl_ios-ede6d2e81fee8a036a0e85ad8e9c86866c6ef82b.tar.gz
Comments review
-rw-r--r--SmartDeviceLink/private/SDLMenuManager.m6
-rw-r--r--SmartDeviceLink/private/SDLPreloadChoicesOperation.m4
-rw-r--r--SmartDeviceLink/private/SDLTextAndGraphicUpdateOperation.m8
-rw-r--r--SmartDeviceLink/public/SDLFileManager.h17
-rw-r--r--SmartDeviceLink/public/SDLFileManager.m12
5 files changed, 21 insertions, 26 deletions
diff --git a/SmartDeviceLink/private/SDLMenuManager.m b/SmartDeviceLink/private/SDLMenuManager.m
index 5db143e70..e85936414 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 fileNeedsUpload:cell.icon]) {
+ if ([self.fileManager fileNeedsUpload:cell.icon]) {
[mutableArtworks addObject:cell.icon];
}
@@ -554,9 +554,9 @@ UInt32 const MenuCellIdMin = 1;
- (BOOL)sdl_areAllCellArtworksUploaded:(NSArray<SDLMenuCell *> *)cells {
for (SDLMenuCell *cell in cells) {
SDLArtwork *artwork = cell.icon;
- if (artwork != nil && !artwork.isStaticIcon && self.fileManager != nil && ![self.fileManager hasUploadedFile:(artwork)]) {
+ if (artwork != nil && !artwork.isStaticIcon && ![self.fileManager hasUploadedFile:artwork]) {
return NO;
- } else if (cell.subCells != nil && (cell.subCells.count) > 0) {
+ } else if (cell.subCells.count > 0) {
return [self sdl_areAllCellArtworksUploaded:cell.subCells];
}
}
diff --git a/SmartDeviceLink/private/SDLPreloadChoicesOperation.m b/SmartDeviceLink/private/SDLPreloadChoicesOperation.m
index ed7b85fee..7ae83efde 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 fileNeedsUpload:cell.artwork])) {
+ if ([self sdl_shouldSendChoicePrimaryImage] && ([self.fileManager fileNeedsUpload:cell.artwork])) {
[artworksToUpload addObject:cell.artwork];
}
- if ([self sdl_shouldSendChoiceSecondaryImage] && self.fileManager != nil && ([self.fileManager fileNeedsUpload:cell.secondaryArtwork])) {
+ if ([self sdl_shouldSendChoiceSecondaryImage] && ([self.fileManager fileNeedsUpload:cell.secondaryArtwork])) {
[artworksToUpload addObject:cell.secondaryArtwork];
}
}
diff --git a/SmartDeviceLink/private/SDLTextAndGraphicUpdateOperation.m b/SmartDeviceLink/private/SDLTextAndGraphicUpdateOperation.m
index 4aaa75803..e96aa24fe 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 fileNeedsUpload:self.updatedState.primaryGraphic] && ![self.fileManager fileNeedsUpload:self.updatedState.secondaryGraphic]) {
+ } else if (![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) {
@@ -516,11 +516,9 @@ NS_ASSUME_NONNULL_BEGIN
#pragma mark - Should Update
- (BOOL)sdl_isArtworkUploaded:(nullable SDLArtwork *)artwork {
- if (artwork != nil) {
- return artwork.isStaticIcon || (self.fileManager != nil && [self.fileManager hasUploadedFile:artwork]);
- }
+ if (artwork == nil) { return NO; }
- return NO;
+ return (artwork.isStaticIcon || [self.fileManager hasUploadedFile:artwork]);
}
- (BOOL)sdl_shouldUpdatePrimaryImage {
diff --git a/SmartDeviceLink/public/SDLFileManager.h b/SmartDeviceLink/public/SDLFileManager.h
index 5a6929fc7..5010b89e4 100644
--- a/SmartDeviceLink/public/SDLFileManager.h
+++ b/SmartDeviceLink/public/SDLFileManager.h
@@ -137,17 +137,16 @@ typedef void (^SDLFileManagerStartupCompletionHandler)(BOOL success, NSError *__
- (void)uploadFiles:(NSArray<SDLFile *> *)files completionHandler:(nullable SDLFileManagerMultiUploadCompletionHandler)completionHandler NS_SWIFT_NAME(upload(files:completionHandler:));
/**
- * 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.
+ * Check if an SDLFile needs to be uploaded to Core or not. This method differs from hasUploadedFile() because it takes the `isStaticIcon` and `overwrite` properties into consideration.
*
- * @param file the SdlFile that needs to be checked
- * @return boolean that tells whether file needs to be uploaded to Core or not
+ * For example, 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 file the SDLFile that needs to be checked
+ * @return BOOL that tells whether file needs to be uploaded to Core or not
*/
-- (BOOL)fileNeedsUpload:(SDLArtwork *)file;
+- (BOOL)fileNeedsUpload:(SDLFile *)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 8bb29cc58..d89d2b89d 100644
--- a/SmartDeviceLink/public/SDLFileManager.m
+++ b/SmartDeviceLink/public/SDLFileManager.m
@@ -284,13 +284,13 @@ SDLFileManagerState *const SDLFileManagerStateStartupError = @"StartupError";
// HAX: [#827](https://github.com/smartdevicelink/sdl_ios/issues/827) Older versions of Core had a bug where list files would cache incorrectly.
if (file.persistent && [self.remoteFileNames containsObject:file.name]) {
// If it's a persistant file, the bug won't present itself; just check if it's on the remote system
- return true;
+ return YES;
} else if (!file.persistent && [self.remoteFileNames containsObject:file.name] && [self.uploadedEphemeralFileNames containsObject:file.name]) {
// If it's an ephemeral file, the bug will present itself; check that it's a remote file AND that we've uploaded it this session
- return true;
+ return YES;
}
- return false;
+ return NO;
}
- (void)uploadFiles:(NSArray<SDLFile *> *)files completionHandler:(nullable SDLFileManagerMultiUploadCompletionHandler)completionHandler {
@@ -427,11 +427,9 @@ SDLFileManagerState *const SDLFileManagerStateStartupError = @"StartupError";
#pragma mark Artworks
- (BOOL)fileNeedsUpload:(SDLFile *)file {
- if (file != nil && !file.isStaticIcon) {
- return (file.overwrite || ![self hasUploadedFile:file]);
- }
+ if (file == nil || file.isStaticIcon) { return NO; }
- return NO;
+ return (file.overwrite || ![self hasUploadedFile:file]);
}
- (void)uploadArtwork:(SDLArtwork *)artwork completionHandler:(nullable SDLFileManagerUploadArtworkCompletionHandler)completion {