|
22 | 22 | * Countly configuration object. |
23 | 23 | */ |
24 | 24 | public class Config { |
25 | | - /** |
26 | | - * Logging level for {@link Log} module |
27 | | - */ |
28 | | - public enum LoggingLevel { |
29 | | - VERBOSE(0), |
30 | | - DEBUG(1), |
31 | | - INFO(2), |
32 | | - WARN(3), |
33 | | - ERROR(4), |
34 | | - OFF(5); |
35 | | - |
36 | | - private final int level; |
37 | | - |
38 | | - LoggingLevel(int level) { |
39 | | - this.level = level; |
40 | | - } |
41 | | - |
42 | | - public int getLevel() { |
43 | | - return level; |
44 | | - } |
45 | | - |
46 | | - public boolean prints(LoggingLevel l) { |
47 | | - return level <= l.level; |
48 | | - } |
49 | | - } |
50 | | - |
51 | | - public enum DeviceIdStrategy { |
52 | | - UUID(0), |
53 | | - CUSTOM_ID(10); |
54 | | - |
55 | | - private final int index; |
56 | | - |
57 | | - DeviceIdStrategy(int level) { |
58 | | - this.index = level; |
59 | | - } |
60 | | - |
61 | | - public int getIndex() { |
62 | | - return index; |
63 | | - } |
64 | | - |
65 | | - public static DeviceIdStrategy fromIndex(int index) { |
66 | | - if (index == UUID.index) { |
67 | | - return UUID; |
68 | | - } |
69 | | - if (index == CUSTOM_ID.index) { |
70 | | - return CUSTOM_ID; |
71 | | - } |
72 | | - return null; |
73 | | - } |
74 | | - } |
75 | | - |
76 | | - public enum Feature { |
77 | | - Events(CoreFeature.Events.getIndex()), |
78 | | - Sessions(CoreFeature.Sessions.getIndex()), |
79 | | - Views(CoreFeature.Views.getIndex()), |
80 | | - CrashReporting(CoreFeature.CrashReporting.getIndex()), |
81 | | - Location(CoreFeature.Location.getIndex()), |
82 | | - UserProfiles(CoreFeature.UserProfiles.getIndex()), |
83 | | - Feedback(CoreFeature.Feedback.getIndex()), |
84 | | - RemoteConfig(CoreFeature.RemoteConfig.getIndex()); |
85 | | - // StarRating(1 << 12), |
86 | | - // PerformanceMonitoring(1 << 14); |
87 | | - |
88 | | - private final int index; |
89 | | - |
90 | | - Feature(int index) { |
91 | | - this.index = index; |
92 | | - } |
93 | | - |
94 | | - public int getIndex() { |
95 | | - return index; |
96 | | - } |
97 | | - |
98 | | - public static Config.Feature byIndex(int index) { |
99 | | - if (index == Events.index) { |
100 | | - return Events; |
101 | | - } else if (index == Sessions.index) { |
102 | | - return Sessions; |
103 | | - } else if (index == Views.index) { |
104 | | - return Views; |
105 | | - } else if (index == CrashReporting.index) { |
106 | | - return CrashReporting; |
107 | | - } else if (index == Location.index) { |
108 | | - return Location; |
109 | | - } else if (index == UserProfiles.index) { |
110 | | - return UserProfiles; |
111 | | - } else if (index == RemoteConfig.index) { |
112 | | - return RemoteConfig; |
113 | | - } else if (index == Feedback.index) { |
114 | | - return Feedback; |
115 | | - } else { |
116 | | - return null; |
117 | | - } |
118 | | - } |
119 | | - } |
120 | | - |
121 | | - /** |
122 | | - * Holder class for various ids met |
123 | | - * adata and id itself. Final, unmodifiable. |
124 | | - */ |
125 | | - public static final class DID { |
126 | | - public static final int STRATEGY_UUID = 0; |
127 | | - public static final int STRATEGY_CUSTOM = 10; |
128 | | - public int strategy; |
129 | | - public String id; |
130 | | - |
131 | | - public DID(int strategy, String id) { |
132 | | - this.strategy = strategy; |
133 | | - this.id = id; |
134 | | - } |
135 | | - |
136 | | - @Override |
137 | | - public boolean equals(Object obj) { |
138 | | - if (!(obj instanceof DID)) { |
139 | | - return false; |
140 | | - } |
141 | | - DID did = (DID) obj; |
142 | | - return did.strategy == strategy && Objects.equals(did.id, id); |
143 | | - } |
144 | | - |
145 | | - @Override |
146 | | - public int hashCode() { |
147 | | - return id.hashCode(); |
148 | | - } |
149 | | - |
150 | | - @Override |
151 | | - public String toString() { |
152 | | - return "DID " + id + " ( " + strategy + ")"; |
153 | | - } |
154 | | - } |
155 | 25 |
|
156 | 26 | protected Log configLog; |
157 | 27 |
|
@@ -360,26 +230,7 @@ public String toString() { |
360 | 230 | */ |
361 | 231 | protected boolean unhandledCrashReportingEnabled = true; |
362 | 232 |
|
363 | | - /** |
364 | | - * Get the maximum amount of breadcrumbs. Default is 100. |
365 | | - * |
366 | | - * @param maxBreadcrumbCount the maximum amount of breadcrumbs |
367 | | - * @return {@code this} instance for method chaining |
368 | | - */ |
369 | | - public Config setMaxBreadcrumbCount(int maxBreadcrumbCount) { |
370 | | - this.maxBreadcrumbCount = maxBreadcrumbCount; |
371 | | - return this; |
372 | | - } |
373 | | - |
374 | | - /** |
375 | | - * Disable automatic crash reporting for unhandled exceptions. |
376 | | - * |
377 | | - * @return {@code this} instance for method chaining |
378 | | - */ |
379 | | - public Config disableUnhandledCrashReporting() { |
380 | | - this.unhandledCrashReportingEnabled = false; |
381 | | - return this; |
382 | | - } |
| 233 | + public ConfigViews views = new ConfigViews(this); |
383 | 234 |
|
384 | 235 | protected String location = null; |
385 | 236 | protected String ip = null; |
@@ -425,6 +276,27 @@ public Config(String serverURL, String serverAppKey, File sdkStorageRootDirector |
425 | 276 | this.sdkStorageRootDirectory = sdkStorageRootDirectory; |
426 | 277 | } |
427 | 278 |
|
| 279 | + /** |
| 280 | + * Get the maximum amount of breadcrumbs. Default is 100. |
| 281 | + * |
| 282 | + * @param maxBreadcrumbCount the maximum amount of breadcrumbs |
| 283 | + * @return {@code this} instance for method chaining |
| 284 | + */ |
| 285 | + public Config setMaxBreadcrumbCount(int maxBreadcrumbCount) { |
| 286 | + this.maxBreadcrumbCount = maxBreadcrumbCount; |
| 287 | + return this; |
| 288 | + } |
| 289 | + |
| 290 | + /** |
| 291 | + * Disable automatic crash reporting for unhandled exceptions. |
| 292 | + * |
| 293 | + * @return {@code this} instance for method chaining |
| 294 | + */ |
| 295 | + public Config disableUnhandledCrashReporting() { |
| 296 | + this.unhandledCrashReportingEnabled = false; |
| 297 | + return this; |
| 298 | + } |
| 299 | + |
428 | 300 | /** |
429 | 301 | * Whether to allow fallback from unavailable device id strategy to Countly OpenUDID derivative. |
430 | 302 | * |
@@ -1458,5 +1330,134 @@ public Config disableLocation() { |
1458 | 1330 | return this; |
1459 | 1331 | } |
1460 | 1332 |
|
1461 | | - public ConfigViews views = new ConfigViews(this); |
| 1333 | + /** |
| 1334 | + * Logging level for {@link Log} module |
| 1335 | + */ |
| 1336 | + public enum LoggingLevel { |
| 1337 | + VERBOSE(0), |
| 1338 | + DEBUG(1), |
| 1339 | + INFO(2), |
| 1340 | + WARN(3), |
| 1341 | + ERROR(4), |
| 1342 | + OFF(5); |
| 1343 | + |
| 1344 | + private final int level; |
| 1345 | + |
| 1346 | + LoggingLevel(int level) { |
| 1347 | + this.level = level; |
| 1348 | + } |
| 1349 | + |
| 1350 | + public int getLevel() { |
| 1351 | + return level; |
| 1352 | + } |
| 1353 | + |
| 1354 | + public boolean prints(LoggingLevel l) { |
| 1355 | + return level <= l.level; |
| 1356 | + } |
| 1357 | + } |
| 1358 | + |
| 1359 | + public enum DeviceIdStrategy { |
| 1360 | + UUID(0), |
| 1361 | + CUSTOM_ID(10); |
| 1362 | + |
| 1363 | + private final int index; |
| 1364 | + |
| 1365 | + DeviceIdStrategy(int level) { |
| 1366 | + this.index = level; |
| 1367 | + } |
| 1368 | + |
| 1369 | + public int getIndex() { |
| 1370 | + return index; |
| 1371 | + } |
| 1372 | + |
| 1373 | + public static DeviceIdStrategy fromIndex(int index) { |
| 1374 | + if (index == UUID.index) { |
| 1375 | + return UUID; |
| 1376 | + } |
| 1377 | + if (index == CUSTOM_ID.index) { |
| 1378 | + return CUSTOM_ID; |
| 1379 | + } |
| 1380 | + return null; |
| 1381 | + } |
| 1382 | + } |
| 1383 | + |
| 1384 | + public enum Feature { |
| 1385 | + Events(CoreFeature.Events.getIndex()), |
| 1386 | + Sessions(CoreFeature.Sessions.getIndex()), |
| 1387 | + Views(CoreFeature.Views.getIndex()), |
| 1388 | + CrashReporting(CoreFeature.CrashReporting.getIndex()), |
| 1389 | + Location(CoreFeature.Location.getIndex()), |
| 1390 | + UserProfiles(CoreFeature.UserProfiles.getIndex()), |
| 1391 | + Feedback(CoreFeature.Feedback.getIndex()), |
| 1392 | + RemoteConfig(CoreFeature.RemoteConfig.getIndex()); |
| 1393 | + // StarRating(1 << 12), |
| 1394 | + // PerformanceMonitoring(1 << 14); |
| 1395 | + |
| 1396 | + private final int index; |
| 1397 | + |
| 1398 | + Feature(int index) { |
| 1399 | + this.index = index; |
| 1400 | + } |
| 1401 | + |
| 1402 | + public int getIndex() { |
| 1403 | + return index; |
| 1404 | + } |
| 1405 | + |
| 1406 | + public static Config.Feature byIndex(int index) { |
| 1407 | + if (index == Events.index) { |
| 1408 | + return Events; |
| 1409 | + } else if (index == Sessions.index) { |
| 1410 | + return Sessions; |
| 1411 | + } else if (index == Views.index) { |
| 1412 | + return Views; |
| 1413 | + } else if (index == CrashReporting.index) { |
| 1414 | + return CrashReporting; |
| 1415 | + } else if (index == Location.index) { |
| 1416 | + return Location; |
| 1417 | + } else if (index == UserProfiles.index) { |
| 1418 | + return UserProfiles; |
| 1419 | + } else if (index == RemoteConfig.index) { |
| 1420 | + return RemoteConfig; |
| 1421 | + } else if (index == Feedback.index) { |
| 1422 | + return Feedback; |
| 1423 | + } else { |
| 1424 | + return null; |
| 1425 | + } |
| 1426 | + } |
| 1427 | + } |
| 1428 | + |
| 1429 | + /** |
| 1430 | + * Holder class for various ids met |
| 1431 | + * adata and id itself. Final, unmodifiable. |
| 1432 | + */ |
| 1433 | + public static final class DID { |
| 1434 | + public static final int STRATEGY_UUID = 0; |
| 1435 | + public static final int STRATEGY_CUSTOM = 10; |
| 1436 | + public int strategy; |
| 1437 | + public String id; |
| 1438 | + |
| 1439 | + public DID(int strategy, String id) { |
| 1440 | + this.strategy = strategy; |
| 1441 | + this.id = id; |
| 1442 | + } |
| 1443 | + |
| 1444 | + @Override |
| 1445 | + public boolean equals(Object obj) { |
| 1446 | + if (!(obj instanceof DID)) { |
| 1447 | + return false; |
| 1448 | + } |
| 1449 | + DID did = (DID) obj; |
| 1450 | + return did.strategy == strategy && Objects.equals(did.id, id); |
| 1451 | + } |
| 1452 | + |
| 1453 | + @Override |
| 1454 | + public int hashCode() { |
| 1455 | + return id.hashCode(); |
| 1456 | + } |
| 1457 | + |
| 1458 | + @Override |
| 1459 | + public String toString() { |
| 1460 | + return "DID " + id + " ( " + strategy + ")"; |
| 1461 | + } |
| 1462 | + } |
1462 | 1463 | } |
0 commit comments