|
1 |
| - |
2 | 1 | package com.instabug.reactlibrary;
|
3 | 2 |
|
4 | 3 | import android.app.Application;
|
|
10 | 9 | import com.facebook.react.uimanager.ViewManager;
|
11 | 10 | import com.instabug.library.Instabug;
|
12 | 11 | import com.instabug.library.InstabugColorTheme;
|
13 |
| -import com.instabug.library.internal.module.InstabugLocale; |
14 | 12 | import com.instabug.library.invocation.InstabugInvocationEvent;
|
15 |
| -import com.instabug.library.invocation.util.InstabugFloatingButtonEdge; |
16 | 13 |
|
17 | 14 | import java.util.ArrayList;
|
18 | 15 | import java.util.Collections;
|
19 | 16 | import java.util.List;
|
20 |
| -import java.util.Locale; |
21 | 17 |
|
22 | 18 | public class RNInstabugReactnativePackage implements ReactPackage {
|
23 | 19 |
|
24 |
| - Application androidApplication; |
| 20 | + private Application androidApplication; |
25 | 21 | private String mAndroidApplicationToken;
|
26 | 22 | private Instabug mInstabug;
|
27 | 23 | private Instabug.Builder mBuilder;
|
28 | 24 | private InstabugInvocationEvent invocationEvent = InstabugInvocationEvent.FLOATING_BUTTON;
|
29 | 25 | private InstabugColorTheme instabugColorTheme = InstabugColorTheme.InstabugColorThemeLight;
|
30 | 26 |
|
31 |
| - public RNInstabugReactnativePackage(Instabug instabug) { |
32 |
| - this.mInstabug = instabug; |
| 27 | + public RNInstabugReactnativePackage(Application androidApplication) { |
| 28 | + this.androidApplication = androidApplication; |
33 | 29 | }
|
34 | 30 |
|
| 31 | + @Deprecated |
35 | 32 | public RNInstabugReactnativePackage(String androidApplicationToken, Application application) {
|
36 | 33 | this(androidApplicationToken, application, "button");
|
37 | 34 | }
|
38 | 35 |
|
39 |
| - public RNInstabugReactnativePackage(String androidApplicationToken, Application application, String invocationEventValue) { |
| 36 | + @Deprecated |
| 37 | + public RNInstabugReactnativePackage(String androidApplicationToken, Application application |
| 38 | + String invocationEventValue) { |
40 | 39 | this(androidApplicationToken, application, invocationEventValue, "light");
|
41 | 40 | }
|
42 | 41 |
|
| 42 | + @Deprecated |
43 | 43 | public RNInstabugReactnativePackage(String androidApplicationToken, Application application,
|
44 | 44 | String invocationEventValue, String instabugColorThemeValue) {
|
45 |
| - |
46 |
| - this.androidApplication = application; |
47 |
| - this.mAndroidApplicationToken = androidApplicationToken; |
48 |
| - |
49 |
| - //setting invocation event |
50 |
| - if (invocationEventValue.equals("button")) { |
51 |
| - this.invocationEvent = InstabugInvocationEvent.FLOATING_BUTTON; |
52 |
| - } else if (invocationEventValue.equals("swipe")) { |
53 |
| - this.invocationEvent = InstabugInvocationEvent.TWO_FINGER_SWIPE_LEFT; |
54 |
| - |
55 |
| - } else if (invocationEventValue.equals("shake")) { |
56 |
| - this.invocationEvent = InstabugInvocationEvent.SHAKE; |
57 |
| - |
58 |
| - } else if (invocationEventValue.equals("screenshot")) { |
59 |
| - this.invocationEvent = InstabugInvocationEvent.SCREENSHOT_GESTURE; |
60 |
| - |
61 |
| - } else if (invocationEventValue.equals("none")) { |
62 |
| - this.invocationEvent = InstabugInvocationEvent.NONE; |
63 |
| - |
64 |
| - } else { |
65 |
| - this.invocationEvent = InstabugInvocationEvent.FLOATING_BUTTON; |
66 |
| - } |
67 |
| - |
68 |
| - //setting instabugColorTheme |
69 |
| - if (instabugColorThemeValue.equals("light")) { |
70 |
| - this.instabugColorTheme = InstabugColorTheme.InstabugColorThemeLight; |
71 |
| - } else if (instabugColorThemeValue.equals("dark")) { |
72 |
| - this.instabugColorTheme = InstabugColorTheme.InstabugColorThemeDark; |
73 |
| - } else { |
74 |
| - this.instabugColorTheme = InstabugColorTheme.InstabugColorThemeLight; |
75 |
| - } |
76 |
| - |
77 |
| - |
78 |
| - mInstabug = new Instabug.Builder(this.androidApplication, this.mAndroidApplicationToken) |
79 |
| - .setFloatingButtonOffsetFromTop(400) |
80 |
| - .setTheme(this.instabugColorTheme) |
81 |
| - .setInvocationEvent(this.invocationEvent) |
82 |
| - .setIntroMessageEnabled(false) |
83 |
| - .setAttachmentTypesEnabled(true, true, true, true, true) |
84 |
| - .setShouldPlayConversationSounds(true) |
85 |
| - .setEnableInAppNotificationSound(true) |
86 |
| - .setEnableSystemNotificationSound(false) |
87 |
| - .setPromptOptionsEnabled(true, true, true) |
88 |
| - .setWillSkipScreenshotAnnotation(false) |
89 |
| - .setFloatingButtonEdge(InstabugFloatingButtonEdge.LEFT) |
90 |
| - .setLocale(new Locale(InstabugLocale.ENGLISH.getCode(), InstabugLocale.ENGLISH.getCountry())) |
91 |
| - .build(); |
92 | 45 | }
|
93 | 46 |
|
94 | 47 | @Override
|
95 | 48 | public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
|
96 | 49 | List<NativeModule> modules = new ArrayList<>();
|
97 |
| - modules.add(new RNInstabugReactnativeModule(reactContext, this.mInstabug)); |
| 50 | + modules.add(new RNInstabugReactnativeModule(reactContext, this.androidApplication)); |
98 | 51 | return modules;
|
99 | 52 | }
|
100 | 53 |
|
|
0 commit comments