[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-taler-ios] 01/28: Haptics
From: |
gnunet |
Subject: |
[taler-taler-ios] 01/28: Haptics |
Date: |
Tue, 19 Sep 2023 03:44:20 +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 551285dced3b70bb173b1d8e3a31f162eb7da30e
Author: Marc Stibane <marc@taler.net>
AuthorDate: Tue Sep 5 18:37:13 2023 +0200
Haptics
---
TalerWallet1/Controllers/Controller.swift | 3 +++
TalerWallet1/Helper/Controller+playSound.swift | 5 +++++
TalerWallet1/Views/Settings/SettingsView.swift | 8 +++++++-
3 files changed, 15 insertions(+), 1 deletion(-)
diff --git a/TalerWallet1/Controllers/Controller.swift
b/TalerWallet1/Controllers/Controller.swift
index 0dbd42c..35c2c6a 100644
--- a/TalerWallet1/Controllers/Controller.swift
+++ b/TalerWallet1/Controllers/Controller.swift
@@ -7,6 +7,7 @@ import AVFoundation
import SwiftUI
import SymLog
import os.log
+import CoreHaptics
enum BackendState {
case none
@@ -32,8 +33,10 @@ class Controller: ObservableObject {
private let symLog = SymLogC()
@Published var backendState: BackendState = .none // only used for
launch animation
+ @AppStorage("useHaptics") var useHaptics: Bool = false // extension
mustn't define this, so it must be here
@AppStorage("playSounds") var playSounds: Int = 0 // extension
mustn't define this, so it must be here
@AppStorage("talerFont") var talerFont: Int = 0 // extension
mustn't define this, so it must be here
+ let hapticCapability = CHHapticEngine.capabilitiesForHardware()
let logger = Logger (subsystem: "net.taler.gnu", category: "Controller")
let player = AVQueuePlayer()
diff --git a/TalerWallet1/Helper/Controller+playSound.swift
b/TalerWallet1/Helper/Controller+playSound.swift
index 31aca38..8374dd1 100644
--- a/TalerWallet1/Helper/Controller+playSound.swift
+++ b/TalerWallet1/Helper/Controller+playSound.swift
@@ -4,12 +4,14 @@
*/
import Foundation
import AVFoundation
+import UIKit
extension Controller {
/// 0 = failure, 1 = received, 2 = sent
func playSound(_ number: Int) {
var soundID: SystemSoundID = 0
+ let notificationGenerator = useHaptics ?
UINotificationFeedbackGenerator() : nil
if number > 9 {
soundID = UInt32(number)
} else {
@@ -34,5 +36,8 @@ extension Controller {
AudioServicesPlaySystemSound(soundID);
}
}
+ if let notificationGenerator {
+ notificationGenerator.notificationOccurred(number == 0 ? .error :
.success)
+ }
}
}
diff --git a/TalerWallet1/Views/Settings/SettingsView.swift
b/TalerWallet1/Views/Settings/SettingsView.swift
index 6394d07..7dbbbee 100644
--- a/TalerWallet1/Views/Settings/SettingsView.swift
+++ b/TalerWallet1/Views/Settings/SettingsView.swift
@@ -21,11 +21,13 @@ struct SettingsView: View {
private let symLog = SymLogV(0)
let navTitle: String
+ @EnvironmentObject private var controller: Controller
#if DEBUG
@AppStorage("developerMode") var developerMode: Bool = true
#else
@AppStorage("developerMode") var developerMode: Bool = false
#endif
+ @AppStorage("useHaptics") var useHaptics: Bool = false
@AppStorage("playSounds") var playSounds: Int = 0
@AppStorage("talerFont") var talerFont: Int = 0
@AppStorage("developDelay") var developDelay: Bool = false
@@ -81,8 +83,12 @@ struct SettingsView: View {
let walletCore = WalletCore.shared
Group {
List {
+ if controller.hapticCapability.supportsHaptics {
+ SettingsToggle(name: String(localized: "Haptics"), value:
$useHaptics,
+ description: String(localized: "Vibration
Feedback"))
+ }
SettingsSpeaker(name: String(localized: "Play Payment
Sounds"), value: $playSounds,
- description: String(localized: "After a
transaction finished"))
+ description: String(localized: "When a
transaction finished"))
SettingsFont(title: String(localized: "Font:"), value:
talerFont, action: redraw)
SettingsStyle(title: String(localized: "Liststyle:"),
myListStyle: $myListStyle)
if diagnosticModeEnabled {
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [taler-taler-ios] branch master updated (7d32de8 -> 8b2cfb1), gnunet, 2023/09/18
- [taler-taler-ios] 02/28: move to HelperViews, gnunet, 2023/09/18
- [taler-taler-ios] 04/28: Font, gnunet, 2023/09/18
- [taler-taler-ios] 01/28: Haptics,
gnunet <=
- [taler-taler-ios] 08/28: Binding+onChange, gnunet, 2023/09/18
- [taler-taler-ios] 10/28: ExchangeTosStatus, gnunet, 2023/09/18
- [taler-taler-ios] 03/28: talerFonts, gnunet, 2023/09/18
- [taler-taler-ios] 09/28: move AgePicker, gnunet, 2023/09/18
- [taler-taler-ios] 13/28: Comment, gnunet, 2023/09/18
- [taler-taler-ios] 06/28: Black, gnunet, 2023/09/18
- [taler-taler-ios] 14/28: ToSButton, gnunet, 2023/09/18
- [taler-taler-ios] 07/28: DebugView static font size, gnunet, 2023/09/18
- [taler-taler-ios] 12/28: Italic, gnunet, 2023/09/18
- [taler-taler-ios] 15/28: Speed up Sidebar, gnunet, 2023/09/18