[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-taler-ios] 41/54: playSound
From: |
gnunet |
Subject: |
[taler-taler-ios] 41/54: playSound |
Date: |
Fri, 30 Jun 2023 22:34:13 +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 62ed87eb501dee37205576eb6272f653b9a5ba9e
Author: Marc Stibane <marc@taler.net>
AuthorDate: Fri Jun 30 17:27:43 2023 +0200
playSound
---
TalerWallet1/Backend/WalletCore.swift | 8 +++++
TalerWallet1/Helper/playSound.swift | 14 +++++---
TalerWallet1/Views/HelperViews/Buttons.swift | 37 ++++++++++++++--------
TalerWallet1/Views/Main/MainView.swift | 2 +-
TalerWallet1/Views/Payment/PaymentURIView.swift | 5 +--
.../Views/Sheets/P2P_Sheets/P2pAcceptDone.swift | 1 -
.../WithdrawAcceptDone.swift | 1 -
7 files changed, 42 insertions(+), 26 deletions(-)
diff --git a/TalerWallet1/Backend/WalletCore.swift
b/TalerWallet1/Backend/WalletCore.swift
index cd6cf88..2bbe07d 100644
--- a/TalerWallet1/Backend/WalletCore.swift
+++ b/TalerWallet1/Backend/WalletCore.swift
@@ -186,6 +186,14 @@ extension WalletCore {
do {
let decoded = try JSONDecoder().decode(TransactionTransition.self,
from: jsonData)
if decoded.newTxState != decoded.oldTxState {
+ if decoded.newTxState.major == .done {
+ let components =
decoded.transactionId.components(separatedBy: [":"])
+ if components.count >= 3 { // txn:$txtype:$uid
+ if let type = TransactionType(rawValue: components[1])
{
+ playSound(type.isIncoming ? 2 : 1)
+ }
+ }
+ }
postNotification(.TransactionStateTransition,
userInfo: [TRANSACTIONTRANSITION: decoded])
}
diff --git a/TalerWallet1/Helper/playSound.swift
b/TalerWallet1/Helper/playSound.swift
index 9f4d3b2..ede020f 100644
--- a/TalerWallet1/Helper/playSound.swift
+++ b/TalerWallet1/Helper/playSound.swift
@@ -6,11 +6,15 @@ import Foundation
import AVFoundation
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)
+ if number < 999 {
+ let sound = (number == 0) ? "payment_failure" :
+ (number == 1) ? "payment_success" : "PaymentReceived"
+ let fileURL = URL(fileURLWithPath: "/System/Library/Audio/UISounds/"
+ + sound + ".caf")
+ AudioServicesCreateSystemSoundID(fileURL as CFURL, &soundID)
+ } else {
+ soundID = UInt32(number)
+ }
AudioServicesPlaySystemSound(soundID);
}
diff --git a/TalerWallet1/Views/HelperViews/Buttons.swift
b/TalerWallet1/Views/HelperViews/Buttons.swift
index 69d1179..3d06b25 100644
--- a/TalerWallet1/Views/HelperViews/Buttons.swift
+++ b/TalerWallet1/Views/HelperViews/Buttons.swift
@@ -4,8 +4,6 @@
*/
import SwiftUI
import Foundation
-import AVFoundation
-
@@ -191,22 +189,33 @@ struct TalerButtonStyle: ButtonStyle {
struct Buttons_Previews: PreviewProvider {
static var previews: some View {
VStack {
- HamburgerButton() {}
- .padding()
- QRButton() {}
- .padding()
- PlusButton() {}
- .padding()
+ HamburgerButton() {
+ playSound(1000)
+ }.padding()
+ QRButton() {
+ playSound(1001)
+ }.padding()
+ PlusButton() {
+ playSound(1002) // == 7
+ }.padding()
+ HamburgerButton() {
+ playSound(1003)
+ }.padding()
+ QRButton() {
+ playSound(1004)
+ }.padding()
+ PlusButton() {
+ playSound(1005)
+ }.padding()
HStack {
ReloadButton(disabled: false) {
- AudioServicesPlaySystemSound(1000)
- }
- .padding()
- ReloadButton(disabled: true) {}
- .padding()
+ playSound(1006)
+ }.padding()
+ ReloadButton(disabled: true) {
+ }.padding()
}
Button(String(localized: "Accept"), action: {
- AudioServicesPlaySystemSound(1015)
+ playSound(1008)
})
.buttonStyle(TalerButtonStyle(type: .prominent))
.padding(.horizontal)
diff --git a/TalerWallet1/Views/Main/MainView.swift
b/TalerWallet1/Views/Main/MainView.swift
index c3b3ff3..e482189 100644
--- a/TalerWallet1/Views/Main/MainView.swift
+++ b/TalerWallet1/Views/Main/MainView.swift
@@ -35,7 +35,7 @@ struct MainView: View {
// any change to rootViewId triggers popToRootView behaviour
.id(viewState.rootViewId)
.onAppear() {
- GNU_Taler.playSound(2)
+ GNU_Taler.playSound(1008) // TODO: Startup chime
soundPlayed = true
}
} else if controller.backendState == .error {
diff --git a/TalerWallet1/Views/Payment/PaymentURIView.swift
b/TalerWallet1/Views/Payment/PaymentURIView.swift
index 8430365..6570737 100644
--- a/TalerWallet1/Views/Payment/PaymentURIView.swift
+++ b/TalerWallet1/Views/Payment/PaymentURIView.swift
@@ -22,10 +22,7 @@ struct PaymentURIView: View {
do {
let confirmPayResult = try await
model.confirmPayM(detailsForUri.proposalId)
symLog.log(confirmPayResult as Any)
- if confirmPayResult.type == "done" {
- GNU_Taler.playSound(1)
- // TODO: Show Hints that Payment was successfull
- } else {
+ if confirmPayResult.type != "done" {
GNU_Taler.playSound(0)
// TODO: show error
}
diff --git a/TalerWallet1/Views/Sheets/P2P_Sheets/P2pAcceptDone.swift
b/TalerWallet1/Views/Sheets/P2P_Sheets/P2pAcceptDone.swift
index 2e73cee..1ceca54 100644
--- a/TalerWallet1/Views/Sheets/P2P_Sheets/P2pAcceptDone.swift
+++ b/TalerWallet1/Views/Sheets/P2P_Sheets/P2pAcceptDone.swift
@@ -46,7 +46,6 @@ struct P2pAcceptDone: View {
_ = try await model.confirmPeerPullDebitM(transactionId)
}
finished = true
- GNU_Taler.playSound( incoming ? 2 : 1)
} catch { // TODO: error
symLog.log(error.localizedDescription)
GNU_Taler.playSound(0)
diff --git a/TalerWallet1/Views/WithdrawBankIntegrated/WithdrawAcceptDone.swift
b/TalerWallet1/Views/WithdrawBankIntegrated/WithdrawAcceptDone.swift
index 137419b..cbc8cb8 100644
--- a/TalerWallet1/Views/WithdrawBankIntegrated/WithdrawAcceptDone.swift
+++ b/TalerWallet1/Views/WithdrawBankIntegrated/WithdrawAcceptDone.swift
@@ -49,7 +49,6 @@ 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)
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [taler-taler-ios] 14/54: Made Model a Singleton, (continued)
- [taler-taler-ios] 14/54: Made Model a Singleton, gnunet, 2023/06/30
- [taler-taler-ios] 40/54: TransactionType, gnunet, 2023/06/30
- [taler-taler-ios] 26/54: PeerPullDebit, gnunet, 2023/06/30
- [taler-taler-ios] 16/54: Dummy, gnunet, 2023/06/30
- [taler-taler-ios] 34/54: sizeCategory, task, gnunet, 2023/06/30
- [taler-taler-ios] 06/54: Notifications, gnunet, 2023/06/30
- [taler-taler-ios] 42/54: BalanceRow, gnunet, 2023/06/30
- [taler-taler-ios] 15/54: Suspend-Resume, gnunet, 2023/06/30
- [taler-taler-ios] 21/54: Sounds, P2P receive, gnunet, 2023/06/30
- [taler-taler-ios] 07/54: Big Model update, removed unneccessary thread-safety code, gnunet, 2023/06/30
- [taler-taler-ios] 41/54: playSound,
gnunet <=
- [taler-taler-ios] 30/54: bugfix, gnunet, 2023/06/30
- [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