Skip to content

Commit

Permalink
Merge branch 'main' into vphong/loginslist-tests
Browse files Browse the repository at this point in the history
* main: (40 commits)
  Dismiss QR Scanner if it not available (#6870)
  Bug# 6733: refactor: cleanup and simplify logic flow (#6895)
  Update .swiftlint.yml
  Fix #6879: reconfig will crash if FxA init is in-progress (#6880)
  Fix #6722: no reload() datasource when app backgrounded (db closed) (#6884)
  Introducing FxAWebViewModel (#6733)
  Fix #6846 - Add Search button to tabbar in home screen (#6853)
  Fix #6722, fix #6271: Library panels crashing on text size change (#6881)
  Issue 6711: Update colours in ETP shield icon (#6874)
  rename master branch to main
  Rename master branch to main
  Fix #6844 - Condition for when internet ins't available or leanplum is slow wasn't met (#6850) (#6852)
  Fix #5934: Wrap text in theme settings (#6872)
  For #6865 - UI Test fix Strict TP test (#6866)
  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
  ...
  • Loading branch information
vphong committed Jun 30, 2020
2 parents 6d54ef8 + f7c9bf7 commit 1a021d7
Show file tree
Hide file tree
Showing 27 changed files with 573 additions and 271 deletions.
4 changes: 2 additions & 2 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@ comma: error
force_try: warning
force_cast: warning


file_header:
required_string: "/* This Source Code Form is subject to the terms of the Mozilla Public\n * License, v. 2.0. If a copy of the MPL was not distributed with this\n * file, You can obtain one at http://mozilla.org/MPL/2.0/. */"
required_pattern: \/\* This Source Code Form is subject to the terms of the Mozilla Public.+

line_length: 1000

reporter: "json" # reporter type (xcode, json, csv, checkstyle)
8 changes: 8 additions & 0 deletions Client.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@
59A68D66379CFA85C4EAF00B /* TwoLineCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 59A68B1F857A8638598A63A0 /* TwoLineCell.swift */; };
59A68E0B4ABBF55E14819668 /* BookmarksPanel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 59A6839879D615FC1C0D71CE /* BookmarksPanel.swift */; };
59A68FD5260B8D520F890F4A /* ReaderPanel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 59A685F4EAD19EDEC854BCA4 /* ReaderPanel.swift */; };
5F130D2E2483508E00B0F7D0 /* FxAWebViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5F130D2D2483508E00B0F7D0 /* FxAWebViewModel.swift */; };
63306D3921103EAE00F25400 /* SavedTab.swift in Sources */ = {isa = PBXBuildFile; fileRef = 63306D3821103EAE00F25400 /* SavedTab.swift */; };
63306D432110B3CD00F25400 /* TabManagerStore.swift in Sources */ = {isa = PBXBuildFile; fileRef = 63306D422110B3CD00F25400 /* TabManagerStore.swift */; };
63306D452110BAF000F25400 /* TabManagerStoreTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 63306D442110BAF000F25400 /* TabManagerStoreTests.swift */; };
Expand Down Expand Up @@ -493,6 +494,7 @@
D4C4BDCE2253725E00986F04 /* LibraryTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D4C4BDCD2253725E00986F04 /* LibraryTests.swift */; };
D4F3D789232F960600FBB9AA /* WhatsNewTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = D4F3D788232F960600FBB9AA /* WhatsNewTest.swift */; };
D81127D81F84023B0050841D /* PhotonActionSheetTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = D81127D71F84023B0050841D /* PhotonActionSheetTest.swift */; };
D815A3A824A53F3200AAB221 /* TabToolbarHelperTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D815A3A724A53F3200AAB221 /* TabToolbarHelperTests.swift */; };
D81E45131F82C56D004EFFBA /* NewTabContentSettingsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D81E45121F82C56C004EFFBA /* NewTabContentSettingsViewController.swift */; };
D821E90E2141B71C00452C55 /* SiriSettingsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D821E9052141B71C00452C55 /* SiriSettingsViewController.swift */; };
D82ED2641FEB3C420059570B /* DefaultSearchPrefsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D82ED2631FEB3C420059570B /* DefaultSearchPrefsTests.swift */; };
Expand Down Expand Up @@ -1424,6 +1426,7 @@
59A685F4EAD19EDEC854BCA4 /* ReaderPanel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ReaderPanel.swift; sourceTree = "<group>"; };
59A68B1F857A8638598A63A0 /* TwoLineCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TwoLineCell.swift; sourceTree = "<group>"; };
59A68CCB63E2A565CB03F832 /* SearchViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SearchViewController.swift; sourceTree = "<group>"; };
5F130D2D2483508E00B0F7D0 /* FxAWebViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FxAWebViewModel.swift; sourceTree = "<group>"; };
63306D3821103EAE00F25400 /* SavedTab.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SavedTab.swift; sourceTree = "<group>"; };
63306D422110B3CD00F25400 /* TabManagerStore.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TabManagerStore.swift; sourceTree = "<group>"; };
63306D442110BAF000F25400 /* TabManagerStoreTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TabManagerStoreTests.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1638,6 +1641,7 @@
D4C4BDCD2253725E00986F04 /* LibraryTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LibraryTests.swift; sourceTree = "<group>"; };
D4F3D788232F960600FBB9AA /* WhatsNewTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WhatsNewTest.swift; sourceTree = "<group>"; };
D81127D71F84023B0050841D /* PhotonActionSheetTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PhotonActionSheetTest.swift; sourceTree = "<group>"; };
D815A3A724A53F3200AAB221 /* TabToolbarHelperTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TabToolbarHelperTests.swift; sourceTree = "<group>"; };
D81E377D2242FF61006AC72D /* Client-Bridging-Header.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "Client-Bridging-Header.h"; path = "Client/Client-Bridging-Header.h"; sourceTree = SOURCE_ROOT; };
D81E45121F82C56C004EFFBA /* NewTabContentSettingsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NewTabContentSettingsViewController.swift; sourceTree = "<group>"; };
D821E9052141B71C00452C55 /* SiriSettingsViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SiriSettingsViewController.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -2744,6 +2748,7 @@
children = (
EB07F85E240D695F00924860 /* PushNotificationSetup.swift */,
C8E2E80723D20FB3005AACE6 /* FxAWebViewController.swift */,
5F130D2D2483508E00B0F7D0 /* FxAWebViewModel.swift */,
C8E2E80823D20FB3005AACE6 /* Avatar.swift */,
C8E2E80923D20FB3005AACE6 /* RustFirefoxAccounts.swift */,
CDB3BE8624746787009320EE /* FirefoxAccountSignInViewController.swift */,
Expand Down Expand Up @@ -3535,6 +3540,7 @@
63306D442110BAF000F25400 /* TabManagerStoreTests.swift */,
E1D8BC7921FF7A0000B100BD /* TPStatsBlocklistsTests.swift */,
DACDE995225E537900C8F37F /* VersionSettingTests.swift */,
D815A3A724A53F3200AAB221 /* TabToolbarHelperTests.swift */,
);
path = ClientTests;
sourceTree = "<group>";
Expand Down Expand Up @@ -5097,6 +5103,7 @@
CAA3B7E62497DCB60094E3C1 /* LoginDataSource.swift in Sources */,
396E38F11EE0C8EC00CC180F /* FxAPushMessageHandler.swift in Sources */,
E4CD9F6D1A77DD2800318571 /* ReaderModeStyleViewController.swift in Sources */,
5F130D2E2483508E00B0F7D0 /* FxAWebViewModel.swift in Sources */,
D0FCF7F51FE45842004A7995 /* UserScriptManager.swift in Sources */,
E4A960061ABB9C450069AD6F /* ReaderModeUtils.swift in Sources */,
435D660323D793DF0046EFA2 /* UpdateModel.swift in Sources */,
Expand Down Expand Up @@ -5358,6 +5365,7 @@
3943A81D1E9807C700D4F6DC /* FxAPushMessageTest.swift in Sources */,
E60D032A1D5118DB002FE3F6 /* SyncStatusResolverTests.swift in Sources */,
E683F0A61E92E0820035D990 /* MockableHistory.swift in Sources */,
D815A3A824A53F3200AAB221 /* TabToolbarHelperTests.swift in Sources */,
A83E5B1E1C1DAAAA0026D912 /* UIPasteboardExtensions.swift in Sources */,
0BF42D4F1A7CD09600889E28 /* TestFavicons.swift in Sources */,
7BBFEE741BB405D900A305AA /* TabManagerTests.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"images" : [
{
"filename" : "trackingprotection-medium-dark.pdf",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
},
"properties" : {
"preserves-vector-representation" : true
}
}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "trackingprotection-medium.pdf"
"filename" : "trackingprotection-medium-light.pdf",
"idiom" : "universal"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
"author" : "xcode",
"version" : 1
},
"properties" : {
"template-rendering-intent" : "original",
"preserves-vector-representation" : true
"preserves-vector-representation" : true,
"template-rendering-intent" : "original"
}
}
}
Binary file not shown.
Binary file not shown.
9 changes: 7 additions & 2 deletions Client/Frontend/Browser/BrowserViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -740,6 +740,7 @@ class BrowserViewController: UIViewController {
}
})
view.setNeedsUpdateConstraints()
navigationToolbar.updateIsSearchStatus(true)
}

fileprivate func hideFirefoxHome() {
Expand All @@ -748,6 +749,7 @@ class BrowserViewController: UIViewController {
}

self.firefoxHomeViewController = nil
navigationToolbar.updateIsSearchStatus(false)
UIView.animate(withDuration: 0.2, delay: 0, options: .beginFromCurrentState, animations: { () -> Void in
firefoxHomeViewController.view.alpha = 0
}, completion: { _ in
Expand Down Expand Up @@ -1157,7 +1159,7 @@ class BrowserViewController: UIViewController {
super.traitCollectionDidChange(previousTraitCollection)

if #available(iOS 13.0, *) {
if ThemeManager.instance.systemThemeIsOn {
if self.traitCollection.hasDifferentColorAppearance(comparedTo: previousTraitCollection), ThemeManager.instance.systemThemeIsOn {
let userInterfaceStyle = traitCollection.userInterfaceStyle
ThemeManager.instance.current = userInterfaceStyle == .dark ? DarkTheme() : NormalTheme()
}
Expand Down Expand Up @@ -2387,7 +2389,10 @@ extension BrowserViewController: Themeable {
webViews.forEach({ $0.applyTheme() })

let tabs = tabManager.tabs
tabs.forEach { $0.applyTheme() }
tabs.forEach {
$0.applyTheme()
urlBar.locationView.tabDidChangeContentBlocking($0)
}

guard let contentScript = self.tabManager.selectedTab?.getContentScript(name: ReaderMode.name()) else { return }
appyThemeForPreferences(profile.prefs, contentScript: contentScript)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,5 +184,9 @@ extension BrowserViewController: TabToolbarDelegate, PhotonActionSheetProtocol {
self.present(backForwardViewController, animated: true, completion: nil)
}
}

func tabToolbarDidPressSearch(_ tabToolbar: TabToolbarProtocol, button: UIButton) {
focusLocationTextField(forTab: tabManager.selectedTab)
}
}

4 changes: 3 additions & 1 deletion Client/Frontend/Browser/QRCodeViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@ class QRCodeViewController: UIViewController {
self.navigationItem.rightBarButtonItem?.isEnabled = false

let alert = UIAlertController(title: "", message: Strings.ScanQRCodePermissionErrorMessage, preferredStyle: .alert)
alert.addAction(UIAlertAction(title: Strings.ScanQRCodeErrorOKButton, style: .default, handler: nil))
alert.addAction(UIAlertAction(title: Strings.ScanQRCodeErrorOKButton, style: .default, handler: { (action) -> Void in
self.dismiss(animated: true)
}))
self.present(alert, animated: true, completion: nil)
}

Expand Down
3 changes: 2 additions & 1 deletion Client/Frontend/Browser/TabLocationView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,8 @@ extension TabLocationView: TabEventHandler {
trackingProtectionButton.alpha = 1.0
switch blocker.status {
case .blocking:
trackingProtectionButton.setImage(UIImage(imageLiteralResourceName: "tracking-protection-active-block"), for: .normal)
let blockImageName = ThemeManager.instance.currentName == .dark ? "tracking-protection-active-block-dark" : "tracking-protection-active-block"
trackingProtectionButton.setImage(UIImage(imageLiteralResourceName: blockImageName), for: .normal)
case .noBlockedURLs:
trackingProtectionButton.setImage(UIImage.templateImageNamed("tracking-protection"), for: .normal)
trackingProtectionButton.alpha = 0.5
Expand Down
51 changes: 45 additions & 6 deletions Client/Frontend/Browser/TabToolbar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ protocol TabToolbarProtocol: AnyObject {
func updateForwardStatus(_ canGoForward: Bool)
func updateReloadStatus(_ isLoading: Bool)
func updatePageStatus(_ isWebPage: Bool)
func updateIsSearchStatus(_ isHomePage: Bool)
func updateTabCount(_ count: Int, animated: Bool)
func privateModeBadge(visible: Bool)
func appMenuBadge(setVisible: Bool)
Expand All @@ -38,6 +39,13 @@ protocol TabToolbarDelegate: AnyObject {
func tabToolbarDidPressLibrary(_ tabToolbar: TabToolbarProtocol, button: UIButton)
func tabToolbarDidPressTabs(_ tabToolbar: TabToolbarProtocol, button: UIButton)
func tabToolbarDidLongPressTabs(_ tabToolbar: TabToolbarProtocol, button: UIButton)
func tabToolbarDidPressSearch(_ tabToolbar: TabToolbarProtocol, button: UIButton)
}

fileprivate enum MiddleButtonState {
case reload
case stop
case search
}

@objcMembers
Expand All @@ -46,15 +54,40 @@ open class TabToolbarHelper: NSObject {

let ImageReload = UIImage.templateImageNamed("nav-refresh")
let ImageStop = UIImage.templateImageNamed("nav-stop")
let ImageSearch = UIImage.templateImageNamed("search")

var loading: Bool = false {
didSet {
if loading {
fileprivate func setMiddleButtonState(_ state: MiddleButtonState) {
switch state {
case .reload:
toolbar.stopReloadButton.setImage(ImageReload, for: .normal)
toolbar.stopReloadButton.accessibilityLabel = NSLocalizedString("Reload", comment: "Accessibility Label for the tab toolbar Reload button")
case .stop:
toolbar.stopReloadButton.setImage(ImageStop, for: .normal)
toolbar.stopReloadButton.accessibilityLabel = NSLocalizedString("Stop", comment: "Accessibility Label for the tab toolbar Stop button")
case .search:
toolbar.stopReloadButton.setImage(ImageSearch, for: .normal)
toolbar.stopReloadButton.accessibilityLabel = NSLocalizedString("Search", comment: "Accessibility Label for the tab toolbar Search button")
}
}

var loading: Bool = false {
didSet {
if !isSearch {
if loading {
setMiddleButtonState(.stop)
} else {
setMiddleButtonState(.reload)
}
}
}
}

var isSearch: Bool = false {
didSet {
if isSearch {
setMiddleButtonState(.search)
} else {
toolbar.stopReloadButton.setImage(ImageReload, for: .normal)
toolbar.stopReloadButton.accessibilityLabel = NSLocalizedString("Reload", comment: "Accessibility Label for the tab toolbar Reload button")
setMiddleButtonState(.stop)
}
}
}
Expand Down Expand Up @@ -142,6 +175,8 @@ open class TabToolbarHelper: NSObject {
func didClickStopReload() {
if loading {
toolbar.tabToolbarDelegate?.tabToolbarDidPressStop(toolbar, button: toolbar.stopReloadButton)
} else if isSearch {
toolbar.tabToolbarDelegate?.tabToolbarDidPressSearch(toolbar, button: toolbar.stopReloadButton)
} else {
toolbar.tabToolbarDelegate?.tabToolbarDidPressReload(toolbar, button: toolbar.stopReloadButton)
}
Expand Down Expand Up @@ -326,12 +361,16 @@ extension TabToolbar: TabToolbarProtocol {
}

func updatePageStatus(_ isWebPage: Bool) {
stopReloadButton.isEnabled = isWebPage

}

func updateTabCount(_ count: Int, animated: Bool) {
tabsButton.updateTabCount(count, animated: animated)
}

func updateIsSearchStatus(_ isSearch: Bool) {
helper?.isSearch = isSearch
}
}

extension TabToolbar: Themeable, PrivateModeUI {
Expand Down
4 changes: 4 additions & 0 deletions Client/Frontend/Browser/URLBarView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -616,6 +616,10 @@ extension URLBarView: TabToolbarProtocol {
stopReloadButton.isEnabled = isWebPage
}

func updateIsSearchStatus(_ isHomePag: Bool) {

}

var access: [Any]? {
get {
if inOverlayMode {
Expand Down
2 changes: 2 additions & 0 deletions Client/Frontend/Library/BookmarkDetailPanel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,8 @@ class BookmarkDetailPanel: SiteTableViewController {
}

override func reloadData() {
// Can be called while app backgrounded and the db closed, don't try to reload the data source in this case
if profile.isShutdown { return }
profile.places.getBookmarksTree(rootGUID: BookmarkRoots.RootGUID, recursive: true).uponQueue(.main) { result in
guard let rootFolder = result.successValue as? BookmarkFolder else {
// TODO: Handle error case?
Expand Down
2 changes: 2 additions & 0 deletions Client/Frontend/Library/BookmarksPanel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,8 @@ class BookmarksPanel: SiteTableViewController, LibraryPanel {
}

override func reloadData() {
// Can be called while app backgrounded and the db closed, don't try to reload the data source in this case
if profile.isShutdown { return }
profile.places.getBookmarksTree(rootGUID: bookmarkFolderGUID, recursive: false).uponQueue(.main) { result in

guard let folder = result.successValue as? BookmarkFolder else {
Expand Down
2 changes: 2 additions & 0 deletions Client/Frontend/Library/HistoryPanel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,8 @@ class HistoryPanel: SiteTableViewController, LibraryPanel {
// MARK: - Loading data

override func reloadData() {
// Can be called while app backgrounded and the db closed, don't try to reload the data source in this case
if profile.isShutdown { return }
guard !isFetchInProgress else { return }
groupedSites = DateGroupedTableData<Site>()

Expand Down
2 changes: 2 additions & 0 deletions Client/Frontend/Settings/ThemeSettingsController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,8 @@ class ThemeSettingsController: ThemedTableViewController {
switch section {
case .systemTheme:
cell.textLabel?.text = Strings.SystemThemeSectionSwitchTitle
cell.textLabel?.numberOfLines = 0
cell.textLabel?.lineBreakMode = .byWordWrapping

let control = UISwitchThemed()

Expand Down
1 change: 0 additions & 1 deletion Client/UserResearch/OnboardingUserResearch.swift
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ class OnboardingUserResearch {
lpVariableValue = boolValue ? .versionV1 : .versionV2
self.updateTelemetry()
}
self.updatedLPVariable = nil
self.onboardingScreenType = lpVariableValue
self.updatedLPVariable?()
}
Expand Down
Loading

0 comments on commit 1a021d7

Please sign in to comment.