Commit 32c1b6e2 authored by Felix Paul Kühne's avatar Felix Paul Kühne

CoreSpotlight is iOS only

further, add search item only after parsing
parent 49ed2904
......@@ -26,7 +26,9 @@
*****************************************************************************/
#import <CoreData/CoreData.h>
#if TARGET_OS_IPHONE
#import <CoreSpotlight/CoreSpotlight.h>
#endif
@class MLShowEpisode;
@class MLAlbumTrack;
......@@ -123,8 +125,10 @@ extern NSString *const MLFileThumbnailWasUpdated;
- (size_t)fileSizeInBytes;
#if TARGET_OS_IPHONE
- (CSSearchableItemAttributeSet *)coreSpotlightAttributeSet;
- (void)updateCoreSpotlightEntry;
#endif
@end
......
......@@ -415,9 +415,9 @@ NSString *const MLFileThumbnailWasUpdated = @"MLFileThumbnailWasUpdated";
return [fileSize unsignedLongLongValue];
}
#if TARGET_OS_IPHONE
- (CSSearchableItemAttributeSet *)coreSpotlightAttributeSet
{
#if TARGET_OS_IPHONE
if (!SYSTEM_RUNS_IOS9)
return nil;
......@@ -480,14 +480,10 @@ NSString *const MLFileThumbnailWasUpdated = @"MLFileThumbnailWasUpdated";
}
return attributeSet;
#else
return nil;
#endif
}
- (void)updateCoreSpotlightEntry
{
#if TARGET_OS_IPHONE
if (SYSTEM_RUNS_IOS9) {
/* create final CS item, which will replace the earlier entity */
CSSearchableItemAttributeSet *attributeSet = [self coreSpotlightAttributeSet];
......@@ -498,7 +494,7 @@ NSString *const MLFileThumbnailWasUpdated = @"MLFileThumbnailWasUpdated";
attributeSet:attributeSet];
[[CSSearchableIndex defaultSearchableIndex] indexSearchableItems:@[item] completionHandler:nil];
}
#endif
}
#endif
@end
......@@ -296,7 +296,9 @@
@catch (NSException *exception) {
APLog(@"failed to set that we fetch info for the file");
}
#if TARGET_OS_IPHONE
[file updateCoreSpotlightEntry];
#endif
[self endParsing];
}
......
......@@ -725,25 +725,6 @@ static NSString *kDecrapifyTitles = @"MLDecrapifyTitles";
else
file.title = [title stringByDeletingPathExtension];
#if TARGET_OS_IPHONE
if (SYSTEM_RUNS_IOS9) {
/* add a preliminary CS item, which will be replaced once we have more information */
CSSearchableItemAttributeSet* attributeSet = [[CSSearchableItemAttributeSet alloc] initWithItemContentType:@"public.audiovisual-content"];
attributeSet.title = file.title;
attributeSet.displayName = file.title;
attributeSet.metadataModificationDate = [NSDate date];
CSSearchableItem *item;
item = [[CSSearchableItem alloc] initWithUniqueIdentifier:file.objectID.URIRepresentation.absoluteString
domainIdentifier:_applicationGroupIdentifier
attributeSet:attributeSet];
// Index the item.
[[CSSearchableIndex defaultSearchableIndex] indexSearchableItems:@[item] completionHandler:^(NSError * __nullable error) {
NSLog(@"Search item indexed");
}];
}
#endif
[[MLFileParserQueue sharedFileParserQueue] addFile:file];
}
......
......@@ -134,7 +134,9 @@
UIImage *thumbnailImage = [UIImage imageWithCGImage:thumbnail];
if (thumbnailImage) {
file.computedThumbnail = [UIImage imageWithCGImage:thumbnail];
#if TARGET_OS_IPHONE
[file updateCoreSpotlightEntry];
#endif
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment