@usercentrics/react-native-sdk 2.7.9 → 2.7.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (27) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/android/build.gradle +3 -3
  3. package/android/src/androidTest/java/com/usercentrics/reactnativemodule/RNUsercentricsModuleTest.kt +82 -33
  4. package/android/src/androidTest/java/com/usercentrics/reactnativemodule/mock/GetCMPDataMock.kt +0 -131
  5. package/android/src/androidTest/java/com/usercentrics/reactnativemodule/mock/ReactContextProviderMock.kt +20 -0
  6. package/android/src/androidTest/res/drawable-hdpi/some_local_image.png +0 -0
  7. package/android/src/main/java/com/usercentrics/reactnativeusercentrics/RNUsercentricsModule.kt +16 -23
  8. package/android/src/main/java/com/usercentrics/reactnativeusercentrics/RNUsercentricsPackage.kt +5 -6
  9. package/android/src/main/java/com/usercentrics/reactnativeusercentrics/ReactContextProvider.kt +10 -0
  10. package/android/src/main/java/com/usercentrics/reactnativeusercentrics/ReactContextProviderImpl.kt +18 -0
  11. package/android/src/main/java/com/usercentrics/reactnativeusercentrics/extensions/BannerFontExtensions.kt +9 -9
  12. package/android/src/main/java/com/usercentrics/reactnativeusercentrics/extensions/BannerSettingsExtensions.kt +42 -41
  13. package/android/src/main/java/com/usercentrics/reactnativeusercentrics/extensions/UsercentricsCMPDataExtensions.kt +0 -42
  14. package/ios/Extensions/UsercentricsCMPData+Dict.swift +0 -42
  15. package/lib/models/CCPASettings.d.ts +1 -4
  16. package/lib/models/CCPASettings.js +1 -4
  17. package/lib/models/CCPASettings.js.map +1 -1
  18. package/lib/models/TCF2Settings.d.ts +1 -5
  19. package/lib/models/TCF2Settings.js +1 -5
  20. package/lib/models/TCF2Settings.js.map +1 -1
  21. package/lib/models/UsercentricsService.d.ts +1 -13
  22. package/lib/models/UsercentricsService.js +1 -13
  23. package/lib/models/UsercentricsService.js.map +1 -1
  24. package/lib/models/UsercentricsSettings.d.ts +3 -24
  25. package/lib/models/UsercentricsSettings.js +3 -24
  26. package/lib/models/UsercentricsSettings.js.map +1 -1
  27. package/package.json +2 -2
@@ -35,57 +35,35 @@ internal class GetCMPDataMock {
35
35
  legalBasisList = listOf("Art. 6 para. 1 s. 1 lit. a GDPR"),
36
36
  retentionPeriodList = listOf(),
37
37
  subConsents = listOf(),
38
- cookieNames = listOf(),
39
38
  language = "en",
40
- isLatest = false,
41
- isShared = false,
42
- shareCustomConsent = "",
43
39
  linkToDpa = "",
44
- defaultConsentStatus = true,
45
40
  legalGround = "Art. 6 para. 1 s. 1 lit. c GDPR",
46
41
  optOutUrl = "",
47
42
  policyOfProcessorUrl = "https://usercentrics.com/de/datenschutzerklarung/",
48
43
  categorySlug = "essential",
49
- retentionPeriod = 0,
50
44
  retentionPeriodDescription = "The consent data (given consent and revocation of consent) are stored for three years. The data will then be deleted immediately or given to the person responsible on request in the form of a data export.",
51
- iabId = "5",
52
45
  dataProtectionOfficer = "datenschutz@usercentrics.com",
53
46
  privacyPolicyURL = "https://usercentrics.com/privacy-policy/",
54
47
  cookiePolicyURL = "",
55
48
  locationOfProcessing = "European Union",
56
49
  dataCollectedDescription = "",
57
- dataPurposesDescription = "",
58
- dataRecipientsDescription = "",
59
- legalBasisDescription = "",
60
- optOutDescription = "",
61
50
  thirdCountryTransfer = "Worldwide",
62
- defaultCategoryLabel = "Essential",
63
51
  description = "",
64
52
  isDeactivated = false,
65
53
  disableLegalBasis = false,
66
54
  )
67
55
  )
68
56
  private val fakeLabels = UsercentricsLabels(
69
- optin = "General Opt-In",
70
- dataScopes = "Data Scopes",
71
- dataAttributes = "Data Attributes",
72
57
  dataPurposes = "Data Purposes",
73
- dataProcessors = "Processing Company",
74
- dataControllers = "Data Controller",
75
58
  accepted = "yes",
76
59
  denied = "no",
77
60
  history = "History",
78
61
  settings = "Settings",
79
62
  subConsents = "Subservices",
80
- btnSelectAll = "Select all",
81
63
  btnAccept = "Accept",
82
64
  btnDeny = "Deny",
83
- btnChipName = "Privacy settings",
84
- statusActive = "active",
85
- statusInactive = "inactive",
86
65
  secondLayerTitle = "Privacy Settings Title",
87
66
  secondLayerDescriptionHtml = "Privacy Settings Description",
88
- btnSaveSettings = "Save settings",
89
67
  btnMore = "more",
90
68
  poweredBy = "Powered by <a href=\"https://usercentrics.com/?utm_source=cmp&utm_medium=powered_by\" rel=\"nofollow\" target=\"_blank\">Usercentrics Consent Management</a>",
91
69
  technologiesUsed = "Technologies Used",
@@ -101,29 +79,18 @@ internal class GetCMPDataMock {
101
79
  addressOfProcessingCompany = "Address of processing company",
102
80
  optOut = "Click here to opt out from this processor across all domains",
103
81
  policyOf = "Click here to read the privacy policy of the data processor",
104
- searchPlaceholder = "Search Services",
105
82
  dataCollectedInfo = "This list represents all (personal) data that is collected by or through the use of this service.",
106
83
  legalBasisInfo = "In the following the required legal basis for the processing of data is listed.",
107
- locationofProcessingInfo = "This is the primary location where the collected data is being processed. If the data is also processed in other countries, you are informed separately.",
108
- retentionPeriodInfo = "The retention period is the time span the collected data is saved for the processing purposes. The data needs to be deleted as soon as it is no longer needed for the stated processing purposes.",
109
84
  dataRecipientsList = "Data Recipients",
110
- dataRecipientsListInfo = "In the following the recipients of the data collected are listed.",
111
85
  transferToThirdCountriesInfo = "This service may forward the collected data to a different country. Please note that this service might transfer the data outside of the EU/EEA and to a country without the required data protection standards. If the data is transferred to the US, there is a risk that your data can be processed by US authorities, for control and surveillance measures, possibly without legal remedies. Below you can find a list of countries to which the data is being transferred. This can be for different reasons like storing or processing.",
112
- dataProtectionOfficerInfo = "Below you can find the email address of the data protection officer of the processing company.",
113
86
  linkToDpaInfo = "Data Processing Agreement",
114
87
  dataPurposesInfo = "This list represents the purposes of the data collection and processing.",
115
88
  technologiesUsedInfo = "This list represents all technologies this service uses to collect data. Typical technologies are Cookies and Pixels that are placed in the browser.",
116
89
  btnBannerReadMore = "Read more",
117
- consentDescription = "Description of the use of the data",
118
90
  descriptionOfService = "Description of Service",
119
91
  technology = "Technology being used to process the data",
120
92
  notAvailable = "not available",
121
- noResults = "No results",
122
- btnViewFullConsentsList = "Display all Services",
123
93
  date = "Date",
124
- comments = "Comments",
125
- ago = "ago",
126
- justNow = "just now",
127
94
  minute = "minute",
128
95
  minutes = "minutes",
129
96
  hour = "hour",
@@ -138,28 +105,14 @@ internal class GetCMPDataMock {
138
105
  categories = "Categories",
139
106
  language = "Language",
140
107
  btnSave = "Save Services",
141
- btnCancel = "Cancel changes",
142
- btnClose = "Close",
143
- btnReset = "Reset",
144
108
  btnMoreInfo = "More Info",
145
- btnAllOn = "Switch all on",
146
- btnAllOff = "Switch all off",
147
- btnSaveAndExit = "Save and close",
148
109
  btnBack = "Back",
149
- titleCenterPrimary = "Privacy Settings",
150
- titleCenterSecondary = "Privacy Settings",
151
- headerCenterPrimary = "Privacy settings",
152
- headerCenterSecondary = "Privacy settings",
153
- btnShowPrivacy = "Show privacy",
154
- btnActivateChangesAndCloseWindow = "Activate changes and close window",
155
110
  copy = "copy",
156
111
  copied = "copied",
157
112
  view = "view",
158
113
  more = "more",
159
114
  less = "less",
160
115
  consents = "Consents",
161
- btnModalSave = "Save settings",
162
- headerModalDescription = "Privacy settings",
163
116
  headerModal = "This tool helps you to select and deactivate various tags / trackers / analytic tools used on this website.",
164
117
  basic = "Basic",
165
118
  advanced = "Advanced",
@@ -168,21 +121,13 @@ internal class GetCMPDataMock {
168
121
  imprintLinkText = "Imprint",
169
122
  privacyPolicyLinkText = "Privacy Policy",
170
123
  cookiePolicyLinkText = "Cookie Policy",
171
- partnerPoweredByLinkText = "",
172
- iabBtnAcceptAll = "Accept All",
173
- iabCategoryNonIab = "Non IAB Vendors",
174
- iabCategoryNonIabDescription = "Vendors not yet registered with IAB Framework.",
175
124
  btnAcceptAll = "Accept All",
176
- iabViewByPurpose = "View by Purpose",
177
- iabExamplePersonalData = "Example for personal data: IP address",
178
- secondLayerAppendix = "",
179
125
  firstLayerTitle = "Privacy Settings",
180
126
  historyDescription = "",
181
127
  consentType = "Consent type",
182
128
  decision = "Decision",
183
129
  explicit = "Explicit",
184
130
  implicit = "Implicit",
185
- showMore = "Show more",
186
131
  storageInformation = "Storage Information",
187
132
  maximumAgeCookieStorage = "Maximum age of cookie storage",
188
133
  second = "second",
@@ -203,30 +148,15 @@ internal class GetCMPDataMock {
203
148
  anyDomain = "any domain (ex. first party cookie)",
204
149
  multipleDomains = "multiple subdomains may exist",
205
150
  storageInformationDescription = "Below you can see the longest potential duration for storage on a device, as set when using the cookie method of storage and if there are any other methods used.",
206
- storedInformation = "Stored Information",
207
- storedInformationDescription = "This service uses different means of storing information on a user’s device as listed below.",
208
- yesImplicit = "yes (website default)",
209
- noImplicit = "no (website default)"
210
151
  )
211
152
  private val fakeFirstLayer = FirstLayer(
212
- descriptionDefault = "",
213
- isCategoryTogglesEnabled = false,
214
- hideLanguageSwitch = false,
215
153
  hideButtonDeny = false,
216
- isOverlayEnabled = true,
217
- title = "",
218
- descriptionShort = "",
219
154
  )
220
155
  private val fakeSecondLayer = SecondLayer(
221
156
  tabsServicesLabel = "Services",
222
- tabsCategoriesIsEnabled = true,
223
- description = "",
224
157
  hideLanguageSwitch = false,
225
158
  tabsCategoriesLabel = "Categories",
226
159
  hideButtonDeny = false,
227
- tabsServicesIsEnabled = true,
228
- isOverlayEnabled = true,
229
- title = "",
230
160
  hideTogglesForServices = false
231
161
  )
232
162
  private val fakeTCF2Settings = TCF2Settings(
@@ -245,11 +175,8 @@ internal class GetCMPDataMock {
245
175
  hideLegitimateInterestToggles = false,
246
176
  secondLayerHideButtonDeny = false,
247
177
  secondLayerHideToggles = false,
248
- vendorToggleAll = false,
249
178
  togglesConsentToggleLabel = "Consent",
250
179
  labelsFeatures = "Features",
251
- firstLayerNoteGlobal =
252
- "Your choices for this website will be applied globally, which means they will be available to other websites that set your choices globally.",
253
180
  togglesSpecialFeaturesToggleOn = "On",
254
181
  vendorSpecialFeatures = "Special Features",
255
182
  appLayerNoteResurface =
@@ -273,8 +200,6 @@ internal class GetCMPDataMock {
273
200
  vendorFeatures = "Features",
274
201
  secondLayerDescription =
275
202
  "You can access more detailed information below regarding all purposes and third-party vendors implemented on this website. You can adjust your privacy settings based on specific purposes and/or at a vendor level at any time.",
276
- firstLayerNoteService =
277
- "Your choices for this website will be applied on this page only. You can change your Privacy Settings or withdraw your consent at any time by clicking on our Privacy Button.",
278
203
  publisherCountryCode = "DE",
279
204
  buttonsSaveLabel = "Save Settings",
280
205
  selectedVendorIds = listOf(),
@@ -282,8 +207,6 @@ internal class GetCMPDataMock {
282
207
  hideNonIabOnFirstLayer = false,
283
208
  linksManageSettingsLabel = "Manage Settings",
284
209
  firstLayerHideToggles = false,
285
- labelsDisclaimer =
286
- "All choices on this website will be applied globally, which means they will be available on other websites that set your choices globally. By clicking on our Privacy Button in the bottom left corner, you can change your settings or withdraw your consent at any time.",
287
210
  gdprApplies = true,
288
211
  linksVendorListLinkLabel = "Vendorlist",
289
212
  tabsPurposeLabel = "Purposes"
@@ -291,13 +214,9 @@ internal class GetCMPDataMock {
291
214
  private val fakeCCPASettings = CCPASettings(
292
215
  secondLayerHideLanguageSwitch = false,
293
216
  secondLayerTitle = "Privacy Settings Title",
294
- reshowCMP = true,
295
217
  iabAgreementExists = false,
296
218
  optOutNoticeLabel = "Do not sell my personal information",
297
- firstLayerHideLanguageSwitch = false,
298
219
  btnSave = "OK",
299
- firstLayerDescription =
300
- "We and our partners are using technologies like cookies and process personal data in order to improve your experience. In case of sale of your personal information you may exercise your consumer right to opt-out by activating the toggle 'Do Not Sell My Personal Information' below. For detailed information about the categories of personal information we collect and the purposes for which information may be used and which Data Processing Services may have access to this information please click on 'More Information' or refer to our privacy policy.",
301
220
  showOnPageLoad = false,
302
221
  btnMoreInfo = "More Information",
303
222
  firstLayerTitle = "Privacy Information",
@@ -326,54 +245,33 @@ internal class GetCMPDataMock {
326
245
  labels = fakeLabels,
327
246
  showInitialViewForVersionChange = listOf(),
328
247
  displayOnlyForEU = false,
329
- urlConsentInfo = "",
330
- updatedAt = "2020-10-26T14:21:05.933Z",
331
248
  secondLayer = fakeSecondLayer,
332
249
  cookiePolicyUrl = "",
333
250
  tcf2 = fakeTCF2Settings,
334
251
  ccpa = fakeCCPASettings,
335
- btnDenyIsVisible = true,
336
252
  privacyPolicyUrl = "https://usercentrics.com/privacy-policy/",
337
253
  firstLayer = fakeFirstLayer,
338
- showLanguageDropdown = true,
339
254
  imprintUrl = "https://usercentrics.com/legal-notice/",
340
- btnMoreInfoIsVisible = true,
341
255
  firstLayerDescriptionHtml = "Privacy Settings test description.",
342
256
  bannerMobileDescriptionIsActive = false,
343
- dataController = "GDPR",
344
257
  firstLayerMobileDescriptionHtml = "",
345
258
  version = "6.0.4",
346
- isLatest = true,
347
259
  language = "en",
348
260
  tcf2Enabled = false,
349
261
  settingsId = "lQ_Dio7QL",
350
262
  languagesAvailable = listOf("en", "de"),
351
- createdAt = "2020-10-26T14:21:05.933Z",
352
263
  enablePoweredBy = true,
353
264
  editableLanguages = listOf("en", "de"),
354
- partnerPoweredByLogoUrl = "",
355
265
  customization = fakeCustomization,
356
- moreInfoButtonUrl = "",
357
- iabConsentIsActive = false,
358
- partnerPoweredByUrl = ""
359
266
  )
360
267
 
361
268
  // From the debugger
362
269
  private val expectedFirstLayer = hashMapOf(
363
- "isOverlayEnabled" to true,
364
- "isCategoryTogglesEnabled" to false,
365
270
  "hideButtonDeny" to false,
366
- "hideLanguageSwitch" to false,
367
- "title" to "",
368
- "descriptionDefault" to "",
369
- "descriptionShort" to "",
370
271
  )
371
272
  private val expectedSecondLayer = hashMapOf(
372
273
  "tabsCategoriesLabel" to "Categories",
373
274
  "tabsServicesLabel" to "Services",
374
- "isOverlayEnabled" to true,
375
- "tabsCategoriesIsEnabled" to true,
376
- "tabsServicesIsEnabled" to true,
377
275
  "hideButtonDeny" to false,
378
276
  "hideLanguageSwitch" to false,
379
277
  )
@@ -483,14 +381,12 @@ internal class GetCMPDataMock {
483
381
  "resurfacePeriodEnded" to true,
484
382
  "resurfacePurposeChanged" to true,
485
383
  "resurfaceVendorAdded" to true,
486
- "vendorToggleAll" to false,
487
384
  "firstLayerDescription" to "We and our third-party vendors use technologies (e.g. cookies) to store and/or access information on user's devices in order to process personal data such as IP addresses or browsing data. You may consent to the processing of your personal data for the listed purposes below. Alternatively you can set your preferences before consenting or refuse to consent. Please note that some vendors may process your personal data based on their legitimate business interest and do not ask for your consent. To exercise your right to object to processing based on legitimate interest please view our vendorlist.",
488
385
  "firstLayerAdditionalInfo" to "",
489
386
  "secondLayerDescription" to "You can access more detailed information below regarding all purposes and third-party vendors implemented on this website. You can adjust your privacy settings based on specific purposes and/or at a vendor level at any time.",
490
387
  "togglesSpecialFeaturesToggleOn" to "On",
491
388
  "togglesSpecialFeaturesToggleOff" to "Off",
492
389
  "appLayerNoteResurface" to "You can change your privacy settings or withdraw your consent at any time by opening the menu point Privacy Settings.",
493
- "firstLayerNoteGlobal" to "Your choices for this website will be applied globally, which means they will be available to other websites that set your choices globally.",
494
390
  "firstLayerNoteResurface" to "You can change your privacy settings or withdraw your consent at any time by clicking on our Privacy Button.",
495
391
  )
496
392
  private val expectedCCPASettings = hashMapOf(
@@ -499,14 +395,11 @@ internal class GetCMPDataMock {
499
395
  "firstLayerTitle" to "Privacy Information",
500
396
  "isActive" to false,
501
397
  "showOnPageLoad" to false,
502
- "reshowCMP" to true,
503
398
  "reshowAfterDays" to 365,
504
399
  "iabAgreementExists" to false,
505
- "firstLayerDescription" to "We and our partners are using technologies like cookies and process personal data in order to improve your experience. In case of sale of your personal information you may exercise your consumer right to opt-out by activating the toggle 'Do Not Sell My Personal Information' below. For detailed information about the categories of personal information we collect and the purposes for which information may be used and which Data Processing Services may have access to this information please click on 'More Information' or refer to our privacy policy.",
506
400
  "appFirstLayerDescription" to "We and our partners are using technologies like cookies and process personal data in order to improve your experience. In case of sale of your personal information you may exercise your consumer right to opt-out by activating the toggle 'Do Not Sell My Personal Information' below. For detailed information about the categories of personal information we collect and the purposes for which information may be used and which Data Processing Services may have access to this information please refer to our privacy policy.",
507
401
  "firstLayerMobileDescriptionIsActive" to false,
508
402
  "firstLayerMobileDescription" to "We and our partners are using technologies like cookies and process personal data in order to improve your experience. In case of sale of your personal information you may exercise your consumer right to opt-out by activating the toggle 'Do Not Sell My Personal Information' below.",
509
- "firstLayerHideLanguageSwitch" to false,
510
403
  "secondLayerTitle" to "Privacy Settings Title",
511
404
  "secondLayerDescription" to "Here you can find detailed information about the categories of personal information we collect and the purposes for which information may be used and which Data Processing Services may have access to this information.",
512
405
  "secondLayerHideLanguageSwitch" to false,
@@ -527,36 +420,24 @@ internal class GetCMPDataMock {
527
420
  "labels" to expectedLabels,
528
421
  "showInitialViewForVersionChange" to listOf<Any>(),
529
422
  "displayOnlyForEU" to false,
530
- "urlConsentInfo" to "",
531
- "updatedAt" to "2020-10-26T14:21:05.933Z",
532
423
  "secondLayer" to expectedSecondLayer,
533
424
  "cookiePolicyUrl" to "",
534
425
  "tcf2" to expectedTCF2Settings,
535
426
  "ccpa" to expectedCCPASettings,
536
- "btnDenyIsVisible" to true,
537
427
  "privacyPolicyUrl" to "https://usercentrics.com/privacy-policy/",
538
428
  "firstLayer" to expectedFirstLayer,
539
- "showLanguageDropdown" to true,
540
429
  "imprintUrl" to "https://usercentrics.com/legal-notice/",
541
- "btnMoreInfoIsVisible" to true,
542
430
  "firstLayerDescriptionHtml" to "Privacy Settings test description.",
543
431
  "bannerMobileDescriptionIsActive" to false,
544
- "dataController" to "GDPR",
545
432
  "firstLayerMobileDescriptionHtml" to "",
546
433
  "version" to "6.0.4",
547
- "isLatest" to true,
548
434
  "language" to "en",
549
435
  "tcf2Enabled" to false,
550
436
  "settingsId" to "lQ_Dio7QL",
551
437
  "languagesAvailable" to listOf("en", "de"),
552
- "createdAt" to "2020-10-26T14:21:05.933Z",
553
438
  "enablePoweredBy" to true,
554
439
  "editableLanguages" to listOf("en", "de"),
555
- "partnerPoweredByLogoUrl" to "",
556
440
  "customization" to expectedCustomization,
557
- "moreInfoButtonUrl" to "",
558
- "iabConsentIsActive" to false,
559
- "partnerPoweredByUrl" to ""
560
441
  )
561
442
  val expectedCategories = listOf(
562
443
  hashMapOf(
@@ -592,31 +473,19 @@ internal class GetCMPDataMock {
592
473
  "legalBasisList" to listOf("Art. 6 para. 1 s. 1 lit. a GDPR"),
593
474
  "retentionPeriodList" to listOf<String>(),
594
475
  "subConsents" to listOf<String>(),
595
- "cookieNames" to listOf<String>(),
596
476
  "language" to "en",
597
- "isLatest" to false,
598
- "isShared" to false,
599
- "shareCustomConsent" to "",
600
477
  "linkToDpa" to "",
601
- "defaultConsentStatus" to true,
602
478
  "legalGround" to "Art. 6 para. 1 s. 1 lit. c GDPR",
603
479
  "optOutUrl" to "",
604
480
  "policyOfProcessorUrl" to "https://usercentrics.com/de/datenschutzerklarung/",
605
481
  "categorySlug" to "essential",
606
- "retentionPeriod" to 0L,
607
482
  "retentionPeriodDescription" to "The consent data (given consent and revocation of consent) are stored for three years. The data will then be deleted immediately or given to the person responsible on request in the form of a data export.",
608
- "iabId" to "5",
609
483
  "dataProtectionOfficer" to "datenschutz@usercentrics.com",
610
484
  "privacyPolicyURL" to "https://usercentrics.com/privacy-policy/",
611
485
  "cookiePolicyURL" to "",
612
486
  "locationOfProcessing" to "European Union",
613
487
  "dataCollectedDescription" to "",
614
- "dataPurposesDescription" to "",
615
- "dataRecipientsDescription" to "",
616
- "legalBasisDescription" to "",
617
- "optOutDescription" to "",
618
488
  "thirdCountryTransfer" to "Worldwide",
619
- "defaultCategoryLabel" to "Essential",
620
489
  "description" to "",
621
490
  "isDeactivated" to false,
622
491
  "disableLegalBasis" to false,
@@ -0,0 +1,20 @@
1
+ package com.usercentrics.reactnativemodule.mock
2
+
3
+ import android.app.Activity
4
+ import android.content.Context
5
+ import com.facebook.react.bridge.ReactApplicationContext
6
+ import com.usercentrics.reactnativeusercentrics.ReactContextProvider
7
+ import io.mockk.mockk
8
+
9
+ internal open class ReactContextProviderMock : ReactContextProvider {
10
+
11
+ private val reactApplicationContext = mockk<ReactApplicationContext>(relaxed = true)
12
+
13
+ override fun context(): Context {
14
+ return reactApplicationContext
15
+ }
16
+
17
+ override fun activity(): Activity? {
18
+ return reactApplicationContext.currentActivity
19
+ }
20
+ }
@@ -8,9 +8,9 @@ import com.usercentrics.sdk.services.tcf.TCFDecisionUILayer
8
8
 
9
9
  internal class RNUsercentricsModule(
10
10
  reactContext: ReactApplicationContext,
11
- private val usercentricsProxy: UsercentricsProxy
12
- ) :
13
- ReactContextBaseJavaModule(reactContext) {
11
+ private val usercentricsProxy: UsercentricsProxy,
12
+ private val reactContextProvider: ReactContextProvider,
13
+ ) : ReactContextBaseJavaModule(reactContext) {
14
14
 
15
15
  override fun getName() = "RNUsercentricsModule"
16
16
 
@@ -33,11 +33,11 @@ internal class RNUsercentricsModule(
33
33
  fun showFirstLayer(options: ReadableMap, promise: Promise) {
34
34
  runOnUiThread {
35
35
  try {
36
- val assetManager = currentActivity!!.assets
37
-
38
- val bannerSettings = options.bannerSettingsFromMap(assetManager)
39
- usercentricsProxy.showFirstLayer(currentActivity!!, bannerSettings, promise)
36
+ val context = reactContextProvider.context()
37
+ val bannerSettings = options.bannerSettingsFromMap(context)
40
38
 
39
+ val activity = reactContextProvider.activity()!!
40
+ usercentricsProxy.showFirstLayer(activity, bannerSettings, promise)
41
41
  } catch (e: Exception) {
42
42
  promise.reject(e)
43
43
  }
@@ -48,10 +48,11 @@ internal class RNUsercentricsModule(
48
48
  fun showSecondLayer(options: ReadableMap, promise: Promise) {
49
49
  runOnUiThread {
50
50
  try {
51
- val assetManager = currentActivity!!.assets
51
+ val context = reactContextProvider.context()
52
+ val bannerSettings = options.bannerSettingsFromMap(context)
52
53
 
53
- val bannerSettings = options.bannerSettingsFromMap(assetManager)
54
- usercentricsProxy.showSecondLayer(currentActivity!!, bannerSettings, promise)
54
+ val activity = reactContextProvider.activity()!!
55
+ usercentricsProxy.showSecondLayer(activity, bannerSettings, promise)
55
56
  } catch (e: Exception) {
56
57
  promise.reject(e)
57
58
  }
@@ -127,8 +128,7 @@ internal class RNUsercentricsModule(
127
128
  fun acceptAllForTCF(fromLayer: Int, consentType: Int, promise: Promise) {
128
129
  promise.resolve(
129
130
  usercentricsProxy.instance.acceptAllForTCF(
130
- TCFDecisionUILayer.values()[fromLayer],
131
- UsercentricsConsentType.values()[consentType]
131
+ TCFDecisionUILayer.values()[fromLayer], UsercentricsConsentType.values()[consentType]
132
132
  ).toWritableArray()
133
133
  )
134
134
  }
@@ -146,8 +146,7 @@ internal class RNUsercentricsModule(
146
146
  fun denyAllForTCF(fromLayer: Int, consentType: Int, promise: Promise) {
147
147
  promise.resolve(
148
148
  usercentricsProxy.instance.denyAllForTCF(
149
- TCFDecisionUILayer.values()[fromLayer],
150
- UsercentricsConsentType.values()[consentType]
149
+ TCFDecisionUILayer.values()[fromLayer], UsercentricsConsentType.values()[consentType]
151
150
  ).toWritableArray()
152
151
  )
153
152
  }
@@ -163,11 +162,7 @@ internal class RNUsercentricsModule(
163
162
 
164
163
  @ReactMethod
165
164
  fun saveDecisionsForTCF(
166
- tcfDecisions: ReadableMap,
167
- fromLayer: Int,
168
- saveDecisions: ReadableArray,
169
- consentType: Int,
170
- promise: Promise
165
+ tcfDecisions: ReadableMap, fromLayer: Int, saveDecisions: ReadableArray, consentType: Int, promise: Promise
171
166
  ) {
172
167
  promise.resolve(
173
168
  usercentricsProxy.instance.saveDecisionsForTCF(
@@ -183,8 +178,7 @@ internal class RNUsercentricsModule(
183
178
  fun saveDecisions(decisions: ReadableArray, consentType: Int, promise: Promise) {
184
179
  promise.resolve(
185
180
  usercentricsProxy.instance.saveDecisions(
186
- decisions.deserializeUserDecision(),
187
- UsercentricsConsentType.values()[consentType]
181
+ decisions.deserializeUserDecision(), UsercentricsConsentType.values()[consentType]
188
182
  ).toWritableArray()
189
183
  )
190
184
  }
@@ -193,8 +187,7 @@ internal class RNUsercentricsModule(
193
187
  fun saveOptOutForCCPA(isOptedOut: Boolean, consentType: Int, promise: Promise) {
194
188
  promise.resolve(
195
189
  usercentricsProxy.instance.saveOptOutForCCPA(
196
- isOptedOut,
197
- UsercentricsConsentType.values()[consentType]
190
+ isOptedOut, UsercentricsConsentType.values()[consentType]
198
191
  ).toWritableArray()
199
192
  )
200
193
  }
@@ -8,15 +8,14 @@ import com.usercentrics.reactnativeusercentrics.api.UsercentricsProxyImpl
8
8
 
9
9
  class RNUsercentricsPackage : ReactPackage {
10
10
 
11
- private var usercentricsProxy = UsercentricsProxyImpl()
11
+ private val usercentricsProxy = UsercentricsProxyImpl()
12
12
 
13
- override fun createViewManagers(reactContext: ReactApplicationContext):
14
- MutableList<ViewManager<*, *>> {
13
+ override fun createViewManagers(reactContext: ReactApplicationContext): MutableList<ViewManager<*, *>> {
15
14
  return mutableListOf()
16
15
  }
17
16
 
18
- override fun createNativeModules(reactContext: ReactApplicationContext):
19
- MutableList<NativeModule> {
20
- return mutableListOf(RNUsercentricsModule(reactContext, usercentricsProxy))
17
+ override fun createNativeModules(reactContext: ReactApplicationContext): MutableList<NativeModule> {
18
+ val reactContextProvider = ReactContextProviderImpl(reactContext)
19
+ return mutableListOf(RNUsercentricsModule(reactContext, usercentricsProxy, reactContextProvider))
21
20
  }
22
21
  }
@@ -0,0 +1,10 @@
1
+ package com.usercentrics.reactnativeusercentrics
2
+
3
+ import android.app.Activity
4
+ import android.content.Context
5
+
6
+ internal interface ReactContextProvider {
7
+
8
+ fun context(): Context
9
+ fun activity(): Activity?
10
+ }
@@ -0,0 +1,18 @@
1
+ package com.usercentrics.reactnativeusercentrics
2
+
3
+ import android.app.Activity
4
+ import android.content.Context
5
+ import com.facebook.react.bridge.ReactApplicationContext
6
+
7
+ internal class ReactContextProviderImpl(
8
+ private val reactContext: ReactApplicationContext
9
+ ) : ReactContextProvider {
10
+
11
+ override fun context(): Context {
12
+ return reactContext
13
+ }
14
+
15
+ override fun activity(): Activity? {
16
+ return reactContext.currentActivity
17
+ }
18
+ }
@@ -1,26 +1,26 @@
1
1
  package com.usercentrics.reactnativeusercentrics.extensions
2
2
 
3
+ import android.content.Context
3
4
  import android.content.res.AssetManager
4
5
  import android.graphics.Typeface
5
6
  import com.facebook.react.bridge.ReadableMap
6
7
  import com.usercentrics.sdk.BannerFont
7
8
 
8
-
9
- internal fun ReadableMap.bannerFontFromMap(assetManager: AssetManager): BannerFont? {
9
+ internal fun ReadableMap.bannerFontFromMap(context: Context): BannerFont? {
10
10
  val size = getDoubleOrNull("fontSize") ?: return null
11
+ val assetManager = context.assets
12
+
11
13
  val regularTypeface = assetManager.createFontFromName(getString("regularFont")) ?: return null
12
14
  val boldTypeface = assetManager.createFontFromName(getString("boldFont")) ?: return null
13
15
 
14
- return BannerFont(
15
- regularTypeface,
16
- boldTypeface,
17
- size.toFloat()
18
- )
16
+ return BannerFont(regularFont = regularTypeface, boldFont = boldTypeface, sizeInSp = size.toFloat())
19
17
  }
20
18
 
21
19
  internal fun AssetManager.createFontFromName(fontName: String?): Typeface? {
22
- if (fontName == null) { return null }
20
+ if (fontName == null) {
21
+ return null
22
+ }
23
23
  val fontsFolder = this.list("fonts")
24
24
  val regularFontName = fontsFolder?.firstOrNull { it.startsWith(fontName) } ?: return null
25
25
  return Typeface.createFromAsset(this, "fonts/$regularFontName")
26
- }
26
+ }