[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-taler-ios] 36/54: playSound
From: |
gnunet |
Subject: |
[taler-taler-ios] 36/54: playSound |
Date: |
Fri, 30 Jun 2023 22:34:08 +0200 |
This is an automated email from the git hooks/post-receive script.
marc-stibane pushed a commit to branch master
in repository taler-ios.
commit e77028d251183015f2881da2ca78da5e168d84d6
Author: Marc Stibane <marc@taler.net>
AuthorDate: Wed Jun 28 17:05:15 2023 +0200
playSound
---
TalerWallet1/Helper/playSound.swift | 6 +++++-
TalerWallet1/Views/Main/MainView.swift | 11 +----------
TalerWallet1/Views/Payment/PaymentURIView.swift | 13 +++----------
TalerWallet1/Views/Sheets/P2P_Sheets/P2pAcceptDone.swift | 12 ++----------
.../Views/WithdrawBankIntegrated/WithdrawAcceptDone.swift | 2 ++
5 files changed, 13 insertions(+), 31 deletions(-)
diff --git a/TalerWallet1/Helper/playSound.swift
b/TalerWallet1/Helper/playSound.swift
index 3bb3978..9f4d3b2 100644
--- a/TalerWallet1/Helper/playSound.swift
+++ b/TalerWallet1/Helper/playSound.swift
@@ -5,7 +5,11 @@
import Foundation
import AVFoundation
-func playSound(fileURL: URL) {
+func playSound(_ number: Int) {
+ let sound = (number == 0) ? "payment_failure" :
+ (number == 1) ? "payment_success" : "PaymentReceived"
+ let fileURL = URL(fileURLWithPath: "/System/Library/Audio/UISounds/"
+ + sound + ".caf")
var soundID: SystemSoundID = 0
AudioServicesCreateSystemSoundID(fileURL as CFURL, &soundID)
AudioServicesPlaySystemSound(soundID);
diff --git a/TalerWallet1/Views/Main/MainView.swift
b/TalerWallet1/Views/Main/MainView.swift
index cc96f62..c3b3ff3 100644
--- a/TalerWallet1/Views/Main/MainView.swift
+++ b/TalerWallet1/Views/Main/MainView.swift
@@ -21,15 +21,6 @@ struct MainView: View {
@State private var urlToOpen: URL? = nil
@Binding var soundPlayed: Bool
- func playSound() -> Void {
- if !soundPlayed {
- let url = URL(fileURLWithPath: "/System/Library/Audio/UISounds/"
- + "PaymentReceived.caf")
- // + "payment_success.caf")
- // + "payment_failure.caf")
- GNU_Taler.playSound(fileURL: url)
- }
- }
func sheetDismissed() -> Void {
symLog.log("sheet dismiss")
}
@@ -44,7 +35,7 @@ struct MainView: View {
// any change to rootViewId triggers popToRootView behaviour
.id(viewState.rootViewId)
.onAppear() {
- playSound()
+ GNU_Taler.playSound(2)
soundPlayed = true
}
} else if controller.backendState == .error {
diff --git a/TalerWallet1/Views/Payment/PaymentURIView.swift
b/TalerWallet1/Views/Payment/PaymentURIView.swift
index 69dbae8..4b806f2 100644
--- a/TalerWallet1/Views/Payment/PaymentURIView.swift
+++ b/TalerWallet1/Views/Payment/PaymentURIView.swift
@@ -17,27 +17,20 @@ struct PaymentURIView: View {
@EnvironmentObject private var model: WalletModel
-
- func playSound(success: Bool) {
- let url = URL(fileURLWithPath:
"/System/Library/Audio/UISounds/payment_"
- + (success ? "success.caf" : "failure.caf"))
- GNU_Taler.playSound(fileURL: url)
- }
-
func acceptAction(detailsForUri: PaymentDetailsForUri) {
Task {
do {
let confirmPayResult = try await
model.confirmPayM(detailsForUri.proposalId)
symLog.log(confirmPayResult as Any)
if confirmPayResult.type == "done" {
- playSound(success: true)
+ GNU_Taler.playSound(1)
// TODO: Show Hints that Payment was successfull
} else {
- playSound(success: false)
+ GNU_Taler.playSound(0)
// TODO: show error
}
} catch {
- playSound(success: false)
+ GNU_Taler.playSound(0)
// TODO: error
symLog.log(error.localizedDescription)
}
diff --git a/TalerWallet1/Views/Sheets/P2P_Sheets/P2pAcceptDone.swift
b/TalerWallet1/Views/Sheets/P2P_Sheets/P2pAcceptDone.swift
index d43dfb3..07407c3 100644
--- a/TalerWallet1/Views/Sheets/P2P_Sheets/P2pAcceptDone.swift
+++ b/TalerWallet1/Views/Sheets/P2P_Sheets/P2pAcceptDone.swift
@@ -16,14 +16,6 @@ struct P2pAcceptDone: View {
@State private var finished: Bool = false
- func playSound(success: Bool, incoming: Bool) {
- let url = URL(fileURLWithPath: "/System/Library/Audio/UISounds/"
- + (success ? (incoming ? "PaymentReceived.caf"
- : "payment_success.caf")
- : "payment_failure.caf"))
- GNU_Taler.playSound(fileURL: url)
- }
-
func reloadOneAction(_ transactionId: String) async throws -> Transaction {
return try await model.getTransactionByIdT(transactionId)
}
@@ -53,10 +45,10 @@ struct P2pAcceptDone: View {
_ = try await model.confirmPeerPullDebitM(transactionId)
}
finished = true
- playSound(success: true, incoming: incoming)
+ GNU_Taler.playSound( incoming ? 2 : 1)
} catch { // TODO: error
symLog.log(error.localizedDescription)
- playSound(success: false, incoming: incoming)
+ GNU_Taler.playSound(0)
}
}
}
diff --git a/TalerWallet1/Views/WithdrawBankIntegrated/WithdrawAcceptDone.swift
b/TalerWallet1/Views/WithdrawBankIntegrated/WithdrawAcceptDone.swift
index 99df0ff..e850999 100644
--- a/TalerWallet1/Views/WithdrawBankIntegrated/WithdrawAcceptDone.swift
+++ b/TalerWallet1/Views/WithdrawBankIntegrated/WithdrawAcceptDone.swift
@@ -48,9 +48,11 @@ struct WithdrawAcceptDone: View {
let result = try await
model.sendAcceptIntWithdrawalM(exchangeBaseUrl, withdrawURL: url.absoluteString)
confirmTransferUrl = result!.confirmTransferUrl
transactionId = result!.transactionId
+ GNU_Taler.playSound(2)
}
} catch { // TODO: error
symLog.log(error.localizedDescription)
+ GNU_Taler.playSound(0)
}
}
}
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [taler-taler-ios] 43/54: confirmTransferUrl, (continued)
- [taler-taler-ios] 43/54: confirmTransferUrl, gnunet, 2023/06/30
- [taler-taler-ios] 33/54: log only release builds, gnunet, 2023/06/30
- [taler-taler-ios] 27/54: Logging, gnunet, 2023/06/30
- [taler-taler-ios] 38/54: actions, gnunet, 2023/06/30
- [taler-taler-ios] 28/54: playSound, gnunet, 2023/06/30
- [taler-taler-ios] 32/54: Adjust DebugView for Notch, gnunet, 2023/06/30
- [taler-taler-ios] 20/54: viewID + comments, gnunet, 2023/06/30
- [taler-taler-ios] 31/54: bump Testflight version, gnunet, 2023/06/30
- [taler-taler-ios] 37/54: Decodable, gnunet, 2023/06/30
- [taler-taler-ios] 29/54: Model cleanup, gnunet, 2023/06/30
- [taler-taler-ios] 36/54: playSound,
gnunet <=
- [taler-taler-ios] 44/54: BalanceReloaded, gnunet, 2023/06/30
- [taler-taler-ios] 35/54: developerMode, gnunet, 2023/06/30
- [taler-taler-ios] 45/54: TransactionDetails, gnunet, 2023/06/30
- [taler-taler-ios] 39/54: Scrollview, gnunet, 2023/06/30
- [taler-taler-ios] 25/54: failTransaction, gnunet, 2023/06/30
- [taler-taler-ios] 23/54: Remove old view, gnunet, 2023/06/30
- [taler-taler-ios] 24/54: balance-change, gnunet, 2023/06/30
- [taler-taler-ios] 47/54: #available(iOS 17.0, *) only with Xcode 15, gnunet, 2023/06/30
- [taler-taler-ios] 46/54: ThreeAmountsSheet, gnunet, 2023/06/30
- [taler-taler-ios] 51/54: remove debugging, gnunet, 2023/06/30