mirror of
https://github.com/lux-tel/session-ios.git
synced 2026-10-30 20:38:32 +00:00
147 lines
6.7 KiB
Swift
147 lines
6.7 KiB
Swift
// Copyright © 2022 Rangeproof Pty Ltd. All rights reserved.
|
|
//
|
|
// stringlint:disable
|
|
|
|
import Foundation
|
|
import SessionUtilitiesKit
|
|
|
|
// stringlint:ignore_contents
|
|
public extension Setting.EnumKey {
|
|
/// Controls how notifications should appear for the user (See `NotificationPreviewType` for the options)
|
|
static let preferencesNotificationPreviewType: Setting.EnumKey = "preferencesNotificationPreviewType"
|
|
|
|
/// Controls what the default sound for notifications is (See `Sound` for the options)
|
|
static let defaultNotificationSound: Setting.EnumKey = "defaultNotificationSound"
|
|
}
|
|
|
|
// stringlint:ignore_contents
|
|
public extension Setting.BoolKey {
|
|
/// Controls whether typing indicators are enabled
|
|
///
|
|
/// **Note:** Only works if both participants in a "contact" thread have this setting enabled
|
|
static let areReadReceiptsEnabled: Setting.BoolKey = "areReadReceiptsEnabled"
|
|
|
|
/// Controls whether typing indicators are enabled
|
|
///
|
|
/// **Note:** Only works if both participants in a "contact" thread have this setting enabled
|
|
static let typingIndicatorsEnabled: Setting.BoolKey = "typingIndicatorsEnabled"
|
|
|
|
/// Controls whether the device will automatically lock the screen
|
|
static let isScreenLockEnabled: Setting.BoolKey = "isScreenLockEnabled"
|
|
|
|
/// Controls whether Link Previews (image & title URL metadata) will be downloaded when the user enters a URL
|
|
///
|
|
/// **Note:** Link Previews are only enabled for HTTPS urls
|
|
static let areLinkPreviewsEnabled: Setting.BoolKey = "areLinkPreviewsEnabled"
|
|
|
|
/// Controls whether Giphy search is enabled
|
|
///
|
|
/// **Note:** Link Previews are only enabled for HTTPS urls
|
|
static let isGiphyEnabled: Setting.BoolKey = "isGiphyEnabled"
|
|
|
|
/// Controls whether Calls are enabled
|
|
static let areCallsEnabled: Setting.BoolKey = "areCallsEnabled"
|
|
|
|
/// Controls whether open group messages older than 6 months should be deleted
|
|
static let trimOpenGroupMessagesOlderThanSixMonths: Setting.BoolKey = "trimOpenGroupMessagesOlderThanSixMonths"
|
|
|
|
/// Controls whether the message requests item has been hidden on the home screen
|
|
static let hasHiddenMessageRequests: Setting.BoolKey = "hasHiddenMessageRequests"
|
|
|
|
/// Controls whether the notification sound should play while the app is in the foreground
|
|
static let playNotificationSoundInForeground: Setting.BoolKey = "playNotificationSoundInForeground"
|
|
|
|
/// A flag indicating whether the user has ever viewed their seed
|
|
static let hasViewedSeed: Setting.BoolKey = "hasViewedSeed"
|
|
|
|
/// A flag indicating whether the user hides the recovery password permanently
|
|
static let hideRecoveryPasswordPermanently: Setting.BoolKey = "hideRecoveryPasswordPermanently"
|
|
|
|
/// A flag indicating whether the user has ever saved a thread
|
|
static let hasSavedThread: Setting.BoolKey = "hasSavedThread"
|
|
|
|
/// A flag indicating whether the user has ever received or tried to send a message (whether succesffully or not)
|
|
static let hasSavedMessage: Setting.BoolKey = "hasSavedMessage"
|
|
|
|
/// A flag indicating whether the user has ever send a message
|
|
static let hasSentAMessage: Setting.BoolKey = "hasSentAMessageKey"
|
|
|
|
/// Controls whether concurrent audio messages should automatically be played after the one the user starts
|
|
/// playing finishes
|
|
static let shouldAutoPlayConsecutiveAudioMessages: Setting.BoolKey = "shouldAutoPlayConsecutiveAudioMessages"
|
|
|
|
/// Controls whether the device will poll for community message requests (SOGS `/inbox` endpoint)
|
|
static let checkForCommunityMessageRequests: Setting.BoolKey = "checkForCommunityMessageRequests"
|
|
|
|
/// Controls whether developer mode is enabled (this displays a section within the Settings screen which allows manual control of feature flags
|
|
/// and system settings for better debugging)
|
|
static let developerModeEnabled: Setting.BoolKey = "developerModeEnabled"
|
|
|
|
/// There is no native api to get local network permission, so we need to modify the state and store in database to update UI accordingly.
|
|
/// Remove this in the future if Apple provides native api
|
|
static let lastSeenHasLocalNetworkPermission: Setting.BoolKey = "lastSeenHasLocalNetworkPermission"
|
|
|
|
/// Controls whether sending pro badges bitmask
|
|
static let isProBadgeEnabled: Setting.BoolKey = "isProBagesEnabled"
|
|
}
|
|
|
|
// stringlint:ignore_contents
|
|
public extension KeyValueStore.StringKey {
|
|
/// This is the most recently recorded Push Notifications token
|
|
static let lastRecordedPushToken: KeyValueStore.StringKey = "lastRecordedPushToken"
|
|
|
|
/// This is the most recently recorded Voip token
|
|
static let lastRecordedVoipToken: KeyValueStore.StringKey = "lastRecordedVoipToken"
|
|
|
|
/// This is the last six emoji used by the user
|
|
static let recentReactionEmoji: KeyValueStore.StringKey = "recentReactionEmoji"
|
|
|
|
/// This is the preferred skin tones preference for the given emoji
|
|
static func emojiPreferredSkinTones(emoji: String) -> KeyValueStore.StringKey {
|
|
return KeyValueStore.StringKey("preferredSkinTones-\(emoji)")
|
|
}
|
|
}
|
|
|
|
// stringlint:ignore_contents
|
|
public extension KeyValueStore.IntKey {
|
|
/// This is the number of times the app has successfully become active, it's not actually used for anything but allows us to make
|
|
/// a database change on launch so the database will output an error if it fails to write
|
|
static let activeCounter: KeyValueStore.IntKey = "activeCounter"
|
|
}
|
|
|
|
public enum Preferences {
|
|
public struct NotificationSettings {
|
|
public let previewType: Preferences.NotificationPreviewType
|
|
public let sound: Preferences.Sound
|
|
public let mentionsOnly: Bool
|
|
public let mutedUntil: TimeInterval?
|
|
|
|
public init(
|
|
previewType: Preferences.NotificationPreviewType,
|
|
sound: Preferences.Sound,
|
|
mentionsOnly: Bool,
|
|
mutedUntil: TimeInterval?
|
|
) {
|
|
self.previewType = previewType
|
|
self.sound = sound
|
|
self.mentionsOnly = mentionsOnly
|
|
self.mutedUntil = mutedUntil
|
|
}
|
|
}
|
|
|
|
// stringlint:ignore_contents
|
|
public static var isCallKitSupported: Bool {
|
|
#if targetEnvironment(simulator)
|
|
/// The iOS simulator doesn't support CallKit, when receiving a call on the simulator and routing it via CallKit it
|
|
/// will immediately trigger a hangup making it difficult to test - instead we just should just avoid using CallKit
|
|
/// entirely on the simulator
|
|
return false
|
|
#else
|
|
guard let regionCode: String = NSLocale.current.regionCode else { return false }
|
|
guard !regionCode.contains("CN") && !regionCode.contains("CHN") else { return false }
|
|
|
|
return true
|
|
#endif
|
|
}
|
|
}
|