Skip to content

Commit 77d2959

Browse files
committed
Merged in release/16.1.0 (pull request #74)
Release/16.1.0
2 parents 5ceb9fb + 8226635 commit 77d2959

26 files changed

Lines changed: 480 additions & 68 deletions

android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,5 +76,5 @@ repositories {
7676
dependencies {
7777
//noinspection GradleDynamicVersion
7878
implementation 'com.facebook.react:react-native:+' // From node_modules
79-
api "$System.env.ANDROID_DEPENDENCY:16.0.+"
79+
api "$System.env.ANDROID_DEPENDENCY:16.1.+"
8080
}

android/src/main/java/com/shakebugs/react/ShakeModule.java

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
import com.facebook.react.bridge.ReactMethod;
1313
import com.facebook.react.bridge.ReadableArray;
1414
import com.facebook.react.bridge.ReadableMap;
15-
import com.facebook.react.bridge.WritableArray;
1615
import com.facebook.react.bridge.WritableMap;
1716
import com.facebook.react.uimanager.NativeViewHierarchyManager;
1817
import com.facebook.react.uimanager.UIBlock;
@@ -34,6 +33,7 @@
3433
import com.shakebugs.shake.privacy.NotificationEventsFilter;
3534
import com.shakebugs.shake.report.ShakeFile;
3635
import com.shakebugs.shake.report.ShakeReportData;
36+
import com.shakebugs.shake.theme.ShakeTheme;
3737

3838
import java.util.List;
3939
import java.util.Map;
@@ -115,6 +115,27 @@ public void run() {
115115
});
116116
}
117117

118+
@ReactMethod
119+
public void setShakeTheme(final ReadableMap shakeThemeMap) {
120+
runOnUiThread(new Runnable() {
121+
@Override
122+
public void run() {
123+
ShakeTheme shakeTheme = mapper.mapMapToShakeTheme(shakeThemeMap);
124+
Shake.getReportConfiguration().setTheme(shakeTheme);
125+
}
126+
});
127+
}
128+
129+
@ReactMethod
130+
public void setHomeSubtitle(final String subtitle) {
131+
runOnUiThread(new Runnable() {
132+
@Override
133+
public void run() {
134+
Shake.getReportConfiguration().setHomeSubtitle(subtitle);
135+
}
136+
});
137+
}
138+
118139
@ReactMethod
119140
public void isUserFeedbackEnabled(Promise promise) {
120141
promise.resolve(Shake.isUserFeedbackEnabled());

android/src/main/java/com/shakebugs/react/utils/Constants.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
public class Constants {
44
public static final String PLATFORM = "ReactNative";
55
public static final String VERSION_CODE = "1";
6-
public static final String VERSION_NAME = "16.0.0";
6+
public static final String VERSION_NAME = "16.1.0";
77
}

android/src/main/java/com/shakebugs/react/utils/Converter.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
import android.annotation.SuppressLint;
44
import android.content.Context;
5+
import android.graphics.Color;
6+
import android.util.DisplayMetrics;
57

68
public class Converter {
79
public static int stringToInt(String string) {
@@ -38,4 +40,19 @@ public static Integer stringToRes(Context context, String resName, String type)
3840
}
3941
return iconRes;
4042
}
43+
44+
public static Float convertDpToPixels(Context context, Double dp) {
45+
if (dp == null) return null;
46+
return dp.floatValue() * (context.getResources().getDisplayMetrics().densityDpi / DisplayMetrics.DENSITY_DEFAULT);
47+
}
48+
49+
public static Float convertPixelsToDp(Context context, Double px) {
50+
if (px == null) return null;
51+
return px.floatValue() / (context.getResources().getDisplayMetrics().densityDpi / DisplayMetrics.DENSITY_DEFAULT);
52+
}
53+
54+
public static Integer stringToColor(String color) {
55+
if (color == null) return null;
56+
return Color.parseColor(color);
57+
}
4158
}

android/src/main/java/com/shakebugs/react/utils/Mapper.java

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import static com.shakebugs.react.utils.Converter.resToString;
44

5-
import android.annotation.SuppressLint;
65
import android.content.Context;
76

87
import com.facebook.react.bridge.ReadableArray;
@@ -28,6 +27,7 @@
2827
import com.shakebugs.shake.internal.domain.models.NetworkRequest;
2928
import com.shakebugs.shake.internal.domain.models.NotificationEvent;
3029
import com.shakebugs.shake.report.ShakeFile;
30+
import com.shakebugs.shake.theme.ShakeTheme;
3131

3232
import java.util.ArrayList;
3333
import java.util.HashMap;
@@ -283,6 +283,37 @@ public WritableMap mapShakeFormToMap(ShakeForm shakeForm) {
283283
return shakeFormMap;
284284
}
285285

286+
public ShakeTheme mapMapToShakeTheme(ReadableMap shakeThemeMap) {
287+
if (shakeThemeMap == null) return null;
288+
289+
String fontFamilyBold = shakeThemeMap.hasKey("fontFamilyBold") ? shakeThemeMap.getString("fontFamilyBold") : null;
290+
String fontFamilyMedium = shakeThemeMap.hasKey("fontFamilyMedium") ? shakeThemeMap.getString("fontFamilyMedium") : null;
291+
String backgroundColor = shakeThemeMap.hasKey("backgroundColor") ? shakeThemeMap.getString("backgroundColor") : null;
292+
String secondaryBackgroundColor = shakeThemeMap.hasKey("secondaryBackgroundColor") ? shakeThemeMap.getString("secondaryBackgroundColor") : null;
293+
String textColor = shakeThemeMap.hasKey("textColor") ? shakeThemeMap.getString("textColor") : null;
294+
String secondaryTextColor = shakeThemeMap.hasKey("secondaryTextColor") ? shakeThemeMap.getString("secondaryTextColor") : null;
295+
String accentColor = shakeThemeMap.hasKey("accentColor") ? shakeThemeMap.getString("accentColor") : null;
296+
String accentTextColor = shakeThemeMap.hasKey("accentTextColor") ? shakeThemeMap.getString("accentTextColor") : null;
297+
String outlineColor = shakeThemeMap.hasKey("outlineColor") ? shakeThemeMap.getString("outlineColor") : null;
298+
Double borderRadius = shakeThemeMap.hasKey("borderRadius") ? shakeThemeMap.getDouble("borderRadius") : null;
299+
Double elevation = shakeThemeMap.hasKey("elevation") ? shakeThemeMap.getDouble("elevation") : null;
300+
301+
ShakeTheme shakeTheme = new ShakeTheme();
302+
shakeTheme.setFontFamilyBoldValue(findAssetPath(context, fontFamilyBold));
303+
shakeTheme.setFontFamilyMediumValue(findAssetPath(context, fontFamilyMedium));
304+
shakeTheme.setBackgroundColorValue(Converter.stringToColor(backgroundColor));
305+
shakeTheme.setSecondaryBackgroundColorValue(Converter.stringToColor(secondaryBackgroundColor));
306+
shakeTheme.setTextColorValue(Converter.stringToColor(textColor));
307+
shakeTheme.setSecondaryTextColorValue(Converter.stringToColor(secondaryTextColor));
308+
shakeTheme.setAccentColorValue(Converter.stringToColor(accentColor));
309+
shakeTheme.setAccentTextColorValue(Converter.stringToColor(accentTextColor));
310+
shakeTheme.setOutlineColorValue(Converter.stringToColor(outlineColor));
311+
shakeTheme.setBorderRadiusValue(Converter.convertDpToPixels(context, borderRadius));
312+
shakeTheme.setElevationValue(Converter.convertDpToPixels(context, elevation));
313+
314+
return shakeTheme;
315+
}
316+
286317
public NetworkRequest mapToNetworkRequest(ReadableMap object) {
287318
if (object == null) return null;
288319

@@ -426,4 +457,22 @@ private Object[] toArray(ReadableArray readableArray) {
426457

427458
return array;
428459
}
460+
461+
private String findAssetPath(Context context, String assetName) {
462+
if (assetName == null) return null;
463+
464+
String[] assetPaths = new String[]{"fonts", "images", "sounds"};
465+
for (String assetPath : assetPaths) {
466+
try {
467+
String[] assets = context.getAssets().list(assetPath);
468+
for (String asset : assets) {
469+
if (asset.contains(assetName)) {
470+
return assetPath + "/" + asset;
471+
}
472+
}
473+
} catch (Exception ignore) {
474+
}
475+
}
476+
return null;
477+
}
429478
}

example/android/app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ android {
9999
minSdkVersion rootProject.ext.minSdkVersion
100100
targetSdkVersion rootProject.ext.targetSdkVersion
101101
versionCode 1
102-
versionName "16.0.0"
102+
versionName "16.1.0"
103103
multiDexEnabled true
104104
}
105105
splits {
69.3 KB
Binary file not shown.
69 KB
Binary file not shown.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"migIndex": 1,
3+
"data": [
4+
{
5+
"path": "src/assets/fonts/HKGrotesk-Regular.otf",
6+
"sha1": "d16193c24d1d33bfed581fbf575ecbbb47645690"
7+
},
8+
{
9+
"path": "src/assets/fonts/HKGrotesk-SemiBold.otf",
10+
"sha1": "b2a30d652829a803c3c225382e37ac63f99f5f49"
11+
},
12+
{
13+
"path": "src/assets/fonts/Lexend-Bold.ttf",
14+
"sha1": "06ab06cd31d372d135c243097fb29c940efb6d6e"
15+
},
16+
{
17+
"path": "src/assets/fonts/Lexend-Regular.ttf",
18+
"sha1": "6c2aa93d8e5b5f5d831452a101c87bae0a0f913d"
19+
}
20+
]
21+
}

example/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,6 @@ Shake.setConsoleLogsEnabled(true);
2020
Shake.setAutoVideoRecording(true);
2121
Shake.setShowIntroMessage(true);
2222
Shake.setSensitiveDataRedactionEnabled(true);
23+
Shake.setHomeSubtitle('React Native Shake Example');
2324

2425
Shake.start(CLIENT_ID, CLIENT_SECRET);

0 commit comments

Comments
 (0)