Commit fe2d7ae6 authored by Carola's avatar Carola Committed by Felix Paul Kühne
Browse files

updated handoff

parent 263e3276
......@@ -61,6 +61,13 @@
<string>org.videolan.vlc-ios</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>NSUserActivityTypes</key>
<array>
<string>org.videolan.vlc-ios.librarymode</string>
<string>org.videolan.vlc-ios.playing</string>
</array>
<key>LSApplicationCategoryType</key>
<string></string>
<key>CFBundleName</key>
<string>VLC for iOS</string>
<key>CFBundlePackageType</key>
......
......@@ -44,6 +44,7 @@
VLCMovieViewController *_movieViewController;
BOOL _passcodeValidated;
BOOL _isRunningMigration;
BOOL _isComingFromHandoff;
}
@end
......@@ -154,9 +155,7 @@
- (BOOL)application:(UIApplication *)application willContinueUserActivityWithType:(NSString *)userActivityType {
if ([userActivityType isEqualToString:@"org.videolan.vlc-ios.librarymode"]) {
//Todo maybe show a spinner here
//might need to setup menu
if ([userActivityType isEqualToString:@"org.videolan.vlc-ios.librarymode"] ||[userActivityType isEqualToString:@"org.videolan.vlc-ios.playing"]) {
return YES;
}
return NO;
......@@ -167,13 +166,10 @@
if([userActivity.activityType isEqualToString:@"org.videolan.vlc-ios.librarymode"]) {
NSDictionary *dict = userActivity.userInfo;
NSInteger row = [(NSNumber *)dict[@"state"] integerValue];
// 0 all
// 1 music
// 2 tvshows
//might need to dismiss spinner
//might need to pass menu to restorationhandler
//then restoreUserActivitystate is called on menuviewcontroller which should in turn call it on underlying vcs
[self.menuViewController selectRowAtIndexPath:[NSIndexPath indexPathForRow:row inSection:0] animated:YES scrollPosition:UITableViewScrollPositionTop];
[self.menuViewController selectRowAtIndexPath:[NSIndexPath indexPathForRow:row inSection:0] animated:NO scrollPosition:UITableViewScrollPositionTop];
[self.playlistViewController restoreUserActivityState:userActivity];
_isComingFromHandoff = YES;
return YES;
}
return NO;
......@@ -328,9 +324,11 @@
- (void)applicationDidBecomeActive:(UIApplication *)application
{
if (!_isRunningMigration) {
if (!_isRunningMigration && !_isComingFromHandoff) {
[[MLMediaLibrary sharedMediaLibrary] updateMediaDatabase];
[self updateMediaList];
} else if(_isComingFromHandoff) {
_isComingFromHandoff = NO;
}
}
......
......@@ -1514,6 +1514,24 @@ static NSString *kDisplayedFirstSteps = @"Did we display the first steps tutoria
return nameRange;
}
#pragma mark - handoff
- (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++){
NSManagedObject *object = _foundMedia[i];
if([object.objectID.URIRepresentation isEqual:folderURL]) {
[self tableView:self.tableView didSelectRowAtIndexPath:[NSIndexPath indexPathForRow:i inSection:0]];
}
}
}
}
- (void)searchDisplayController:(UISearchDisplayController *)controller didLoadSearchResultsTableView:(UITableView *)tableView
{
tableView.rowHeight = 90.;
......
......@@ -89,6 +89,7 @@
@"URIRepresentation": self.managedObject.objectID.URIRepresentation.absoluteString,
}
};
[self updateUserActivity:@"org.videolan.vlc-ios.playing" userInfo:@{@"playingmedia":self.managedObject.objectID.URIRepresentation} webpageURL:nil];
[WKInterfaceController openParentApplication:dict reply:^(NSDictionary *replyInfo, NSError *error) {
[self showNowPlaying:nil];
}];
......
......@@ -111,7 +111,9 @@ typedef enum {
- (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]]) {
[self pushControllerWithName:@"tableViewController" context:object];
[self updateUserActivity:@"org.videolan.vlc-ios.librarymode" userInfo:@{@"state" : @(self.libraryMode), @"folder":((NSManagedObject *)object).objectID.URIRepresentation} webpageURL:nil];
} else {
[self pushControllerWithName:@"detailInfo" context:object];
}
......@@ -301,7 +303,7 @@ typedef enum {
- (void)setLibraryMode:(VLCLibraryMode)libraryMode
{
//should also handle diving into a folder
[self updateUserActivity:@"org.videolan.vlc-ios.librarymode" userInfo:@{@"state" : @(self.libraryMode)} webpageURL:nil];
[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