diff --git a/Source/AccountViewController.swift b/Source/AccountViewController.swift index 99fdf8d4d5..c4c0348e96 100644 --- a/Source/AccountViewController.swift +++ b/Source/AccountViewController.swift @@ -63,7 +63,7 @@ class AccountViewController: UIViewController, UITableViewDelegate, UITableViewD tableView.register(AccountViewCell.self, forCellReuseIdentifier: AccountViewCell.identifier) let textStyle = OEXMutableTextStyle(weight: .normal, size: .base, color : OEXStyles.shared().neutralBlack()) textStyle.alignment = NSTextAlignment.center - versionLabel.attributedText = textStyle.attributedString(withText: Strings.versionDisplay(number: Bundle.main.oex_buildVersionString(), environment: "")) + versionLabel.attributedText = textStyle.attributedString(withText: Strings.versionDisplay(number: Bundle.main.oex_displayVersionString(), environment: "")) versionLabel.accessibilityIdentifier = "AccountViewController:version-label" tableView.accessibilityIdentifier = "AccountViewController:table-view" addConstraints() diff --git a/Source/Core/Code/NSBundle+OEXConveniences.h b/Source/Core/Code/NSBundle+OEXConveniences.h index d19e8e532d..039a00587e 100644 --- a/Source/Core/Code/NSBundle+OEXConveniences.h +++ b/Source/Core/Code/NSBundle+OEXConveniences.h @@ -14,8 +14,10 @@ NS_ASSUME_NONNULL_BEGIN /// The user facing version, like 2.1.2 - (NSString*)oex_shortVersionString; -/// The user facing version, like 2.1.23 +/// The build number, like 6512 - (NSString*)oex_buildVersionString; +/// The user facing version string, like 2.1.2 (6512) +- (NSString*)oex_displayVersionString; /// The user facing app name, like edX - (NSString*)oex_appName; diff --git a/Source/Core/Code/NSBundle+OEXConveniences.m b/Source/Core/Code/NSBundle+OEXConveniences.m index 0fce390c56..6519c31d90 100644 --- a/Source/Core/Code/NSBundle+OEXConveniences.m +++ b/Source/Core/Code/NSBundle+OEXConveniences.m @@ -22,6 +22,10 @@ - (NSString*)oex_buildVersionString { return [[NSBundle mainBundle] objectForInfoDictionaryKey: (__bridge NSString*)kCFBundleVersionKey]; } +- (NSString*)oex_displayVersionString { + return [NSString stringWithFormat:@"%@ (%@)", [self oex_shortVersionString], [self oex_buildVersionString]]; +} + - (NSLocale*)oex_displayLocale { NSString* localization = [NSBundle mainBundle].preferredLocalizations.firstObject; NSLocale* locale = [[NSLocale alloc] initWithLocaleIdentifier:localization]; diff --git a/Source/OEXAnalytics+AppReview.swift b/Source/OEXAnalytics+AppReview.swift index 95c0c3f1ae..d494c23b23 100644 --- a/Source/OEXAnalytics+AppReview.swift +++ b/Source/OEXAnalytics+AppReview.swift @@ -18,7 +18,7 @@ private let rateTheAppDisplayName = "AppReviews: Rate The App" extension OEXAnalytics { private func additionalParams(selectedRating: Int? = nil) -> [String: String] { - var params = [key_app_version : Bundle.main.oex_buildVersionString()] + var params = [key_app_version : Bundle.main.oex_shortVersionString()] if let rating = selectedRating{ params[key_rating] = String(rating) } diff --git a/Source/OEXAnalytics+Swift.swift b/Source/OEXAnalytics+Swift.swift index e7f46cc52a..0ca6eb85d4 100644 --- a/Source/OEXAnalytics+Swift.swift +++ b/Source/OEXAnalytics+Swift.swift @@ -316,7 +316,7 @@ extension OEXAnalytics { event.displayName = AnalyticsDisplayName.CourseSearch.rawValue event.category = AnalyticsCategory.Discovery.rawValue event.label = query - trackEvent(event, forComponent: nil, withInfo: ["action": action, "app_version": Bundle.main.oex_buildVersionString()]) + trackEvent(event, forComponent: nil, withInfo: ["action": action, "app_version": Bundle.main.oex_shortVersionString()]) } func trackChromecastConnected() { @@ -448,7 +448,7 @@ extension OEXAnalytics { event.category = OEXAnalyticsCategoryUserEngagement event.label = AnalyticsCategory.Discovery.rawValue - trackEvent(event, forComponent: nil, withInfo: ["action":"landing_screen","app_version": Bundle.main.oex_buildVersionString()]) + trackEvent(event, forComponent: nil, withInfo: ["action":"landing_screen","app_version": Bundle.main.oex_shortVersionString()]) } func trackResumeCourseTapped(courseID: String, blockID: String) { diff --git a/Source/OEXInterface+AppReview.swift b/Source/OEXInterface+AppReview.swift index ce16b0e1e5..936f83e82f 100644 --- a/Source/OEXInterface+AppReview.swift +++ b/Source/OEXInterface+AppReview.swift @@ -21,7 +21,7 @@ extension OEXInterface { /// Save the app version when app review is done func saveAppVersionWhenLastRated(version: String? = nil) { - UserDefaults.standard.set(version ?? Bundle.main.oex_buildVersionString(), forKey: OEXSavedAppVersionWhenLastRated) + UserDefaults.standard.set(version ?? Bundle.main.oex_shortVersionString(), forKey: OEXSavedAppVersionWhenLastRated) UserDefaults.standard.synchronize() } diff --git a/Source/OEXInterface+WhatsNew.swift b/Source/OEXInterface+WhatsNew.swift index c9f4d2809e..b7145ad4b4 100644 --- a/Source/OEXInterface+WhatsNew.swift +++ b/Source/OEXInterface+WhatsNew.swift @@ -13,7 +13,7 @@ private let WhatsNewShownFor = "whats_new_show_for" extension OEXInterface { // save current version of app on whatsNew appearance func saveAppVersionOnWhatsNewAppear() { - UserDefaults.standard.set(Bundle.main.oex_buildVersionString(), forKey: WhatsNewShownFor) + UserDefaults.standard.set(Bundle.main.oex_shortVersionString(), forKey: WhatsNewShownFor) UserDefaults.standard.synchronize() } diff --git a/Source/OEXInterface.m b/Source/OEXInterface.m index 374ef31ab5..61feb1000a 100644 --- a/Source/OEXInterface.m +++ b/Source/OEXInterface.m @@ -1221,7 +1221,7 @@ - (UserCourseEnrollment*)enrollmentForCourseWithID:(NSString*)courseID { #pragma mark - App Version - (void) saveAppVersion { - [[NSUserDefaults standardUserDefaults] setObject:[NSBundle mainBundle].oex_buildVersionString forKey:OEXSavedAppVersionKey]; + [[NSUserDefaults standardUserDefaults] setObject:[NSBundle mainBundle].oex_shortVersionString forKey:OEXSavedAppVersionKey]; [[NSUserDefaults standardUserDefaults] synchronize]; } diff --git a/Source/OEXLoginViewController.m b/Source/OEXLoginViewController.m index 1aca6bba6a..5ac8fa3682 100644 --- a/Source/OEXLoginViewController.m +++ b/Source/OEXLoginViewController.m @@ -164,7 +164,7 @@ - (void)viewDidLoad { NSString* environmentName = self.environment.config.environmentName; if(environmentName.length > 0) { - NSString* appVersion = [NSBundle mainBundle].oex_buildVersionString; + NSString* appVersion = [NSBundle mainBundle].oex_displayVersionString; self.versionLabel.text = [Strings versionDisplayWithNumber:appVersion environment:environmentName]; } else { diff --git a/Source/RatingViewController.swift b/Source/RatingViewController.swift index dded6a247c..11cc27eae3 100644 --- a/Source/RatingViewController.swift +++ b/Source/RatingViewController.swift @@ -31,7 +31,7 @@ class RatingViewController: UIViewController, RatingContainerDelegate { guard let _ = environment.config.appReviewURI, environment.interface?.reachable ?? false && environment.config.isAppReviewsEnabled else { return false } if let appRating = environment.interface?.getSavedAppRating(), let lastVersionForAppReview = environment.interface?.getSavedAppVersionWhenLastRated(){ - let version = Version(version: (Bundle.main.oex_buildVersionString())) + let version = Version(version: (Bundle.main.oex_shortVersionString())) let savedVersion = Version(version: lastVersionForAppReview) let validVersionDiff = version.isNMinorVersionsDiff(otherVersion: savedVersion, minorVersionDiff: minimumVersionDifferenceForNegativeRating) diff --git a/Source/UserAgentGenerator.swift b/Source/UserAgentGenerator.swift index 01ffc7774a..c89dc344f3 100644 --- a/Source/UserAgentGenerator.swift +++ b/Source/UserAgentGenerator.swift @@ -15,7 +15,7 @@ class UserAgentGenerator: NSObject { static var appVersionDescriptor : String { let bundle = Bundle.main - let components = [bundle.oex_appName(), bundle.bundleIdentifier, bundle.oex_buildVersionString()].compactMap{ return $0 } + let components = [bundle.oex_appName(), bundle.bundleIdentifier, bundle.oex_shortVersionString()].compactMap{ return $0 } return components.joined(separator: "/") } diff --git a/Source/WhatsNewViewController.swift b/Source/WhatsNewViewController.swift index 6de005bb6f..52d6d080e2 100644 --- a/Source/WhatsNewViewController.swift +++ b/Source/WhatsNewViewController.swift @@ -39,7 +39,7 @@ class WhatsNewViewController: UIViewController, UIPageViewControllerDelegate, UI self.dataModel = dataModel } else { - self.dataModel = WhatsNewDataModel(environment: environment as? RouterEnvironment, version: Bundle.main.oex_buildVersionString()) + self.dataModel = WhatsNewDataModel(environment: environment as? RouterEnvironment, version: Bundle.main.oex_shortVersionString()) } titleString = title ?? Strings.WhatsNew.headerText pageController = UIPageViewController(transitionStyle: .scroll, navigationOrientation: .horizontal, options: nil) @@ -52,7 +52,7 @@ class WhatsNewViewController: UIViewController, UIPageViewControllerDelegate, UI } static func canShowWhatsNew(environment: RouterEnvironment?) -> Bool { - let appVersion = Version(version: Bundle.main.oex_buildVersionString()) + let appVersion = Version(version: Bundle.main.oex_shortVersionString()) let savedAppVersion = Version(version: environment?.interface?.getSavedAppVersionForWhatsNew() ?? "") let validDiff = appVersion.isNMinorVersionsDiff(otherVersion: savedAppVersion, minorVersionDiff: 1) return (validDiff && environment?.config.isWhatsNewEnabled ?? false) @@ -185,18 +185,18 @@ class WhatsNewViewController: UIViewController, UIPageViewControllerDelegate, UI //MARK:- Analytics private func logScreenEvent() { - let params = [key_app_version : Bundle.main.oex_buildVersionString()] + let params = [key_app_version : Bundle.main.oex_shortVersionString()] environment.analytics.trackScreen(withName: AnalyticsScreenName.WhatsNew.rawValue, courseID: nil, value: nil, additionalInfo: params) } private func logCloseEvent() { (pagesViewed == 1) ? (pagesViewed = pagesViewed) : (pagesViewed -= 1) - let params = [key_app_version : Bundle.main.oex_buildVersionString(), "total_viewed": pagesViewed, "currently_viewed": currentPageIndex + 1, "total_screens": dataModel.fields?.count ?? 0] as [String : Any] + let params = [key_app_version : Bundle.main.oex_shortVersionString(), "total_viewed": pagesViewed, "currently_viewed": currentPageIndex + 1, "total_screens": dataModel.fields?.count ?? 0] as [String : Any] environment.analytics.trackEvent(whatsNewEvent(name: AnalyticsEventName.WhatsNewClose.rawValue, displayName: "WhatsNew: Close"), forComponent: nil, withInfo: params) } private func logDoneEvent() { - let params = [key_app_version : Bundle.main.oex_buildVersionString(), "total_screens": dataModel.fields?.count ?? 0] as [String : Any] + let params = [key_app_version : Bundle.main.oex_shortVersionString(), "total_screens": dataModel.fields?.count ?? 0] as [String : Any] environment.analytics.trackEvent(whatsNewEvent(name: AnalyticsEventName.WhatsNewDone.rawValue, displayName: "WhatsNew: Done"), forComponent: nil, withInfo: params) } diff --git a/Test/OEXInterface+AppReviewTests.swift b/Test/OEXInterface+AppReviewTests.swift index 8e33026b01..fd1c132e7e 100644 --- a/Test/OEXInterface+AppReviewTests.swift +++ b/Test/OEXInterface+AppReviewTests.swift @@ -37,7 +37,7 @@ class OEXInterface_AppReviewTests: XCTestCase { func testDefaultAppVersion() { interface.saveAppVersionWhenLastRated() - XCTAssertEqual(interface.getSavedAppVersionWhenLastRated(), Bundle.main.oex_buildVersionString()) + XCTAssertEqual(interface.getSavedAppVersionWhenLastRated(), Bundle.main.oex_shortVersionString()) } func testCustomAppVersion() {