@kontextso/sdk-react-native 3.3.0-rc.5 → 3.3.0-rc.6
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.
package/android/build.gradle
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
package so.kontext.react
|
|
2
2
|
|
|
3
|
-
import com.facebook.react.bridge.Promise
|
|
4
|
-
import com.facebook.react.bridge.ReactApplicationContext
|
|
5
3
|
import android.content.Context
|
|
6
|
-
import android.content.SharedPreferences
|
|
7
4
|
import android.media.AudioManager
|
|
8
|
-
import
|
|
5
|
+
import androidx.preference.PreferenceManager
|
|
6
|
+
import com.facebook.react.bridge.Promise
|
|
7
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
9
8
|
|
|
10
9
|
class RNKontextModuleImpl(private val reactContext: ReactApplicationContext) {
|
|
11
10
|
fun isSoundOn(promise: Promise?) {
|
|
@@ -19,34 +18,39 @@ class RNKontextModuleImpl(private val reactContext: ReactApplicationContext) {
|
|
|
19
18
|
|
|
20
19
|
fun getTcfData(promise: Promise?) {
|
|
21
20
|
if (promise == null) return
|
|
22
|
-
|
|
21
|
+
|
|
23
22
|
try {
|
|
24
23
|
val prefs = PreferenceManager.getDefaultSharedPreferences(reactContext.applicationContext)
|
|
25
|
-
|
|
24
|
+
|
|
26
25
|
val tcString: String? = prefs.getString("IABTCF_TCString", null)
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
26
|
+
|
|
27
|
+
val gdprAppliesRaw: Int? =
|
|
28
|
+
if (prefs.contains("IABTCF_gdprApplies")) {
|
|
29
|
+
// Most CMPs store as Int
|
|
30
|
+
try {
|
|
31
|
+
prefs.getInt("IABTCF_gdprApplies", 0)
|
|
32
|
+
} catch (_: Throwable) {
|
|
33
|
+
// Some CMPs might store as String
|
|
34
|
+
prefs.getString("IABTCF_gdprApplies", null)?.toIntOrNull()
|
|
35
|
+
}
|
|
36
|
+
} else null
|
|
37
|
+
|
|
38
|
+
val gdprApplies: Int? = when (gdprAppliesRaw) {
|
|
39
|
+
0 -> 0
|
|
40
|
+
1 -> 1
|
|
41
|
+
else -> null
|
|
41
42
|
}
|
|
42
|
-
|
|
43
|
+
|
|
43
44
|
val out = HashMap<String, Any?>(2)
|
|
44
45
|
out["tcString"] = tcString
|
|
45
46
|
out["gdprApplies"] = gdprApplies
|
|
46
|
-
|
|
47
47
|
promise.resolve(out)
|
|
48
|
-
} catch (
|
|
49
|
-
|
|
48
|
+
} catch (_: Throwable) {
|
|
49
|
+
// Don’t break preload if reading fails
|
|
50
|
+
val out = HashMap<String, Any?>(2)
|
|
51
|
+
out["tcString"] = null
|
|
52
|
+
out["gdprApplies"] = null
|
|
53
|
+
promise.resolve(out)
|
|
50
54
|
}
|
|
51
55
|
}
|
|
52
56
|
|