@truewatchtech/react-native-mobile 0.4.0-alpha.4 → 0.4.1

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 (154) hide show
  1. package/FTMobileReactNativeSDK.podspec +32 -3
  2. package/android/build.gradle +7 -19
  3. package/android/src/main/java/com/ft/sdk/reactnative/FTMobileImpl.java +434 -5
  4. package/android/src/main/java/com/ft/sdk/reactnative/FTRUMImpl.java +12 -0
  5. package/android/src/newarch/java/com/ft/sdk/reactnative/FTLogModule.java +7 -14
  6. package/android/src/newarch/java/com/ft/sdk/reactnative/FTMobileModule.java +46 -12
  7. package/android/src/newarch/java/com/ft/sdk/reactnative/FTRUMModule.java +12 -13
  8. package/android/src/newarch/java/com/ft/sdk/reactnative/FTTraceModule.java +6 -8
  9. package/android/src/oldarch/java/com/ft/sdk/reactnative/FTMobileModule.java +34 -2
  10. package/android/src/rnpost74/java/com/ft/sdk/reactnative/FTMobilePackage.java +14 -3
  11. package/android/src/rnpre74/java/com/ft/sdk/reactnative/FTMobilePackage.java +0 -3
  12. package/ios/FTMobileReactNative.h +9 -5
  13. package/ios/FTMobileReactNative.mm +619 -0
  14. package/ios/FTReactNativeLog.h +8 -3
  15. package/ios/FTReactNativeLog.mm +79 -0
  16. package/ios/FTReactNativeRUM.h +8 -3
  17. package/ios/{FTReactNativeRUM.m → FTReactNativeRUM.mm} +143 -84
  18. package/ios/FTReactNativeTrace.h +8 -2
  19. package/ios/FTReactNativeTrace.mm +74 -0
  20. package/ios/FtMobileAgent.xcodeproj/project.pbxproj +17 -1
  21. package/lib/commonjs/ft_logger.js +14 -13
  22. package/lib/commonjs/ft_logger.js.map +1 -1
  23. package/lib/commonjs/ft_mobile_agent.js +153 -6
  24. package/lib/commonjs/ft_mobile_agent.js.map +1 -1
  25. package/lib/commonjs/ft_rum.js +55 -21
  26. package/lib/commonjs/ft_rum.js.map +1 -1
  27. package/lib/commonjs/ft_tracing.js +29 -10
  28. package/lib/commonjs/ft_tracing.js.map +1 -1
  29. package/lib/commonjs/index.js +24 -13
  30. package/lib/commonjs/index.js.map +1 -1
  31. package/lib/commonjs/rum/FTRumActionTracking.js +10 -4
  32. package/lib/commonjs/rum/FTRumActionTracking.js.map +1 -1
  33. package/lib/commonjs/rum/FTRumErrorTracking.js +4 -4
  34. package/lib/commonjs/rum/FTRumErrorTracking.js.map +1 -1
  35. package/lib/commonjs/specs/NativeFTMobileReactNative.js +10 -0
  36. package/lib/commonjs/specs/NativeFTMobileReactNative.js.map +1 -0
  37. package/lib/commonjs/specs/NativeFTReactNativeLog.js +10 -0
  38. package/lib/commonjs/specs/NativeFTReactNativeLog.js.map +1 -0
  39. package/lib/commonjs/specs/NativeFTReactNativeRUM.js +10 -0
  40. package/lib/commonjs/specs/NativeFTReactNativeRUM.js.map +1 -0
  41. package/lib/commonjs/specs/NativeFTReactNativeTrace.js +10 -0
  42. package/lib/commonjs/specs/NativeFTReactNativeTrace.js.map +1 -0
  43. package/lib/commonjs/version.js +1 -1
  44. package/lib/commonjs/version.js.map +1 -1
  45. package/lib/module/ft_logger.js +14 -12
  46. package/lib/module/ft_logger.js.map +1 -1
  47. package/lib/module/ft_mobile_agent.js +159 -5
  48. package/lib/module/ft_mobile_agent.js.map +1 -1
  49. package/lib/module/ft_rum.js +54 -16
  50. package/lib/module/ft_rum.js.map +1 -1
  51. package/lib/module/ft_tracing.js +29 -9
  52. package/lib/module/ft_tracing.js.map +1 -1
  53. package/lib/module/index.js +3 -4
  54. package/lib/module/index.js.map +1 -1
  55. package/lib/module/rum/FTRumActionTracking.js +10 -4
  56. package/lib/module/rum/FTRumActionTracking.js.map +1 -1
  57. package/lib/module/rum/FTRumErrorTracking.js +4 -4
  58. package/lib/module/rum/FTRumErrorTracking.js.map +1 -1
  59. package/lib/module/specs/NativeFTMobileReactNative.js +5 -0
  60. package/lib/module/specs/NativeFTMobileReactNative.js.map +1 -0
  61. package/lib/module/specs/NativeFTReactNativeLog.js +5 -0
  62. package/lib/module/specs/NativeFTReactNativeLog.js.map +1 -0
  63. package/lib/module/specs/NativeFTReactNativeRUM.js +5 -0
  64. package/lib/module/specs/NativeFTReactNativeRUM.js.map +1 -0
  65. package/lib/module/specs/NativeFTReactNativeTrace.js +5 -0
  66. package/lib/module/specs/NativeFTReactNativeTrace.js.map +1 -0
  67. package/lib/module/version.js +1 -1
  68. package/lib/module/version.js.map +1 -1
  69. package/lib/typescript/ft_logger.d.ts +6 -6
  70. package/lib/typescript/ft_mobile_agent.d.ts +165 -14
  71. package/lib/typescript/ft_rum.d.ts +32 -8
  72. package/lib/typescript/ft_tracing.d.ts +6 -6
  73. package/lib/typescript/index.d.ts +3 -4
  74. package/lib/typescript/specs/NativeFTMobileReactNative.d.ts +75 -0
  75. package/lib/typescript/specs/NativeFTReactNativeLog.d.ts +23 -0
  76. package/lib/typescript/specs/NativeFTReactNativeRUM.d.ts +89 -0
  77. package/lib/typescript/specs/NativeFTReactNativeTrace.d.ts +24 -0
  78. package/lib/typescript/version.d.ts +1 -1
  79. package/package.json +29 -96
  80. package/scripts/replace-react-require.js +37 -38
  81. package/src/ft_logger.tsx +72 -40
  82. package/src/ft_mobile_agent.tsx +374 -91
  83. package/src/ft_rum.tsx +227 -121
  84. package/src/ft_tracing.tsx +58 -37
  85. package/src/index.tsx +58 -18
  86. package/src/rum/FTRumActionTracking.tsx +212 -204
  87. package/src/rum/FTRumErrorTracking.tsx +70 -71
  88. package/src/specs/NativeFTMobileReactNative.ts +83 -0
  89. package/src/specs/NativeFTReactNativeLog.ts +29 -0
  90. package/src/specs/NativeFTReactNativeRUM.ts +104 -0
  91. package/src/specs/NativeFTReactNativeTrace.ts +26 -0
  92. package/src/version.ts +1 -1
  93. package/LICENSE +0 -201
  94. package/android/.project +0 -17
  95. package/android/.settings/org.eclipse.buildship.core.prefs +0 -13
  96. package/android/gradlew +0 -185
  97. package/android/local.properties +0 -8
  98. package/android/src/main/java/com/ft/sdk/InnerClassProxy.java +0 -8
  99. package/android/src/main/java/com/ft/sdk/reactnative/FTSessionReplayImpl.java +0 -60
  100. package/android/src/main/java/com/ft/sdk/reactnative/extensions/ReactDrawablesExt.java +0 -155
  101. package/android/src/main/java/com/ft/sdk/reactnative/sessionreplay/NoopTextPropertiesResolver.java +0 -23
  102. package/android/src/main/java/com/ft/sdk/reactnative/sessionreplay/ReactNativeSessionReplayExtensionSupport.java +0 -57
  103. package/android/src/main/java/com/ft/sdk/reactnative/sessionreplay/ShadowNodeWrapper.java +0 -84
  104. package/android/src/main/java/com/ft/sdk/reactnative/sessionreplay/TextPropertiesResolver.java +0 -20
  105. package/android/src/main/java/com/ft/sdk/reactnative/sessionreplay/mappers/DefaultMapper.java +0 -78
  106. package/android/src/main/java/com/ft/sdk/reactnative/sessionreplay/mappers/Pair.java +0 -11
  107. package/android/src/main/java/com/ft/sdk/reactnative/sessionreplay/mappers/ReactEditTextMapper.java +0 -136
  108. package/android/src/main/java/com/ft/sdk/reactnative/sessionreplay/mappers/ReactNativeImageViewMapper.java +0 -117
  109. package/android/src/main/java/com/ft/sdk/reactnative/sessionreplay/mappers/ReactTextMapper.java +0 -57
  110. package/android/src/main/java/com/ft/sdk/reactnative/sessionreplay/mappers/ReactViewGroupMapper.java +0 -22
  111. package/android/src/main/java/com/ft/sdk/reactnative/sessionreplay/mappers/ReactViewModalMapper.java +0 -21
  112. package/android/src/main/java/com/ft/sdk/reactnative/sessionreplay/resources/ReactDrawableCopier.java +0 -35
  113. package/android/src/main/java/com/ft/sdk/reactnative/sessionreplay/utils/DrawableUtils.java +0 -34
  114. package/android/src/main/java/com/ft/sdk/reactnative/sessionreplay/utils/ReflectionUtils.java +0 -43
  115. package/android/src/main/java/com/ft/sdk/reactnative/sessionreplay/utils/text/FabricTextViewUtils.java +0 -69
  116. package/android/src/main/java/com/ft/sdk/reactnative/sessionreplay/utils/text/LegacyTextViewUtils.java +0 -97
  117. package/android/src/main/java/com/ft/sdk/reactnative/sessionreplay/utils/text/TextViewUtils.java +0 -184
  118. package/android/src/main/java/com/ft/sdk/reactnative/utils/ColorUtils.java +0 -24
  119. package/android/src/newarch/java/com/ft/sdk/reactnative/FTSessionReplayModule.java +0 -30
  120. package/android/src/oldarch/java/com/ft/sdk/reactnative/FTSessionReplayModule.java +0 -25
  121. package/android/src/rn69/java/com/ft/sdk/reactnative/sessionreplay/utils/ReactViewBackgroundDrawableUtils.java +0 -100
  122. package/android/src/rn75/java/com/ft/sdk/reactnative/sessionreplay/extensions/LengthPercentageExt.java +0 -27
  123. package/android/src/rn75/java/com/ft/sdk/reactnative/sessionreplay/utils/ReactViewBackgroundDrawableUtils.java +0 -116
  124. package/android/src/rn76/java/com/ft/sdk/reactnative/sessionreplay/extensions/LengthPercentageExt.java +0 -38
  125. package/android/src/rn76/java/com/ft/sdk/reactnative/sessionreplay/utils/ReactViewBackgroundDrawableUtils.java +0 -117
  126. package/android/src/rn79/java/com/ft/sdk/reactnative/sessionreplay/extensions/LengthPercentageExt.java +0 -38
  127. package/android/src/rn79/java/com/ft/sdk/reactnative/sessionreplay/utils/ReactViewBackgroundDrawableUtils.java +0 -132
  128. package/android/src/rn80/java/com/ft/sdk/reactnative/sessionreplay/extensions/ComputedBorderRadiusExt.java +0 -58
  129. package/android/src/rn80/java/com/ft/sdk/reactnative/sessionreplay/utils/ReactViewBackgroundDrawableUtils.java +0 -190
  130. package/android/src/rnlegacy/java/com/ft/sdk/reactnative/sessionreplay/utils/ReactViewBackgroundDrawableUtils.java +0 -120
  131. package/ios/.idea/.name +0 -1
  132. package/ios/.idea/ios.iml +0 -2
  133. package/ios/.idea/modules.xml +0 -8
  134. package/ios/.idea/vcs.xml +0 -6
  135. package/ios/.idea/xcode.xml +0 -4
  136. package/ios/FTMobileReactNative.m +0 -184
  137. package/ios/FTRCTTextViewRecorder.h +0 -33
  138. package/ios/FTRCTTextViewRecorder.m +0 -120
  139. package/ios/FTReactNativeLog.m +0 -60
  140. package/ios/FTReactNativeSessionReplay.h +0 -6
  141. package/ios/FTReactNativeSessionReplay.mm +0 -44
  142. package/ios/FTReactNativeTrace.m +0 -56
  143. package/ios/FtMobileAgent.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -4
  144. package/ios/FtMobileAgent.xcodeproj/project.xcworkspace/xcuserdata/Brandon.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  145. package/ios/FtMobileAgent.xcodeproj/project.xcworkspace/xcuserdata/Brandon.xcuserdatad/xcschemes/xcschememanagement.plist +0 -5
  146. package/ios/FtMobileAgent.xcodeproj/xcuserdata/Brandon.xcuserdatad/xcschemes/FtMobileAgent.xcscheme +0 -56
  147. package/ios/FtMobileAgent.xcodeproj/xcuserdata/Brandon.xcuserdatad/xcschemes/xcschememanagement.plist +0 -14
  148. package/ios/RCTVersion.h +0 -8
  149. package/lib/commonjs/ft_session_replay.js +0 -34
  150. package/lib/commonjs/ft_session_replay.js.map +0 -1
  151. package/lib/module/ft_session_replay.js +0 -29
  152. package/lib/module/ft_session_replay.js.map +0 -1
  153. package/lib/typescript/ft_session_replay.d.ts +0 -27
  154. package/src/ft_session_replay.tsx +0 -34
@@ -1,8 +0,0 @@
1
- package com.ft.sdk;
2
-
3
- public class InnerClassProxy {
4
-
5
- public static void addPkgInfo(FTSDKConfig config, String key, String value) {
6
- config.addPkgInfo(key, value);
7
- }
8
- }
@@ -1,60 +0,0 @@
1
- package com.ft.sdk.reactnative;
2
-
3
- import com.ft.sdk.reactnative.sessionreplay.ReactNativeSessionReplayExtensionSupport;
4
- import com.ft.sdk.reactnative.sessionreplay.utils.text.TextViewUtils;
5
- import com.ft.sdk.reactnative.utils.ReactNativeUtils;
6
- import com.facebook.react.bridge.Promise;
7
- import com.facebook.react.bridge.ReactContext;
8
- import com.facebook.react.bridge.ReactMethod;
9
- import com.facebook.react.bridge.ReadableMap;
10
- import com.ft.sdk.FTSdk;
11
- import com.ft.sdk.SessionReplayManager;
12
- import com.ft.sdk.sessionreplay.FTSessionReplayConfig;
13
- import com.ft.sdk.sessionreplay.SessionReplayPrivacy;
14
-
15
- public class FTSessionReplayImpl {
16
-
17
- public static final String NAME = "FTReactNativeSessionReplay";
18
-
19
-
20
- @ReactMethod
21
- public void sessionReplayConfig(ReadableMap context, Promise promise, ReactContext reactContext) {
22
- java.util.HashMap<String, Object> map = context.toHashMap();
23
-
24
- Double sampleRate = map.get("sampleRate") instanceof Double ? (Double) map.get("sampleRate") : null;
25
- Integer privacy = ReactNativeUtils.convertToNativeInt(map.get("privacy"));
26
- FTSessionReplayConfig sessionReplayConfig = new FTSessionReplayConfig();
27
-
28
- if (sampleRate != null) {
29
- sessionReplayConfig.setSampleRate(sampleRate.floatValue());
30
- }
31
-
32
- SessionReplayPrivacy sessionReplayPrivacy;
33
- if (privacy != null) {
34
- switch (privacy) {
35
- case 0:
36
- sessionReplayPrivacy = SessionReplayPrivacy.MASK;
37
- break;
38
- case 1:
39
- sessionReplayPrivacy = SessionReplayPrivacy.ALLOW;
40
- break;
41
- case 2:
42
- sessionReplayPrivacy = SessionReplayPrivacy.MASK_USER_INPUT;
43
- break;
44
- default:
45
- sessionReplayPrivacy = SessionReplayPrivacy.MASK;
46
- }
47
- } else {
48
- sessionReplayPrivacy = SessionReplayPrivacy.MASK;
49
- }
50
- sessionReplayConfig.setPrivacy(sessionReplayPrivacy);
51
- TextViewUtils textViewUtils = TextViewUtils.create(reactContext,
52
- SessionReplayManager.get().getInternalLogger());
53
- sessionReplayConfig.addExtensionSupport(
54
- new ReactNativeSessionReplayExtensionSupport(textViewUtils
55
- )
56
- ).setDelayInit(true);
57
- FTSdk.initSessionReplayConfig(sessionReplayConfig);
58
- promise.resolve(null);
59
- }
60
- }
@@ -1,155 +0,0 @@
1
- /*
2
- * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
3
- * This product includes software developed at Datadog (https://www.datadoghq.com/).
4
- * Copyright 2016-Present Datadog, Inc.
5
- */
6
-
7
- package com.ft.sdk.reactnative.extensions;
8
-
9
- import android.content.res.Resources;
10
- import android.graphics.Bitmap;
11
- import android.graphics.Bitmap.Config;
12
- import android.graphics.Canvas;
13
- import android.graphics.drawable.BitmapDrawable;
14
- import android.graphics.drawable.Drawable;
15
- import android.graphics.drawable.ShapeDrawable;
16
- import android.graphics.drawable.VectorDrawable;
17
- import android.widget.ImageView;
18
- import androidx.appcompat.graphics.drawable.DrawerArrowDrawable;
19
- import com.facebook.drawee.drawable.ArrayDrawable;
20
- import com.facebook.drawee.drawable.ForwardingDrawable;
21
- import com.facebook.drawee.drawable.RoundedBitmapDrawable;
22
- import com.facebook.drawee.drawable.ScaleTypeDrawable;
23
- import com.facebook.drawee.drawable.ScalingUtils;
24
-
25
- public class ReactDrawablesExt {
26
- public static ImageView.ScaleType imageViewScaleType(ScaleTypeDrawable scaleTypeDrawable) {
27
- ScalingUtils.ScaleType scaleType = scaleTypeDrawable.getScaleType();
28
- if (scaleType == ScalingUtils.ScaleType.CENTER) return ImageView.ScaleType.CENTER;
29
- if (scaleType == ScalingUtils.ScaleType.CENTER_CROP) return ImageView.ScaleType.CENTER_CROP;
30
- if (scaleType == ScalingUtils.ScaleType.CENTER_INSIDE) return ImageView.ScaleType.CENTER_INSIDE;
31
- if (scaleType == ScalingUtils.ScaleType.FIT_CENTER) return ImageView.ScaleType.FIT_CENTER;
32
- if (scaleType == ScalingUtils.ScaleType.FIT_START) return ImageView.ScaleType.FIT_START;
33
- if (scaleType == ScalingUtils.ScaleType.FIT_END) return ImageView.ScaleType.FIT_END;
34
- if (scaleType == ScalingUtils.ScaleType.FIT_XY) return ImageView.ScaleType.FIT_XY;
35
- return null;
36
- }
37
-
38
- public static ScaleTypeDrawable getScaleTypeDrawable(ArrayDrawable arrayDrawable) {
39
- for (int i = 0; i < arrayDrawable.getNumberOfLayers(); i++) {
40
- Drawable drawable = getDrawableOrNull(arrayDrawable, i);
41
- if (drawable instanceof ScaleTypeDrawable) return (ScaleTypeDrawable) drawable;
42
- }
43
- return null;
44
- }
45
-
46
- public static Drawable getDrawableOrNull(ArrayDrawable arrayDrawable, int index) {
47
- try {
48
- return arrayDrawable.getDrawable(index);
49
- } catch (IllegalArgumentException e) {
50
- return null;
51
- }
52
- }
53
-
54
- public static Bitmap tryToExtractBitmap(ForwardingDrawable forwardingDrawable, Resources resources) {
55
- Drawable forwardedDrawable = forwardingDrawable.getDrawable();
56
- if (forwardedDrawable != null) {
57
- return tryToExtractBitmap(forwardedDrawable, resources);
58
- } else {
59
- return toBitmapOrNull(forwardingDrawable, forwardingDrawable.getIntrinsicWidth(), forwardingDrawable.getIntrinsicHeight(), Config.ARGB_8888);
60
- }
61
- }
62
-
63
- public static Bitmap tryToExtractBitmap(RoundedBitmapDrawable roundedBitmapDrawable) {
64
- try {
65
- java.lang.reflect.Field field = RoundedBitmapDrawable.class.getDeclaredField("mBitmap");
66
- field.setAccessible(true);
67
- Object value = field.get(roundedBitmapDrawable);
68
- if (value instanceof Bitmap) {
69
- return (Bitmap) value;
70
- }
71
- } catch (NoSuchFieldException | IllegalAccessException e) {
72
- // ignore
73
- } catch (Exception e) {
74
- // ignore
75
- }
76
- return toBitmapOrNull(roundedBitmapDrawable, roundedBitmapDrawable.getIntrinsicWidth(), roundedBitmapDrawable.getIntrinsicHeight(), Config.ARGB_8888);
77
- }
78
-
79
- public static Bitmap tryToExtractBitmap(BitmapDrawable bitmapDrawable, Resources resources) {
80
- if (bitmapDrawable.getBitmap() != null) {
81
- return bitmapDrawable.getBitmap();
82
- }
83
- if (bitmapDrawable.getConstantState() != null) {
84
- Drawable copy = bitmapDrawable.getConstantState().newDrawable(resources);
85
- if (copy instanceof BitmapDrawable) {
86
- Bitmap b = ((BitmapDrawable) copy).getBitmap();
87
- if (b != null) return b;
88
- }
89
- return toBitmapOrNull(copy, copy.getIntrinsicWidth(), copy.getIntrinsicHeight(), Config.ARGB_8888);
90
- }
91
- return null;
92
- }
93
-
94
- public static Bitmap tryToExtractBitmap(ArrayDrawable arrayDrawable, Resources resources) {
95
- int width = 0, height = 0;
96
- for (int i = 0; i < arrayDrawable.getNumberOfLayers(); i++) {
97
- Drawable drawable = getDrawableOrNull(arrayDrawable, i);
98
- if (drawable instanceof ScaleTypeDrawable) {
99
- return tryToExtractBitmap((ScaleTypeDrawable) drawable, resources);
100
- }
101
- if (drawable != null && drawable.getIntrinsicWidth() * drawable.getIntrinsicHeight() > width * height) {
102
- width = drawable.getIntrinsicWidth();
103
- height = drawable.getIntrinsicHeight();
104
- }
105
- }
106
- if (width > 0 && height > 0) {
107
- return toBitmapOrNull(arrayDrawable, width, height, Config.ARGB_8888);
108
- } else {
109
- return null;
110
- }
111
- }
112
-
113
- public static Bitmap tryToExtractBitmap(Drawable drawable, Resources resources) {
114
- if (drawable instanceof ArrayDrawable) {
115
- return tryToExtractBitmap((ArrayDrawable) drawable, resources);
116
- } else if (drawable instanceof ForwardingDrawable) {
117
- return tryToExtractBitmap((ForwardingDrawable) drawable, resources);
118
- } else if (drawable instanceof RoundedBitmapDrawable) {
119
- return tryToExtractBitmap((RoundedBitmapDrawable) drawable);
120
- } else if (drawable instanceof BitmapDrawable) {
121
- return tryToExtractBitmap((BitmapDrawable) drawable, resources);
122
- } else if (drawable instanceof VectorDrawable || drawable instanceof ShapeDrawable || drawable instanceof DrawerArrowDrawable) {
123
- return toBitmapOrNull(drawable, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), Config.ARGB_8888);
124
- } else {
125
- return null;
126
- }
127
- }
128
-
129
- public static Bitmap toBitmapOrNull(Drawable drawable, int width, int height, Config config) {
130
- if (drawable instanceof BitmapDrawable && ((BitmapDrawable) drawable).getBitmap() == null) {
131
- return null;
132
- }
133
- return toBitmap(drawable, width, height, config);
134
- }
135
-
136
- public static Bitmap toBitmap(Drawable drawable, int width, int height, Config config) {
137
- if (drawable instanceof BitmapDrawable) {
138
- Bitmap bitmap = ((BitmapDrawable) drawable).getBitmap();
139
- if (bitmap == null) {
140
- return Bitmap.createBitmap(width, height, config != null ? config : Config.ARGB_8888);
141
- }
142
- if (config == null || bitmap.getConfig() == config) {
143
- if (width == bitmap.getWidth() && height == bitmap.getHeight()) {
144
- return bitmap;
145
- }
146
- return Bitmap.createScaledBitmap(bitmap, width, height, true);
147
- }
148
- }
149
- Bitmap bitmap = Bitmap.createBitmap(width, height, config != null ? config : Config.ARGB_8888);
150
- drawable.setBounds(0, 0, width, height);
151
- drawable.draw(new Canvas(bitmap));
152
- // restore bounds if needed
153
- return bitmap;
154
- }
155
- }
@@ -1,23 +0,0 @@
1
- /*
2
- *
3
- * * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
4
- * * This product includes software developed at Datadog (https://www.datadoghq.com/).
5
- * * Copyright 2016-Present Datadog, Inc.
6
- *
7
- */
8
-
9
- package com.ft.sdk.reactnative.sessionreplay;
10
-
11
- import android.widget.TextView;
12
- import com.ft.sdk.sessionreplay.model.TextWireframe;
13
-
14
- public class NoopTextPropertiesResolver implements TextPropertiesResolver {
15
- @Override
16
- public TextWireframe addReactNativeProperties(
17
- TextWireframe originalWireframe,
18
- TextView view,
19
- float pixelDensity
20
- ) {
21
- return originalWireframe;
22
- }
23
- }
@@ -1,57 +0,0 @@
1
- /*
2
- * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
3
- * This product includes software developed at Datadog (https://www.datadoghq.com/).
4
- * Copyright 2016-Present Datadog, Inc.
5
- */
6
-
7
- package com.ft.sdk.reactnative.sessionreplay;
8
-
9
- import com.ft.sdk.reactnative.sessionreplay.mappers.ReactEditTextMapper;
10
- import com.ft.sdk.reactnative.sessionreplay.mappers.ReactNativeImageViewMapper;
11
- import com.ft.sdk.reactnative.sessionreplay.mappers.ReactTextMapper;
12
- import com.ft.sdk.reactnative.sessionreplay.mappers.ReactViewGroupMapper;
13
- import com.ft.sdk.reactnative.sessionreplay.mappers.ReactViewModalMapper;
14
- import com.ft.sdk.reactnative.sessionreplay.utils.text.TextViewUtils;
15
- import com.facebook.react.views.image.ReactImageView;
16
- import com.facebook.react.views.modal.ReactModalHostView;
17
- import com.facebook.react.views.text.ReactTextView;
18
- import com.facebook.react.views.textinput.ReactEditText;
19
- import com.facebook.react.views.view.ReactViewGroup;
20
- import com.ft.sdk.sessionreplay.ExtensionSupport;
21
- import com.ft.sdk.sessionreplay.MapperTypeWrapper;
22
- import com.ft.sdk.sessionreplay.recorder.OptionSelectorDetector;
23
- import com.ft.sdk.sessionreplay.utils.DrawableToColorMapper;
24
-
25
- import java.util.ArrayList;
26
- import java.util.Arrays;
27
- import java.util.Collections;
28
- import java.util.List;
29
-
30
- public class ReactNativeSessionReplayExtensionSupport implements ExtensionSupport {
31
- private final TextViewUtils textViewUtils;
32
-
33
- public ReactNativeSessionReplayExtensionSupport(TextViewUtils textViewUtils) {
34
- this.textViewUtils = textViewUtils;
35
- }
36
-
37
- @Override
38
- public List<MapperTypeWrapper<?>> getCustomViewMappers() {
39
- return Arrays.asList(
40
- new MapperTypeWrapper<>(ReactImageView.class, new ReactNativeImageViewMapper()),
41
- new MapperTypeWrapper<>(ReactViewGroup.class, new ReactViewGroupMapper()),
42
- new MapperTypeWrapper<>(ReactTextView.class, new ReactTextMapper(textViewUtils)),
43
- new MapperTypeWrapper<>(ReactEditText.class, new ReactEditTextMapper(textViewUtils)),
44
- new MapperTypeWrapper<>(ReactModalHostView.class, new ReactViewModalMapper())
45
- );
46
- }
47
-
48
- @Override
49
- public List<OptionSelectorDetector> getOptionSelectorDetectors() {
50
- return new ArrayList<>();
51
- }
52
-
53
- @Override
54
- public List<DrawableToColorMapper> getCustomDrawableMapper() {
55
- return new ArrayList<>();
56
- }
57
- }
@@ -1,84 +0,0 @@
1
- /*
2
- *
3
- * * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
4
- * * This product includes software developed at Datadog (https://www.datadoghq.com/).
5
- * * Copyright 2016-Present Datadog, Inc.
6
- *
7
- */
8
-
9
- package com.ft.sdk.reactnative.sessionreplay;
10
-
11
- import androidx.annotation.VisibleForTesting;
12
- import com.ft.sdk.reactnative.sessionreplay.utils.ReflectionUtils;
13
- import com.facebook.react.bridge.ReactContext;
14
- import com.facebook.react.uimanager.ReactShadowNode;
15
- import com.facebook.react.uimanager.UIImplementation;
16
- import com.facebook.react.uimanager.UIManagerModule;
17
-
18
- import java.util.concurrent.CountDownLatch;
19
- import java.util.concurrent.TimeUnit;
20
-
21
- public class ShadowNodeWrapper {
22
- private final ReactShadowNode<?> shadowNode;
23
- private final ReflectionUtils reflectionUtils;
24
-
25
- public static final String UI_IMPLEMENTATION_FIELD_NAME = "mUIImplementation";
26
-
27
- public ShadowNodeWrapper(ReactShadowNode<?> shadowNode, ReflectionUtils reflectionUtils) {
28
- this.shadowNode = shadowNode;
29
- this.reflectionUtils = reflectionUtils;
30
- }
31
-
32
- public Object getDeclaredShadowNodeField(String fieldName) {
33
- if (shadowNode != null) {
34
- return reflectionUtils.getDeclaredField(shadowNode, fieldName);
35
- }
36
- return null;
37
- }
38
-
39
- public static ShadowNodeWrapper getShadowNodeWrapper(
40
- ReactContext reactContext,
41
- UIManagerModule uiManagerModule,
42
- ReflectionUtils reflectionUtils,
43
- int viewId
44
- ) {
45
- if (reactContext == null) {
46
- return null;
47
- }
48
-
49
- CountDownLatch countDownLatch = new CountDownLatch(1);
50
- final ReactShadowNode<?>[] target = new ReactShadowNode[1];
51
-
52
- Runnable shadowNodeRunnable = new Runnable() {
53
- @Override
54
- public void run() {
55
- ReactShadowNode<?> node = resolveShadowNode(reflectionUtils, uiManagerModule, viewId);
56
- if (node != null) {
57
- target[0] = node;
58
- }
59
- countDownLatch.countDown();
60
- }
61
- };
62
-
63
- reactContext.runOnNativeModulesQueueThread(shadowNodeRunnable);
64
- try {
65
- countDownLatch.await(5, TimeUnit.SECONDS);
66
- } catch (InterruptedException e) {
67
- Thread.currentThread().interrupt();
68
- }
69
-
70
- if (target[0] == null) {
71
- return null;
72
- }
73
-
74
- return new ShadowNodeWrapper(target[0], reflectionUtils);
75
- }
76
-
77
- private static ReactShadowNode<?> resolveShadowNode(ReflectionUtils reflectionUtils, UIManagerModule uiManagerModule, int tag) {
78
- if (uiManagerModule == null ) {
79
- return null;
80
- }
81
- UIImplementation uiManagerImplementation = (UIImplementation) reflectionUtils.getDeclaredField(uiManagerModule, UI_IMPLEMENTATION_FIELD_NAME);
82
- return uiManagerImplementation != null ? uiManagerImplementation.resolveShadowNode(tag) : null;
83
- }
84
- }
@@ -1,20 +0,0 @@
1
- /*
2
- *
3
- * * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
4
- * * This product includes software developed at Datadog (https://www.datadoghq.com/).
5
- * * Copyright 2016-Present Datadog, Inc.
6
- *
7
- */
8
-
9
- package com.ft.sdk.reactnative.sessionreplay;
10
-
11
- import android.widget.TextView;
12
- import com.ft.sdk.sessionreplay.model.TextWireframe;
13
-
14
- public interface TextPropertiesResolver {
15
- TextWireframe addReactNativeProperties(
16
- TextWireframe originalWireframe,
17
- TextView view,
18
- float pixelDensity
19
- );
20
- }
@@ -1,78 +0,0 @@
1
- /*
2
- * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
3
- * This product includes software developed at Datadog (https://www.datadoghq.com/).
4
- * Copyright 2016-Present Datadog, Inc.
5
- */
6
-
7
- package com.ft.sdk.reactnative.sessionreplay.mappers;
8
-
9
- import android.graphics.drawable.Drawable;
10
- import android.view.View;
11
-
12
- import com.ft.sdk.reactnative.sessionreplay.utils.DrawableUtils;
13
- import com.ft.sdk.reactnative.sessionreplay.utils.ReactViewBackgroundDrawableUtils;
14
- import com.ft.sdk.sessionreplay.model.ShapeBorder;
15
- import com.ft.sdk.sessionreplay.model.ShapeStyle;
16
- import com.ft.sdk.sessionreplay.model.ShapeWireframe;
17
- import com.ft.sdk.sessionreplay.model.Wireframe;
18
- import com.ft.sdk.sessionreplay.recorder.MappingContext;
19
- import com.ft.sdk.sessionreplay.recorder.mapper.BaseWireframeMapper;
20
- import com.ft.sdk.sessionreplay.utils.AsyncJobStatusCallback;
21
- import com.ft.sdk.sessionreplay.utils.DefaultColorStringFormatter;
22
- import com.ft.sdk.sessionreplay.utils.DefaultViewBoundsResolver;
23
- import com.ft.sdk.sessionreplay.utils.DefaultViewIdentifierResolver;
24
- import com.ft.sdk.sessionreplay.utils.DrawableToColorMapperFactory;
25
- import com.ft.sdk.sessionreplay.utils.GlobalBounds;
26
- import com.ft.sdk.sessionreplay.utils.InternalLogger;
27
-
28
- import java.util.Collections;
29
- import java.util.List;
30
-
31
- public class DefaultMapper<T extends View> extends BaseWireframeMapper<T> {
32
- private final DrawableUtils drawableUtils;
33
-
34
- public DefaultMapper(DrawableUtils drawableUtils) {
35
- super(
36
- DefaultViewIdentifierResolver.get(),
37
- DefaultColorStringFormatter.get(),
38
- DefaultViewBoundsResolver.get(),
39
- DrawableToColorMapperFactory.getDefault()
40
- );
41
- this.drawableUtils = drawableUtils;
42
- }
43
-
44
- @Override
45
- public List<Wireframe> map(
46
- T view,
47
- MappingContext mappingContext,
48
- AsyncJobStatusCallback asyncJobStatusCallback,
49
- InternalLogger internalLogger
50
- ) {
51
- float pixelDensity = mappingContext.getSystemInformation().getScreenDensity();
52
- GlobalBounds viewGlobalBounds =
53
- DefaultViewBoundsResolver.get().resolveViewGlobalBounds(view, pixelDensity);
54
- Drawable backgroundDrawable = drawableUtils.getReactBackgroundFromDrawable(view.getBackground());
55
-
56
- float opacity = view.getAlpha();
57
-
58
- Pair<ShapeStyle, ShapeBorder> shapeAndBorder =
59
- backgroundDrawable != null ?
60
- drawableUtils.resolveShapeAndBorder(backgroundDrawable, opacity, pixelDensity)
61
- : new Pair<>(null, null);
62
-
63
- ShapeStyle shapeStyle = shapeAndBorder.first;
64
- ShapeBorder border = shapeAndBorder.second;
65
-
66
- ShapeWireframe shapeWireframe = new ShapeWireframe(
67
- resolveViewId(view),
68
- viewGlobalBounds.getX(),
69
- viewGlobalBounds.getY(),
70
- viewGlobalBounds.getWidth(),
71
- viewGlobalBounds.getHeight(),
72
- null,
73
- shapeStyle,
74
- border
75
- );
76
- return Collections.singletonList(shapeWireframe);
77
- }
78
- }
@@ -1,11 +0,0 @@
1
- package com.ft.sdk.reactnative.sessionreplay.mappers;
2
-
3
- public class Pair<F, S> {
4
- public final F first;
5
- public final S second;
6
-
7
- public Pair(F first, S second) {
8
- this.first = first;
9
- this.second = second;
10
- }
11
- }
@@ -1,136 +0,0 @@
1
- /*
2
- * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
3
- * This product includes software developed at Datadog (https://www.datadoghq.com/).
4
- * Copyright 2016-Present Datadog, Inc.
5
- */
6
-
7
- package com.ft.sdk.reactnative.sessionreplay.mappers;
8
-
9
- import android.graphics.drawable.Drawable;
10
- import android.view.View;
11
-
12
- import com.ft.sdk.reactnative.sessionreplay.utils.ReactViewBackgroundDrawableUtils;
13
- import com.ft.sdk.reactnative.sessionreplay.utils.text.TextViewUtils;
14
- import com.facebook.react.views.textinput.ReactEditText;
15
- import com.ft.sdk.sessionreplay.model.ImageWireframe;
16
- import com.ft.sdk.sessionreplay.model.PlaceholderWireframe;
17
- import com.ft.sdk.sessionreplay.model.ShapeBorder;
18
- import com.ft.sdk.sessionreplay.model.ShapeStyle;
19
- import com.ft.sdk.sessionreplay.model.ShapeWireframe;
20
- import com.ft.sdk.sessionreplay.model.Wireframe;
21
- import com.ft.sdk.sessionreplay.recorder.MappingContext;
22
- import com.ft.sdk.sessionreplay.recorder.mapper.BaseAsyncBackgroundWireframeMapper;
23
- import com.ft.sdk.sessionreplay.recorder.mapper.EditTextMapper;
24
- import com.ft.sdk.sessionreplay.utils.AsyncJobStatusCallback;
25
- import com.ft.sdk.sessionreplay.utils.DefaultColorStringFormatter;
26
- import com.ft.sdk.sessionreplay.utils.DefaultViewBoundsResolver;
27
- import com.ft.sdk.sessionreplay.utils.DefaultViewIdentifierResolver;
28
- import com.ft.sdk.sessionreplay.utils.DrawableToColorMapperFactory;
29
- import com.ft.sdk.sessionreplay.utils.GlobalBounds;
30
- import com.ft.sdk.sessionreplay.utils.InternalLogger;
31
-
32
- import java.util.ArrayList;
33
- import java.util.List;
34
-
35
- public class ReactEditTextMapper extends BaseAsyncBackgroundWireframeMapper<ReactEditText> {
36
- private final TextViewUtils textViewUtils;
37
- private final ReactViewBackgroundDrawableUtils drawableUtils = new ReactViewBackgroundDrawableUtils();
38
- private final EditTextMapper editTextMapper;
39
-
40
- public ReactEditTextMapper(TextViewUtils textViewUtils) {
41
- super(
42
- DefaultViewIdentifierResolver.get(),
43
- DefaultColorStringFormatter.get(),
44
- DefaultViewBoundsResolver.get(),
45
- DrawableToColorMapperFactory.getDefault()
46
- );
47
- this.textViewUtils = textViewUtils;
48
- this.editTextMapper = new EditTextMapper(
49
- viewIdentifierResolver,
50
- colorStringFormatter,
51
- viewBoundsResolver,
52
- drawableToColorMapper
53
- );
54
- }
55
-
56
- @Override
57
- public List<Wireframe> map(
58
- ReactEditText view,
59
- MappingContext mappingContext,
60
- AsyncJobStatusCallback asyncJobStatusCallback,
61
- InternalLogger internalLogger
62
- ) {
63
- List<Wireframe> backgroundWireframes = new ArrayList<>(super.map(view, mappingContext, asyncJobStatusCallback, internalLogger));
64
- List<Wireframe> editTextWireframes = editTextMapper.map(
65
- view,
66
- mappingContext,
67
- asyncJobStatusCallback,
68
- internalLogger
69
- );
70
-
71
- List<Wireframe> filteredEditTextWireframes = new ArrayList<>();
72
- for (Wireframe wf : editTextWireframes) {
73
- if (!(wf instanceof ImageWireframe) && !(wf instanceof PlaceholderWireframe)) {
74
- filteredEditTextWireframes.add(wf);
75
- }
76
- }
77
- backgroundWireframes.addAll(filteredEditTextWireframes);
78
- return textViewUtils.mapTextViewToWireframes(
79
- backgroundWireframes,
80
- view,
81
- mappingContext
82
- );
83
- }
84
-
85
- @Override
86
- public Wireframe resolveBackgroundAsImageWireframe(
87
- View view,
88
- GlobalBounds bounds,
89
- int width,
90
- int height,
91
- MappingContext mappingContext,
92
- AsyncJobStatusCallback asyncJobStatusCallback
93
- ) {
94
- if (!(view instanceof ReactEditText)) {
95
- return super.resolveBackgroundAsImageWireframe(
96
- view,
97
- bounds,
98
- width,
99
- height,
100
- mappingContext,
101
- asyncJobStatusCallback
102
- );
103
- }
104
- Drawable backgroundDrawable = drawableUtils.getReactBackgroundFromDrawable(((ReactEditText) view).getBackground());
105
- if (backgroundDrawable == null) {
106
- return null;
107
- }
108
- float density = mappingContext.getSystemInformation().getScreenDensity();
109
- Long identifier = viewIdentifierResolver.resolveChildUniqueIdentifier(
110
- view,
111
- "drawable0"
112
- );
113
- if (identifier == null) {
114
- return null;
115
- }
116
- GlobalBounds globalBounds = viewBoundsResolver.resolveViewGlobalBounds(
117
- view,
118
- density
119
- );
120
- Pair<ShapeStyle, ShapeBorder> shapeAndBorder = drawableUtils.resolveShapeAndBorder(
121
- backgroundDrawable,
122
- ((ReactEditText) view).getAlpha(),
123
- mappingContext.getSystemInformation().getScreenDensity()
124
- );
125
- return new ShapeWireframe(
126
- identifier,
127
- globalBounds.getX(),
128
- globalBounds.getY(),
129
- globalBounds.getWidth(),
130
- globalBounds.getHeight(),
131
- null,
132
- shapeAndBorder.first,
133
- shapeAndBorder.second
134
- );
135
- }
136
- }