@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.
- package/FTMobileReactNativeSDK.podspec +32 -3
- package/android/build.gradle +7 -19
- package/android/src/main/java/com/ft/sdk/reactnative/FTMobileImpl.java +434 -5
- package/android/src/main/java/com/ft/sdk/reactnative/FTRUMImpl.java +12 -0
- package/android/src/newarch/java/com/ft/sdk/reactnative/FTLogModule.java +7 -14
- package/android/src/newarch/java/com/ft/sdk/reactnative/FTMobileModule.java +46 -12
- package/android/src/newarch/java/com/ft/sdk/reactnative/FTRUMModule.java +12 -13
- package/android/src/newarch/java/com/ft/sdk/reactnative/FTTraceModule.java +6 -8
- package/android/src/oldarch/java/com/ft/sdk/reactnative/FTMobileModule.java +34 -2
- package/android/src/rnpost74/java/com/ft/sdk/reactnative/FTMobilePackage.java +14 -3
- package/android/src/rnpre74/java/com/ft/sdk/reactnative/FTMobilePackage.java +0 -3
- package/ios/FTMobileReactNative.h +9 -5
- package/ios/FTMobileReactNative.mm +619 -0
- package/ios/FTReactNativeLog.h +8 -3
- package/ios/FTReactNativeLog.mm +79 -0
- package/ios/FTReactNativeRUM.h +8 -3
- package/ios/{FTReactNativeRUM.m → FTReactNativeRUM.mm} +143 -84
- package/ios/FTReactNativeTrace.h +8 -2
- package/ios/FTReactNativeTrace.mm +74 -0
- package/ios/FtMobileAgent.xcodeproj/project.pbxproj +17 -1
- package/lib/commonjs/ft_logger.js +14 -13
- package/lib/commonjs/ft_logger.js.map +1 -1
- package/lib/commonjs/ft_mobile_agent.js +153 -6
- package/lib/commonjs/ft_mobile_agent.js.map +1 -1
- package/lib/commonjs/ft_rum.js +55 -21
- package/lib/commonjs/ft_rum.js.map +1 -1
- package/lib/commonjs/ft_tracing.js +29 -10
- package/lib/commonjs/ft_tracing.js.map +1 -1
- package/lib/commonjs/index.js +24 -13
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/rum/FTRumActionTracking.js +10 -4
- package/lib/commonjs/rum/FTRumActionTracking.js.map +1 -1
- package/lib/commonjs/rum/FTRumErrorTracking.js +4 -4
- package/lib/commonjs/rum/FTRumErrorTracking.js.map +1 -1
- package/lib/commonjs/specs/NativeFTMobileReactNative.js +10 -0
- package/lib/commonjs/specs/NativeFTMobileReactNative.js.map +1 -0
- package/lib/commonjs/specs/NativeFTReactNativeLog.js +10 -0
- package/lib/commonjs/specs/NativeFTReactNativeLog.js.map +1 -0
- package/lib/commonjs/specs/NativeFTReactNativeRUM.js +10 -0
- package/lib/commonjs/specs/NativeFTReactNativeRUM.js.map +1 -0
- package/lib/commonjs/specs/NativeFTReactNativeTrace.js +10 -0
- package/lib/commonjs/specs/NativeFTReactNativeTrace.js.map +1 -0
- package/lib/commonjs/version.js +1 -1
- package/lib/commonjs/version.js.map +1 -1
- package/lib/module/ft_logger.js +14 -12
- package/lib/module/ft_logger.js.map +1 -1
- package/lib/module/ft_mobile_agent.js +159 -5
- package/lib/module/ft_mobile_agent.js.map +1 -1
- package/lib/module/ft_rum.js +54 -16
- package/lib/module/ft_rum.js.map +1 -1
- package/lib/module/ft_tracing.js +29 -9
- package/lib/module/ft_tracing.js.map +1 -1
- package/lib/module/index.js +3 -4
- package/lib/module/index.js.map +1 -1
- package/lib/module/rum/FTRumActionTracking.js +10 -4
- package/lib/module/rum/FTRumActionTracking.js.map +1 -1
- package/lib/module/rum/FTRumErrorTracking.js +4 -4
- package/lib/module/rum/FTRumErrorTracking.js.map +1 -1
- package/lib/module/specs/NativeFTMobileReactNative.js +5 -0
- package/lib/module/specs/NativeFTMobileReactNative.js.map +1 -0
- package/lib/module/specs/NativeFTReactNativeLog.js +5 -0
- package/lib/module/specs/NativeFTReactNativeLog.js.map +1 -0
- package/lib/module/specs/NativeFTReactNativeRUM.js +5 -0
- package/lib/module/specs/NativeFTReactNativeRUM.js.map +1 -0
- package/lib/module/specs/NativeFTReactNativeTrace.js +5 -0
- package/lib/module/specs/NativeFTReactNativeTrace.js.map +1 -0
- package/lib/module/version.js +1 -1
- package/lib/module/version.js.map +1 -1
- package/lib/typescript/ft_logger.d.ts +6 -6
- package/lib/typescript/ft_mobile_agent.d.ts +165 -14
- package/lib/typescript/ft_rum.d.ts +32 -8
- package/lib/typescript/ft_tracing.d.ts +6 -6
- package/lib/typescript/index.d.ts +3 -4
- package/lib/typescript/specs/NativeFTMobileReactNative.d.ts +75 -0
- package/lib/typescript/specs/NativeFTReactNativeLog.d.ts +23 -0
- package/lib/typescript/specs/NativeFTReactNativeRUM.d.ts +89 -0
- package/lib/typescript/specs/NativeFTReactNativeTrace.d.ts +24 -0
- package/lib/typescript/version.d.ts +1 -1
- package/package.json +29 -96
- package/scripts/replace-react-require.js +37 -38
- package/src/ft_logger.tsx +72 -40
- package/src/ft_mobile_agent.tsx +374 -91
- package/src/ft_rum.tsx +227 -121
- package/src/ft_tracing.tsx +58 -37
- package/src/index.tsx +58 -18
- package/src/rum/FTRumActionTracking.tsx +212 -204
- package/src/rum/FTRumErrorTracking.tsx +70 -71
- package/src/specs/NativeFTMobileReactNative.ts +83 -0
- package/src/specs/NativeFTReactNativeLog.ts +29 -0
- package/src/specs/NativeFTReactNativeRUM.ts +104 -0
- package/src/specs/NativeFTReactNativeTrace.ts +26 -0
- package/src/version.ts +1 -1
- package/LICENSE +0 -201
- package/android/.project +0 -17
- package/android/.settings/org.eclipse.buildship.core.prefs +0 -13
- package/android/gradlew +0 -185
- package/android/local.properties +0 -8
- package/android/src/main/java/com/ft/sdk/InnerClassProxy.java +0 -8
- package/android/src/main/java/com/ft/sdk/reactnative/FTSessionReplayImpl.java +0 -60
- package/android/src/main/java/com/ft/sdk/reactnative/extensions/ReactDrawablesExt.java +0 -155
- package/android/src/main/java/com/ft/sdk/reactnative/sessionreplay/NoopTextPropertiesResolver.java +0 -23
- package/android/src/main/java/com/ft/sdk/reactnative/sessionreplay/ReactNativeSessionReplayExtensionSupport.java +0 -57
- package/android/src/main/java/com/ft/sdk/reactnative/sessionreplay/ShadowNodeWrapper.java +0 -84
- package/android/src/main/java/com/ft/sdk/reactnative/sessionreplay/TextPropertiesResolver.java +0 -20
- package/android/src/main/java/com/ft/sdk/reactnative/sessionreplay/mappers/DefaultMapper.java +0 -78
- package/android/src/main/java/com/ft/sdk/reactnative/sessionreplay/mappers/Pair.java +0 -11
- package/android/src/main/java/com/ft/sdk/reactnative/sessionreplay/mappers/ReactEditTextMapper.java +0 -136
- package/android/src/main/java/com/ft/sdk/reactnative/sessionreplay/mappers/ReactNativeImageViewMapper.java +0 -117
- package/android/src/main/java/com/ft/sdk/reactnative/sessionreplay/mappers/ReactTextMapper.java +0 -57
- package/android/src/main/java/com/ft/sdk/reactnative/sessionreplay/mappers/ReactViewGroupMapper.java +0 -22
- package/android/src/main/java/com/ft/sdk/reactnative/sessionreplay/mappers/ReactViewModalMapper.java +0 -21
- package/android/src/main/java/com/ft/sdk/reactnative/sessionreplay/resources/ReactDrawableCopier.java +0 -35
- package/android/src/main/java/com/ft/sdk/reactnative/sessionreplay/utils/DrawableUtils.java +0 -34
- package/android/src/main/java/com/ft/sdk/reactnative/sessionreplay/utils/ReflectionUtils.java +0 -43
- package/android/src/main/java/com/ft/sdk/reactnative/sessionreplay/utils/text/FabricTextViewUtils.java +0 -69
- package/android/src/main/java/com/ft/sdk/reactnative/sessionreplay/utils/text/LegacyTextViewUtils.java +0 -97
- package/android/src/main/java/com/ft/sdk/reactnative/sessionreplay/utils/text/TextViewUtils.java +0 -184
- package/android/src/main/java/com/ft/sdk/reactnative/utils/ColorUtils.java +0 -24
- package/android/src/newarch/java/com/ft/sdk/reactnative/FTSessionReplayModule.java +0 -30
- package/android/src/oldarch/java/com/ft/sdk/reactnative/FTSessionReplayModule.java +0 -25
- package/android/src/rn69/java/com/ft/sdk/reactnative/sessionreplay/utils/ReactViewBackgroundDrawableUtils.java +0 -100
- package/android/src/rn75/java/com/ft/sdk/reactnative/sessionreplay/extensions/LengthPercentageExt.java +0 -27
- package/android/src/rn75/java/com/ft/sdk/reactnative/sessionreplay/utils/ReactViewBackgroundDrawableUtils.java +0 -116
- package/android/src/rn76/java/com/ft/sdk/reactnative/sessionreplay/extensions/LengthPercentageExt.java +0 -38
- package/android/src/rn76/java/com/ft/sdk/reactnative/sessionreplay/utils/ReactViewBackgroundDrawableUtils.java +0 -117
- package/android/src/rn79/java/com/ft/sdk/reactnative/sessionreplay/extensions/LengthPercentageExt.java +0 -38
- package/android/src/rn79/java/com/ft/sdk/reactnative/sessionreplay/utils/ReactViewBackgroundDrawableUtils.java +0 -132
- package/android/src/rn80/java/com/ft/sdk/reactnative/sessionreplay/extensions/ComputedBorderRadiusExt.java +0 -58
- package/android/src/rn80/java/com/ft/sdk/reactnative/sessionreplay/utils/ReactViewBackgroundDrawableUtils.java +0 -190
- package/android/src/rnlegacy/java/com/ft/sdk/reactnative/sessionreplay/utils/ReactViewBackgroundDrawableUtils.java +0 -120
- package/ios/.idea/.name +0 -1
- package/ios/.idea/ios.iml +0 -2
- package/ios/.idea/modules.xml +0 -8
- package/ios/.idea/vcs.xml +0 -6
- package/ios/.idea/xcode.xml +0 -4
- package/ios/FTMobileReactNative.m +0 -184
- package/ios/FTRCTTextViewRecorder.h +0 -33
- package/ios/FTRCTTextViewRecorder.m +0 -120
- package/ios/FTReactNativeLog.m +0 -60
- package/ios/FTReactNativeSessionReplay.h +0 -6
- package/ios/FTReactNativeSessionReplay.mm +0 -44
- package/ios/FTReactNativeTrace.m +0 -56
- package/ios/FtMobileAgent.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -4
- package/ios/FtMobileAgent.xcodeproj/project.xcworkspace/xcuserdata/Brandon.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/ios/FtMobileAgent.xcodeproj/project.xcworkspace/xcuserdata/Brandon.xcuserdatad/xcschemes/xcschememanagement.plist +0 -5
- package/ios/FtMobileAgent.xcodeproj/xcuserdata/Brandon.xcuserdatad/xcschemes/FtMobileAgent.xcscheme +0 -56
- package/ios/FtMobileAgent.xcodeproj/xcuserdata/Brandon.xcuserdatad/xcschemes/xcschememanagement.plist +0 -14
- package/ios/RCTVersion.h +0 -8
- package/lib/commonjs/ft_session_replay.js +0 -34
- package/lib/commonjs/ft_session_replay.js.map +0 -1
- package/lib/module/ft_session_replay.js +0 -29
- package/lib/module/ft_session_replay.js.map +0 -1
- package/lib/typescript/ft_session_replay.d.ts +0 -27
- package/src/ft_session_replay.tsx +0 -34
|
@@ -1,117 +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.Rect;
|
|
10
|
-
import android.graphics.drawable.Drawable;
|
|
11
|
-
import android.widget.ImageView;
|
|
12
|
-
|
|
13
|
-
import com.ft.sdk.reactnative.extensions.ReactDrawablesExt;
|
|
14
|
-
import com.ft.sdk.reactnative.sessionreplay.resources.ReactDrawableCopier;
|
|
15
|
-
import com.facebook.drawee.drawable.FadeDrawable;
|
|
16
|
-
import com.facebook.react.views.image.ReactImageView;
|
|
17
|
-
import com.ft.sdk.sessionreplay.internal.utils.ImageViewUtils;
|
|
18
|
-
import com.ft.sdk.sessionreplay.internal.utils.RectExt;
|
|
19
|
-
import com.ft.sdk.sessionreplay.model.Wireframe;
|
|
20
|
-
import com.ft.sdk.sessionreplay.model.WireframeClip;
|
|
21
|
-
import com.ft.sdk.sessionreplay.recorder.MappingContext;
|
|
22
|
-
import com.ft.sdk.sessionreplay.recorder.mapper.BaseAsyncBackgroundWireframeMapper;
|
|
23
|
-
import com.ft.sdk.sessionreplay.utils.AsyncJobStatusCallback;
|
|
24
|
-
import com.ft.sdk.sessionreplay.utils.DefaultColorStringFormatter;
|
|
25
|
-
import com.ft.sdk.sessionreplay.utils.DefaultViewBoundsResolver;
|
|
26
|
-
import com.ft.sdk.sessionreplay.utils.DefaultViewIdentifierResolver;
|
|
27
|
-
import com.ft.sdk.sessionreplay.utils.DrawableToColorMapperFactory;
|
|
28
|
-
import com.ft.sdk.sessionreplay.utils.InternalLogger;
|
|
29
|
-
|
|
30
|
-
import java.util.ArrayList;
|
|
31
|
-
import java.util.List;
|
|
32
|
-
|
|
33
|
-
public class ReactNativeImageViewMapper extends BaseAsyncBackgroundWireframeMapper<ReactImageView> {
|
|
34
|
-
private final ReactDrawableCopier drawableCopier = new ReactDrawableCopier();
|
|
35
|
-
private final ImageViewUtils imageViewUtils = ImageViewUtils.get();
|
|
36
|
-
|
|
37
|
-
public ReactNativeImageViewMapper() {
|
|
38
|
-
super(
|
|
39
|
-
DefaultViewIdentifierResolver.get(),
|
|
40
|
-
DefaultColorStringFormatter.get(),
|
|
41
|
-
DefaultViewBoundsResolver.get(),
|
|
42
|
-
DrawableToColorMapperFactory.getDefault()
|
|
43
|
-
);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
@Override
|
|
47
|
-
public List<Wireframe> map(
|
|
48
|
-
ReactImageView view,
|
|
49
|
-
MappingContext mappingContext,
|
|
50
|
-
AsyncJobStatusCallback asyncJobStatusCallback,
|
|
51
|
-
InternalLogger internalLogger
|
|
52
|
-
) {
|
|
53
|
-
List<Wireframe> wireframes = new ArrayList<>(super.map(view, mappingContext, asyncJobStatusCallback, internalLogger));
|
|
54
|
-
|
|
55
|
-
Drawable drawable = view.getDrawable() != null ? view.getDrawable().getCurrent() : null;
|
|
56
|
-
if (drawable == null) {
|
|
57
|
-
return wireframes;
|
|
58
|
-
}
|
|
59
|
-
Rect parentRect = imageViewUtils.resolveParentRectAbsPosition(view);
|
|
60
|
-
ImageView.ScaleType scaleType = (drawable instanceof FadeDrawable)
|
|
61
|
-
? ReactDrawablesExt.imageViewScaleType(ReactDrawablesExt.getScaleTypeDrawable((FadeDrawable) drawable))
|
|
62
|
-
: view.getScaleType();
|
|
63
|
-
Rect contentRect = imageViewUtils.resolveContentRectWithScaling(view, drawable, scaleType);
|
|
64
|
-
|
|
65
|
-
android.content.res.Resources resources = view.getResources();
|
|
66
|
-
float density = resources.getDisplayMetrics().density;
|
|
67
|
-
|
|
68
|
-
WireframeClip clipping = view.getCropToPadding()
|
|
69
|
-
? RectExt.toWireframeClip(imageViewUtils.calculateClipping(parentRect, contentRect, density))
|
|
70
|
-
: null;
|
|
71
|
-
|
|
72
|
-
long contentXPosInDp = (long) (contentRect.left / density);
|
|
73
|
-
long contentYPosInDp = (long) (contentRect.top / density);
|
|
74
|
-
int contentWidthPx = contentRect.width();
|
|
75
|
-
int contentHeightPx = contentRect.height();
|
|
76
|
-
|
|
77
|
-
// resolve foreground
|
|
78
|
-
Wireframe imageWireframe = mappingContext.getImageWireframeHelper().createImageWireframeByDrawable(
|
|
79
|
-
view,
|
|
80
|
-
mappingContext.getImagePrivacy(),
|
|
81
|
-
wireframes.size(),
|
|
82
|
-
contentXPosInDp,
|
|
83
|
-
contentYPosInDp,
|
|
84
|
-
contentWidthPx,
|
|
85
|
-
contentHeightPx,
|
|
86
|
-
true,
|
|
87
|
-
drawable,
|
|
88
|
-
drawableCopier,
|
|
89
|
-
asyncJobStatusCallback,
|
|
90
|
-
clipping,
|
|
91
|
-
null,
|
|
92
|
-
null,
|
|
93
|
-
"drawable",
|
|
94
|
-
generateUUID(view)
|
|
95
|
-
);
|
|
96
|
-
if (imageWireframe != null) {
|
|
97
|
-
wireframes.add(imageWireframe);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
return wireframes;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
private String generateUUID(ReactImageView reactImageView) {
|
|
104
|
-
int hashCode = System.identityHashCode(reactImageView);
|
|
105
|
-
String drawableType = reactImageView.getDrawable() != null ? reactImageView.getDrawable().getCurrent().getClass().getName() : "null";
|
|
106
|
-
return drawableType + "-" + hashCode;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
private WireframeClip toWireframeClip(Rect rect) {
|
|
110
|
-
return new WireframeClip(
|
|
111
|
-
(long) rect.top,
|
|
112
|
-
(long) rect.bottom,
|
|
113
|
-
(long) rect.left,
|
|
114
|
-
(long) rect.right
|
|
115
|
-
);
|
|
116
|
-
}
|
|
117
|
-
}
|
package/android/src/main/java/com/ft/sdk/reactnative/sessionreplay/mappers/ReactTextMapper.java
DELETED
|
@@ -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.mappers;
|
|
8
|
-
|
|
9
|
-
import com.ft.sdk.reactnative.sessionreplay.utils.text.TextViewUtils;
|
|
10
|
-
import com.facebook.react.views.text.ReactTextView;
|
|
11
|
-
import com.ft.sdk.sessionreplay.model.ImageWireframe;
|
|
12
|
-
import com.ft.sdk.sessionreplay.model.PlaceholderWireframe;
|
|
13
|
-
import com.ft.sdk.sessionreplay.model.Wireframe;
|
|
14
|
-
import com.ft.sdk.sessionreplay.recorder.MappingContext;
|
|
15
|
-
import com.ft.sdk.sessionreplay.recorder.mapper.TextViewMapper;
|
|
16
|
-
import com.ft.sdk.sessionreplay.utils.AsyncJobStatusCallback;
|
|
17
|
-
import com.ft.sdk.sessionreplay.utils.DefaultColorStringFormatter;
|
|
18
|
-
import com.ft.sdk.sessionreplay.utils.DefaultViewBoundsResolver;
|
|
19
|
-
import com.ft.sdk.sessionreplay.utils.DefaultViewIdentifierResolver;
|
|
20
|
-
import com.ft.sdk.sessionreplay.utils.DrawableToColorMapperFactory;
|
|
21
|
-
import com.ft.sdk.sessionreplay.utils.InternalLogger;
|
|
22
|
-
|
|
23
|
-
import java.util.ArrayList;
|
|
24
|
-
import java.util.List;
|
|
25
|
-
|
|
26
|
-
public class ReactTextMapper extends TextViewMapper<ReactTextView> {
|
|
27
|
-
private final TextViewUtils textViewUtils;
|
|
28
|
-
|
|
29
|
-
public ReactTextMapper(TextViewUtils textViewUtils) {
|
|
30
|
-
super(
|
|
31
|
-
DefaultViewIdentifierResolver.get(),
|
|
32
|
-
DefaultColorStringFormatter.get(),
|
|
33
|
-
DefaultViewBoundsResolver.get(),
|
|
34
|
-
DrawableToColorMapperFactory.getDefault()
|
|
35
|
-
);
|
|
36
|
-
this.textViewUtils = textViewUtils;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
@Override
|
|
41
|
-
public List<Wireframe> map(ReactTextView view, MappingContext mappingContext, AsyncJobStatusCallback asyncJobStatusCallback, InternalLogger internalLogger) {
|
|
42
|
-
List<Wireframe> wireframes = super.map(view, mappingContext, asyncJobStatusCallback, internalLogger);
|
|
43
|
-
List<Wireframe> mappedWireframes = textViewUtils.mapTextViewToWireframes(
|
|
44
|
-
wireframes,
|
|
45
|
-
view,
|
|
46
|
-
mappingContext
|
|
47
|
-
);
|
|
48
|
-
List<Wireframe> result = new ArrayList<>();
|
|
49
|
-
for (Wireframe wf : mappedWireframes) {
|
|
50
|
-
if (!(wf instanceof ImageWireframe) &&
|
|
51
|
-
!(wf instanceof PlaceholderWireframe)) {
|
|
52
|
-
result.add(wf);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
return result;
|
|
56
|
-
}
|
|
57
|
-
}
|
package/android/src/main/java/com/ft/sdk/reactnative/sessionreplay/mappers/ReactViewGroupMapper.java
DELETED
|
@@ -1,22 +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 com.ft.sdk.reactnative.sessionreplay.utils.DrawableUtils;
|
|
10
|
-
import com.ft.sdk.reactnative.sessionreplay.utils.ReactViewBackgroundDrawableUtils;
|
|
11
|
-
import com.facebook.react.views.view.ReactViewGroup;
|
|
12
|
-
import com.ft.sdk.sessionreplay.recorder.mapper.TraverseAllChildrenMapper;
|
|
13
|
-
|
|
14
|
-
public class ReactViewGroupMapper extends DefaultMapper<ReactViewGroup> implements TraverseAllChildrenMapper<ReactViewGroup> {
|
|
15
|
-
public ReactViewGroupMapper() {
|
|
16
|
-
this(new ReactViewBackgroundDrawableUtils());
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
public ReactViewGroupMapper(DrawableUtils drawableUtils) {
|
|
20
|
-
super(drawableUtils);
|
|
21
|
-
}
|
|
22
|
-
}
|
package/android/src/main/java/com/ft/sdk/reactnative/sessionreplay/mappers/ReactViewModalMapper.java
DELETED
|
@@ -1,21 +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 com.ft.sdk.reactnative.sessionreplay.utils.ReactViewBackgroundDrawableUtils;
|
|
10
|
-
import com.ft.sdk.reactnative.sessionreplay.utils.DrawableUtils;
|
|
11
|
-
import com.facebook.react.views.modal.ReactModalHostView;
|
|
12
|
-
|
|
13
|
-
public class ReactViewModalMapper extends DefaultMapper<ReactModalHostView> {
|
|
14
|
-
public ReactViewModalMapper() {
|
|
15
|
-
this(new ReactViewBackgroundDrawableUtils());
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
public ReactViewModalMapper(DrawableUtils drawableUtils) {
|
|
19
|
-
super(drawableUtils);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
@@ -1,35 +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.resources;
|
|
8
|
-
|
|
9
|
-
import android.content.res.Resources;
|
|
10
|
-
import android.graphics.drawable.BitmapDrawable;
|
|
11
|
-
import android.graphics.drawable.Drawable;
|
|
12
|
-
|
|
13
|
-
import com.ft.sdk.reactnative.extensions.ReactDrawablesExt;
|
|
14
|
-
import com.ft.sdk.sessionreplay.resources.DefaultDrawableCopier;
|
|
15
|
-
import com.ft.sdk.sessionreplay.resources.DrawableCopier;
|
|
16
|
-
|
|
17
|
-
public class ReactDrawableCopier implements DrawableCopier {
|
|
18
|
-
private final DefaultDrawableCopier defaultCopier = new DefaultDrawableCopier();
|
|
19
|
-
|
|
20
|
-
@Override
|
|
21
|
-
public Drawable copy(Drawable originalDrawable, Resources resources) {
|
|
22
|
-
if (originalDrawable.getConstantState() != null) {
|
|
23
|
-
return defaultCopier.copy(originalDrawable, resources);
|
|
24
|
-
} else {
|
|
25
|
-
android.graphics.Bitmap bitmap = ReactDrawablesExt.tryToExtractBitmap(originalDrawable, resources);
|
|
26
|
-
if (bitmap != null) {
|
|
27
|
-
BitmapDrawable bitmapDrawable = new BitmapDrawable(resources, bitmap);
|
|
28
|
-
bitmapDrawable.setBounds(originalDrawable.getBounds());
|
|
29
|
-
bitmapDrawable.setAlpha(originalDrawable.getAlpha());
|
|
30
|
-
return bitmapDrawable;
|
|
31
|
-
}
|
|
32
|
-
return null;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
}
|
|
@@ -1,34 +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.utils;
|
|
8
|
-
|
|
9
|
-
import android.graphics.drawable.Drawable;
|
|
10
|
-
|
|
11
|
-
import com.ft.sdk.reactnative.sessionreplay.mappers.Pair;
|
|
12
|
-
import com.ft.sdk.sessionreplay.model.ShapeBorder;
|
|
13
|
-
import com.ft.sdk.sessionreplay.model.ShapeStyle;
|
|
14
|
-
|
|
15
|
-
public abstract class DrawableUtils {
|
|
16
|
-
protected final ReflectionUtils reflectionUtils;
|
|
17
|
-
|
|
18
|
-
public DrawableUtils() {
|
|
19
|
-
this(new ReflectionUtils());
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
public DrawableUtils(ReflectionUtils reflectionUtils) {
|
|
23
|
-
this.reflectionUtils = reflectionUtils;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
public abstract Pair<ShapeStyle, ShapeBorder> resolveShapeAndBorder(
|
|
27
|
-
Drawable drawable,
|
|
28
|
-
float opacity,
|
|
29
|
-
float pixelDensity
|
|
30
|
-
);
|
|
31
|
-
|
|
32
|
-
public abstract Drawable getReactBackgroundFromDrawable(Drawable drawable);
|
|
33
|
-
|
|
34
|
-
}
|
package/android/src/main/java/com/ft/sdk/reactnative/sessionreplay/utils/ReflectionUtils.java
DELETED
|
@@ -1,43 +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.utils;
|
|
8
|
-
|
|
9
|
-
import java.lang.reflect.Field;
|
|
10
|
-
|
|
11
|
-
public class ReflectionUtils {
|
|
12
|
-
public Object getDeclaredField(Object instance, String fieldName) {
|
|
13
|
-
if (instance == null) {
|
|
14
|
-
return null;
|
|
15
|
-
}
|
|
16
|
-
Class<?> classInstance = instance.getClass();
|
|
17
|
-
Field declaredField = searchForField(classInstance, fieldName);
|
|
18
|
-
|
|
19
|
-
if (declaredField != null) {
|
|
20
|
-
declaredField.setAccessible(true);
|
|
21
|
-
try {
|
|
22
|
-
return declaredField.get(instance);
|
|
23
|
-
} catch (IllegalAccessException e) {
|
|
24
|
-
return null;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
return null;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
private Field searchForField(Class<?> className, String fieldName) {
|
|
31
|
-
for (Field field : className.getDeclaredFields()) {
|
|
32
|
-
if (field.getName().equals(fieldName)) {
|
|
33
|
-
return field;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
if (className.getSuperclass() != null) {
|
|
38
|
-
return searchForField(className.getSuperclass(), fieldName);
|
|
39
|
-
} else {
|
|
40
|
-
return null;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
package com.ft.sdk.reactnative.sessionreplay.utils.text;
|
|
2
|
-
|
|
3
|
-
import android.text.Spannable;
|
|
4
|
-
import android.text.style.ForegroundColorSpan;
|
|
5
|
-
import android.view.View;
|
|
6
|
-
import android.widget.TextView;
|
|
7
|
-
|
|
8
|
-
import com.ft.sdk.reactnative.sessionreplay.utils.DrawableUtils;
|
|
9
|
-
import com.ft.sdk.reactnative.utils.ColorUtils;
|
|
10
|
-
import com.facebook.react.bridge.ReactContext;
|
|
11
|
-
import com.ft.sdk.garble.utils.LogUtils;
|
|
12
|
-
import com.ft.sdk.sessionreplay.model.TextStyle;
|
|
13
|
-
import com.ft.sdk.sessionreplay.model.TextWireframe;
|
|
14
|
-
import com.ft.sdk.sessionreplay.utils.InternalLogger;
|
|
15
|
-
|
|
16
|
-
import java.util.Locale;
|
|
17
|
-
|
|
18
|
-
public class FabricTextViewUtils extends TextViewUtils {
|
|
19
|
-
private static final String TAG = "FabricTextViewUtils";
|
|
20
|
-
private final ReactContext reactContext;
|
|
21
|
-
private final InternalLogger logger;
|
|
22
|
-
|
|
23
|
-
public FabricTextViewUtils(ReactContext reactContext, InternalLogger logger, DrawableUtils drawableUtils) {
|
|
24
|
-
super(reactContext, drawableUtils);
|
|
25
|
-
this.reactContext = reactContext;
|
|
26
|
-
this.logger = logger;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
@Override
|
|
30
|
-
protected TextStyle resolveTextStyle(TextWireframe textWireframe, float pixelsDensity, TextView view) {
|
|
31
|
-
String fontColor = getTextColor(view, textWireframe);
|
|
32
|
-
Long fontSize = getFontSize(view, pixelsDensity);
|
|
33
|
-
String fontFamily = getFontFamily(textWireframe);
|
|
34
|
-
return new TextStyle(fontFamily, fontSize, fontColor);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
private String getTextColor(TextView view, TextWireframe textWireframe) {
|
|
38
|
-
Spannable spanned = (Spannable) getFieldFromView(view, TextViewUtils.SPANNED_FIELD_NAME);
|
|
39
|
-
ForegroundColorSpan[] spans = spanned != null ? spanned.getSpans(0, spanned.length(), ForegroundColorSpan.class) : null;
|
|
40
|
-
String fontColor = (spans != null && spans.length > 0)
|
|
41
|
-
? ColorUtils.formatAsRgba(spans[0].getForegroundColor())
|
|
42
|
-
: textWireframe.getTextStyle().getColor();
|
|
43
|
-
return fontColor;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
private Long getFontSize(TextView view, float pixelsDensity) {
|
|
47
|
-
return (long) (view.getTextSize() / pixelsDensity);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
private String getFontFamily(TextWireframe textWireframe) {
|
|
51
|
-
String fontFamily = textWireframe.getTextStyle().getFamily();
|
|
52
|
-
return resolveFontFamily(fontFamily.toLowerCase(Locale.US));
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
public Object getFieldFromView(View view, String value) {
|
|
56
|
-
try {
|
|
57
|
-
java.lang.reflect.Field field = view.getClass().getDeclaredField(value);
|
|
58
|
-
field.setAccessible(true);
|
|
59
|
-
return field.get(view);
|
|
60
|
-
} catch (Exception e) {
|
|
61
|
-
handleError(e, TextViewUtils.RESOLVE_FABRICFIELD_ERROR);
|
|
62
|
-
return null;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
private void handleError(Exception e, String message) {
|
|
67
|
-
logger.e(TAG, "message:" + message + "," + LogUtils.getStackTraceString(e));
|
|
68
|
-
}
|
|
69
|
-
}
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
package com.ft.sdk.reactnative.sessionreplay.utils.text;
|
|
2
|
-
|
|
3
|
-
import android.widget.TextView;
|
|
4
|
-
|
|
5
|
-
import com.ft.sdk.reactnative.sessionreplay.ShadowNodeWrapper;
|
|
6
|
-
import com.ft.sdk.reactnative.sessionreplay.utils.DrawableUtils;
|
|
7
|
-
import com.ft.sdk.reactnative.sessionreplay.utils.ReflectionUtils;
|
|
8
|
-
import com.ft.sdk.reactnative.utils.ColorUtils;
|
|
9
|
-
import com.facebook.react.bridge.ReactContext;
|
|
10
|
-
import com.facebook.react.uimanager.UIManagerModule;
|
|
11
|
-
import com.facebook.react.views.text.TextAttributes;
|
|
12
|
-
import com.ft.sdk.garble.utils.LogUtils;
|
|
13
|
-
import com.ft.sdk.sessionreplay.model.TextStyle;
|
|
14
|
-
import com.ft.sdk.sessionreplay.model.TextWireframe;
|
|
15
|
-
import com.ft.sdk.sessionreplay.utils.InternalLogger;
|
|
16
|
-
|
|
17
|
-
import java.util.Locale;
|
|
18
|
-
|
|
19
|
-
public class LegacyTextViewUtils extends TextViewUtils {
|
|
20
|
-
private static final String TAG = "LegacyTextViewUtils";
|
|
21
|
-
private final ReactContext reactContext;
|
|
22
|
-
private final InternalLogger logger;
|
|
23
|
-
private final ReflectionUtils reflectionUtils;
|
|
24
|
-
private UIManagerModule uiManager;
|
|
25
|
-
|
|
26
|
-
public LegacyTextViewUtils(ReactContext reactContext, InternalLogger logger, ReflectionUtils reflectionUtils, DrawableUtils drawableUtils) {
|
|
27
|
-
super(reactContext, drawableUtils);
|
|
28
|
-
this.reactContext = reactContext;
|
|
29
|
-
this.logger = logger;
|
|
30
|
-
this.reflectionUtils = reflectionUtils;
|
|
31
|
-
this.uiManager = getUiManagerModule();
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
@Override
|
|
35
|
-
protected TextStyle resolveTextStyle(TextWireframe textWireframe, float pixelsDensity, TextView view) {
|
|
36
|
-
ShadowNodeWrapper shadowNodeWrapper = ShadowNodeWrapper.getShadowNodeWrapper(
|
|
37
|
-
reactContext,
|
|
38
|
-
uiManager,
|
|
39
|
-
reflectionUtils,
|
|
40
|
-
view.getId()
|
|
41
|
-
);
|
|
42
|
-
if (shadowNodeWrapper == null) return null;
|
|
43
|
-
String fontFamily = getFontFamily(shadowNodeWrapper);
|
|
44
|
-
if (fontFamily == null) fontFamily = textWireframe.getTextStyle().getFamily();
|
|
45
|
-
Long fontSize = getFontSize(shadowNodeWrapper);
|
|
46
|
-
if (fontSize != null) {
|
|
47
|
-
fontSize = (long) (fontSize / pixelsDensity);
|
|
48
|
-
} else {
|
|
49
|
-
fontSize = textWireframe.getTextStyle().getSize();
|
|
50
|
-
}
|
|
51
|
-
String fontColor = getTextColor(shadowNodeWrapper);
|
|
52
|
-
if (fontColor == null) fontColor = textWireframe.getTextStyle().getColor();
|
|
53
|
-
return new TextStyle(fontFamily, fontSize, fontColor);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
private String getTextColor(ShadowNodeWrapper shadowNodeWrapper) {
|
|
57
|
-
if (shadowNodeWrapper == null) return null;
|
|
58
|
-
Boolean isColorSet = (Boolean) shadowNodeWrapper.getDeclaredShadowNodeField(TextViewUtils.IS_COLOR_SET_FIELD_NAME);
|
|
59
|
-
if (isColorSet == null || !isColorSet) {
|
|
60
|
-
return "#000000FF";
|
|
61
|
-
}
|
|
62
|
-
Integer resolvedColor = (Integer) shadowNodeWrapper.getDeclaredShadowNodeField(TextViewUtils.COLOR_FIELD_NAME);
|
|
63
|
-
if (resolvedColor != null) {
|
|
64
|
-
return ColorUtils.formatAsRgba(resolvedColor);
|
|
65
|
-
}
|
|
66
|
-
return null;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
private Long getFontSize(ShadowNodeWrapper shadowNodeWrapper) {
|
|
70
|
-
if (shadowNodeWrapper == null) return null;
|
|
71
|
-
TextAttributes textAttributes = (TextAttributes) shadowNodeWrapper.getDeclaredShadowNodeField(TextViewUtils.TEXT_ATTRIBUTES_FIELD_NAME);
|
|
72
|
-
if (textAttributes != null) {
|
|
73
|
-
return (long) textAttributes.getEffectiveFontSize();
|
|
74
|
-
}
|
|
75
|
-
return null;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
private String getFontFamily(ShadowNodeWrapper shadowNodeWrapper) {
|
|
79
|
-
if (shadowNodeWrapper == null) return null;
|
|
80
|
-
String fontFamily = (String) shadowNodeWrapper.getDeclaredShadowNodeField(TextViewUtils.FONT_FAMILY_FIELD_NAME);
|
|
81
|
-
if (fontFamily != null) {
|
|
82
|
-
return resolveFontFamily(fontFamily.toLowerCase(Locale.US));
|
|
83
|
-
}
|
|
84
|
-
return null;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
private UIManagerModule getUiManagerModule() {
|
|
88
|
-
try {
|
|
89
|
-
return reactContext.getNativeModule(UIManagerModule.class);
|
|
90
|
-
} catch (IllegalStateException e) {
|
|
91
|
-
logger.w(
|
|
92
|
-
TAG, TextViewUtils.RESOLVE_UIMANAGERMODULE_ERROR + ":" + LogUtils.getStackTraceString(e)
|
|
93
|
-
);
|
|
94
|
-
return null;
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
}
|
package/android/src/main/java/com/ft/sdk/reactnative/sessionreplay/utils/text/TextViewUtils.java
DELETED
|
@@ -1,184 +0,0 @@
|
|
|
1
|
-
package com.ft.sdk.reactnative.sessionreplay.utils.text;
|
|
2
|
-
|
|
3
|
-
import android.view.Gravity;
|
|
4
|
-
import android.widget.TextView;
|
|
5
|
-
|
|
6
|
-
import com.ft.sdk.reactnative.BuildConfig;
|
|
7
|
-
import com.ft.sdk.reactnative.sessionreplay.mappers.Pair;
|
|
8
|
-
import com.ft.sdk.reactnative.sessionreplay.utils.DrawableUtils;
|
|
9
|
-
import com.ft.sdk.reactnative.sessionreplay.utils.ReactViewBackgroundDrawableUtils;
|
|
10
|
-
import com.ft.sdk.reactnative.sessionreplay.utils.ReflectionUtils;
|
|
11
|
-
import com.facebook.react.bridge.ReactContext;
|
|
12
|
-
import com.ft.sdk.sessionreplay.model.Alignment;
|
|
13
|
-
import com.ft.sdk.sessionreplay.model.ShapeBorder;
|
|
14
|
-
import com.ft.sdk.sessionreplay.model.ShapeStyle;
|
|
15
|
-
import com.ft.sdk.sessionreplay.model.TextPosition;
|
|
16
|
-
import com.ft.sdk.sessionreplay.model.TextStyle;
|
|
17
|
-
import com.ft.sdk.sessionreplay.model.TextWireframe;
|
|
18
|
-
import com.ft.sdk.sessionreplay.model.Vertical;
|
|
19
|
-
import com.ft.sdk.sessionreplay.model.Wireframe;
|
|
20
|
-
import com.ft.sdk.sessionreplay.recorder.MappingContext;
|
|
21
|
-
import com.ft.sdk.sessionreplay.utils.InternalLogger;
|
|
22
|
-
|
|
23
|
-
import java.util.ArrayList;
|
|
24
|
-
import java.util.List;
|
|
25
|
-
|
|
26
|
-
public abstract class TextViewUtils {
|
|
27
|
-
protected final ReactContext reactContext;
|
|
28
|
-
protected final DrawableUtils drawableUtils;
|
|
29
|
-
|
|
30
|
-
public TextViewUtils(ReactContext reactContext, DrawableUtils drawableUtils) {
|
|
31
|
-
this.reactContext = reactContext;
|
|
32
|
-
this.drawableUtils = drawableUtils;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
public List<Wireframe> mapTextViewToWireframes(
|
|
36
|
-
List<Wireframe> wireframes,
|
|
37
|
-
TextView view,
|
|
38
|
-
MappingContext mappingContext
|
|
39
|
-
) {
|
|
40
|
-
List<Wireframe> result = new ArrayList<>();
|
|
41
|
-
float pixelDensity = mappingContext.getSystemInformation().getScreenDensity();
|
|
42
|
-
for (Wireframe originalWireframe : wireframes) {
|
|
43
|
-
if (!(originalWireframe instanceof TextWireframe)) {
|
|
44
|
-
result.add(originalWireframe);
|
|
45
|
-
} else {
|
|
46
|
-
result.add(addReactNativeProperties(
|
|
47
|
-
(TextWireframe) originalWireframe,
|
|
48
|
-
view,
|
|
49
|
-
pixelDensity
|
|
50
|
-
));
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
return result;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
public TextWireframe addReactNativeProperties(
|
|
57
|
-
TextWireframe originalWireframe,
|
|
58
|
-
TextView view,
|
|
59
|
-
float pixelDensity
|
|
60
|
-
) {
|
|
61
|
-
Pair<ShapeStyle, ShapeBorder> shapeAndBorder = resolveShapeStyleAndBorder(view, pixelDensity);
|
|
62
|
-
ShapeStyle shapeStyle = shapeAndBorder != null ? shapeAndBorder.first : originalWireframe.getShapeStyle();
|
|
63
|
-
ShapeBorder border = shapeAndBorder != null ? shapeAndBorder.second : originalWireframe.getBorder();
|
|
64
|
-
|
|
65
|
-
Pair<TextStyle, TextPosition> textStyleAndPosition = resolveTextStyleAndPosition(originalWireframe, view, pixelDensity);
|
|
66
|
-
TextStyle textStyle = textStyleAndPosition != null ? textStyleAndPosition.first : originalWireframe.getTextStyle();
|
|
67
|
-
TextPosition textPosition = textStyleAndPosition != null ? textStyleAndPosition.second : originalWireframe.getTextPosition();
|
|
68
|
-
|
|
69
|
-
// nothing changed, return the original wireframe
|
|
70
|
-
if (shapeStyle == originalWireframe.getShapeStyle()
|
|
71
|
-
&& border == originalWireframe.getBorder()
|
|
72
|
-
&& textStyle == originalWireframe.getTextStyle()
|
|
73
|
-
&& textPosition == originalWireframe.getTextPosition()) {
|
|
74
|
-
return originalWireframe;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
return new TextWireframe(
|
|
78
|
-
originalWireframe.getId(),
|
|
79
|
-
originalWireframe.getX(),
|
|
80
|
-
originalWireframe.getY(),
|
|
81
|
-
originalWireframe.getWidth(),
|
|
82
|
-
originalWireframe.getHeight(),
|
|
83
|
-
originalWireframe.getClip(),
|
|
84
|
-
shapeStyle,
|
|
85
|
-
border,
|
|
86
|
-
originalWireframe.getText(),
|
|
87
|
-
textStyle,
|
|
88
|
-
textPosition
|
|
89
|
-
);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
protected Pair<TextStyle, TextPosition> resolveTextStyleAndPosition(
|
|
93
|
-
TextWireframe originalWireframe,
|
|
94
|
-
TextView view,
|
|
95
|
-
float pixelDensity
|
|
96
|
-
) {
|
|
97
|
-
if (!reactContext.hasActiveReactInstance()) {
|
|
98
|
-
return null;
|
|
99
|
-
}
|
|
100
|
-
TextStyle textStyle = resolveTextStyle(originalWireframe, pixelDensity, view);
|
|
101
|
-
if (textStyle == null) return null;
|
|
102
|
-
Alignment alignment = resolveTextAlignment(view, originalWireframe);
|
|
103
|
-
TextPosition textPosition = new TextPosition(
|
|
104
|
-
originalWireframe.getTextPosition() != null ? originalWireframe.getTextPosition().getPadding()
|
|
105
|
-
: null, alignment
|
|
106
|
-
);
|
|
107
|
-
return new Pair<>(textStyle, textPosition);
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
protected Pair<ShapeStyle, ShapeBorder> resolveShapeStyleAndBorder(
|
|
111
|
-
TextView view,
|
|
112
|
-
float pixelDensity
|
|
113
|
-
) {
|
|
114
|
-
android.graphics.drawable.Drawable backgroundDrawable = drawableUtils.getReactBackgroundFromDrawable(view.getBackground());
|
|
115
|
-
if (backgroundDrawable == null) return null;
|
|
116
|
-
float opacity = view.getAlpha();
|
|
117
|
-
return drawableUtils.resolveShapeAndBorder(backgroundDrawable, opacity, pixelDensity);
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
protected Alignment resolveTextAlignment(
|
|
121
|
-
TextView view,
|
|
122
|
-
TextWireframe textWireframe
|
|
123
|
-
) {
|
|
124
|
-
int gravity = view.getGravity();
|
|
125
|
-
com.ft.sdk.sessionreplay.model.Horizontal horizontal = textWireframe.getTextPosition() != null && textWireframe.getTextPosition().getAlignment() != null ? textWireframe.getTextPosition().getAlignment().getHorizontal() : null;
|
|
126
|
-
Vertical vertical;
|
|
127
|
-
switch (gravity & Gravity.VERTICAL_GRAVITY_MASK) {
|
|
128
|
-
case Gravity.TOP:
|
|
129
|
-
vertical = Vertical.TOP;
|
|
130
|
-
break;
|
|
131
|
-
case Gravity.CENTER_VERTICAL:
|
|
132
|
-
case Gravity.CENTER:
|
|
133
|
-
vertical = Vertical.CENTER;
|
|
134
|
-
break;
|
|
135
|
-
case Gravity.BOTTOM:
|
|
136
|
-
vertical = Vertical.BOTTOM;
|
|
137
|
-
break;
|
|
138
|
-
default:
|
|
139
|
-
vertical = Vertical.TOP;
|
|
140
|
-
}
|
|
141
|
-
return new Alignment(horizontal, vertical);
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
protected String resolveFontFamily(String typefaceName) {
|
|
145
|
-
switch (typefaceName) {
|
|
146
|
-
case ROBOTO_TYPEFACE_NAME:
|
|
147
|
-
return SANS_SERIF_FAMILY_NAME;
|
|
148
|
-
case MONOSPACE_FAMILY_NAME:
|
|
149
|
-
return MONOSPACE_FAMILY_NAME;
|
|
150
|
-
case SERIF_FAMILY_NAME:
|
|
151
|
-
return SERIF_FAMILY_NAME;
|
|
152
|
-
default:
|
|
153
|
-
return SANS_SERIF_FAMILY_NAME;
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
protected abstract TextStyle resolveTextStyle(
|
|
158
|
-
TextWireframe textWireframe,
|
|
159
|
-
float pixelsDensity,
|
|
160
|
-
TextView view
|
|
161
|
-
);
|
|
162
|
-
|
|
163
|
-
public static final String TEXT_ATTRIBUTES_FIELD_NAME = "mTextAttributes";
|
|
164
|
-
public static final String FONT_FAMILY_FIELD_NAME = "mFontFamily";
|
|
165
|
-
public static final String COLOR_FIELD_NAME = "mColor";
|
|
166
|
-
public static final String IS_COLOR_SET_FIELD_NAME = "mIsColorSet";
|
|
167
|
-
public static final String SPANNED_FIELD_NAME = "mSpanned";
|
|
168
|
-
private static final String ROBOTO_TYPEFACE_NAME = "roboto";
|
|
169
|
-
private static final String SERIF_FAMILY_NAME = "serif";
|
|
170
|
-
private static final String SANS_SERIF_FAMILY_NAME = "roboto, sans-serif";
|
|
171
|
-
public static final String MONOSPACE_FAMILY_NAME = "monospace";
|
|
172
|
-
public static final String RESOLVE_UIMANAGERMODULE_ERROR = "Unable to resolve UIManagerModule";
|
|
173
|
-
public static final String RESOLVE_FABRICFIELD_ERROR = "Unable to resolve field from fabric view";
|
|
174
|
-
public static final String NULL_FABRICFIELD_ERROR = "Null value found when trying to resolve field from fabric view";
|
|
175
|
-
|
|
176
|
-
public static TextViewUtils create(ReactContext reactContext, InternalLogger logger) {
|
|
177
|
-
if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) {
|
|
178
|
-
return new FabricTextViewUtils(reactContext, logger, new ReactViewBackgroundDrawableUtils());
|
|
179
|
-
} else {
|
|
180
|
-
return new LegacyTextViewUtils(reactContext, logger, new ReflectionUtils(), new ReactViewBackgroundDrawableUtils());
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
}
|