Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
* Add ios 12 compatibility.

* Fix iOS 12 UI.

* Check for passcode error.

* Set version.

* Update package.

* Change version to 1.0.1.

* Remove check.

* Change to light status bar.

eu-digital-green-certificates#53

* Change URL.

eu-digital-green-certificates#57

* Add secure background delegate.

* Add tap to reveal.

eu-digital-green-certificates#56

Co-authored-by: Andreas Scheibal <[email protected]>
  • Loading branch information
yspreen and ascheibal authored May 20, 2021
1 parent 316247a commit 8ad0419
Show file tree
Hide file tree
Showing 13 changed files with 91 additions and 42 deletions.
4 changes: 2 additions & 2 deletions DGCAWallet.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -686,7 +686,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.0.0;
MARKETING_VERSION = 1.0.1;
PRODUCT_BUNDLE_IDENTIFIER = "com.t-systems.DGCAWallet.dev";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
Expand All @@ -707,7 +707,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.0.0;
MARKETING_VERSION = 1.0.1;
PRODUCT_BUNDLE_IDENTIFIER = "com.t-systems.DGCAWallet.dev";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"repositoryURL": "https://github.com/eu-digital-green-certificates/dgca-app-core-ios",
"state": {
"branch": "main",
"revision": "0792980147e02bf6db0738af157bb2a8d31ea3cf",
"revision": "98c54595046e40068b570b69bd04a15668874569",
"version": null
}
},
Expand All @@ -24,8 +24,8 @@
"repositoryURL": "https://github.com/SCENEE/FloatingPanel",
"state": {
"branch": null,
"revision": "16fea625be25d9a713630a4a43cbc0778740ebf4",
"version": "2.3.0"
"revision": "da4668aa2b8277dd8ce2741ac5c39394431400fc",
"version": "2.3.1"
}
},
{
Expand Down
25 changes: 11 additions & 14 deletions DGCAWallet/Services/SecureBackground.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,30 +62,27 @@ struct SecureBackground {

static var paused = false
static var activation = Date()
public static func checkId(completion: ((Bool) -> Void)?) {
public static func checkId(from controller: UIViewController? = nil, completion: ((Bool) -> Void)?) {
guard !paused else {
return
}
paused = true
let context = LAContext()
context.localizedCancelTitle = l10n("auth.later")
let reason = l10n("auth.confirm")
var error: NSError?
guard context.canEvaluatePolicy(.deviceOwnerAuthentication, error: &error) else {
paused = false
completion?(true)
return
}
context.evaluatePolicy(.deviceOwnerAuthentication, localizedReason: reason ) { success, _ in
context.evaluatePolicy(.deviceOwnerAuthentication, localizedReason: reason ) { success, err in
if success {
// Move to the main thread because a state update triggers UI changes.
DispatchQueue.main.async {
paused = false
completion?(true)
}
paused = false
completion?(true)
} else {
paused = false
completion?(false)
if controller == nil || (err as? LAError)?.code != LAError.passcodeNotSet {
completion?(false)
return
}
controller?.showAlert(title: l10n("auth.confirm"), subtitle: l10n("auth.error")) { _ in
completion?(false)
}
}
}
}
Expand Down
12 changes: 9 additions & 3 deletions DGCAWallet/SupportingFiles/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,19 @@ import UIKit

@main
class AppDelegate: UIResponder, UIApplicationDelegate {

var window: UIWindow?
func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
// Override point for customization after application launch.
return true
if #available(iOS 13, *) {
return true
} else {
self.window = UIWindow()
self.window!.rootViewController = UIStoryboard(name: "Main", bundle: .main).instantiateInitialViewController()
self.window!.makeKeyAndVisible()
return true
}
}

func applicationWillResignActive(_ application: UIApplication) {
Expand Down
13 changes: 10 additions & 3 deletions DGCAWallet/SupportingFiles/SceneDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,23 @@

import UIKit

@available(iOS 13.0, *)
class SceneDelegate: UIResponder, UIWindowSceneDelegate {

var window: UIWindow?
func scene(_ scene: UIScene,
willConnectTo session: UISceneSession,
options connectionOptions: UIScene.ConnectionOptions) {
if let windowScene = scene as? UIWindowScene {
self.window = UIWindow(windowScene: windowScene)
self.window!.rootViewController = UIStoryboard(name: "Main", bundle: .main).instantiateInitialViewController()
self.window!.makeKeyAndVisible()
}
}

@available(iOS 13.0, *)
func sceneWillResignActive(_ scene: UIScene) {
SecureBackground.enable()
}

@available(iOS 13.0, *)
func sceneDidBecomeActive(_ scene: UIScene) {
SecureBackground.disable()
}
Expand Down
2 changes: 2 additions & 0 deletions DGCAWallet/SupportingFiles/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
"tan.label" = "TAN: %@";
"auth.confirm" = "Confirm Identity";
"auth.later" = "Try Later";
"auth.error" = "Could not verify device ownership. Please try setting a passcode for this device before opening the app.";
"cert.delete.title" = "Delete Certificate";
"cert.delete.body" = "Are you sure you want to delete this certificate? This action cannot be undone.";
"tap-to-reveal" = "tap to reveal";
"app-version" = "App Version %@";
8 changes: 8 additions & 0 deletions DGCAWallet/ViewControllers/CertCode.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@ class CertCodeVC: UIViewController {

imageView.image = hCert.qrCode
tanLabel.text = ""
if tan != nil {
tanLabel.text = String(format: l10n("tan.label"), l10n("tap-to-reveal"))
tanLabel.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(tapToReveal)))
tanLabel.isUserInteractionEnabled = true
}
}

@IBAction func tapToReveal() {
if let tan = tan {
tanLabel.text = String(format: l10n("tan.label"), tan)
}
Expand Down
23 changes: 13 additions & 10 deletions DGCAWallet/ViewControllers/CertificateViewer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,15 @@ class CertificateViewerVC: UIViewController {
@IBOutlet weak var cancelButton: UIButton!
@IBOutlet weak var cancelButtonConstraint: NSLayoutConstraint!

var hCert: HCert!
var hCert: HCert?
var tan: String?
weak var childDismissedDelegate: CertViewerDelegate?
public var isSaved = true

func draw() {
guard let hCert = hCert else {
return
}
nameLabel.text = hCert.fullName
if !isSaved {
dismissButton.setTitle(l10n("btn.save"), for: .normal)
Expand All @@ -53,16 +56,16 @@ class CertificateViewerVC: UIViewController {
view.layoutIfNeeded()
}

override func viewDidLoad() {
super.viewDidLoad()

draw()
}

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

return
if #available(iOS 13.0, *) {
draw()
} else {
DispatchQueue.main.async { [weak self] in
self?.draw()
}
}
}

var newCertAdded = false
Expand Down
12 changes: 7 additions & 5 deletions DGCAWallet/ViewControllers/Home.swift
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,13 @@ class HomeVC: UIViewController {
showAlert(title: l10n("info.outdated"), subtitle: l10n("info.outdated.body"))
return
}
SecureBackground.checkId { [weak self] in
if $0 {
self?.performSegue(withIdentifier: "list", sender: self)
} else {
self?.checkId()
SecureBackground.checkId(from: self) { success in
DispatchQueue.main.async { [weak self] in
if success {
self?.performSegue(withIdentifier: "list", sender: self)
} else {
self?.checkId()
}
}
}
}
Expand Down
12 changes: 12 additions & 0 deletions DGCAWallet/ViewControllers/List.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ class ListVC: UIViewController {
}
}

override var preferredStatusBarStyle: UIStatusBarStyle {
return .lightContent
}

override func viewDidLoad() {
super.viewDidLoad()

Expand Down Expand Up @@ -138,6 +142,14 @@ extension ListVC: CertViewerDelegate {
}

extension ListVC: ScanVCDelegate {
func disableBackgroundDetection() {
SecureBackground.paused = true
}

func enableBackgroundDetection() {
SecureBackground.paused = false
}

func hCertScanned(_ cert: HCert) {
newHCertScanned = cert
DispatchQueue.main.async { [weak self] in
Expand Down
10 changes: 10 additions & 0 deletions Localization/DGCAWallet/en.xcloc/Localized Contents/en.xliff
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,11 @@
<target>Confirm Identity</target>
<note/>
</trans-unit>
<trans-unit id="auth.error" xml:space="preserve">
<source>Could not verify device ownership. Please try setting a passcode for this device before opening the app.</source>
<target>Could not verify device ownership. Please try setting a passcode for this device before opening the app.</target>
<note/>
</trans-unit>
<trans-unit id="auth.later" xml:space="preserve">
<source>Try Later</source>
<target>Try Later</target>
Expand Down Expand Up @@ -268,6 +273,11 @@
<target>TAN: %@</target>
<note/>
</trans-unit>
<trans-unit id="tap-to-reveal" xml:space="preserve">
<source>tap to reveal</source>
<target>tap to reveal</target>
<note/>
</trans-unit>
</body>
</file>
</xliff>
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
"tan.label" = "TAN: %@";
"auth.confirm" = "Confirm Identity";
"auth.later" = "Try Later";
"auth.error" = "Could not verify device ownership. Please try setting a passcode for this device before opening the app.";
"cert.delete.title" = "Delete Certificate";
"cert.delete.body" = "Are you sure you want to delete this certificate? This action cannot be undone.";
"tap-to-reveal" = "tap to reveal";
"app-version" = "App Version %@";
4 changes: 2 additions & 2 deletions context.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
// catch-all for normal versions
"privacyUrl": "https://publications.europa.eu/en/web/about-us/legal-notices/eu-mobile-apps",
"context": {
"url": "https://dgca-issuance-web.cfapps.eu10.hana.ondemand.com/dgca-issuance-service/context",
"url": "https://issuance-dgca-test.cfapps.eu10.hana.ondemand.com/dgca-issuance-service/context",
"pubKeys": [
"lKdU1EbQubxyDDm2q3N8KclZ2C94Num3xXjG0pk+3eI=",
"r/mIkG3eEpVdm+u/ko/cwxzOMo1bk4TyHIlByibiA5E="
]
},
"endpoints": {
"claim": {
"url": "https://dgca-issuance-web.cfapps.eu10.hana.ondemand.com/dgca-issuance-service/dgci/wallet/claim",
"url": "https://issuance-dgca-test.cfapps.eu10.hana.ondemand.com/dgca-issuance-service/dgci/wallet/claim",
"pubKeys": [
"lKdU1EbQubxyDDm2q3N8KclZ2C94Num3xXjG0pk+3eI=",
"r/mIkG3eEpVdm+u/ko/cwxzOMo1bk4TyHIlByibiA5E="
Expand Down

0 comments on commit 8ad0419

Please sign in to comment.