iOS: Fix Force Touch shortcuts not working on first launch.

Also makes them continue to work when you change the bundle identifier (necessary if you want to keep a self-compiled version of NewsBlur at the same time as the official version).
This commit is contained in:
Nicholas Riley 2015-12-16 21:57:05 -05:00
parent b04b7c7832
commit 603468d297
2 changed files with 20 additions and 11 deletions

View file

@ -380,6 +380,8 @@
}
if (storiesCollection.inSearch && storiesCollection.searchQuery) {
[self.searchBar setText:storiesCollection.searchQuery];
[self.storyTitlesTable setContentOffset:CGPointMake(0, 0)];
[self.searchBar becomeFirstResponder];
} else {
[self.searchBar setText:@""];
}

View file

@ -250,20 +250,27 @@
- (BOOL)handleShortcutItem:(UIApplicationShortcutItem *)shortcutItem {
NSString *type = shortcutItem.type;
NSString *prefix = [[NSBundle mainBundle].bundleIdentifier stringByAppendingString:@"."];
BOOL handled = YES;
if (!self.dictFeeds) {
if (!self.activeUsername) {
handled = NO;
} else if ([type isEqualToString:@"com.newsblur.NewsBlur.AddFeed"]) {
[self.navigationController popToRootViewControllerAnimated:NO];
[self performSelector:@selector(delayedAddSite) withObject:nil afterDelay:0.0];
} else if ([type isEqualToString:@"com.newsblur.NewsBlur.AllStories"]) {
[self.navigationController popToRootViewControllerAnimated:NO];
[self.feedsViewController didSelectSectionHeaderWithTag:2];
} else if ([type isEqualToString:@"com.newsblur.NewsBlur.Search"]) {
[self.navigationController popToRootViewControllerAnimated:NO];
[self.feedsViewController didSelectSectionHeaderWithTag:2];
[self.feedDetailViewController.searchBar performSelector:@selector(becomeFirstResponder) withObject:nil afterDelay:0.5];
} else if ([type startsWith:prefix]) {
type = [type substringFromIndex:[prefix length]];
if ([type isEqualToString:@"AddFeed"]) {
[self.navigationController popToRootViewControllerAnimated:NO];
[self performSelector:@selector(delayedAddSite) withObject:nil afterDelay:0.0];
} else if ([type isEqualToString:@"AllStories"]) {
[self.navigationController popToRootViewControllerAnimated:NO];
[self.feedsViewController didSelectSectionHeaderWithTag:2];
} else if ([type isEqualToString:@"Search"]) {
[self.navigationController popToRootViewControllerAnimated:NO];
[self.feedsViewController didSelectSectionHeaderWithTag:2];
self.feedDetailViewController.storiesCollection.searchQuery = @"";
self.feedDetailViewController.storiesCollection.inSearch = YES;
} else {
handled = NO;
}
} else {
handled = NO;
}