Commit 3e573604 authored by Felix Paul Kühne's avatar Felix Paul Kühne

handoff: fix incorrect category selection

parent ad781be7
......@@ -14,12 +14,13 @@
#import <MediaLibraryKit/MLMediaLibrary.h>
typedef NS_ENUM(NSUInteger, VLCLibraryMode) {
VLCLibraryModeNone = 0,
VLCLibraryModeAllFiles,
VLCLibraryModeAllAlbums,
VLCLibraryModeAllSeries,
};
typedef enum {
VLCLibraryModeAllFiles = 0,
VLCLibraryModeAllAlbums = 1,
VLCLibraryModeAllSeries = 2,
VLCLibraryModeCreateFolder = 3,
VLCLibraryModeFolder = 4
} VLCLibraryMode;
@interface MLMediaLibrary (playlist)
......
......@@ -38,7 +38,7 @@
{
NSMutableArray *objects = [NSMutableArray array];
if (libraryMode == VLCLibraryModeNone) {
if (libraryMode == VLCLibraryModeFolder) {
return objects;
}
......
......@@ -158,7 +158,7 @@
} else {
if (error != nil) {
NSLog(@"removed persistentStore since it was corrupt");
APLog(@"removed persistentStore since it was corrupt");
NSURL *storeURL = ((MLMediaLibrary *)[MLMediaLibrary sharedMediaLibrary]).persistentStoreURL;
[[NSFileManager defaultManager] removeItemAtURL:storeURL error:&error];
}
......@@ -178,12 +178,11 @@
#pragma mark - Handoff
- (BOOL)application:(UIApplication *)application willContinueUserActivityWithType:(NSString *)userActivityType {
if ([userActivityType isEqualToString:@"org.videolan.vlc-ios.librarymode"] ||[userActivityType isEqualToString:@"org.videolan.vlc-ios.playing"]) {
- (BOOL)application:(UIApplication *)application willContinueUserActivityWithType:(NSString *)userActivityType
{
if ([userActivityType isEqualToString:@"org.videolan.vlc-ios.librarymode"] ||[userActivityType isEqualToString:@"org.videolan.vlc-ios.playing"])
return YES;
}
return NO;
}
......@@ -191,9 +190,10 @@
if([userActivity.activityType isEqualToString:@"org.videolan.vlc-ios.librarymode"]) {
NSDictionary *dict = userActivity.userInfo;
NSInteger row = [(NSNumber *)dict[@"state"] integerValue];
VLCLibraryMode row = (VLCLibraryMode)[(NSNumber *)dict[@"state"] integerValue];
[self.menuViewController selectRowAtIndexPath:[NSIndexPath indexPathForRow:row inSection:0] animated:NO scrollPosition:UITableViewScrollPositionTop];
[self.playlistViewController setLibraryMode:(VLCLibraryMode)row];
[self.playlistViewController restoreUserActivityState:userActivity];
_isComingFromHandoff = YES;
return YES;
......@@ -557,10 +557,8 @@
- (void)openMediaFromManagedObject:(NSManagedObject *)mediaObject
{
BOOL retainFullscreenPlayback = false;
if (self.movieViewController.presentingViewController) {
NSLog(@"movie player is open");
if (self.movieViewController.presentingViewController)
retainFullscreenPlayback = YES;
}
VLCPlaybackController *vpc = [VLCPlaybackController sharedInstance];
......@@ -644,7 +642,7 @@
} else if ([name isEqualToString:VLCWatchMessageNameSetVolume]) {
[self setVolumeFromWatch:message];
} else {
NSLog(@"Did not handle request from WatchKit Extension: %@",userInfo);
APLog(@"Did not handle request from WatchKit Extension: %@",userInfo);
}
reply(responseDict);
}
......@@ -658,7 +656,7 @@
managedObject = [[MLMediaLibrary sharedMediaLibrary] objectForURIRepresentation:uriRepresentation];
}
if (managedObject == nil) {
NSLog(@"%s file not found: %@",__PRETTY_FUNCTION__,message);
APLog(@"%s file not found: %@",__PRETTY_FUNCTION__,message);
return;
}
......
......@@ -735,7 +735,6 @@ static NSString *kDisplayedFirstSteps = @"Did we display the first steps tutoria
- (void)swipeRightOnCollectionViewCellGestureAction:(UIGestureRecognizer *)recognizer
{
NSLog(@"swipeRightOnCollectionViewCellGestureAction");
NSIndexPath *path = [self.collectionView indexPathForItemAtPoint:[recognizer locationInView:self.collectionView]];
VLCPlaylistCollectionViewCell *cell = (VLCPlaylistCollectionViewCell *)[self.collectionView cellForItemAtIndexPath:path];
[cell showMetadata:!cell.showsMetaData];
......@@ -1546,15 +1545,18 @@ static NSString *kDisplayedFirstSteps = @"Did we display the first steps tutoria
#pragma mark - handoff
- (void)restoreUserActivityState:(NSUserActivity *)activity {
if([activity.activityType isEqualToString:@"org.videolan.vlc-ios.librarymode"]) {
- (void)restoreUserActivityState:(NSUserActivity *)activity
{
if([activity.activityType isEqualToString:@"org.videolan.vlc-ios.librarymode"])
{
NSDictionary *dict = activity.userInfo;
NSURL *folderURL = dict[@"folder"];
if (!folderURL) return;
for (int i = 0; i<_foundMedia.count; i++){
NSUInteger count = _foundMedia.count;
for (NSUInteger i = 0; i < count; i++) {
NSManagedObject *object = _foundMedia[i];
if([object.objectID.URIRepresentation isEqual:folderURL]) {
[self tableView:self.tableView didSelectRowAtIndexPath:[NSIndexPath indexPathForRow:i inSection:0]];
}
......
......@@ -54,7 +54,7 @@ static NSString *const VLCDBUpdateNotificationRemote = @"org.videolan.ios-app.db
} else {
self.groupObject = context;
self.title = [self.groupObject name];
self.libraryMode = VLCLibraryModeNone;
self.libraryMode = VLCLibraryModeFolder;
}
[self addNowPlayingMenu];
......@@ -82,9 +82,11 @@ static NSString *const VLCDBUpdateNotificationRemote = @"org.videolan.ios-app.db
- (void)table:(WKInterfaceTable *)table didSelectRowAtIndex:(NSInteger)rowIndex {
id object = self.tableController.displayedObjects[rowIndex];
if ([object isKindOfClass:[MLAlbum class]] || [object isKindOfClass:[MLLabel class]] || [object isKindOfClass:[MLShow class]]) {
NSLog(@"we have class %@", [object class]);
[self pushControllerWithName:@"tableViewController" context:object];
[self updateUserActivity:@"org.videolan.vlc-ios.librarymode" userInfo:@{@"state" : @(self.libraryMode), @"folder":((NSManagedObject *)object).objectID.URIRepresentation} webpageURL:nil];
[self updateUserActivity:@"org.videolan.vlc-ios.librarymode"
userInfo:@{@"state" : @(self.libraryMode), @"folder":((NSManagedObject *)object).objectID.URIRepresentation}
webpageURL:nil];
} else {
[self pushControllerWithName:@"detailInfo" context:object];
}
......
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