Brion VIBBER has submitted this change and it was merged. Change subject: Hooked up basic share sheet. ......................................................................
Hooked up basic share sheet. Change-Id: Ib2eb26ec68515a01204157cc207eee5db66d1e3c --- M wikipedia/Categories/NSString+Extras.h M wikipedia/Categories/NSString+Extras.m M wikipedia/Data/Operations/DownloadNonLeadSectionsOp.m M wikipedia/View Controllers/History/HistoryViewController.m M wikipedia/View Controllers/Navigation/Bottom/BottomMenuViewController.m M wikipedia/View Controllers/Navigation/Top/TopMenuButtonView.m M wikipedia/View Controllers/SavedPages/SavedPagesViewController.m M wikipedia/View Controllers/SearchResults/SearchResultsController.m M wikipedia/View Controllers/WebView/WebViewController.m 9 files changed, 58 insertions(+), 21 deletions(-) Approvals: Brion VIBBER: Verified; Looks good to me, approved diff --git a/wikipedia/Categories/NSString+Extras.h b/wikipedia/Categories/NSString+Extras.h index 2d9a6dd..5574f05 100644 --- a/wikipedia/Categories/NSString+Extras.h +++ b/wikipedia/Categories/NSString+Extras.h @@ -14,6 +14,7 @@ - (NSString *)randomlyRepeatMaxTimes:(NSUInteger)maxTimes; -- (NSString *)cleanWikiTitle; +- (NSString *)wikiTitleWithoutUnderscores; +- (NSString *)wikiTitleWithoutSpaces; @end diff --git a/wikipedia/Categories/NSString+Extras.m b/wikipedia/Categories/NSString+Extras.m index 1b0975e..74fc208 100644 --- a/wikipedia/Categories/NSString+Extras.m +++ b/wikipedia/Categories/NSString+Extras.m @@ -99,9 +99,14 @@ return [NSString stringWithFormat:@"<%@>", [randStr stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]]]; } -- (NSString *)cleanWikiTitle +- (NSString *)wikiTitleWithoutUnderscores { return [self stringByReplacingOccurrencesOfString:@"_" withString:@" "]; } +- (NSString *)wikiTitleWithoutSpaces +{ + return [self stringByReplacingOccurrencesOfString:@" " withString:@"_"]; +} + @end diff --git a/wikipedia/Data/Operations/DownloadNonLeadSectionsOp.m b/wikipedia/Data/Operations/DownloadNonLeadSectionsOp.m index 00048d1..376c605 100644 --- a/wikipedia/Data/Operations/DownloadNonLeadSectionsOp.m +++ b/wikipedia/Data/Operations/DownloadNonLeadSectionsOp.m @@ -68,7 +68,7 @@ NSMutableDictionary *mutableSection = section.mutableCopy; if ([mutableSection[@"fromtitle"] isKindOfClass:[NSString class]]) { NSString *fromTitle = mutableSection[@"fromtitle"]; - if ([[title cleanWikiTitle] isEqualToString:[fromTitle cleanWikiTitle]]) { + if ([[title wikiTitleWithoutUnderscores] isEqualToString:[fromTitle wikiTitleWithoutUnderscores]]) { [mutableSection removeObjectForKey:@"fromtitle"]; } }else{ diff --git a/wikipedia/View Controllers/History/HistoryViewController.m b/wikipedia/View Controllers/History/HistoryViewController.m index 4fffbe3..80fdd4e 100644 --- a/wikipedia/View Controllers/History/HistoryViewController.m +++ b/wikipedia/View Controllers/History/HistoryViewController.m @@ -283,7 +283,7 @@ historyEntry = (History *)[articleDataContext_.mainContext objectWithID:historyEntryId]; }]; - NSString *title = [historyEntry.article.title cleanWikiTitle]; + NSString *title = [historyEntry.article.title wikiTitleWithoutUnderscores]; NSString *language = [NSString stringWithFormat:@"\n%@", historyEntry.article.domainName]; NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init]; diff --git a/wikipedia/View Controllers/Navigation/Bottom/BottomMenuViewController.m b/wikipedia/View Controllers/Navigation/Bottom/BottomMenuViewController.m index 29602ef..a7ec2b2 100644 --- a/wikipedia/View Controllers/Navigation/Bottom/BottomMenuViewController.m +++ b/wikipedia/View Controllers/Navigation/Bottom/BottomMenuViewController.m @@ -12,6 +12,8 @@ #import "TopMenuButtonView.h" #import "TopMenuLabel.h" #import "UIViewController+Alert.h" +#import "UIView+TemporaryAnimatedXF.h" +#import "NSString+Extras.h" typedef NS_ENUM(NSInteger, BottomMenuItemTag) { BOTTOM_MENU_BUTTON_UNKNOWN = 0, @@ -70,14 +72,25 @@ #pragma mark Bottom bar button methods -//TODO: Pull bottomBarView and into own object (and its subviews - the back and forward view/buttons/methods, etc). - - (void)buttonPushed:(UITapGestureRecognizer *)sender { - TopMenuButtonView *tappedButton = (TopMenuButtonView *)sender.view; - if (!tappedButton.enabled)return; + // If the tapped item was a button, first animate it briefly, then perform action. + if([sender.view isKindOfClass:[TopMenuButtonView class]]){ + TopMenuButtonView *button = (TopMenuButtonView *)sender.view; + if (!button.enabled)return; + CGFloat animationScale = 1.25f; + [button.label animateAndRewindXF: CATransform3DMakeScale(animationScale, animationScale, 1.0f) + afterDelay: 0.0 + duration: 0.06f + then: ^{ + [self performActionForButton:button]; + }]; + } +} - switch (tappedButton.tag) { +- (void)performActionForButton:(TopMenuButtonView *)button +{ + switch (button.tag) { case BOTTOM_MENU_BUTTON_PREVIOUS: [self backButtonPushed]; break; @@ -94,8 +107,31 @@ - (void)shareButtonPushed { - [self showAlert:@"TODO: hook up share sheet!"]; - [self fadeAlert]; + NSString *title = @""; + NSURL *URL = nil; + + NSManagedObjectID *articleID = + [articleDataContext_.mainContext getArticleIDForTitle: [SessionSingleton sharedInstance].currentArticleTitle + domain: [SessionSingleton sharedInstance].currentArticleDomain]; + if (articleID) { + Article *article = (Article *)[articleDataContext_.mainContext objectWithID:articleID]; + if (article) { + NSString *titleWithoutSpaces = [article.title wikiTitleWithoutSpaces]; + URL = [NSURL URLWithString:[NSString stringWithFormat:@"https://%@.%@/wiki/%@", article.domain, article.site, titleWithoutSpaces]]; + } + } + + UIActivityViewController *shareActivityViewController = + [[UIActivityViewController alloc] initWithActivityItems: @[title, URL] + applicationActivities: @[]]; + + [self presentViewController:shareActivityViewController animated:YES completion:^{ + + }]; + + [shareActivityViewController setCompletionHandler:^(NSString *activityType, BOOL completed) { + + }]; } - (void)backButtonPushed diff --git a/wikipedia/View Controllers/Navigation/Top/TopMenuButtonView.m b/wikipedia/View Controllers/Navigation/Top/TopMenuButtonView.m index eff696c..156ed0b 100644 --- a/wikipedia/View Controllers/Navigation/Top/TopMenuButtonView.m +++ b/wikipedia/View Controllers/Navigation/Top/TopMenuButtonView.m @@ -42,7 +42,7 @@ -(void)setEnabled:(BOOL)enabled { _enabled = enabled; - self.alpha = (enabled) ? 1.0 : 0.5; + self.alpha = (enabled) ? 1.0 : 0.2; } -(void)constrainLabel diff --git a/wikipedia/View Controllers/SavedPages/SavedPagesViewController.m b/wikipedia/View Controllers/SavedPages/SavedPagesViewController.m index c2e9137..b8e7c43 100644 --- a/wikipedia/View Controllers/SavedPages/SavedPagesViewController.m +++ b/wikipedia/View Controllers/SavedPages/SavedPagesViewController.m @@ -153,7 +153,7 @@ savedEntry = (Saved *)[articleDataContext_.mainContext objectWithID:savedEntryId]; }]; - NSString *title = [savedEntry.article.title cleanWikiTitle]; + NSString *title = [savedEntry.article.title wikiTitleWithoutUnderscores]; NSString *language = [NSString stringWithFormat:@"\n%@", savedEntry.article.domainName]; NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init]; diff --git a/wikipedia/View Controllers/SearchResults/SearchResultsController.m b/wikipedia/View Controllers/SearchResults/SearchResultsController.m index c859374..60d28a9 100644 --- a/wikipedia/View Controllers/SearchResults/SearchResultsController.m +++ b/wikipedia/View Controllers/SearchResults/SearchResultsController.m @@ -185,7 +185,7 @@ NSMutableArray *orderedResults = @[].mutableCopy; for (NSString *title in searchResults) { - NSString *cleanTitle = [title cleanWikiTitle]; + NSString *cleanTitle = [title wikiTitleWithoutUnderscores]; [orderedResults addObject:@{@"title": cleanTitle, @"thumbnail": @{}}.mutableCopy]; } @@ -384,7 +384,7 @@ NSString *title = self.searchResultsOrdered[indexPath.row][@"title"]; // Set CurrentArticleTitle so web view knows what to load. - title = [title cleanWikiTitle]; + title = [title wikiTitleWithoutUnderscores]; [self hideKeyboard]; diff --git a/wikipedia/View Controllers/WebView/WebViewController.m b/wikipedia/View Controllers/WebView/WebViewController.m index 9bde147..d029ea7 100644 --- a/wikipedia/View Controllers/WebView/WebViewController.m +++ b/wikipedia/View Controllers/WebView/WebViewController.m @@ -883,11 +883,6 @@ // [[SessionSingleton sharedInstance].zeroConfigState toggleFakeZeroOn]; } --(NSString *)cleanTitle:(NSString *)title -{ - return [title stringByReplacingOccurrencesOfString:@"_" withString:@" "]; -} - #pragma mark Article loading ops - (void)navigateToPage: (NSString *)title @@ -895,7 +890,7 @@ discoveryMethod: (ArticleDiscoveryMethod)discoveryMethod invalidatingCache: (BOOL)invalidateCache { - NSString *cleanTitle = [self cleanTitle:title]; + NSString *cleanTitle = [title wikiTitleWithoutUnderscores]; // Don't try to load nothing. Core data takes exception with such nonsense. if (cleanTitle == nil) return; -- To view, visit https://gerrit.wikimedia.org/r/134765 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ib2eb26ec68515a01204157cc207eee5db66d1e3c Gerrit-PatchSet: 1 Gerrit-Project: apps/ios/wikipedia Gerrit-Branch: master Gerrit-Owner: Mhurd <mh...@wikimedia.org> Gerrit-Reviewer: Brion VIBBER <br...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits