Skip to content

Commit

Permalink
Merge branch 'main' into wt/sticker
Browse files Browse the repository at this point in the history
  • Loading branch information
thatswinnie committed Nov 14, 2024
2 parents c93cecc + 1f59f7b commit 121cd99
Show file tree
Hide file tree
Showing 370 changed files with 5,957 additions and 972 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/firefox-ios-autofill-playwrite-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,5 @@ jobs:
env:
JOB_STATUS: ${{ job.status == 'success' && ':white_check_mark:' || job.status == 'failure' && ':x:' }}
JOB_STATUS_COLOR: ${{ job.status == 'success' && '#36a64f' || job.status == 'failure' && '#FF0000' }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
SLACK_WEBHOOK_URL: ${{ secrets.WEBHOOK_SLACK_TOKEN }}
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,4 @@ jobs:
call-firefox-ios-autofill-playwrite-tests:
uses: ./.github/workflows/firefox-ios-autofill-playwrite-tests.yml
secrets:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
SLACK_WEBHOOK_URL: ${{ secrets.WEBHOOK_SLACK_TOKEN }}
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ jobs:
env:
JOB_STATUS: ${{ job.status == 'success' && ':white_check_mark:' || job.status == 'failure' && ':x:' }}
JOB_STATUS_COLOR: ${{ job.status == 'success' && '#36a64f' || job.status == 'failure' && '#FF0000' }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
SLACK_WEBHOOK_URL: ${{ secrets.WEBHOOK_SLACK_TOKEN }}
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK
with:
payload-file-path: "./test-fixtures/ci/slack-notification-payload-remote-settings-fetch.json"
2 changes: 1 addition & 1 deletion .github/workflows/update_readme_current_tech_stack.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:

jobs:
update_readme_with_current_stack:
runs-on: ubuntu-latest
runs-on: macos-latest

steps:
- name: Checkout code
Expand Down
2 changes: 1 addition & 1 deletion BrowserKit/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ let package = Package(
exact: "2.0.0"),
.package(
url: "https://github.com/getsentry/sentry-cocoa.git",
exact: "8.36.0"),
exact: "8.21.0"),
.package(
url: "https://github.com/nbhasin2/GCDWebServer.git",
branch: "master"),
Expand Down
19 changes: 15 additions & 4 deletions BrowserKit/Sources/Common/Utilities/AppInfo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,24 @@ open class AppInfo {
}

public static var bundleIdentifier: String {
return applicationBundle.object(forInfoDictionaryKey: "CFBundleIdentifier") as! String
guard let bundleIdentifier = applicationBundle.object(forInfoDictionaryKey: "CFBundleIdentifier") as? String else {
fatalError("CFBundleIdentifier not found in info.plist")
}
return bundleIdentifier
}

public static var appVersion: String {
return applicationBundle.object(forInfoDictionaryKey: "CFBundleShortVersionString") as! String
guard let appVersion = applicationBundle.object(forInfoDictionaryKey: "CFBundleShortVersionString") as? String else {
fatalError("CFBundleShortVersionString not found in info.plist")
}
return appVersion
}

public static var buildNumber: String {
return applicationBundle.object(forInfoDictionaryKey: String(kCFBundleVersionKey)) as! String
guard let buildNumber = applicationBundle.object(forInfoDictionaryKey: String(kCFBundleVersionKey)) as? String else {
fatalError("kCFBundleVersionKey not found in info.plist")
}
return buildNumber
}

/// Return the base bundle identifier.
Expand All @@ -38,7 +47,9 @@ open class AppInfo {
/// of the *base* bundle identifier.
public static var baseBundleIdentifier: String {
let bundle = Bundle.main
let packageType = bundle.object(forInfoDictionaryKey: "CFBundlePackageType") as! String
guard let packageType = bundle.object(forInfoDictionaryKey: "CFBundlePackageType") as? String else {
fatalError("CFBundlePackageType not found in info.plist")
}
let baseBundleIdentifier = bundle.bundleIdentifier!
if packageType == "XPC!" {
let components = baseBundleIdentifier.components(separatedBy: ".")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,16 @@ public final class NavigationHeaderView: UIView {

public func setupAccessibility(closeButtonA11yLabel: String,
closeButtonA11yId: String,
titleA11yId: String? = nil,
backButtonA11yLabel: String,
backButtonA11yId: String) {
let closeButtonViewModel = CloseButtonViewModel(a11yLabel: closeButtonA11yLabel,
a11yIdentifier: closeButtonA11yId)
closeButton.configure(viewModel: closeButtonViewModel)
if let titleA11yId {
titleLabel.isAccessibilityElement = true
titleLabel.accessibilityIdentifier = titleA11yId
}
backButton.accessibilityIdentifier = backButtonA11yId
backButton.accessibilityLabel = backButtonA11yLabel
}
Expand Down
2 changes: 2 additions & 0 deletions BrowserKit/Sources/MenuKit/MenuDetailView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,12 @@ public final class MenuDetailView: UIView,

public func setupAccessibilityIdentifiers(closeButtonA11yLabel: String,
closeButtonA11yId: String,
titleA11yId: String? = nil,
backButtonA11yLabel: String,
backButtonA11yId: String) {
detailHeaderView.setupAccessibility(closeButtonA11yLabel: closeButtonA11yLabel,
closeButtonA11yId: closeButtonA11yId,
titleA11yId: titleA11yId,
backButtonA11yLabel: backButtonA11yLabel,
backButtonA11yId: backButtonA11yId)
}
Expand Down
4 changes: 2 additions & 2 deletions BrowserKit/Sources/Redux/DispatchStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ public protocol DispatchStore {
func dispatch(_ action: Action)
}

public protocol DefaultDispatchStore: DispatchStore {
associatedtype State: StateType
public protocol DefaultDispatchStore<State>: DispatchStore where State: StateType {
associatedtype State

var state: State { get }

Expand Down
1 change: 1 addition & 0 deletions BrowserKit/Sources/Redux/Store.swift
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ public class Store<State: StateType>: DefaultDispatchStore {
// (Note: this is true even if the action's UUID differs from the screen's window's UUID).
// Typically, reducers should compare the action's UUID to the incoming state UUID and skip
// processing for actions originating in other windows.
// Note that only reducers for active screens are processed.
let newState = reducer(state, action)

// Middlewares are all given an opportunity to respond to the action. This is only done once
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,9 +257,15 @@ public class BrowserAddressToolbar: UIView,
}

private func updateActionStack(stackView: UIStackView, toolbarElements: [ToolbarElement]) {
let existingButtons = stackView.arrangedSubviews.compactMap { $0 as? ToolbarButton }
stackView.removeAllArrangedViews()

toolbarElements.forEach { toolbarElement in
let button = toolbarElement.numberOfTabs != nil ? TabNumberButton() : ToolbarButton()
// find existing button or create new one
// we do this to avoid having a new button every time we re-configure the address toolbar
// as this can result in button taps not resulting in correct action because the action
// as the reference to an old and not displayed button (e.g. the menu that is displayed from the menu button)
let button = newOrExistingToolbarButton(for: toolbarElement, existingButtons: existingButtons)
button.configure(element: toolbarElement)
stackView.addArrangedSubview(button)

Expand All @@ -279,6 +285,17 @@ public class BrowserAddressToolbar: UIView,
}
}

private func newOrExistingToolbarButton(for element: ToolbarElement,
existingButtons: [ToolbarButton]) -> ToolbarButton {
let existingButton = existingButtons.first { $0.isButtonFor(toolbarElement: element) }

guard let existingButton else {
return element.numberOfTabs != nil ? TabNumberButton() : ToolbarButton()
}

return existingButton
}

private func updateActionSpacing() {
// Browser action spacing
let hasBrowserActions = !browserActionStack.arrangedSubviews.isEmpty
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ final class LocationView: UIView,
static let gradientViewWidth: CGFloat = 40
static let iconContainerCornerRadius: CGFloat = 8
static let lockIconImageViewSize = CGSize(width: 40, height: 24)
static let iconContainerNoLockLeadingSpace: CGFloat = 16
}

private var urlAbsolutePath: String?
Expand Down Expand Up @@ -248,7 +249,10 @@ final class LocationView: UIView,
removeContainerIcons()
iconContainerStackView.addArrangedSubview(lockIconButton)
updateURLTextFieldLeadingConstraint()
iconContainerStackViewLeadingConstraint?.constant = 0

let leadingConstraint = lockIconImageName == nil ? UX.iconContainerNoLockLeadingSpace : 0.0

iconContainerStackViewLeadingConstraint?.constant = leadingConstraint
updateGradient()
}

Expand Down Expand Up @@ -282,7 +286,7 @@ final class LocationView: UIView,
urlTextField.text = text

// Start overlay mode & select text when in edit mode with a search term
if shouldShowKeyboard == true && state.shouldSelectSearchTerm == true {
if shouldShowKeyboard, state.shouldSelectSearchTerm {
DispatchQueue.main.async {
self.urlTextField.text = text
self.urlTextField.selectAll(nil)
Expand Down
17 changes: 17 additions & 0 deletions BrowserKit/Sources/ToolbarKit/ToolbarButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@ class ToolbarButton: UIButton, ThemeApplicable {
if let maskImageName = element.maskImageName {
addMaskIcon(maskImageName: maskImageName)
}
} else {
// Remove badge & mask icons
imageView?.subviews.forEach { view in
guard view as? UIImageView != nil else { return }
view.removeFromSuperview()
}
}
layoutIfNeeded()
}
Expand All @@ -96,6 +102,17 @@ class ToolbarButton: UIButton, ThemeApplicable {
configuration = updatedConfiguration
}

public func isButtonFor(toolbarElement: ToolbarElement) -> Bool {
guard let config = configuration else { return false }

return isSelected == toolbarElement.isSelected &&
config.image == imageConfiguredForRTL(for: toolbarElement) &&
isEnabled == toolbarElement.isEnabled &&
accessibilityIdentifier == toolbarElement.a11yId &&
accessibilityLabel == toolbarElement.a11yLabel &&
accessibilityHint == toolbarElement.a11yHint
}

private func addBadgeIcon(imageName: String) {
badgeImageView = UIImageView(image: UIImage(named: imageName))
guard let badgeImageView, configuration?.image != nil else { return }
Expand Down
57 changes: 33 additions & 24 deletions firefox-ios/Account/FxAPushMessageHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import Shared
import Account
import Common
import enum MozillaAppServices.IncomingDeviceCommand
import enum MozillaAppServices.AccountEvent

let PendingAccountDisconnectedKey = "PendingAccountDisconnect"

Expand Down Expand Up @@ -34,36 +35,15 @@ extension FxAPushMessageHandler {
RustFirefoxAccounts.reconfig(prefs: self.profile.prefs) { accountManager in
accountManager.deviceConstellation()?.handlePushMessage(pushPayload: message) { result in
guard case .success(let event) = result else {
let err: PushMessageError
if case .failure(let error) = result {
self.logger.log("Failed to get any events from FxA",
level: .warning,
category: .sync,
description: error.localizedDescription)
err = PushMessageError.messageIncomplete(error.localizedDescription)
} else {
self.logger.log("Got zero events from FxA",
level: .warning,
category: .sync,
description: "No events retrieved from fxa")
err = PushMessageError.messageIncomplete("empty message")
}
let err = self.makePushErrorMessageFrom(result: result)
completion(.failure(err))
return
}

switch event {
case .commandReceived(let deviceCommand):
switch deviceCommand {
case .tabReceived(_, let tabData):
let title = tabData.entries.last?.title ?? ""
let url = tabData.entries.last?.url ?? ""
let command = CommandReceived.tabReceived(tab: ["title": title, "url": url])
completion(.success(PushMessage.commandReceived(command: command)))
case .tabsClosed(_, let payload):
let command = CommandReceived.tabsClosed(urls: payload.urls)
completion(.success(PushMessage.commandReceived(command: command)))
}
let pushMessage = self.makePushMessageFrom(deviceCommand: deviceCommand)
completion(.success(pushMessage))
case .deviceConnected(let deviceName):
completion(.success(PushMessage.deviceConnected(deviceName)))
case let .deviceDisconnected(_, isLocalDevice):
Expand All @@ -83,6 +63,35 @@ extension FxAPushMessageHandler {
}
}
}

private func makePushErrorMessageFrom(result: Result<AccountEvent, Error>) -> PushMessageError {
if case .failure(let error) = result {
self.logger.log("Failed to get any events from FxA",
level: .warning,
category: .sync,
description: error.localizedDescription)
return PushMessageError.messageIncomplete(error.localizedDescription)
} else {
self.logger.log("Got zero events from FxA",
level: .warning,
category: .sync,
description: "No events retrieved from fxa")
return PushMessageError.messageIncomplete("empty message")
}
}

private func makePushMessageFrom(deviceCommand: IncomingDeviceCommand) -> PushMessage {
switch deviceCommand {
case .tabReceived(_, let tabData):
let title = tabData.entries.last?.title ?? ""
let url = tabData.entries.last?.url ?? ""
let command = CommandReceived.tabReceived(tab: ["title": title, "url": url])
return PushMessage.commandReceived(command: command)
case .tabsClosed(_, let payload):
let command = CommandReceived.tabsClosed(urls: payload.urls)
return PushMessage.commandReceived(command: command)
}
}
}

enum PushMessageType: String {
Expand Down
Loading

0 comments on commit 121cd99

Please sign in to comment.