Skip to content
Snippets Groups Projects
Commit c769bc6d authored by Rawaha El Houssayni's avatar Rawaha El Houssayni Committed by Rawaha El Houssayni
Browse files

settings: typing indicator

Add settings toggle to enable or disable the typing
indicator feature.
Change-Id: I9b37bbf922242282eb85eba50267342c56f78b82
parent 1a02d64e
No related branches found
No related tags found
No related merge requests found
......@@ -453,8 +453,10 @@ internal enum L10n {
internal static let turnServer = L10n.tr("Localizable", "accountPage.turnServer", fallback: "TURN address")
/// TURN username
internal static let turnUsername = L10n.tr("Localizable", "accountPage.turnUsername", fallback: "TURN username")
/// Typing indicator
internal static let typingIndicator = L10n.tr("Localizable", "accountPage.typingIndicator", fallback: "Typing indicator")
/// Enable typing indicator
internal static let typingIndicator = L10n.tr("Localizable", "accountPage.typingIndicator", fallback: "Enable typing indicator")
/// Send and receive typing indicators showing that a message is being typed.
internal static let typingIndicatorExplanation = L10n.tr("Localizable", "accountPage.typingIndicatorExplanation", fallback: "Send and receive typing indicators showing that a message is being typed.")
/// Unblock
internal static let unblockContact = L10n.tr("Localizable", "accountPage.unblockContact", fallback: "Unblock")
/// Unlink
......
......@@ -31,6 +31,7 @@ class AccountSettings: ObservableObject {
@Published var showNotificationPermitionIssue: Bool = false
@Published var upnpEnabled: Bool = false
@Published var turnEnabled: Bool = false
@Published var typingIndicator: Bool = true
@Published var autoRegistrationEnabled: Bool = false
@Published var autoRegistrationExpirationTime = ""
......@@ -120,6 +121,7 @@ extension AccountSettings {
self.proxyAddress = self.account.proxy
self.callsFromUnknownContacts = self.getBoolState(for: ConfigKey.dhtPublicIn)
self.peerDiscovery = self.getBoolState(for: ConfigKey.dhtPeerDiscovery)
self.typingIndicator = self.getBoolState(for: ConfigKey.typingIndicator)
self.verifyNotificationPermissionStatus()
observeNotificationPermissionChanges()
}
......@@ -133,6 +135,15 @@ extension AccountSettings {
self.callsFromUnknownContacts = enable
}
func enableTypingIndicator(enable: Bool) {
if self.typingIndicator == enable {
return
}
let property = ConfigKeyModel(withKey: ConfigKey.typingIndicator)
self.accountService.switchAccountPropertyTo(state: enable, accountId: account.id, property: property)
self.typingIndicator = enable
}
func enableProxyList(enable: Bool) {
if self.proxyListEnabled == enable {
return
......
......@@ -42,6 +42,31 @@ struct CallSettingsView: View {
}
}
struct ChatSettingsView: View {
@StateObject var model: AccountSettings
init(injectionBag: InjectionBag, account: AccountModel) {
_model = StateObject(wrappedValue: AccountSettings(account: account, injectionBag: injectionBag))
}
var body: some View {
List {
VStack(alignment: .leading) {
ToggleCell(
toggleText: L10n.AccountPage.typingIndicator,
getAction: { model.typingIndicator },
setAction: { newValue in model.enableTypingIndicator(enable: newValue) }
)
Text(L10n.AccountPage.typingIndicatorExplanation)
.font(.footnote)
.foregroundColor(Color(UIColor.secondaryLabel))
}
}
.navigationBarTitleDisplayMode(.inline)
.navigationTitle(L10n.AccountPage.chats)
}
}
struct NotificationsSettingsView: View {
@StateObject var model: AccountSettings
......
......@@ -31,6 +31,9 @@ struct SettingsSummaryView: View {
SettingsRow(iconName: "shield", title: L10n.AccountPage.security)
}
} else {
NavigationLink(destination: ChatSettingsView(injectionBag: model.injectionBag, account: model.account)) {
SettingsRow(iconName: "message", title: L10n.AccountPage.chats)
}
NavigationLink(destination: CallSettingsView(injectionBag: model.injectionBag, account: model.account)) {
SettingsRow(iconName: "phone", title: L10n.Global.call)
}
......
......@@ -111,6 +111,7 @@ enum ConfigKey: String {
case accountPublish = "Account.accountPublish"
case managerUri = "Account.managerUri"
case managerUsername = "Account.managerUsername"
case typingIndicator = "Account.sendComposing"
}
/**
......
......@@ -406,7 +406,8 @@
"accountPage.dhtConfiguration" = "OpenDHT configuration";
"accountPage.nameServer" = "Name server";
"accountPage.chats" = "Chats";
"accountPage.typingIndicator" = "Typing indicator";
"accountPage.typingIndicator" = "Enable typing indicator";
"accountPage.typingIndicatorExplanation" = "Send and receive typing indicators showing that a message is being typed.";
// Backup Account
"backupAccount.explanation" = "This Jami account exists only on this device. The account will be lost if this device is lost or if the application is uninstalled. It is recommended to make a backup of this account.";
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment