Skip to content

Commit

Permalink
Merge branch 'master' into vphong/loginslist-mvvm-old
Browse files Browse the repository at this point in the history
* master: (26 commits)
  Fix #6862: UA test broken (#6863)
  Noorhashem/today widget fixes (#6861)
  Revert "Fix: #6764 #6763 #6766 #6765 String cutting off in widget after copying link and color contrast of the copied link label" (#6860)
  Send dev in UA instead of 0.0.1 (#6849)
  Push subscription expired handling (#6851)
  code styling
  code styling
  code styling
  edits to label color variables definetions
  code styling
  removed extra tabs
  fixed support for ios 112.4 colors
  removed tab + edits to constraints for buttons
  edit in constraint for widget button
  styling edits
  removed commented lines
  bug fixes : widget constraints + color contrasts of labels in light/dark themes + added pdf button designs
  fixed the cut-off of copied link labels and the contrast of the color for light/dark mode
  Fixed #6730: open apps preview should hide all screens in private browsing (#6757)
  Fix #4717 - Provide feedback when pinning a site (#6785)
  ...
  • Loading branch information
vphong committed Jun 26, 2020
2 parents 9a483fe + b4cfa5d commit 63f7f2e
Show file tree
Hide file tree
Showing 34 changed files with 414 additions and 135 deletions.
2 changes: 1 addition & 1 deletion Account/FxAPushMessageHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ extension FxAPushMessageHandler {

guard let string = plaintext else {
// The app will detect this missing, and re-register. see AppDelegate+PushNotifications.swift.
keychain.removeObject(forKey: KeychainKey.apnsToken)
keychain.removeObject(forKey: KeychainKey.apnsToken, withAccessibility: .afterFirstUnlock)
return deferMaybe(PushMessageError.notDecrypted)
}

Expand Down
2 changes: 1 addition & 1 deletion Cartfile.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ github "google/EarlGrey" "935df455f3937662575c868524ddd64078539741"
github "jrendel/SwiftKeychainWrapper" "3.4.0"
github "kif-framework/KIF" "v3.7.8"
github "mozilla-mobile/MappaMundi" "1d17845e4bd6077d790aca5a2b4a468f19567934"
github "mozilla-mobile/telemetry-ios" "v1.1.2"
github "mozilla-mobile/telemetry-ios" "v1.1.3"
github "mozilla-services/shavar-prod-lists" "1f282be9bc7bf86cf4d695e2a63dbcdf2eecfb89"
github "mozilla/application-services" "v60.0.0"
github "mozilla/glean" "v31.1.0"
Expand Down
1 change: 0 additions & 1 deletion Client.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -4613,7 +4613,6 @@
"$(SRCROOT)/Carthage/Build/iOS/Telemetry.framework",
"$(SRCROOT)/Carthage/Build/iOS/SwiftProtobuf.framework",
"$(SRCROOT)/Carthage/Build/iOS/Leanplum.framework",
"$(SRCROOT)/Carthage/Build/iOS/ObjcExceptionBridging.framework",
"$(SRCROOT)/Carthage/Build/iOS/Glean.framework",
);
name = "Copy Carthage Dependencies";
Expand Down
12 changes: 11 additions & 1 deletion Client/Application/AppDelegate+PushNotifications.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,21 @@ extension AppDelegate {
}
}

// If we see our local device with a pushEndpointExpired flag, clear the APNS token and re-register.
NotificationCenter.default.addObserver(forName: .constellationStateUpdate, object: nil, queue: nil) { notification in
if let newState = notification.userInfo?["newState"] as? ConstellationState {
if newState.localDevice?.subscriptionExpired ?? false {
KeychainWrapper.sharedAppContainerKeychain.removeObject(forKey: KeychainKey.apnsToken, withAccessibility: .afterFirstUnlock)
NotificationCenter.default.post(name: .RegisterForPushNotifications, object: nil)
}
}
}

// Use sync event as a periodic check for the apnsToken.
// The notification service extension can clear this token if there is an error, and the main app can detect this and re-register.
NotificationCenter.default.addObserver(forName: .ProfileDidStartSyncing, object: nil, queue: .main) { _ in
let kc = KeychainWrapper.sharedAppContainerKeychain
if kc.object(forKey: KeychainKey.apnsToken) == nil {
if kc.object(forKey: KeychainKey.apnsToken, withAccessibility: .afterFirstUnlock) == nil {
NotificationCenter.default.post(name: .RegisterForPushNotifications, object: nil)
}
}
Expand Down
13 changes: 7 additions & 6 deletions Client/Frontend/Browser/BrowserViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -342,9 +342,11 @@ class BrowserViewController: UIViewController {
return
}

view.bringSubviewToFront(webViewContainerBackdrop)
webViewContainerBackdrop.alpha = 1
webViewContainer.alpha = 0
urlBar.locationContainer.alpha = 0
firefoxHomeViewController?.view.alpha = 0
topTabsViewController?.switchForegroundStatus(isInForeground: false)
presentedViewController?.popoverPresentationController?.containerView?.alpha = 0
presentedViewController?.view.alpha = 0
Expand All @@ -356,12 +358,14 @@ class BrowserViewController: UIViewController {
UIView.animate(withDuration: 0.2, delay: 0, options: UIView.AnimationOptions(), animations: {
self.webViewContainer.alpha = 1
self.urlBar.locationContainer.alpha = 1
self.firefoxHomeViewController?.view.alpha = 1
self.topTabsViewController?.switchForegroundStatus(isInForeground: true)
self.presentedViewController?.popoverPresentationController?.containerView?.alpha = 1
self.presentedViewController?.view.alpha = 1
self.view.backgroundColor = UIColor.clear
}, completion: { _ in
self.webViewContainerBackdrop.alpha = 0
self.view.sendSubviewToBack(self.webViewContainerBackdrop)
})

// Re-show toolbar which might have been hidden during scrolling (prior to app moving into the background)
Expand All @@ -376,7 +380,7 @@ class BrowserViewController: UIViewController {
KeyboardHelper.defaultHelper.addDelegate(self)

webViewContainerBackdrop = UIView()
webViewContainerBackdrop.backgroundColor = UIColor.Photon.Grey50
webViewContainerBackdrop.backgroundColor = UIColor.Photon.Ink90
webViewContainerBackdrop.alpha = 0
view.addSubview(webViewContainerBackdrop)

Expand Down Expand Up @@ -483,7 +487,7 @@ class BrowserViewController: UIViewController {
}

webViewContainerBackdrop.snp.makeConstraints { make in
make.edges.equalTo(webViewContainer)
make.edges.equalTo(self.view)
}
}

Expand Down Expand Up @@ -539,7 +543,6 @@ class BrowserViewController: UIViewController {

override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)

// On iPhone, if we are about to show the On-Boarding, blank out the tab so that it does
// not flash before we present. This change of alpha also participates in the animation when
// the intro view is dismissed.
Expand Down Expand Up @@ -2078,9 +2081,7 @@ extension BrowserViewController {
object = .settings
}

let signInVC = AppInfo.isChinaEdition ?
FxAWebViewController(pageType: .emailLoginFlow, profile: profile, dismissalStyle: .dismiss, deepLinkParams: deepLinkParams) :
FirefoxAccountSignInViewController(profile: profile, parentType: parentType, deepLinkParams: deepLinkParams)
let signInVC = FirefoxAccountSignInViewController(profile: profile, parentType: parentType, deepLinkParams: deepLinkParams)
UnifiedTelemetry.recordEvent(category: .firefoxAccount, method: .view, object: object)
return signInVC
}
Expand Down
17 changes: 11 additions & 6 deletions Client/Frontend/Browser/TabManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,10 @@ class TabManager: NSObject {

fileprivate let navDelegate: TabManagerNavDelegate

public static func makeWebViewConfig(isPrivate: Bool, blockPopups: Bool) -> WKWebViewConfiguration {
public static func makeWebViewConfig(isPrivate: Bool, prefs: Prefs?) -> WKWebViewConfiguration {
let configuration = WKWebViewConfiguration()
configuration.processPool = WKProcessPool()
let blockPopups = prefs?.boolForKey(PrefsKeys.KeyBlockPopups) ?? true
configuration.preferences.javaScriptCanOpenWindowsAutomatically = !blockPopups
// We do this to go against the configuration of the <meta name="viewport">
// tag to behave the same way as Safari :-(
Expand All @@ -79,14 +80,12 @@ class TabManager: NSObject {

// A WKWebViewConfiguration used for normal tabs
lazy fileprivate var configuration: WKWebViewConfiguration = {
let blockPopups = profile.prefs.boolForKey("blockPopups") ?? true
return TabManager.makeWebViewConfig(isPrivate: false, blockPopups: blockPopups)
return TabManager.makeWebViewConfig(isPrivate: false, prefs: profile.prefs)
}()

// A WKWebViewConfiguration used for private mode tabs
lazy fileprivate var privateConfiguration: WKWebViewConfiguration = {
let blockPopups = profile.prefs.boolForKey("blockPopups") ?? true
return TabManager.makeWebViewConfig(isPrivate: true, blockPopups: blockPopups)
return TabManager.makeWebViewConfig(isPrivate: true, prefs: profile.prefs)
}()

var selectedIndex: Int { return _selectedIndex }
Expand Down Expand Up @@ -441,6 +440,10 @@ class TabManager: NSObject {
tabs.remove(at: removalIndex)
assert(count == prevCount - 1, "Make sure the tab count was actually removed")

if (tab.isPrivate && privateTabs.count < 1) {
privateConfiguration = TabManager.makeWebViewConfig(isPrivate: true, prefs: profile.prefs)
}

tab.closeAndRemovePrivateBrowsingData()

if notify {
Expand Down Expand Up @@ -474,6 +477,8 @@ class TabManager: NSObject {
}
privateTabs.forEach { $0.closeAndRemovePrivateBrowsingData() }
tabs = normalTabs

privateConfiguration = TabManager.makeWebViewConfig(isPrivate: true, prefs: profile.prefs)
}

func removeTabsWithUndoToast(_ tabs: [Tab]) {
Expand Down Expand Up @@ -550,7 +555,7 @@ class TabManager: NSObject {

@objc func prefsDidChange() {
DispatchQueue.main.async {
let allowPopups = !(self.profile.prefs.boolForKey("blockPopups") ?? true)
let allowPopups = !(self.profile.prefs.boolForKey(PrefsKeys.KeyBlockPopups) ?? true)
// Each tab may have its own configuration, so we should tell each of them in turn.
for tab in self.tabs {
tab.webView?.configuration.preferences.javaScriptCanOpenWindowsAutomatically = allowPopups
Expand Down
23 changes: 20 additions & 3 deletions Client/Frontend/Browser/TabTrayControllerV1.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ class TabTrayControllerV1: UIViewController {
var tabDisplayManager: TabDisplayManager!
var tabCellIdentifer: TabDisplayer.TabCellIdentifer = TabCell.Identifier
var otherBrowsingModeOffset = CGPoint.zero
// Backdrop used for displaying greyed background for private tabs
var webViewContainerBackdrop: UIView!
var collectionView: UICollectionView!

let statusBarBG = UIView()
Expand Down Expand Up @@ -161,6 +163,10 @@ class TabTrayControllerV1: UIViewController {
super.viewDidLoad()
tabManager.addDelegate(self)
view.accessibilityLabel = NSLocalizedString("Tabs Tray", comment: "Accessibility label for the Tabs Tray view.")

webViewContainerBackdrop = UIView()
webViewContainerBackdrop.backgroundColor = UIColor.Photon.Ink90
webViewContainerBackdrop.alpha = 0

collectionView.alwaysBounceVertical = true
collectionView.backgroundColor = UIColor.theme.tabTray.background
Expand All @@ -173,7 +179,7 @@ class TabTrayControllerV1: UIViewController {
searchBarHolder.addSubview(roundedSearchBarHolder)
searchBarHolder.addSubview(searchBar)
searchBarHolder.backgroundColor = UIColor.theme.tabTray.toolbar
[collectionView, toolbar, searchBarHolder, cancelButton].forEach { view.addSubview($0) }
[webViewContainerBackdrop, collectionView, toolbar, searchBarHolder, cancelButton].forEach { view.addSubview($0) }
makeConstraints()

// The statusBar needs a background color
Expand Down Expand Up @@ -222,6 +228,11 @@ class TabTrayControllerV1: UIViewController {
}

fileprivate func makeConstraints() {

webViewContainerBackdrop.snp.makeConstraints { make in
make.edges.equalTo(self.view)
}

collectionView.snp.makeConstraints { make in
make.left.equalTo(view.safeArea.left)
make.right.equalTo(view.safeArea.right)
Expand Down Expand Up @@ -518,20 +529,26 @@ extension TabTrayControllerV1 {
extension TabTrayControllerV1 {
@objc func appWillResignActiveNotification() {
if tabDisplayManager.isPrivate {
webViewContainerBackdrop.alpha = 1
view.bringSubviewToFront(webViewContainerBackdrop)
collectionView.alpha = 0
searchBarHolder.alpha = 0
emptyPrivateTabsView.alpha = 0
}
}

@objc func appDidBecomeActiveNotification() {
// Re-show any components that might have been hidden because they were being displayed
// as part of a private mode tab
UIView.animate(withDuration: 0.2) {
UIView.animate(withDuration: 0.2, animations: {
self.collectionView.alpha = 1

self.emptyPrivateTabsView.alpha = 1
if self.tabDisplayManager.isPrivate, !self.privateTabsAreEmpty() {
self.searchBarHolder.alpha = 1
}
}) { _ in
self.webViewContainerBackdrop.alpha = 0
self.view.sendSubviewToBack(self.webViewContainerBackdrop)
}
}
}
Expand Down
6 changes: 5 additions & 1 deletion Client/Frontend/Library/BookmarksPanel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,11 @@ extension BookmarksPanel: LibraryPanelContextMenu {
}

let pinTopSite = PhotonActionSheetItem(title: Strings.PinTopsiteActionTitle, iconString: "action_pin", handler: { _, _ in
_ = self.profile.history.addPinnedTopSite(site)
_ = self.profile.history.addPinnedTopSite(site).uponQueue(.main) { result in
if result.isSuccess {
SimpleToast().showAlertWithText(Strings.AppMenuAddPinToTopSitesConfirmMessage, bottomContainer: self.view)
}
}
})
actions.append(pinTopSite)

Expand Down
6 changes: 5 additions & 1 deletion Client/Frontend/Library/HistoryPanel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,11 @@ class HistoryPanel: SiteTableViewController, LibraryPanel {
}

func pinToTopSites(_ site: Site) {
_ = profile.history.addPinnedTopSite(site).value
_ = profile.history.addPinnedTopSite(site).uponQueue(.main) { result in
if result.isSuccess {
SimpleToast().showAlertWithText(Strings.AppMenuAddPinToTopSitesConfirmMessage, bottomContainer: self.view)
}
}
}

func navigateToRecentlyClosed() {
Expand Down
8 changes: 2 additions & 6 deletions Client/Frontend/Settings/AppSettingsOptions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,7 @@ class ConnectSetting: WithoutAccountSetting {
override var accessibilityIdentifier: String? { return "SignInToSync" }

override func onClick(_ navigationController: UINavigationController?) {
let viewController = AppInfo.isChinaEdition ?
FxAWebViewController(pageType: .emailLoginFlow, profile: profile, dismissalStyle: .popToRootVC, deepLinkParams: nil) :
FirefoxAccountSignInViewController(profile: profile, parentType: .settings, deepLinkParams: nil)
let viewController = FirefoxAccountSignInViewController(profile: profile, parentType: .settings, deepLinkParams: nil)
UnifiedTelemetry.recordEvent(category: .firefoxAccount, method: .view, object: .settings)
navigationController?.pushViewController(viewController, animated: true)
}
Expand Down Expand Up @@ -340,9 +338,7 @@ class AccountStatusSetting: WithAccountSetting {

override func onClick(_ navigationController: UINavigationController?) {
guard !profile.rustFxA.accountNeedsReauth() else {
let vc = AppInfo.isChinaEdition ?
FxAWebViewController(pageType: .emailLoginFlow, profile: profile, dismissalStyle: .popToRootVC, deepLinkParams: nil) :
FirefoxAccountSignInViewController(profile: profile, parentType: .settings, deepLinkParams: nil)
let vc = FirefoxAccountSignInViewController(profile: profile, parentType: .settings, deepLinkParams: nil)
UnifiedTelemetry.recordEvent(category: .firefoxAccount, method: .view, object: .settings)
navigationController?.pushViewController(vc, animated: true)
return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class AppSettingsTableViewController: SettingsTableViewController {
HomeSetting(settings: self),
OpenWithSetting(settings: self),
ThemeSetting(settings: self),
BoolSetting(prefs: prefs, prefKey: "blockPopups", defaultValue: true,
BoolSetting(prefs: prefs, prefKey: PrefsKeys.KeyBlockPopups, defaultValue: true,
titleText: NSLocalizedString("Block Pop-up Windows", comment: "Block pop-up windows setting")),
]

Expand Down
4 changes: 3 additions & 1 deletion Client/Frontend/Settings/SettingsContentViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,9 @@ class SettingsContentViewController: UIViewController, WKNavigationDelegate {
}

func makeWebView() -> WKWebView {
let config = TabManager.makeWebViewConfig(isPrivate: true, blockPopups: true)
let config = TabManager.makeWebViewConfig(isPrivate: true, prefs: nil)
config.preferences.javaScriptCanOpenWindowsAutomatically = false

let webView = WKWebView(
frame: CGRect(width: 1, height: 1),
configuration: config
Expand Down
2 changes: 2 additions & 0 deletions Client/Frontend/Strings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,8 @@ extension Strings {
public static let AppMenuAddBookmarkConfirmMessage = NSLocalizedString("Menu.AddBookmark.Confirm", value: "Bookmark Added", comment: "Toast displayed to the user after a bookmark has been added.")
public static let AppMenuTabSentConfirmMessage = NSLocalizedString("Menu.TabSent.Confirm", value: "Tab Sent", comment: "Toast displayed to the user after a tab has been sent successfully.")
public static let AppMenuRemoveBookmarkConfirmMessage = NSLocalizedString("Menu.RemoveBookmark.Confirm", value: "Bookmark Removed", comment: "Toast displayed to the user after a bookmark has been removed.")
public static let AppMenuAddPinToTopSitesConfirmMessage = NSLocalizedString("Menu.AddPin.Confirm", value: "Pinned To Top Sites", comment: "Toast displayed to the user after adding the item to the Top Sites.")
public static let AppMenuRemovePinFromTopSitesConfirmMessage = NSLocalizedString("Menu.RemovePin.Confirm", value: "Removed From Top Sites", comment: "Toast displayed to the user after removing the item from the Top Sites.")
public static let AppMenuAddToReadingListConfirmMessage = NSLocalizedString("Menu.AddToReadingList.Confirm", value: "Added To Reading List", comment: "Toast displayed to the user after adding the item to their reading list.")
public static let SendToDeviceTitle = NSLocalizedString("Send to Device", tableName: "3DTouchActions", comment: "Label for preview action on Tab Tray Tab to send the current tab to another device")
public static let PageActionMenuTitle = NSLocalizedString("Menu.PageActions.Title", value: "Page Actions", comment: "Label for title in page action menu.")
Expand Down
15 changes: 12 additions & 3 deletions Client/Frontend/Widgets/PhotonActionSheet/PageActionMenu.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ enum ButtonToastAction {
case bookmarkPage
case removeBookmark
case copyUrl
case pinPage
case removePinPage
}

extension PhotonActionSheetProtocol {
Expand Down Expand Up @@ -97,9 +99,12 @@ extension PhotonActionSheetProtocol {
guard let site = val.successValue?.asArray().first?.flatMap({ $0 }) else {
return succeed()
}

return self.profile.history.addPinnedTopSite(site)
}.uponQueue(.main) { _ in }
}.uponQueue(.main) { result in
if result.isSuccess {
success(Strings.AppMenuAddPinToTopSitesConfirmMessage, .pinPage)
}
}
}

let removeTopSitesPin = PhotonActionSheetItem(title: Strings.RemovePinTopsiteActionTitle, iconString: "action_unpin") { _, _ in
Expand All @@ -111,7 +116,11 @@ extension PhotonActionSheetProtocol {
}

return self.profile.history.removeFromPinnedTopSites(site)
}.uponQueue(.main) { _ in }
}.uponQueue(.main) { result in
if result.isSuccess {
success(Strings.AppMenuRemovePinFromTopSitesConfirmMessage, .removePinPage)
}
}
}

let sendToDevice = PhotonActionSheetItem(title: Strings.SendToDeviceTitle, iconString: "menu-Send-to-Device") { _, _ in
Expand Down
2 changes: 1 addition & 1 deletion Client/Frontend/photon-colors.swift
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ extension UIColor {
static let Ink60 = UIColor(rgb: 0x464B76)
static let Ink70 = UIColor(rgb: 0x363959)
static let Ink80 = UIColor(rgb: 0x202340)
static let Ink90 = UIColor(rgb: 0x0f1126)
static let Ink90 = UIColor(rgb: 0x1D1133)

static let White100 = UIColor(rgb: 0xffffff)

Expand Down
11 changes: 8 additions & 3 deletions ClientTests/ClientTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,14 @@ class ClientTests: XCTestCase {
let ua = UserAgent.syncUserAgent
let device = DeviceInfo.deviceModel()
let systemVersion = UIDevice.current.systemVersion
let expectedRegex = "^Firefox-iOS-Sync/[0-9\\.]+b[0-9]* \\(\(device); iPhone OS \(systemVersion)\\) \\([-_A-Za-z0-9= \\(\\)]+\\)$"
let loc = ua.range(of: expectedRegex, options: .regularExpression)
XCTAssertTrue(loc != nil, "Sync UA is as expected. Was \(ua)")

if AppInfo.appVersion != "0.0.1" {
let expectedRegex = "^Firefox-iOS-Sync/[0-9\\.]+b[0-9]* \\(\(device); iPhone OS \(systemVersion)\\) \\([-_A-Za-z0-9= \\(\\)]+\\)$"
let loc = ua.range(of: expectedRegex, options: .regularExpression)
XCTAssertTrue(loc != nil, "Sync UA is as expected. Was \(ua)")
} else {
XCTAssertTrue(ua.range(of: "dev") != nil)
}
}

func testMobileUserAgent() {
Expand Down
Loading

0 comments on commit 63f7f2e

Please sign in to comment.