Fjalapeno has submitted this change and it was merged.

Change subject: add bundle info utils and fix About page
......................................................................


add bundle info utils and fix About page

The About page was only showing the build number, not the entire
version. So, I wrote some categories to show either the "release
version" (e.g. 4.1.3) for release builds and "debug version" (4.1.3.96)
for debug builds.

Screenshots:
- debug: 
https://www.dropbox.com/s/154vw45gkt78dn0/debug%20build%20about.png?dl=0
- release: 
https://www.dropbox.com/s/vzgd9sj7rvp6mki/release%20build%20about.png?dl=0

Bug: T97810
Change-Id: I1fa0277214e671520d555a6a3c7816edeee1c93d
---
M Wikipedia.xcodeproj/project.pbxproj
A Wikipedia/Categories/NSBundle+WMFInfoUtils.h
A Wikipedia/Categories/NSBundle+WMFInfoUtils.m
M Wikipedia/View Controllers/About/AboutViewController.m
M Wikipedia/mw-utils/WikipediaAppUtils.m
5 files changed, 86 insertions(+), 7 deletions(-)

Approvals:
  Fjalapeno: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/Wikipedia.xcodeproj/project.pbxproj 
b/Wikipedia.xcodeproj/project.pbxproj
index df0f578..ee16ed9 100644
--- a/Wikipedia.xcodeproj/project.pbxproj
+++ b/Wikipedia.xcodeproj/project.pbxproj
@@ -241,6 +241,7 @@
                BCA9575D1ABE473800B62AE8 /* OldDataSchemaMigratorTests.m in 
Sources */ = {isa = PBXBuildFile; fileRef = BCA9575C1ABE473800B62AE8 /* 
OldDataSchemaMigratorTests.m */; };
                BCA96E731AAA354D009A61FA /* WMFGradientView.m in Sources */ = 
{isa = PBXBuildFile; fileRef = BCA96E721AAA354D009A61FA /* WMFGradientView.m 
*/; };
                BCA96E771AAA35EE009A61FA /* UIView+WMFDefaultNib.m in Sources 
*/ = {isa = PBXBuildFile; fileRef = BCA96E761AAA35EE009A61FA /* 
UIView+WMFDefaultNib.m */; };
+               BCAC50C11AF3F7460015936C /* NSBundle+WMFInfoUtils.m in Sources 
*/ = {isa = PBXBuildFile; fileRef = BCAC50C01AF3F7460015936C /* 
NSBundle+WMFInfoUtils.m */; };
                BCB3AE861AC11320004AD205 /* 
NSPersistentStoreCoordinator+WMFTempCoordinator.m in Sources */ = {isa = 
PBXBuildFile; fileRef = BCB3AE851AC11320004AD205 /* 
NSPersistentStoreCoordinator+WMFTempCoordinator.m */; };
                BCB3AE8A1AC11458004AD205 /* 
NSManagedObjectContext+WMFTempContext.m in Sources */ = {isa = PBXBuildFile; 
fileRef = BCB3AE891AC11458004AD205 /* NSManagedObjectContext+WMFTempContext.m 
*/; };
                BCB3AEA71AC1DDE4004AD205 /* OldDataSchemaMigrator.m in Sources 
*/ = {isa = PBXBuildFile; fileRef = BCB3AEA61AC1DDE4004AD205 /* 
OldDataSchemaMigrator.m */; };
@@ -785,6 +786,8 @@
                BCA96E721AAA354D009A61FA /* WMFGradientView.m */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path 
= WMFGradientView.m; sourceTree = "<group>"; };
                BCA96E751AAA35EE009A61FA /* UIView+WMFDefaultNib.h */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = 
"UIView+WMFDefaultNib.h"; sourceTree = "<group>"; };
                BCA96E761AAA35EE009A61FA /* UIView+WMFDefaultNib.m */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path 
= "UIView+WMFDefaultNib.m"; sourceTree = "<group>"; };
+               BCAC50BF1AF3F7460015936C /* NSBundle+WMFInfoUtils.h */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = 
"NSBundle+WMFInfoUtils.h"; sourceTree = "<group>"; };
+               BCAC50C01AF3F7460015936C /* NSBundle+WMFInfoUtils.m */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path 
= "NSBundle+WMFInfoUtils.m"; sourceTree = "<group>"; };
                BCB3AE841AC11320004AD205 /* 
NSPersistentStoreCoordinator+WMFTempCoordinator.h */ = {isa = PBXFileReference; 
fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = 
"NSPersistentStoreCoordinator+WMFTempCoordinator.h"; sourceTree = "<group>"; };
                BCB3AE851AC11320004AD205 /* 
NSPersistentStoreCoordinator+WMFTempCoordinator.m */ = {isa = PBXFileReference; 
fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = 
"NSPersistentStoreCoordinator+WMFTempCoordinator.m"; sourceTree = "<group>"; };
                BCB3AE881AC11458004AD205 /* 
NSManagedObjectContext+WMFTempContext.h */ = {isa = PBXFileReference; 
fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = 
"NSManagedObjectContext+WMFTempContext.h"; sourceTree = "<group>"; };
@@ -1879,6 +1882,8 @@
                                0EBC567E1AD442CC00E82CDD /* 
BITHockeyManager+WMFExtensions.m */,
                                04B0E3E81AE8252800379AE0 /* NSURL+WMFRest.h */,
                                04B0E3E91AE8252800379AE0 /* NSURL+WMFRest.m */,
+                               BCAC50BF1AF3F7460015936C /* 
NSBundle+WMFInfoUtils.h */,
+                               BCAC50C01AF3F7460015936C /* 
NSBundle+WMFInfoUtils.m */,
                        );
                        path = Categories;
                        sourceTree = "<group>";
@@ -2990,6 +2995,7 @@
                                0443961B1A3C11A30081557D /* 
NearbyResultCollectionCell.m in Sources */,
                                0487048519F8262600B7D307 /* EditTokenFetcher.m 
in Sources */,
                                04CCCFF71935094000E3F60C /* 
PrimaryMenuTableViewCell.m in Sources */,
+                               BCAC50C11AF3F7460015936C /* 
NSBundle+WMFInfoUtils.m in Sources */,
                                0487048F19F8262600B7D307 /* 
WikiTextSectionFetcher.m in Sources */,
                                0EA4402E1AA6281200B09DBA /* 
NSDateFormatter+WMFExtensions.m in Sources */,
                                C913C89C1A94019A00BEEAF0 /* 
WMFSuggestedPagesFunnel.m in Sources */,
diff --git a/Wikipedia/Categories/NSBundle+WMFInfoUtils.h 
b/Wikipedia/Categories/NSBundle+WMFInfoUtils.h
new file mode 100644
index 0000000..d106816
--- /dev/null
+++ b/Wikipedia/Categories/NSBundle+WMFInfoUtils.h
@@ -0,0 +1,34 @@
+//
+//  NSBundle+WMFInfoUtils.h
+//  Wikipedia
+//
+//  Created by Brian Gerstle on 5/1/15.
+//  Copyright (c) 2015 Wikimedia Foundation. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+
+@interface NSBundle (WMFInfoUtils)
+
+/// @return The value for Info.plist key `CFBundleIdentifier`, i.e. the app's 
bundle identifier.
+- (NSString*)wmf_bundleIdentifier;
+
+/// @return `YES` if `wmf_bundleIdentifier` ends in "wikipedia", otherwise 
`NO`.
+- (BOOL)wmf_isAppStoreBundleIdentifier;
+
+/// @return The value for Info.plist key `CFBundleShortVersionString`, i.e. 
the "public" app version.
+- (NSString*)wmf_shortVersionString;
+
+/// @return The value for Info.plist key `CFBundleVersion`, i.e. the build 
number.
+- (NSString*)wmf_bundleVersion;
+
+/// @return A string which represents the full app verison, including the 
build number (e.g. `4.1.3.96`).
+- (NSString*)wmf_debugVersion;
+
+/// Alias for `wmf_shortVersionString`.
+- (NSString*)wmf_releaseVersion;
+
+/// @return Either `wmf_releaseVersion` or `wmf_debugVersion` depending on the 
bundle identifier.
+- (NSString*)wmf_versionForCurrentBundleIdentifier;
+
+@end
diff --git a/Wikipedia/Categories/NSBundle+WMFInfoUtils.m 
b/Wikipedia/Categories/NSBundle+WMFInfoUtils.m
new file mode 100644
index 0000000..485ff92
--- /dev/null
+++ b/Wikipedia/Categories/NSBundle+WMFInfoUtils.m
@@ -0,0 +1,41 @@
+//
+//  NSBundle+WMFInfoUtils.m
+//  Wikipedia
+//
+//  Created by Brian Gerstle on 5/1/15.
+//  Copyright (c) 2015 Wikimedia Foundation. All rights reserved.
+//
+
+#import "NSBundle+WMFInfoUtils.h"
+
+@implementation NSBundle (WMFInfoUtils)
+
+- (NSString*)wmf_bundleIdentifier {
+    return [self objectForInfoDictionaryKey:@"CFBundleIdentifier"];
+}
+
+- (BOOL)wmf_isAppStoreBundleIdentifier {
+    return [[self wmf_bundleIdentifier] hasSuffix:@"wikipedia"];
+}
+
+- (NSString*)wmf_bundleVersion {
+    return [self objectForInfoDictionaryKey:@"CFBundleVersion"] ? : @"";
+}
+
+- (NSString*)wmf_shortVersionString {
+    return [self objectForInfoDictionaryKey:@"CFBundleShortVersionString"] ? : 
@"";
+}
+
+- (NSString*)wmf_releaseVersion {
+    return [self wmf_shortVersionString];
+}
+
+- (NSString*)wmf_debugVersion {
+    return [[self wmf_releaseVersion] stringByAppendingFormat:@".%@", [self 
wmf_bundleVersion] ? : @"0"];
+}
+
+- (NSString*)wmf_versionForCurrentBundleIdentifier {
+    return [self wmf_isAppStoreBundleIdentifier] ? [self wmf_releaseVersion] : 
[self wmf_debugVersion];
+}
+
+@end
diff --git a/Wikipedia/View Controllers/About/AboutViewController.m 
b/Wikipedia/View Controllers/About/AboutViewController.m
index 12e248c..9904ec8 100644
--- a/Wikipedia/View Controllers/About/AboutViewController.m
+++ b/Wikipedia/View Controllers/About/AboutViewController.m
@@ -10,6 +10,7 @@
 #import <BlocksKit/BlocksKit.h>
 #import "TopMenuTextFieldContainer.h"
 #import "TopMenuTextField.h"
+#import "NSBundle+WMFInfoUtils.h"
 
 static NSString* const kWMFAboutHTMLFile  = @"about.html";
 static NSString* const kWMFAboutPlistName = @"AboutViewController";
@@ -239,10 +240,7 @@
          [NSString stringWithFormat:@"document.getElementById('%@').innerHTML 
= \"%@\";", divId, twnString]];
     };
 
-    NSDictionary* appInfo = [[NSBundle mainBundle] infoDictionary];
-    NSString* version     = appInfo[@"CFBundleVersion"] ? 
appInfo[@"CFBundleVersion"] : @"Unknown version";
-
-    setDivHTML(@"version", version);
+    setDivHTML(@"version", [[NSBundle mainBundle] 
wmf_versionForCurrentBundleIdentifier]);
     setDivHTML(@"wikipedia", MWLocalizedString(@"about-wikipedia", nil));
     setDivHTML(@"contributors_title", MWLocalizedString(@"about-contributors", 
nil));
     setDivHTML(@"contributors_body", self.contributors);
diff --git a/Wikipedia/mw-utils/WikipediaAppUtils.m 
b/Wikipedia/mw-utils/WikipediaAppUtils.m
index e0a6b12..c471c2a 100644
--- a/Wikipedia/mw-utils/WikipediaAppUtils.m
+++ b/Wikipedia/mw-utils/WikipediaAppUtils.m
@@ -4,6 +4,7 @@
 #import "WikipediaAppUtils.h"
 #import "WMFAssetsFile.h"
 #import "SessionSingleton.h"
+#import "NSBundle+WMFInfoUtils.h"
 
 NSUInteger MegabytesToBytes(NSUInteger m){
     static NSUInteger const MEGABYTE = 1 << 20;
@@ -22,12 +23,11 @@
 @implementation WikipediaAppUtils
 
 + (NSString*)appVersion {
-    NSDictionary* appInfo = [[NSBundle mainBundle] infoDictionary];
-    return [NSString stringWithFormat:@"%@", [appInfo 
objectForKey:@"CFBundleShortVersionString"]];
+    return [[NSBundle mainBundle] wmf_versionForCurrentBundleIdentifier];
 }
 
 + (NSString*)bundleID {
-    return [[NSBundle mainBundle] 
objectForInfoDictionaryKey:@"CFBundleIdentifier"];
+    return [[NSBundle mainBundle] wmf_bundleVersion];
 }
 
 + (NSString*)formFactor {

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I1fa0277214e671520d555a6a3c7816edeee1c93d
Gerrit-PatchSet: 1
Gerrit-Project: apps/ios/wikipedia
Gerrit-Branch: master
Gerrit-Owner: Bgerstle <bgers...@wikimedia.org>
Gerrit-Reviewer: Fjalapeno <cfl...@wikimedia.org>
Gerrit-Reviewer: Mhurd <mh...@wikimedia.org>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to