Commit 8d461ba8 authored by Felix Paul Kühne's avatar Felix Paul Kühne

handoff: further clean-up and partial fixes

parent 276ebd7d
......@@ -64,6 +64,7 @@
<key>NSUserActivityTypes</key>
<array>
<string>org.videolan.vlc-ios.librarymode</string>
<string>org.videolan.vlc-ios.libraryselection</string>
<string>org.videolan.vlc-ios.playing</string>
</array>
<key>LSApplicationCategoryType</key>
......
......@@ -180,20 +180,30 @@
- (BOOL)application:(UIApplication *)application willContinueUserActivityWithType:(NSString *)userActivityType
{
if ([userActivityType isEqualToString:@"org.videolan.vlc-ios.librarymode"] ||[userActivityType isEqualToString:@"org.videolan.vlc-ios.playing"])
if ([userActivityType isEqualToString:@"org.videolan.vlc-ios.librarymode"] ||
[userActivityType isEqualToString:@"org.videolan.vlc-ios.playing"] ||
[userActivityType isEqualToString:@"org.videolan.vlc-ios.libraryselection"])
return YES;
return NO;
}
- (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void (^)(NSArray *))restorationHandler {
- (BOOL)application:(UIApplication *)application
continueUserActivity:(NSUserActivity *)userActivity
restorationHandler:(void (^)(NSArray *))restorationHandler
{
NSString *userActivityType = userActivity.activityType;
if([userActivity.activityType isEqualToString:@"org.videolan.vlc-ios.librarymode"]) {
if([userActivityType isEqualToString:@"org.videolan.vlc-ios.librarymode"] ||
[userActivityType isEqualToString:@"org.videolan.vlc-ios.libraryselection"]) {
NSDictionary *dict = userActivity.userInfo;
VLCLibraryMode row = (VLCLibraryMode)[(NSNumber *)dict[@"state"] integerValue];
VLCLibraryMode libraryMode = (VLCLibraryMode)[(NSNumber *)dict[@"state"] integerValue];
if (libraryMode <= VLCLibraryModeAllSeries) {
[self.menuViewController selectRowAtIndexPath:[NSIndexPath indexPathForRow:libraryMode inSection:0] animated:NO scrollPosition:UITableViewScrollPositionTop];
[self.playlistViewController setLibraryMode:(VLCLibraryMode)libraryMode];
}
[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;
......
......@@ -15,12 +15,7 @@
#define EXPERIMENTAL_LIBRARY 1
typedef enum {
VLCLibraryModeAllFiles = 0,
VLCLibraryModeAllAlbums = 1,
VLCLibraryModeAllSeries = 2,
VLCLibraryModeCreateFolder = 3
} VLCLibraryMode;
#import "MLMediaLibrary+playlist.h"
@class EmptyLibraryView;
......
......@@ -1551,11 +1551,14 @@ static NSString *kDisplayedFirstSteps = @"Did we display the first steps tutoria
- (void)restoreUserActivityState:(NSUserActivity *)activity
{
if([activity.activityType isEqualToString:@"org.videolan.vlc-ios.librarymode"])
{
NSString *userActivityType = activity.activityType;
if([userActivityType isEqualToString:@"org.videolan.vlc-ios.librarymode"] ||
[userActivityType isEqualToString:@"org.videolan.vlc-ios.libraryselection"]) {
NSDictionary *dict = activity.userInfo;
NSURL *folderURL = dict[@"folder"];
if (!folderURL) return;
NSString *folderPath = dict[@"folder"];
if (!folderPath) return;
NSURL *folderURL = [NSURL URLWithString:folderPath];
NSUInteger count = _foundMedia.count;
for (NSUInteger i = 0; i < count; i++) {
......
......@@ -81,11 +81,16 @@ 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}
NSString *folderRepresentation = [((NSManagedObject *)object).objectID.URIRepresentation absoluteString];
NSDictionary *userDict = @{@"state" : @(self.libraryMode),
@"folder" : folderRepresentation};
[self invalidateUserActivity];
[self updateUserActivity:@"org.videolan.vlc-ios.libraryselection"
userInfo:userDict
webpageURL:nil];
} else {
[self pushControllerWithName:@"detailInfo" context:object];
......@@ -138,6 +143,7 @@ static NSString *const VLCDBUpdateNotificationRemote = @"org.videolan.ios-app.db
- (void)setLibraryMode:(VLCLibraryMode)libraryMode
{
//should also handle diving into a folder
[self invalidateUserActivity];
[self updateUserActivity:@"org.videolan.vlc-ios.librarymode" userInfo:@{@"state" : @(libraryMode)} webpageURL:nil];
_libraryMode = libraryMode;
}
......
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