-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbugsee_repository.dart
More file actions
151 lines (123 loc) · 4.69 KB
/
bugsee_repository.dart
File metadata and controls
151 lines (123 loc) · 4.69 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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
import 'package:app/access/bugsee/bugsee_configuration_data.dart';
import 'package:app/access/persistence_exception.dart';
import 'package:shared_preferences/shared_preferences.dart';
abstract interface class BugseeRepository {
factory BugseeRepository() = _BugseeRepository;
/// Load the current bugsee configuration stored in shared prefs.
Future<BugseeConfigurationData> getBugseeConfiguration();
/// Update the current Bugsee enabled flag in shared prefs.
Future setIsBugseeEnabled(bool isBugseeEnabled);
/// Update the current video captured or not flag in shared prefs.
Future setIsVideoCaptureEnabled(bool isVideoCaptureEnabled);
/// Update whether data is obscured in shared prefs.
Future setIsDataObscure(bool isDataObscure);
/// Update the logCollection flag in shared prefs.
Future setIsLogCollectionEnabled(bool isLogCollectionEnabled);
/// Update the logFilter flag in shared prefs.
Future setIsLogFilterEnabled(bool isLogFilterEnabled);
/// Update the attachFile boolean flag in shared prefs.
Future setAttachLogFileEnabled(bool attachLogFile);
}
final class _BugseeRepository implements BugseeRepository {
final String _bugseeEnabledKey = 'bugseeEnabledKey';
final String _bugseeVideoCaptureKey = 'bugseeVideoCaptureKey';
final String _bugseeDataObscureKey = 'bugseeDataObscureKey';
final String _bugseeDisableLogCollectionKey = 'bugseeDisableLogCollectionKey';
final String _bugseeDisableLogFilterKey = 'bugseeDisableLogFilterKey';
final String _bugseeAttachLogFileKey = 'bugseeAttachLogFileKey';
@override
Future<BugseeConfigurationData> getBugseeConfiguration() async {
final sharedPrefInstance = await SharedPreferences.getInstance();
return BugseeConfigurationData(
isBugseeEnabled: sharedPrefInstance.getBool(_bugseeEnabledKey),
isVideoCaptureEnabled: sharedPrefInstance.getBool(_bugseeVideoCaptureKey),
isDataObscured: sharedPrefInstance.getBool(_bugseeDataObscureKey),
isLogCollectionEnabled:
sharedPrefInstance.getBool(_bugseeDisableLogCollectionKey),
isLogsFilterEnabled:
sharedPrefInstance.getBool(_bugseeDisableLogFilterKey),
attachLogFileEnabled: sharedPrefInstance.getBool(_bugseeAttachLogFileKey),
);
}
@override
Future setIsBugseeEnabled(bool isBugseeEnabled) async {
final sharedPrefInstance = await SharedPreferences.getInstance();
bool isSaved = await sharedPrefInstance.setBool(
_bugseeEnabledKey,
isBugseeEnabled,
);
if (!isSaved) {
throw PersistenceException(
message: 'Error while setting $_bugseeEnabledKey $isBugseeEnabled',
);
}
}
@override
Future setIsVideoCaptureEnabled(bool isVideoCaptureEnabled) async {
final sharedPrefInstance = await SharedPreferences.getInstance();
bool isSaved = await sharedPrefInstance.setBool(
_bugseeVideoCaptureKey,
isVideoCaptureEnabled,
);
if (!isSaved) {
throw PersistenceException(
message:
'Error while setting $_bugseeVideoCaptureKey $isVideoCaptureEnabled',
);
}
}
@override
Future setIsDataObscure(bool isDataObscured) async {
final sharedPrefInstance = await SharedPreferences.getInstance();
bool isSaved = await sharedPrefInstance.setBool(
_bugseeDataObscureKey,
isDataObscured,
);
if (!isSaved) {
throw PersistenceException(
message: 'Error while setting $_bugseeDataObscureKey $isDataObscured',
);
}
}
@override
Future setIsLogCollectionEnabled(bool isLogCollected) async {
final sharedPrefInstance = await SharedPreferences.getInstance();
bool isSaved = await sharedPrefInstance.setBool(
_bugseeDisableLogCollectionKey,
isLogCollected,
);
if (!isSaved) {
throw PersistenceException(
message:
'Error while setting $_bugseeDisableLogCollectionKey $isLogCollected',
);
}
}
@override
Future setIsLogFilterEnabled(bool isLogFilterEnabled) async {
final sharedPrefInstance = await SharedPreferences.getInstance();
bool isSaved = await sharedPrefInstance.setBool(
_bugseeDisableLogFilterKey,
isLogFilterEnabled,
);
if (!isSaved) {
throw PersistenceException(
message:
'Error while setting $_bugseeDisableLogFilterKey $isLogFilterEnabled',
);
}
}
@override
Future setAttachLogFileEnabled(bool attachLogFile) async {
final sharedPrefInstance = await SharedPreferences.getInstance();
bool isSaved = await sharedPrefInstance.setBool(
_bugseeAttachLogFileKey,
attachLogFile,
);
if (!isSaved) {
throw PersistenceException(
message: 'Error while setting $_bugseeAttachLogFileKey $attachLogFile',
);
}
}
}