Skip to content
This repository has been archived by the owner on Mar 6, 2024. It is now read-only.

Fixes #1165: Add Screen Tips #1329

Merged
merged 23 commits into from
Aug 31, 2018
Merged

Fixes #1165: Add Screen Tips #1329

merged 23 commits into from
Aug 31, 2018

Conversation

oliviabrown9
Copy link
Contributor

No description provided.

@oliviabrown9
Copy link
Contributor Author

@joeyg Would love if you could take a look at this!

Copy link
Contributor

@sblatz sblatz left a 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.
favorite_site_bug

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?
siri

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!

@@ -266,6 +277,10 @@ class AppDelegate: UIResponder, UIApplicationDelegate, ModalDelegate, AppSplashC

}

func applicationWillEnterForeground(_ application: UIApplication) {
browserViewController.tipManager = TipManager()
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

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?
Copy link
Contributor

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"

Copy link
Contributor Author

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, *) {
Copy link
Contributor

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?

Copy link
Contributor Author

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)

Copy link
Contributor

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!

tipTitleLabel.textColor = UIConstants.colors.defaultFont
tipTitleLabel.font = UIConstants.fonts.shareTrackerStatsLabel
tipTitleLabel.numberOfLines = 0
tipTitleLabel.minimumScaleFactor = 0.65
Copy link
Contributor

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?)

@@ -117,21 +162,55 @@ class HomeView: UIView {
fatalError("init(coder:) has not been implemented")
}

func showTipView() {
description1.isHidden = true
Copy link
Contributor

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 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love this! 🎉

}
}

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)
Copy link
Contributor

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?

if canShowTip(with: tip.identifier) {
return tip
}
else {
Copy link
Contributor

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 }

else {
return fetchTip()
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: whitespace

}
return defaults.bool(forKey: id)
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: whitespace

Copy link
Contributor

@sblatz sblatz left a 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! 😄

}
}
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: whitespace

Copy link
Contributor

@joeyg joeyg left a 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!

@@ -50,10 +50,21 @@ class AppDelegate: UIResponder, UIApplicationDelegate, ModalDelegate, AppSplashC
setupErrorTracking()
setupTelemetry()
TPStatsBlocklistChecker.shared.startup()
browserViewController.tipManager = TipManager()
Copy link
Contributor

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 the TipManager class
  • Modify BrowserViewController constructor to include the argument tipmanager: 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 {
Copy link
Contributor

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, *)
Copy link
Contributor

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 ?

Copy link
Contributor Author

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)
Copy link
Contributor

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


lazy var requestDesktopTip = Tip(title: UIConstants.strings.requestDesktopTipTitle, description: UIConstants.strings.requestDesktopTipDescription, identifier: TipKey.requestDesktopTip)

@available(iOS 12.0, *)
Copy link
Contributor

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?

Blockzilla/AppDelegate.swift Show resolved Hide resolved
@oliviabrown9 oliviabrown9 merged commit 71dbe9f into v7.0-dev Aug 31, 2018
@oliviabrown9 oliviabrown9 deleted the oliviabrown9/screen-tips branch August 31, 2018 21:10
@oliviabrown9 oliviabrown9 mentioned this pull request Aug 31, 2018
isabelrios pushed a commit to isabelrios/firefox-ios that referenced this pull request Feb 14, 2024
…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
isabelrios pushed a commit to isabelrios/firefox-ios that referenced this pull request Feb 20, 2024
…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
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants