-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathSettingsBackupConfig.swift
More file actions
92 lines (84 loc) · 3.14 KB
/
SettingsBackupConfig.swift
File metadata and controls
92 lines (84 loc) · 3.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
import Foundation
/// Configuration for settings backup/restore operations
enum SettingsBackupConfig {
enum SettingKeyType {
case string(optional: Bool)
case bool
case double(optional: Bool, minValue: Double = 0)
case int(optional: Bool, minValue: Int = 0)
case stringArray(optional: Bool)
}
static let serverSettingsKeys: [String] = [
"electrumServer",
"rapidGossipSyncUrl",
]
static let appStateKeys: [String] = [
"hasSeenContactsIntro",
"hasSeenProfileIntro",
"hasSeenNotificationsIntro",
"hasSeenQuickpayIntro",
"hasSeenShopIntro",
"hasSeenTransferIntro",
"hasSeenTransferToSpendingIntro",
"hasSeenTransferToSavingsIntro",
"hasSeenWidgetsIntro",
"showHomeViewEmptyState",
"appUpdateIgnoreTimestamp",
"backupIgnoreTimestamp",
"highBalanceIgnoreCount",
"highBalanceIgnoreTimestamp",
"dismissedSuggestions",
"lastUsedTags",
]
static let settingsKeyTypes: [String: SettingKeyType] = [
"primaryDisplay": .string(optional: true),
"bitcoinDisplayUnit": .string(optional: true),
"selectedCurrency": .string(optional: true),
"defaultTransactionSpeed": .string(optional: true),
"coinSelectionMethod": .string(optional: true),
"coinSelectionAlgorithm": .string(optional: true),
"selectedAddressType": .string(optional: true),
"addressTypesToMonitor": .string(optional: true),
"enableQuickpay": .bool,
"showWidgets": .bool,
"showWidgetTitles": .bool,
"swipeBalanceToHide": .bool,
"hideBalance": .bool,
"hideBalanceOnOpen": .bool,
"readClipboard": .bool,
"warnWhenSendingOver100": .bool,
"backupVerified": .bool,
"enableNotifications": .bool,
"quickpayAmount": .double(optional: false),
]
static var settingsKeys: [String] {
Array(settingsKeyTypes.keys) + serverSettingsKeys
}
static let iosToAndroidFieldMapping: [String: String] = [
"readClipboard": "enableAutoReadClipboard",
"swipeBalanceToHide": "enableSwipeToHideBalance",
"warnWhenSendingOver100": "enableSendAmountWarning",
"bitcoinDisplayUnit": "displayUnit",
"enableQuickpay": "isQuickPayEnabled",
"enableNotifications": "notificationsGranted",
// Note: PIN settings are intentionally NOT backed up for security
// PIN itself cannot be backed up, so PIN settings shouldn't be either
]
static let algorithmMapping: [String: String] = [
"branchAndBound": "BranchAndBound",
"largestFirst": "LargestFirst",
"oldestFirst": "FirstInFirstOut",
"singleRandomDraw": "SingleRandomDraw",
]
static func convertAlgorithm(_ value: String, toAndroid: Bool) -> String {
if toAndroid {
return algorithmMapping[value] ?? "BranchAndBound"
} else {
// Reverse lookup
for (ios, android) in algorithmMapping where android == value {
return ios
}
return "largestFirst"
}
}
}