2018-07-02 12:37:44 +00:00
|
|
|
/*
|
|
|
|
Copyright 2018 New Vector Ltd
|
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
import Foundation
|
|
|
|
|
2018-07-02 14:49:36 +00:00
|
|
|
/// Store Riot specific app settings.
|
2018-07-02 12:37:44 +00:00
|
|
|
@objcMembers
|
|
|
|
final class RiotSettings: NSObject {
|
|
|
|
|
|
|
|
// MARK: - Constants
|
|
|
|
|
|
|
|
private enum UserDefaultsKeys {
|
|
|
|
static let enableCrashReport = "enableCrashReport"
|
|
|
|
static let enableRageShake = "enableRageShake"
|
|
|
|
static let createConferenceCallsWithJitsi = "createConferenceCallsWithJitsi"
|
|
|
|
static let userInterfaceTheme = "userInterfaceTheme"
|
|
|
|
static let notificationsShowDecryptedContent = "showDecryptedContent"
|
|
|
|
static let pinRoomsWithMissedNotifications = "pinRoomsWithMissedNotif"
|
|
|
|
static let pinRoomsWithUnreadMessages = "pinRoomsWithUnread"
|
2019-08-28 15:04:49 +00:00
|
|
|
static let allowStunServerFallback = "allowStunServerFallback"
|
|
|
|
static let stunServerFallback = "stunServerFallback"
|
2019-12-06 11:14:13 +00:00
|
|
|
static let enableCrossSigning = "enableCrossSigning"
|
|
|
|
static let enableDMKeyVerification = "enableDMKeyVerification"
|
2018-07-02 12:37:44 +00:00
|
|
|
}
|
2019-01-11 11:43:47 +00:00
|
|
|
|
|
|
|
/// Riot Standard Room Member Power Level
|
|
|
|
@objc
|
|
|
|
public enum RoomPowerLevel: Int {
|
|
|
|
case moderator = 50
|
|
|
|
case admin = 100
|
|
|
|
}
|
|
|
|
|
2018-07-02 12:37:44 +00:00
|
|
|
static let shared = RiotSettings()
|
|
|
|
|
|
|
|
// MARK: - Public
|
|
|
|
|
|
|
|
// MARK: Notifications
|
|
|
|
|
2018-07-03 08:31:14 +00:00
|
|
|
/// Indicate if `showDecryptedContentInNotifications` settings has been set once.
|
|
|
|
var isShowDecryptedContentInNotificationsHasBeenSetOnce: Bool {
|
|
|
|
return UserDefaults.standard.object(forKey: UserDefaultsKeys.notificationsShowDecryptedContent) != nil
|
|
|
|
}
|
|
|
|
|
2018-07-02 14:49:36 +00:00
|
|
|
/// Indicate if encrypted messages content should be displayed in notifications.
|
2018-07-02 12:37:44 +00:00
|
|
|
var showDecryptedContentInNotifications: Bool {
|
|
|
|
get {
|
|
|
|
return UserDefaults.standard.bool(forKey: UserDefaultsKeys.notificationsShowDecryptedContent)
|
|
|
|
} set {
|
|
|
|
UserDefaults.standard.set(newValue, forKey: UserDefaultsKeys.notificationsShowDecryptedContent)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-07-02 14:49:36 +00:00
|
|
|
/// Indicate if rooms with missed notifications should be displayed first on home screen.
|
2018-07-02 12:37:44 +00:00
|
|
|
var pinRoomsWithMissedNotificationsOnHome: Bool {
|
|
|
|
get {
|
|
|
|
return UserDefaults.standard.bool(forKey: UserDefaultsKeys.pinRoomsWithMissedNotifications)
|
|
|
|
} set {
|
|
|
|
UserDefaults.standard.set(newValue, forKey: UserDefaultsKeys.pinRoomsWithMissedNotifications)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-07-02 14:49:36 +00:00
|
|
|
/// Indicate if rooms with unread messages should be displayed first on home screen.
|
2018-07-02 12:37:44 +00:00
|
|
|
var pinRoomsWithUnreadMessagesOnHome: Bool {
|
|
|
|
get {
|
|
|
|
return UserDefaults.standard.bool(forKey: UserDefaultsKeys.pinRoomsWithUnreadMessages)
|
|
|
|
} set {
|
|
|
|
UserDefaults.standard.set(newValue, forKey: UserDefaultsKeys.pinRoomsWithUnreadMessages)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// MARK: User interface
|
|
|
|
|
|
|
|
var userInterfaceTheme: String? {
|
|
|
|
get {
|
|
|
|
return UserDefaults.standard.string(forKey: UserDefaultsKeys.userInterfaceTheme)
|
|
|
|
} set {
|
|
|
|
UserDefaults.standard.set(newValue, forKey: UserDefaultsKeys.userInterfaceTheme)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// MARK: Other
|
|
|
|
|
2018-07-02 14:49:36 +00:00
|
|
|
/// Indicate if `enableCrashReport` settings has been set once.
|
|
|
|
var isEnableCrashReportHasBeenSetOnce: Bool {
|
|
|
|
return UserDefaults.standard.object(forKey: UserDefaultsKeys.enableCrashReport) != nil
|
|
|
|
}
|
|
|
|
|
2018-07-02 12:37:44 +00:00
|
|
|
var enableCrashReport: Bool {
|
|
|
|
get {
|
|
|
|
return UserDefaults.standard.bool(forKey: UserDefaultsKeys.enableCrashReport)
|
|
|
|
} set {
|
|
|
|
UserDefaults.standard.set(newValue, forKey: UserDefaultsKeys.enableCrashReport)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var enableRageShake: Bool {
|
|
|
|
get {
|
|
|
|
return UserDefaults.standard.bool(forKey: UserDefaultsKeys.enableRageShake)
|
|
|
|
} set {
|
|
|
|
UserDefaults.standard.set(newValue, forKey: UserDefaultsKeys.enableRageShake)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// MARK: Labs
|
|
|
|
|
|
|
|
var createConferenceCallsWithJitsi: Bool {
|
|
|
|
get {
|
|
|
|
return UserDefaults.standard.bool(forKey: UserDefaultsKeys.createConferenceCallsWithJitsi)
|
|
|
|
} set {
|
|
|
|
UserDefaults.standard.set(newValue, forKey: UserDefaultsKeys.createConferenceCallsWithJitsi)
|
|
|
|
}
|
|
|
|
}
|
2019-08-28 15:04:49 +00:00
|
|
|
|
2019-12-06 11:14:13 +00:00
|
|
|
var enableCrossSigning: Bool {
|
|
|
|
get {
|
|
|
|
return UserDefaults.standard.bool(forKey: UserDefaultsKeys.enableCrossSigning)
|
|
|
|
} set {
|
|
|
|
UserDefaults.standard.set(newValue, forKey: UserDefaultsKeys.enableCrossSigning)
|
|
|
|
}
|
|
|
|
}
|
2019-08-28 15:04:49 +00:00
|
|
|
|
|
|
|
// MARK: Calls
|
|
|
|
|
|
|
|
/// Indicate if `allowStunServerFallback` settings has been set once.
|
|
|
|
var isAllowStunServerFallbackHasBeenSetOnce: Bool {
|
|
|
|
return UserDefaults.standard.object(forKey: UserDefaultsKeys.allowStunServerFallback) != nil
|
|
|
|
}
|
|
|
|
|
|
|
|
var allowStunServerFallback: Bool {
|
|
|
|
get {
|
|
|
|
return UserDefaults.standard.bool(forKey: UserDefaultsKeys.allowStunServerFallback)
|
|
|
|
} set {
|
|
|
|
UserDefaults.standard.set(newValue, forKey: UserDefaultsKeys.allowStunServerFallback)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var stunServerFallback: String? {
|
|
|
|
return UserDefaults.standard.string(forKey: UserDefaultsKeys.stunServerFallback)
|
|
|
|
}
|
2018-07-02 12:37:44 +00:00
|
|
|
}
|