Skip to content

Commit

Permalink
Refactor FXIOS-10855 #23671 Reenable rating prompt with different rul…
Browse files Browse the repository at this point in the history
…es (#24253)

* - Moved default browser user default to default browser util
- Change logic of rating prompt, remove cumulative days of use counter
- Call rating prompt on init of BVC
- Remove rating prompt from dependency container

* Fix tests

* Use time interval instead of calendar
  • Loading branch information
lmarceau authored Jan 21, 2025
1 parent ae23a35 commit f1074ee
Show file tree
Hide file tree
Showing 12 changed files with 198 additions and 629 deletions.
8 changes: 0 additions & 8 deletions firefox-ios/Client.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1055,8 +1055,6 @@
8ADC2A212A3399DC00543DAA /* YourRightsSetting.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8ADC2A202A3399DC00543DAA /* YourRightsSetting.swift */; };
8ADEC6832A40F208002D2ED8 /* AppSettingsTableViewControllerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8ADEC6822A40F208002D2ED8 /* AppSettingsTableViewControllerTests.swift */; };
8ADED7EC27691351009C19E6 /* CalendarExtensionsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8ADED7EB27691351009C19E6 /* CalendarExtensionsTests.swift */; };
8ADED7EE276A7750009C19E6 /* CumulativeDaysOfUseCounter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8ADED7ED276A7750009C19E6 /* CumulativeDaysOfUseCounter.swift */; };
8ADED7F0276A7788009C19E6 /* CumulativeDaysOfUseCounterTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8ADED7EF276A7788009C19E6 /* CumulativeDaysOfUseCounterTests.swift */; };
8AE0BF4F2819B10E00F33EC4 /* TopSitesSettingsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8AE0BF4E2819B10E00F33EC4 /* TopSitesSettingsViewController.swift */; };
8AE1E1CB27B18F560024C45E /* SearchBarSettingsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8AE1E1CA27B18F560024C45E /* SearchBarSettingsViewController.swift */; };
8AE1E1CD27B191110024C45E /* SearchBarSettingsViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8AE1E1CC27B191110024C45E /* SearchBarSettingsViewModel.swift */; };
Expand Down Expand Up @@ -7880,8 +7878,6 @@
8ADC2A202A3399DC00543DAA /* YourRightsSetting.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YourRightsSetting.swift; sourceTree = "<group>"; };
8ADEC6822A40F208002D2ED8 /* AppSettingsTableViewControllerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppSettingsTableViewControllerTests.swift; sourceTree = "<group>"; };
8ADED7EB27691351009C19E6 /* CalendarExtensionsTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CalendarExtensionsTests.swift; sourceTree = "<group>"; };
8ADED7ED276A7750009C19E6 /* CumulativeDaysOfUseCounter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CumulativeDaysOfUseCounter.swift; sourceTree = "<group>"; };
8ADED7EF276A7788009C19E6 /* CumulativeDaysOfUseCounterTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CumulativeDaysOfUseCounterTests.swift; sourceTree = "<group>"; };
8AE0BF4E2819B10E00F33EC4 /* TopSitesSettingsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TopSitesSettingsViewController.swift; sourceTree = "<group>"; };
8AE1E1CA27B18F560024C45E /* SearchBarSettingsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SearchBarSettingsViewController.swift; sourceTree = "<group>"; };
8AE1E1CC27B191110024C45E /* SearchBarSettingsViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SearchBarSettingsViewModel.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -11538,7 +11534,6 @@
8A1E3BE028CBAC1F003388C4 /* Utils */ = {
isa = PBXGroup;
children = (
8ADED7EF276A7788009C19E6 /* CumulativeDaysOfUseCounterTests.swift */,
8A13FA8E2AD83F00007527AB /* DefaultBackgroundTabLoaderTests.swift */,
961D6B822995AF84001B9CF1 /* GeneralizedImageFetcherTests.swift */,
C8E78BDC27F4A1E700C48BAA /* HistoryDeletionUtilityTests.swift */,
Expand Down Expand Up @@ -14070,7 +14065,6 @@
5AD3B67D2CF665AE00AFA1FE /* UIApplicationInterface.swift */,
5AD3B67B2CF65DE300AFA1FE /* LocaleInterface.swift */,
8A13FA8C2AD834FA007527AB /* BackgroundTabLoader.swift */,
8ADED7ED276A7750009C19E6 /* CumulativeDaysOfUseCounter.swift */,
C8BA0E7527F20B8E00DD8214 /* HistoryDeletionUtility.swift */,
C2296FCB2A601C190046ECA6 /* IntensityVisualEffectView.swift */,
F85C7F112721048E004BDBA4 /* Layout.swift */,
Expand Down Expand Up @@ -16397,7 +16391,6 @@
8AAAB0592C1B7240008830B3 /* MockRustFirefoxSuggest.swift in Sources */,
0BDDB33F2CA6B1F000D501DF /* EditFolderViewModel.swift in Sources */,
602B3D6729B0E1DB0066DEF8 /* ConversionValueUtil.swift in Sources */,
8ADED7EE276A7750009C19E6 /* CumulativeDaysOfUseCounter.swift in Sources */,
7AC7E0502C160FF800051D4D /* ReaderPanelEmptyStateView.swift in Sources */,
4346FF08295BA6A300F4D220 /* CreditCardSettingsViewController.swift in Sources */,
E19B38B528A42EBC00D8C541 /* WallpaperCellViewModel.swift in Sources */,
Expand Down Expand Up @@ -17442,7 +17435,6 @@
8A5189C92C1B614E00CDB668 /* SearchViewModelTests.swift in Sources */,
E1463D0629830E4F0074E16E /* MockUserNotificationCenter.swift in Sources */,
439B78182A09721600CAAE37 /* FormAutofillHelperTests.swift in Sources */,
8ADED7F0276A7788009C19E6 /* CumulativeDaysOfUseCounterTests.swift in Sources */,
8A7653C528A2E69100924ABF /* MockPocketAPI.swift in Sources */,
8A83B74A2A265044002FF9AC /* SettingsCoordinatorTests.swift in Sources */,
E1B9A2C42CADA78300F6A0E9 /* ToolbarTelemetryTests.swift in Sources */,
Expand Down
2 changes: 0 additions & 2 deletions firefox-ios/Client/Application/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate, FeatureFlaggable {
)

lazy var themeManager: ThemeManager = DefaultThemeManager(sharedContainerIdentifier: AppInfo.sharedContainerIdentifier)
lazy var ratingPromptManager = RatingPromptManager(profile: profile)
lazy var appSessionManager: AppSessionProvider = AppSessionManager()
lazy var notificationSurfaceManager = NotificationSurfaceManager()
lazy var tabDataStore = DefaultTabDataStore()
Expand Down Expand Up @@ -168,7 +167,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate, FeatureFlaggable {
if self?.featureFlags.isFeatureEnabled(.cleanupHistoryReenabled, checking: .buildOnly) ?? false {
self?.profile.cleanupHistoryIfNeeded()
}
self?.ratingPromptManager.updateData()
}

DispatchQueue.global().async { [weak self] in
Expand Down
9 changes: 9 additions & 0 deletions firefox-ios/Client/Application/DefaultBrowserUtil.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,15 @@ struct DefaultBrowserUtil {
self.logger = logger
}

enum UserDefaultsKey: String {
case keyIsBrowserDefault = "com.moz.isBrowserDefault.key"
}

static var isBrowserDefault: Bool {
get { UserDefaults.standard.object(forKey: UserDefaultsKey.keyIsBrowserDefault.rawValue) as? Bool ?? false }
set { UserDefaults.standard.set(newValue, forKey: UserDefaultsKey.keyIsBrowserDefault.rawValue) }
}

func processUserDefaultState(isFirstRun: Bool) {
guard #available(iOS 18.2, *) else { return }

Expand Down
3 changes: 0 additions & 3 deletions firefox-ios/Client/Application/DependencyHelper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ class DependencyHelper {
let appSessionProvider: AppSessionProvider = appDelegate.appSessionManager
AppContainer.shared.register(service: appSessionProvider)

let ratingPromptManager: RatingPromptManager = appDelegate.ratingPromptManager
AppContainer.shared.register(service: ratingPromptManager)

let downloadQueue: DownloadQueue = appDelegate.appSessionManager.downloadQueue
AppContainer.shared.register(service: downloadQueue)

Expand Down
2 changes: 1 addition & 1 deletion firefox-ios/Client/Coordinators/Router/RouteBuilder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ final class RouteBuilder: FeatureFlaggable {
}
} else if urlScanner.isHTTPScheme {
TelemetryWrapper.gleanRecordEvent(category: .action, method: .open, object: .asDefaultBrowser)
RatingPromptManager.isBrowserDefault = true
DefaultBrowserUtil.isBrowserDefault = true
// Use the last browsing mode the user was in
return .search(url: url, isPrivate: isPrivate, options: [.focusLocationField])
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class GleanPlumbContextProvider {
}

private var isDefaultBrowser: Bool {
return userDefaults.bool(forKey: RatingPromptManager.UserDefaultsKey.keyIsBrowserDefault.rawValue)
return userDefaults.bool(forKey: DefaultBrowserUtil.UserDefaultsKey.keyIsBrowserDefault.rawValue)
}

private var numberOfAppLaunches: Int32 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,6 @@ class BrowserViewController: UIViewController,
tabManager: TabManager,
themeManager: ThemeManager = AppContainer.shared.resolve(),
notificationCenter: NotificationProtocol = NotificationCenter.default,
ratingPromptManager: RatingPromptManager = AppContainer.shared.resolve(),
downloadQueue: DownloadQueue = AppContainer.shared.resolve(),
logger: Logger = DefaultLogger.shared,
appAuthenticator: AppAuthenticationProtocol = AppAuthenticator()
Expand All @@ -281,7 +280,7 @@ class BrowserViewController: UIViewController,
self.tabManager = tabManager
self.themeManager = themeManager
self.notificationCenter = notificationCenter
self.ratingPromptManager = ratingPromptManager
self.ratingPromptManager = RatingPromptManager(prefs: profile.prefs)
self.readerModeCache = DiskReaderModeCache.sharedInstance
self.downloadQueue = downloadQueue
self.logger = logger
Expand Down Expand Up @@ -345,6 +344,9 @@ class BrowserViewController: UIViewController,
guard !AppEventQueue.activityIsCompleted(.browserUpdatedForAppActivation(tabWindowUUID)) else { return }
self?.browserDidBecomeActive()
}

ratingPromptManager.updateData()
ratingPromptManager.showRatingPromptIfNeeded()
}

@objc
Expand Down
Loading

0 comments on commit f1074ee

Please sign in to comment.