-
Notifications
You must be signed in to change notification settings - Fork 262
Conversation
…to oliviabrown9/screen-tips
@joeyg Would love if you could take a look at this! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some cleanup necessary here. I encountered the following bugs:
Favorite Site
When using the favorite site tip's cancel button, you then have to press "Done" again, making it cumbersome to get back to the home view.
Siri Shortcut
When we open the Siri Shortcut options, it's not immediately clear where they're at. Is it possible to scroll the tableView to that position before it's loaded so it's easily visible?
No max tips
Currently, every tip is getting shown before the "Browse Erase Repeat" text comes back. On Android we only show 3 tips before going back to that text. Not sure if this is a deliberate change for iOS though!
Blockzilla/AppDelegate.swift
Outdated
@@ -266,6 +277,10 @@ class AppDelegate: UIResponder, UIApplicationDelegate, ModalDelegate, AppSplashC | |||
|
|||
} | |||
|
|||
func applicationWillEnterForeground(_ application: UIApplication) { | |||
browserViewController.tipManager = TipManager() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems expensive to construct every time we enter the foreground. Is there a smaller function we can run instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I personally don't think this is an issue. The only option would be to reset the TipManager's possible tips, but this is essentially all that re-initializing it does as well, unless I'm mistaken.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair point! Another side effect: if I background the app and open it again, it's possible I see a tip I just saw (after I navigate away and press erase). This is more related to the "only show 3 tips" thing, but I could hypothetically get 3 of the same tip if I close the app in between each erase, which seems bad IMO
|
||
return shouldShowTrackerStatsToUser == true && | ||
getNumberOfLifetimeTrackersBlocked(userDefaults: userDefaults) >= 10 | ||
let shouldShowTipsToUser = userDefaults.object(forKey: BrowserViewController.userDefaultsShareTrackerStatsKeyNEW) as! Bool? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this key correct? "userDefaultsShareTrackerStatsKeyNEW"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately, yes
case TipManager.TipKey.biometricTip, TipManager.TipKey.siriEraseTip: | ||
showSettings() | ||
case TipManager.TipKey.siriFavoriteTip: | ||
if #available(iOS 12.0, *) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this tip be shown at all if the user isn't on iOS 12? Perhaps this if #available should be placed elsewhere?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I construct it so that this tip never gets added to the possible tips in the TipManager. However, because the SiriFavoriteVC is only @/available for iOS 12, the compiler requires an additional check. Users should never have the option to click on this tip (because it will never be possible)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, it's an annoying compiler thing; I was wondering why we were checking twice. Makes sense!
Blockzilla/HomeView.swift
Outdated
tipTitleLabel.textColor = UIConstants.colors.defaultFont | ||
tipTitleLabel.font = UIConstants.fonts.shareTrackerStatsLabel | ||
tipTitleLabel.numberOfLines = 0 | ||
tipTitleLabel.minimumScaleFactor = 0.65 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: magic number (could we change the trackerStatsLabel to use whatever constant this ends up having too?)
Blockzilla/HomeView.swift
Outdated
@@ -117,21 +162,55 @@ class HomeView: UIView { | |||
fatalError("init(coder:) has not been implemented") | |||
} | |||
|
|||
func showTipView() { | |||
description1.isHidden = true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know you didn't add this variable, but this is an awful name 😂 I have no idea what it's referring to. Could you please refactor it if it's not too much work?
self.showVc = showVc | ||
} | ||
|
||
static func == (lhs: Tip, rhs: Tip) -> Bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love this! 🎉
Blockzilla/TipManager.swift
Outdated
} | ||
} | ||
|
||
lazy var autocompleteTip = Tip(title: "Autocomplete URLs for the sites you use most", description: "Long-press any URL in the address bar", identifier: TipKey.autocompleteTip) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know I said you could hardcode these, so I apologize for the confusion 😅 but can you still put them in UIConstants just not as localizable strings?
Blockzilla/TipManager.swift
Outdated
if canShowTip(with: tip.identifier) { | ||
return tip | ||
} | ||
else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: put else on same line as }
Blockzilla/TipManager.swift
Outdated
else { | ||
return fetchTip() | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: whitespace
Blockzilla/TipManager.swift
Outdated
} | ||
return defaults.bool(forKey: id) | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: whitespace
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One nit, but looks good to me! 😄
Blockzilla/HomeView.swift
Outdated
} | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: whitespace
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your help on this!
Blockzilla/AppDelegate.swift
Outdated
@@ -50,10 +50,21 @@ class AppDelegate: UIResponder, UIApplicationDelegate, ModalDelegate, AppSplashC | |||
setupErrorTracking() | |||
setupTelemetry() | |||
TPStatsBlocklistChecker.shared.startup() | |||
browserViewController.tipManager = TipManager() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets flip this around a bit and have TipManager
manage the singleton. I think the changes would be:
- Add
static let shared = TipManager()
in theTipManager
class - Modify
BrowserViewController
constructor to include the argumenttipmanager: TipManager = TipManager.shared
- Modify
HomeView
constructor to also take in a TipManager and optionally pass that in based on if tips are visible at that time.
let settingsViewController = SettingsViewController(searchEngineManager: searchEngineManager, whatsNew: browserToolbar.toolset) | ||
|
||
let settingsViewController: UIViewController! | ||
if shouldScrollToSiri { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be leaned up to just one line:
settingsViewController = SettingsViewController(searchEngineManager: searchEngineManager, whatsNew: browserToolbar.toolset, shouldScrollToSiri: shouldScrollToSiri)
let settingsNavController = UINavigationController(rootViewController: settingsViewController) | ||
settingsNavController.modalPresentationStyle = .formSheet | ||
|
||
modalDelegate.presentModal(viewController: settingsNavController, animated: true) | ||
|
||
Telemetry.default.recordEvent(category: TelemetryEventCategory.action, method: TelemetryEventMethod.click, object: TelemetryEventObject.settingsButton) | ||
} | ||
|
||
@available(iOS 12.0, *) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like there is a lot of @available(iOS 12.0, *)
code in here for the Siri tips. Could it be simplified to a static property or function on TipManager? Should make cleanup a bit easier when this is no longer needed.
static func showSiriTips() { ...@avaialble stuff here
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cleaned up significantly, though still checking once in TipManager and once in bvc to handle displaying SiriSettings in bvc.
@@ -942,6 +953,7 @@ extension BrowserViewController: URLBarDelegate { | |||
func urlBarDidLongPress(_ urlBar: URLBar) { | |||
let customURLItem = PhotonActionSheetItem(title: UIConstants.strings.customURLMenuButton, iconString: "icon_link") { action in | |||
urlBar.addCustomURL() | |||
UserDefaults.standard.set(false, forKey: TipManager.TipKey.autocompleteTip) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like it would be nice to have TipManager
take care of setting the UserDefaults
value. BrowserViewController
shouldn't have to know that TipManager
uses UserDefaults
Blockzilla/TipManager.swift
Outdated
|
||
lazy var requestDesktopTip = Tip(title: UIConstants.strings.requestDesktopTipTitle, description: UIConstants.strings.requestDesktopTipDescription, identifier: TipKey.requestDesktopTip) | ||
|
||
@available(iOS 12.0, *) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does the existence of this property need to be hidden to old OS versions?
…focus-ios#1329) * Successfully fetching tips * In progress * Add share tracker as a tip * Show description correctly * Support two line description * Deep linking UI * Specific tip strings * Show settings * Handle sessions correctly * Change to 50% * Biometric tip added correctly * Don't show tips after using feature * Whitespace * Remove unnecessary pbxproj changes * Nits * Don't go back to settings * Scroll to siri section * More whitespace * Consisten if else bracing * Fixes mozilla-mobile/focus-ios#1327: Add Telemetry for Screen Tips (mozilla-mobile/focus-ios#1334) * Refactoring
…illa-mobile/focus-ios#1329) * Successfully fetching tips * In progress * Add share tracker as a tip * Show description correctly * Support two line description * Deep linking UI * Specific tip strings * Show settings * Handle sessions correctly * Change to 50% * Biometric tip added correctly * Don't show tips after using feature * Whitespace * Remove unnecessary pbxproj changes * Nits * Don't go back to settings * Scroll to siri section * More whitespace * Consisten if else bracing * Fixes mozilla-mobile/focus-ios#1327: Add Telemetry for Screen Tips (mozilla-mobile/focus-ios#1334) * Refactoring
No description provided.