Skip to content

Commit

Permalink
Release version 3.10.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Team Mobile Schorsch committed Sep 30, 2024
1 parent daedec8 commit fc825d5
Show file tree
Hide file tree
Showing 42 changed files with 239 additions and 150 deletions.
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ let package = Package(
dependencies: [
// Dependencies declare other packages that this package depends on.
// .package(url: /* package url */, from: "1.0.0"),
.package(name: "GiniBankAPILibrary", url: "https://github.com/gini/bank-api-library-ios.git", .exact("3.3.0"))
.package(name: "GiniBankAPILibrary", url: "https://github.com/gini/bank-api-library-ios.git", .exact("3.3.1"))
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
Expand Down
4 changes: 2 additions & 2 deletions Sources/GiniCaptureSDK/Core/Custom views/GiniBarButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -193,14 +193,14 @@ public final class GiniBarButton {
return attributes
}

public func setContentHuggingPriority(_ priority: UILayoutPriority,
public func setContentHuggingPriority(_ priority: UILayoutPriority,
for axis: NSLayoutConstraint.Axis) {
stackView.setContentHuggingPriority(priority, for: axis)
titleLabel.setContentHuggingPriority(priority, for: axis)
imageView.setContentHuggingPriority(priority, for: axis)
}

public func setContentCompressionResistancePriority(_ priority: UILayoutPriority,
public func setContentCompressionResistancePriority(_ priority: UILayoutPriority,
for axis: NSLayoutConstraint.Axis) {
stackView.setContentCompressionResistancePriority(priority, for: axis)
titleLabel.setContentCompressionResistancePriority(priority, for: axis)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import UIKit
o that the button's width and height can be adjusted by the Auto Layout system.
**/

public class MultilineTitleButton: UIButton {
public class MultilineTitleButton: GiniCaptureButton {

/**
`init?(coder:)` is used for creating an instance of the class from a nib file
Expand Down
21 changes: 10 additions & 11 deletions Sources/GiniCaptureSDK/Core/Extensions/UIImage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -159,20 +159,19 @@ extension UIImage {
}
}


extension UIImage.Orientation {
init(_ cgOrientation: AVCaptureVideoOrientation) {
switch cgOrientation {
case .portrait:
self = .up
case .landscapeRight:
self = .right
case .landscapeLeft:
self = .left
case .portraitUpsideDown:
self = .down
@unknown default:
fatalError("Unknown AVCaptureVideoOrientation case encountered")
case .portrait:
self = .up
case .landscapeRight:
self = .right
case .landscapeLeft:
self = .left
case .portraitUpsideDown:
self = .down
@unknown default:
fatalError("Unknown AVCaptureVideoOrientation case encountered")
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ extension UIViewController {
cancelActionTitle: cancelActionTitle,
confirmActionTitle: confirmActionTitle,
confirmAction: positiveAction)

GiniAnalyticsManager.track(event: .errorDialogShown,
screenName: .camera,
properties: [GiniAnalyticsProperty(key: .errorMessage, value: message)])
Expand Down
92 changes: 40 additions & 52 deletions Sources/GiniCaptureSDK/Core/GiniConfiguration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,14 @@ import GiniBankAPILibrary
*/
public var customMenuItems: [HelpMenuItem] = []

// MAKR: - Transaction Docs feature
/**
* Indicates whether the Transaction Docs feature is enabled or not. If set to `true`,
* the user will be presented with an alert dialog in the photo payment flow to choose
* whether to attach images or PDFs to the transaction.
*/
public var transactionDocsEnabled: Bool = true

/**
Sets the default error logger. It is only used when giniErrorLoggerIsOn is true.

Expand Down Expand Up @@ -475,6 +483,26 @@ import GiniBankAPILibrary
amountToPay: ExtractionAmount) {
guard let documentService = documentService else { return }

let updatedExtractions = buildPaymentExtractions(paymentRecipient,
paymentReference,
paymentPurpose,
iban,
bic,
amountToPay)

documentService.sendFeedback(with: updatedExtractions, updatedCompoundExtractions: nil)

documentService.resetToInitialState()
self.documentService = nil
}

private func buildPaymentExtractions(_ paymentRecipient: String,
_ paymentReference: String,
_ paymentPurpose: String,
_ iban: String,
_ bic: String,
_ amountToPay: ExtractionAmount) -> [Extraction] {

let formattedPriceValue = amountToPay.value.stringValue(withDecimalPoint: 2) ?? "\(amountToPay.value)"
let amountToPayString = "\(formattedPriceValue)" + ":" + amountToPay.currency.rawValue

Expand Down Expand Up @@ -508,18 +536,12 @@ import GiniBankAPILibrary
entity: "amount",
value: amountToPayString,
name: "amountToPay")

let updatedExtractions: [Extraction] = [paymentRecipientExtraction,
paymentReferenceExtraction,
paymentPurposeExtraction,
ibanExtraction,
bicExtraction,
amountExtraction]

documentService.sendFeedback(with: updatedExtractions, updatedCompoundExtractions: nil)

documentService.resetToInitialState()
self.documentService = nil
return [paymentRecipientExtraction,
paymentReferenceExtraction,
paymentPurposeExtraction,
ibanExtraction,
bicExtraction,
amountExtraction]
}
// swiftlint:enable function_parameter_count

Expand Down Expand Up @@ -566,46 +588,12 @@ import GiniBankAPILibrary
amountToPay: ExtractionAmount) {
guard let documentService = documentService else { return }

let formattedPriceValue = amountToPay.value.stringValue(withDecimalPoint: 2) ?? "\(amountToPay.value)"
let amountToPayString = "\(formattedPriceValue)" + ":" + amountToPay.currency.rawValue

let paymentRecipientExtraction = Extraction(box: nil,
candidates: nil,
entity: "companyname",
value: paymentRecipient,
name: "paymentRecipient")
let paymentReferenceExtraction = Extraction(box: nil,
candidates: nil,
entity: "reference",
value: paymentReference,
name: "paymentReference")
let paymentPurposeExtraction = Extraction(box: nil,
candidates: nil,
entity: "text",
value: paymentPurpose,
name: "paymentPurpose")
let ibanExtraction = Extraction(box: nil,
candidates: nil,
entity: "iban",
value: iban,
name: "iban")
let bicExtraction = Extraction(box: nil,
candidates: nil,
entity: "bic",
value: bic,
name: "bic")
let amountExtraction = Extraction(box: nil,
candidates: nil,
entity: "amount",
value: amountToPayString,
name: "amountToPay")

let updatedExtractions: [Extraction] = [paymentRecipientExtraction,
paymentReferenceExtraction,
paymentPurposeExtraction,
ibanExtraction,
bicExtraction,
amountExtraction]
let updatedExtractions = buildPaymentExtractions(paymentRecipient,
paymentReference,
paymentPurpose,
iban,
bic,
amountToPay)

documentService.sendFeedback(with: updatedExtractions, updatedCompoundExtractions: nil)
}
Expand Down
13 changes: 12 additions & 1 deletion Sources/GiniCaptureSDK/Core/Helpers/ButtonConfiguration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,22 @@ extension BottomLabelButton {
}
}

public extension UIButton {
public class GiniCaptureButton: UIButton {
var traitCollectionUpdated: () -> Void = {}
public override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
traitCollectionUpdated()
}
}

public extension GiniCaptureButton {
func configure(with configuration: ButtonConfiguration) {
self.backgroundColor = configuration.backgroundColor
self.layer.borderColor = configuration.borderColor.cgColor
self.layer.shadowColor = configuration.shadowColor.cgColor
traitCollectionUpdated = { [weak self] in
self?.layer.borderColor = configuration.borderColor.cgColor
self?.layer.shadowColor = configuration.shadowColor.cgColor
}
self.setTitleColor(configuration.titleColor, for: .normal)
self.setTitleColor(configuration.titleColor, for: .highlighted)
self.setTitleColor(configuration.titleColor, for: .selected)
Expand Down
28 changes: 14 additions & 14 deletions Sources/GiniCaptureSDK/Core/Helpers/GiniCaptureUtils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// GiniCaptureUtils.swift
// GiniCapture
//
// Created by Peter Pult on 15/06/16.
// Copyright © 2016 Gini GmbH. All rights reserved.
//

Expand All @@ -14,9 +13,9 @@ public func giniCaptureBundle() -> Bundle {

/**
Returns an optional `UIImage` instance with the given `name` preferably from the client's bundle.

- parameter name: The name of the image file without file extension.

- returns: Image if found with name.
*/
public func UIImageNamedPreferred(named name: String) -> UIImage? {
Expand All @@ -39,9 +38,9 @@ public func UIImageNamedPreferred(named name: String) -> UIImage? {

/**
Returns an optional `UIColor` instance with the given `name` preferably from the client's bundle.

- parameter name: The name of the UIColor from `GiniColors` asset catalog.

- returns: color if found with name.
*/
public func UIColorPreferred(named name: String) -> UIColor {
Expand Down Expand Up @@ -84,10 +83,10 @@ public func UIColorPreferredByProvider(named name: String) -> UIColor {

/**
Returns a localized string resource preferably from the client's bundle.

- parameter key: The key to search for in the strings file.
- parameter comment: The corresponding comment.

- returns: String resource for the given key.
*/
public func NSLocalizedStringPreferredFormat(_ key: String,
Expand All @@ -106,7 +105,7 @@ public func NSLocalizedStringPreferredFormat(_ key: String,
fallbackKey: fallbackKey,
comment: comment,
bundle: customBundle) {

return clientLocalizedStringCustomBundle
}
}
Expand All @@ -118,7 +117,7 @@ private func giniLocalizedString(_ key: String,
fallbackKey: String,
comment: String) -> String {
let giniBundle = giniCaptureBundle()

var defaultFormat = NSLocalizedString(key,
bundle: giniBundle,
comment: comment)
Expand All @@ -141,7 +140,7 @@ private func clientLocalizedString(_ key: String,
var fallbackClientString = NSLocalizedString(fallbackKey,
bundle: bundle,
comment: comment)

if let localizedResourceName = GiniConfiguration.shared.localizedStringsTableName {
clientString = NSLocalizedString(key,
tableName: localizedResourceName,
Expand All @@ -152,11 +151,12 @@ private func clientLocalizedString(_ key: String,
bundle: bundle,
comment: comment)
}

guard (clientString.lowercased() != key.lowercased() || fallbackClientString.lowercased() != fallbackKey.lowercased()) else {

guard clientString.lowercased() != key.lowercased()
|| fallbackClientString.lowercased() != fallbackKey.lowercased() else {
return nil
}

return clientString
}

Expand Down Expand Up @@ -225,7 +225,7 @@ public class Constraints {
}

/**
Measure the time spent executing a block
Measure the time spent executing a block
*/

func measure(block: () -> Void) {
Expand Down
5 changes: 4 additions & 1 deletion Sources/GiniCaptureSDK/Core/Models/GiniCaptureDocument.swift
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,10 @@ private extension GiniCaptureDocumentBuilder {
self.data = data
}

override func writeContents(_ contents: Any, to url: URL, for saveOperation: UIDocument.SaveOperation, originalContentsURL: URL?) throws {
override func writeContents(_ contents: Any,
to url: URL,
for saveOperation: UIDocument.SaveOperation,
originalContentsURL: URL?) throws {
if (contents as? Data) == nil, (contents as? FileWrapper) == nil {
throw DocumentError.unrecognizedContent
}
Expand Down
7 changes: 4 additions & 3 deletions Sources/GiniCaptureSDK/Core/Screens/Camera/Camera.swift
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,8 @@ fileprivate extension Camera {
// Configure video data output.
videoDataOutput.alwaysDiscardsLateVideoFrames = true
videoDataOutput.setSampleBufferDelegate(self, queue: videoDataOutputQueue)
videoDataOutput.videoSettings = [kCVPixelBufferPixelFormatTypeKey as String: kCVPixelFormatType_420YpCbCr8BiPlanarFullRange]
let videoSettings = [kCVPixelBufferPixelFormatTypeKey as String: kCVPixelFormatType_420YpCbCr8BiPlanarFullRange]
videoDataOutput.videoSettings = videoSettings
if !session.canAddOutput(videoDataOutput) {
for output in session.outputs {
session.removeOutput(output)
Expand Down Expand Up @@ -402,8 +403,8 @@ fileprivate extension Camera {
for result in extractIBANS(string: candidate.string) {
let ibanRectTransformed = visionResult.boundingBox.applying(visionToAVFTransform)
if let videoPreviewLayer = videoPreviewLayer, let regionOfInterest = regionOfInterest {
let convertedRect = videoPreviewLayer.layerRectConverted(fromMetadataOutputRect: ibanRectTransformed)
if regionOfInterest.contains(convertedRect) {
let newRect = videoPreviewLayer.layerRectConverted(fromMetadataOutputRect: ibanRectTransformed)
if regionOfInterest.contains(newRect) {
ibans.insert(result)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,10 @@ final class CameraViewController: UIViewController {
self.qrCodeOverLay.isHidden = false
self.cameraPreviewViewController.changeQRFrameColor(to: .GiniCapture.success2)
}


// Voiceover announcement
playVoiceOverMessage(success: true)

// this event is sent once per SDK session since the message can be displayed often in the same session
GiniAnalyticsManager.track(event: .qr_code_scanned,
screenName: .camera,
Expand All @@ -596,9 +599,23 @@ final class CameraViewController: UIViewController {
self.qrCodeOverLay.isHidden = false
self.cameraPreviewViewController.changeQRFrameColor(to: .GiniCapture.warning3)
}

// Voiceover announcement
playVoiceOverMessage(success: false)

sendGiniAnalyticsEventForInvalidQRCode()
qrCodeOverLay.configureQrCodeOverlay(withCorrectQrCode: false)
}

private func playVoiceOverMessage(success: Bool) {
// Determine the appropriate message based on success
let message = success
? NSLocalizedStringPreferredFormat("ginicapture.QRscanning.correct", comment: "QR Detected")
: NSLocalizedStringPreferredFormat("ginicapture.QRscanning.incorrect.title", comment: "Unknown QR")

// Post the announcement for VoiceOver
UIAccessibility.post(notification: .announcement, argument: message)
}

private func sendGiniAnalyticsEventForInvalidQRCode() {
guard invalidQRCodeOverlayFirstAppearance else { return }
Expand Down
Loading

0 comments on commit fc825d5

Please sign in to comment.