Commit 99628b4e authored by Felix Paul Kühne's avatar Felix Paul Kühne

Add 3D Touch Quick Actions (closes #16359)

parent b888fcae
......@@ -183,6 +183,33 @@ NSString *const VLCDropboxSessionWasAuthorized = @"VLCDropboxSessionWasAuthorize
[_watchCommunication startRelayingNotificationName:VLCPlaybackControllerPlaybackMetadataDidChange object:nil];
}
/* add our static shortcut items the dynamic way to ease l10n and dynamic elements to be introduced later */
if ([UIApplicationShortcutItem class] != nil) {
if (application.shortcutItems == nil || application.shortcutItems.count < 4) {
UIApplicationShortcutItem *localLibraryItem = [[UIApplicationShortcutItem alloc] initWithType:kVLCApplicationShortcutLocalLibrary
localizedTitle:NSLocalizedString(@"SECTION_HEADER_LIBRARY",nil)
localizedSubtitle:nil
icon:[UIApplicationShortcutIcon iconWithTemplateImageName:@"AllFiles"]
userInfo:nil];
UIApplicationShortcutItem *localServerItem = [[UIApplicationShortcutItem alloc] initWithType:kVLCApplicationShortcutLocalServers
localizedTitle:NSLocalizedString(@"LOCAL_NETWORK",nil)
localizedSubtitle:nil
icon:[UIApplicationShortcutIcon iconWithTemplateImageName:@"Local"]
userInfo:nil];
UIApplicationShortcutItem *openNetworkStreamItem = [[UIApplicationShortcutItem alloc] initWithType:kVLCApplicationShortcutOpenNetworkStream
localizedTitle:NSLocalizedString(@"OPEN_NETWORK",nil)
localizedSubtitle:nil
icon:[UIApplicationShortcutIcon iconWithTemplateImageName:@"OpenNetStream"]
userInfo:nil];
UIApplicationShortcutItem *cloudsItem = [[UIApplicationShortcutItem alloc] initWithType:kVLCApplicationShortcutClouds
localizedTitle:NSLocalizedString(@"CLOUD_SERVICES",nil)
localizedSubtitle:nil
icon:[UIApplicationShortcutIcon iconWithTemplateImageName:@"iCloudIcon"]
userInfo:nil];
application.shortcutItems = @[localLibraryItem, localServerItem, openNetworkStreamItem, cloudsItem];
}
}
return YES;
}
......@@ -385,6 +412,11 @@ didFailToContinueUserActivityWithType:(NSString *)userActivityType
[[NSUserDefaults standardUserDefaults] synchronize];
}
- (void)application:(UIApplication *)application performActionForShortcutItem:(UIApplicationShortcutItem *)shortcutItem completionHandler:(void (^)(BOOL))completionHandler
{
[[VLCSidebarController sharedInstance] performActionForShortcutItem:shortcutItem];
}
#pragma mark - media discovering
- (void)mediaFileAdded:(NSString *)fileName loading:(BOOL)isLoading
......
......@@ -95,6 +95,11 @@
#define kVLCUserActivityLibrarySelection @"org.videolan.vlc-ios.libraryselection"
#define kVLCUserActivityLibraryMode @"org.videolan.vlc-ios.librarymode"
#define kVLCApplicationShortcutLocalLibrary @"ApplicationShortcutLocalLibrary"
#define kVLCApplicationShortcutLocalServers @"ApplicationShortcutLocalServers"
#define kVLCApplicationShortcutOpenNetworkStream @"ApplicationShortcutOpenNetworkStream"
#define kVLCApplicationShortcutClouds @"ApplicationShortcutClouds"
/* LEGACY KEYS, DO NOT USE IN NEW CODE */
#define kVLCFTPServer @"ftp-server"
#define kVLCFTPLogin @"ftp-login"
......
......@@ -324,8 +324,10 @@ static NSString *WiFiCellIdentifier = @"VLCMenuWiFiCell";
[(VLCLibraryViewController *)viewController setLibraryMode:(int)itemIndex];
}
if (!viewController)
if (!viewController) {
APLog(@"no view controller found for menu item");
return;
}
VLCSidebarController *sidebarController = [VLCSidebarController sharedInstance];
if ([sidebarController.contentViewController isKindOfClass:[UINavigationController class]]) {
......
......@@ -22,6 +22,8 @@
- (void)selectRowAtIndexPath:(NSIndexPath *)indexPath scrollPosition:(UITableViewScrollPosition)scrollPosition;
- (void)performActionForShortcutItem:(UIApplicationShortcutItem *)shortcutItem;
@property (readonly) UIViewController *fullViewController;
@property (readwrite, retain) UIViewController *contentViewController;
......
......@@ -119,4 +119,18 @@
}
}
- (void)performActionForShortcutItem:(UIApplicationShortcutItem *)shortcutItem
{
NSString *itemType = shortcutItem.type;
if ([itemType isEqualToString:kVLCApplicationShortcutLocalLibrary]) {
[self selectRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] scrollPosition:UITableViewScrollPositionNone];
} else if ([itemType isEqualToString:kVLCApplicationShortcutLocalServers]) {
[self selectRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:1] scrollPosition:UITableViewScrollPositionNone];
} else if ([itemType isEqualToString:kVLCApplicationShortcutOpenNetworkStream]) {
[self selectRowAtIndexPath:[NSIndexPath indexPathForRow:1 inSection:1] scrollPosition:UITableViewScrollPositionNone];
} else if ([itemType isEqualToString:kVLCApplicationShortcutClouds]) {
[self selectRowAtIndexPath:[NSIndexPath indexPathForRow:4 inSection:1] scrollPosition:UITableViewScrollPositionNone];
}
}
@end
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