Brion VIBBER has submitted this change and it was merged.

Change subject: Fix for search term highlighting font size and TOC updates.
......................................................................


Fix for search term highlighting font size and TOC updates.

When non-lead section of article were retrieved while TOC was
open, there was a regression which caused new sections/images
to not appear in the TOC until it was closed and opened again.

Ran ttfautohint on WikiFont.ttf

Fix for sharing some articles with special characters in
their titles causing app crash.

When you select a search result the top menu switches back
to default chrome.

Returned search result text size - had accidentally shrunken
the result article titles.

Change-Id: I1d96b8f9d01e5077f5091a4ad161a36272ac6112
---
M wikipedia/Categories/Article+Convenience.h
M wikipedia/Categories/Article+Convenience.m
M wikipedia/Defines/Defines.h
M wikipedia/Fonts/WikiFont.ttf
M wikipedia/View Controllers/Navigation/Bottom/BottomMenuViewController.m
M wikipedia/View Controllers/Navigation/Top/TopMenuViewController.m
M wikipedia/View Controllers/SearchResults/SearchResultsController.m
M wikipedia/View Controllers/WebView/WebViewController.m
8 files changed, 54 insertions(+), 24 deletions(-)

Approvals:
  Brion VIBBER: Verified; Looks good to me, approved



diff --git a/wikipedia/Categories/Article+Convenience.h 
b/wikipedia/Categories/Article+Convenience.h
index 8c6dac3..ed58405 100644
--- a/wikipedia/Categories/Article+Convenience.h
+++ b/wikipedia/Categories/Article+Convenience.h
@@ -12,4 +12,6 @@
 // larger than 99 x 99 px.
 - (UIImage *)getThumbnailUsingContext:(NSManagedObjectContext *)context;
 
+- (NSURL *)desktopURL;
+
 @end
diff --git a/wikipedia/Categories/Article+Convenience.m 
b/wikipedia/Categories/Article+Convenience.m
index 167ad22..70a22d0 100644
--- a/wikipedia/Categories/Article+Convenience.m
+++ b/wikipedia/Categories/Article+Convenience.m
@@ -5,6 +5,7 @@
 #import "ArticleCoreDataObjects.h"
 #import "Image+Convenience.h"
 #import "Defines.h"
+#import "NSString+Extras.h"
 
 @implementation Article (Convenience)
 
@@ -88,4 +89,17 @@
     return sectionImages;
 }
 
+-(NSURL *)desktopURL
+{
+    NSString *titleWithoutSpaces = [self.title wikiTitleWithoutSpaces];
+    
+    NSString *urlString =
+        [NSString stringWithFormat:@"https://%@.%@/wiki/%@";, self.domain, 
self.site, titleWithoutSpaces];
+    
+    NSString *encodedUrlString =
+        [urlString 
stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
+    
+    return encodedUrlString ? [NSURL URLWithString:encodedUrlString] : nil;
+}
+
 @end
diff --git a/wikipedia/Defines/Defines.h b/wikipedia/Defines/Defines.h
index 2983b1b..01ab479 100644
--- a/wikipedia/Defines/Defines.h
+++ b/wikipedia/Defines/Defines.h
@@ -4,11 +4,14 @@
 #define SEARCH_RESULT_HEIGHT 60
 #define SEARCH_MAX_RESULTS @"25"
 
-#define SEARCH_FONT [UIFont systemFontOfSize:14.0]
-#define SEARCH_FONT_COLOR [UIColor colorWithWhite:0.0 alpha:0.85]
+#define SEARCH_TEXT_FIELD_FONT [UIFont systemFontOfSize:14.0]
+#define SEARCH_TEXT_FIELD_HIGHLIGHTED_COLOR [UIColor blackColor]
 
-#define SEARCH_FONT_HIGHLIGHTED [UIFont boldSystemFontOfSize:16.0]
-#define SEARCH_FONT_HIGHLIGHTED_COLOR [UIColor blackColor]
+#define SEARCH_RESULT_FONT [UIFont systemFontOfSize:16.0]
+#define SEARCH_RESULT_FONT_COLOR [UIColor colorWithWhite:0.0 alpha:0.85]
+
+#define SEARCH_RESULT_FONT_HIGHLIGHTED [UIFont boldSystemFontOfSize:16.0]
+#define SEARCH_RESULT_FONT_HIGHLIGHTED_COLOR [UIColor blackColor]
 
 #define SEARCH_FIELD_PLACEHOLDER_TEXT_COLOR [UIColor colorWithRed:0.7 
green:0.7 blue:0.7 alpha:1.0]
 
diff --git a/wikipedia/Fonts/WikiFont.ttf b/wikipedia/Fonts/WikiFont.ttf
index ab851d0..66ec0c0 100644
--- a/wikipedia/Fonts/WikiFont.ttf
+++ b/wikipedia/Fonts/WikiFont.ttf
Binary files differ
diff --git a/wikipedia/View 
Controllers/Navigation/Bottom/BottomMenuViewController.m b/wikipedia/View 
Controllers/Navigation/Bottom/BottomMenuViewController.m
index a7ec2b2..b5df308 100644
--- a/wikipedia/View Controllers/Navigation/Bottom/BottomMenuViewController.m
+++ b/wikipedia/View Controllers/Navigation/Bottom/BottomMenuViewController.m
@@ -14,6 +14,7 @@
 #import "UIViewController+Alert.h"
 #import "UIView+TemporaryAnimatedXF.h"
 #import "NSString+Extras.h"
+#import "Article+Convenience.h"
 
 typedef NS_ENUM(NSInteger, BottomMenuItemTag) {
     BOTTOM_MENU_BUTTON_UNKNOWN = 0,
@@ -108,7 +109,7 @@
 - (void)shareButtonPushed
 {
     NSString *title = @"";
-    NSURL *URL = nil;
+    NSURL *desktopURL = nil;
 
     NSManagedObjectID *articleID =
     [articleDataContext_.mainContext getArticleIDForTitle: [SessionSingleton 
sharedInstance].currentArticleTitle
@@ -116,13 +117,18 @@
     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]];
+            desktopURL = [article desktopURL];
+            title = article.title;
         }
     }
     
+    if (!desktopURL) {
+        NSLog(@"Could not retrieve desktop URL for article.")
+        return;
+    }
+    
     UIActivityViewController *shareActivityViewController =
-        [[UIActivityViewController alloc] initWithActivityItems: @[title, URL]
+        [[UIActivityViewController alloc] initWithActivityItems: @[title, 
desktopURL]
                                           applicationActivities: @[]];
     
     [self presentViewController:shareActivityViewController animated:YES 
completion:^{
diff --git a/wikipedia/View Controllers/Navigation/Top/TopMenuViewController.m 
b/wikipedia/View Controllers/Navigation/Top/TopMenuViewController.m
index afd4983..e552ed1 100644
--- a/wikipedia/View Controllers/Navigation/Top/TopMenuViewController.m
+++ b/wikipedia/View Controllers/Navigation/Top/TopMenuViewController.m
@@ -248,8 +248,8 @@
     self.textField.translatesAutoresizingMaskIntoConstraints = NO;
     self.textField.returnKeyType = UIReturnKeyDone;
     self.textField.autocorrectionType = UITextAutocorrectionTypeNo;
-    self.textField.font = SEARCH_FONT;
-    self.textField.textColor = SEARCH_FONT_HIGHLIGHTED_COLOR;
+    self.textField.font = SEARCH_TEXT_FIELD_FONT;
+    self.textField.textColor = SEARCH_TEXT_FIELD_HIGHLIGHTED_COLOR;
     self.textField.tag = NAVBAR_TEXT_FIELD;
     self.textField.clearButtonMode = UITextFieldViewModeNever;
     self.textField.contentVerticalAlignment = 
UIControlContentVerticalAlignmentCenter;
diff --git a/wikipedia/View Controllers/SearchResults/SearchResultsController.m 
b/wikipedia/View Controllers/SearchResults/SearchResultsController.m
index 60d28a9..dd536af 100644
--- a/wikipedia/View Controllers/SearchResults/SearchResultsController.m
+++ b/wikipedia/View Controllers/SearchResults/SearchResultsController.m
@@ -262,11 +262,11 @@
 
     // Set base color and font of the entire result title
     [str addAttribute:NSFontAttributeName
-                value:SEARCH_FONT
+                value:SEARCH_RESULT_FONT
                 range:NSMakeRange(0, str.length)];
 
     [str addAttribute:NSForegroundColorAttributeName
-                value:SEARCH_FONT_COLOR
+                value:SEARCH_RESULT_FONT_COLOR
                 range:NSMakeRange(0, str.length)];
 
     for (NSString *word in self.currentSearchStringWordsToHighlight) {
@@ -278,11 +278,11 @@
                                           ];
 
         [str addAttribute:NSFontAttributeName
-                    value:SEARCH_FONT_HIGHLIGHTED
+                    value:SEARCH_RESULT_FONT_HIGHLIGHTED
                     range:rangeOfThisWordInTitle];
         
         [str addAttribute:NSForegroundColorAttributeName
-                    value:SEARCH_FONT_HIGHLIGHTED_COLOR
+                    value:SEARCH_RESULT_FONT_HIGHLIGHTED_COLOR
                     range:rangeOfThisWordInTitle];
     }
     return str;
diff --git a/wikipedia/View Controllers/WebView/WebViewController.m 
b/wikipedia/View Controllers/WebView/WebViewController.m
index 027e01c..d4c6340 100644
--- a/wikipedia/View Controllers/WebView/WebViewController.m
+++ b/wikipedia/View Controllers/WebView/WebViewController.m
@@ -201,9 +201,9 @@
 {
     [super viewWillAppear:animated];
     
-    if (ROOT.topMenuViewController.navBarMode != NAVBAR_MODE_SEARCH) {
+    //if (ROOT.topMenuViewController.navBarMode != NAVBAR_MODE_SEARCH) {
         ROOT.topMenuViewController.navBarMode = NAVBAR_MODE_DEFAULT;
-    }
+    //}
 }
 
 -(void)viewWillDisappear:(BOOL)animated
@@ -291,8 +291,10 @@
     return (self.webViewLeftConstraint.constant == 0) ? NO : YES;
 }
 
--(void)tocHideWithDurationNextRunLoop:(NSNumber *)duration
+-(void)tocHideIfSafeToToggleDuringNextRunLoopWithDuration:(NSNumber *)duration
 {
+    if(self.unsafeToToggleTOC || !self.tocVC) return;
+
     // iOS 6 can blank out the web view this isn't scheduled for next run loop.
     [[NSRunLoop currentRunLoop] performSelector: 
@selector(tocHideWithDuration:)
                                          target: self
@@ -303,7 +305,6 @@
 
 -(void)tocHideWithDuration:(NSNumber *)duration
 {
-    if(self.unsafeToToggleTOC || !self.tocVC)return;
     self.unsafeToToggleTOC = YES;
 
     // Clear alerts
@@ -330,9 +331,11 @@
                      }];
 }
 
--(void)tocShowWithDurationNextRunLoop:(NSNumber *)duration
+-(void)tocShowIfSafeToToggleDuringNextRunLoopWithDuration:(NSNumber *)duration
 {
     if([[SessionSingleton sharedInstance] isCurrentArticleMain]) return;
+
+    if(self.unsafeToToggleTOC || self.tocVC) return;
 
     // iOS 6 can blank out the web view this isn't scheduled for next run loop.
     [[NSRunLoop currentRunLoop] performSelector: 
@selector(tocShowWithDuration:)
@@ -344,7 +347,6 @@
 
 -(void)tocShowWithDuration:(NSNumber *)duration
 {
-    if(self.unsafeToToggleTOC || self.tocVC)return;
     self.unsafeToToggleTOC = YES;
 
     // Clear alerts
@@ -410,12 +412,12 @@
 
 -(void)tocHide
 {
-    [self tocHideWithDurationNextRunLoop:TOC_TOGGLE_ANIMATION_DURATION];
+    [self 
tocHideIfSafeToToggleDuringNextRunLoopWithDuration:TOC_TOGGLE_ANIMATION_DURATION];
 }
 
 -(void)tocShow
 {
-    [self tocShowWithDurationNextRunLoop:TOC_TOGGLE_ANIMATION_DURATION];
+    [self 
tocShowIfSafeToToggleDuringNextRunLoopWithDuration:TOC_TOGGLE_ANIMATION_DURATION];
 }
 
 -(void)tocToggle
@@ -1309,7 +1311,7 @@
         self.scrollOffset = scrollOffset;
 
 
-        if (mode != DISPLAY_LEAD_SECTION) {
+        if ((mode != DISPLAY_LEAD_SECTION) && ![[SessionSingleton 
sharedInstance] isCurrentArticleMain]) {
             [sectionTextArray addObject: [self renderLanguageButtonForCount: 
langCount.integerValue]];
         }
 
@@ -1329,7 +1331,10 @@
 
         if ([self tocDrawerIsOpen]) {
             // Drawer is already open, so just refresh the toc quickly w/o 
animation.
-            [self tocShowWithDurationNextRunLoop:@0.0f];
+            // Make sure "tocShowWithDuration:" is allowed to happen even if 
the TOC
+            // is already onscreen or non-lead sections won't appear in the 
TOC when
+            // they've been retrieved if the TOC is open.
+            [self tocShowWithDuration:@0.0f];
         }
     }];
 }

-- 
To view, visit https://gerrit.wikimedia.org/r/134775
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I1d96b8f9d01e5077f5091a4ad161a36272ac6112
Gerrit-PatchSet: 4
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

Reply via email to