Skip to content

Commit fb4cedb

Browse files
Merge pull request #50 from Instabug/SALMAT/testRelease
Salmat/test release
2 parents 8dd1ccc + d1c1daa commit fb4cedb

File tree

5 files changed

+104
-10
lines changed

5 files changed

+104
-10
lines changed

InstabugSample/index.ios.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import {
1919
TouchableHighlight,
2020
RecyclerViewBackedScrollView,
2121
ActionSheetIOS,
22+
TextInput
2223
} from 'react-native';
2324

2425
import Instabug from'instabug-reactnative';
@@ -36,6 +37,8 @@ export default class InstabugSample extends Component {
3637
}
3738
});
3839

40+
41+
3942
const ds = new ListView.DataSource({rowHasChanged: (r1, r2) => r1 !== r2});
4043
this.state = {
4144
dataSource: ds.cloneWithRows(this._genRows({})),
@@ -256,12 +259,18 @@ export default class InstabugSample extends Component {
256259
render() {
257260
console.log(JSON.stringify(this.state));
258261
return (
262+
<View>
259263
<ListView
260264
dataSource={this.state.dataSource}
261265
renderRow={this._renderRow.bind(this)}
262266
renderScrollComponent={props => <RecyclerViewBackedScrollView {...props} />}
263267
style={styles.listView}
264268
/>
269+
<TextInput
270+
style={{height: 40}}
271+
placeholder="Type here to translate!"
272+
/>
273+
</View>
265274
);
266275
}
267276
}

android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ public class RNInstabugReactnativeModule extends ReactContextBaseJavaModule {
5454
private final String INVOCATION_MODE_NEW_FEEDBACK = "feedback";
5555
private final String INVOCATION_MODE_NEW_CHAT = "chat";
5656
private final String INVOCATION_MODE_CHATS_LIST = "chats";
57+
//FloatingButtonEdge
58+
private final String FLOATING_BUTTON_EDGE_RIGHT = "right";
59+
private final String FLOATING_BUTTON_EDGE_LEFT = "left";
5760
//locales
5861
private final String LOCALE_ARABIC = "arabic";
5962
private final String LOCALE_CHINESE_SIMPLIFIED = "chinesesimplified";
@@ -991,6 +994,20 @@ public void setSurveysEnabled(boolean surveysEnabled) {
991994
}
992995
}
993996

997+
/**
998+
* Sets the default value of the intro message guide that gets shown on launching the app
999+
*
1000+
* @param enabled true to show intro message guide
1001+
*/
1002+
@ReactMethod
1003+
public void setIntroMessageEnabled(boolean enabled) {
1004+
try {
1005+
mInstabug.setIntroMessageEnabled(enabled);
1006+
} catch (Exception e) {
1007+
e.printStackTrace();
1008+
}
1009+
}
1010+
9941011

9951012
/**
9961013
* Sets the runnable that gets executed just before showing any valid survey<br/>
@@ -1232,6 +1249,9 @@ public Map<String, Object> getConstants() {
12321249
constants.put("invocationModeNewChat", INVOCATION_MODE_NEW_CHAT);
12331250
constants.put("invocationModeChatsList", INVOCATION_MODE_CHATS_LIST);
12341251

1252+
constants.put("floatingButtonEdgeLeft",FLOATING_BUTTON_EDGE_LEFT);
1253+
constants.put("floatingButtonEdgeRight",FLOATING_BUTTON_EDGE_RIGHT);
1254+
12351255
constants.put("localeArabic", LOCALE_ARABIC);
12361256
constants.put("localeChineseSimplified", LOCALE_CHINESE_SIMPLIFIED);
12371257
constants.put("localeChineseTraditional", LOCALE_CHINESE_TRADITIONAL);

android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativePackage.java

Lines changed: 69 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import com.instabug.library.Instabug;
1111
import com.instabug.library.InstabugColorTheme;
1212
import com.instabug.library.invocation.InstabugInvocationEvent;
13+
import com.instabug.library.invocation.util.InstabugFloatingButtonEdge;
1314
import android.graphics.Color;
1415

1516
import java.util.ArrayList;
@@ -26,7 +27,8 @@ public class RNInstabugReactnativePackage implements ReactPackage {
2627
private InstabugColorTheme instabugColorTheme = InstabugColorTheme.InstabugColorThemeLight;
2728

2829
public RNInstabugReactnativePackage(String androidApplicationToken, Application androidApplication,
29-
String invocationEventValue, String primaryColor) {
30+
String invocationEventValue, String primaryColor,
31+
InstabugFloatingButtonEdge floatingButtonEdge, int offset) {
3032
this.androidApplication = androidApplication;
3133
this.mAndroidApplicationToken = androidApplicationToken;
3234

@@ -55,7 +57,73 @@ public RNInstabugReactnativePackage(String androidApplicationToken, Application
5557
.build();
5658

5759
Instabug.setPrimaryColor(Color.parseColor(primaryColor));
60+
Instabug.setFloatingButtonEdge(floatingButtonEdge);
61+
Instabug.setFloatingButtonOffsetFromTop(offset);
62+
63+
}
64+
65+
public RNInstabugReactnativePackage(String androidApplicationToken, Application androidApplication,
66+
String invocationEventValue, String primaryColor) {
67+
new RNInstabugReactnativePackage(androidApplicationToken,androidApplication,invocationEventValue,primaryColor,
68+
InstabugFloatingButtonEdge.LEFT,250);
69+
}
70+
71+
public static class Builder {
72+
//FloatingButtonEdge
73+
private final String FLOATING_BUTTON_EDGE_RIGHT = "right";
74+
private final String FLOATING_BUTTON_EDGE_LEFT = "left";
75+
76+
String androidApplicationToken;
77+
Application application;
78+
String invocationEvent;
79+
String primaryColor;
80+
InstabugFloatingButtonEdge floatingButtonEdge;
81+
int offset;
82+
83+
public Builder(String androidApplicationToken, Application application) {
84+
this.androidApplicationToken = androidApplicationToken;
85+
this.application = application;
86+
}
87+
88+
public Builder setInvocationEvent(String invocationEvent) {
89+
this.invocationEvent = invocationEvent;
90+
return this;
91+
}
92+
93+
public Builder setPrimaryColor(String primaryColor) {
94+
this.primaryColor = primaryColor;
95+
return this;
96+
}
97+
98+
public Builder setFloatingEdge(String floatingEdge) {
99+
this.floatingButtonEdge = getFloatingButtonEdge(floatingEdge);
100+
return this;
101+
}
102+
103+
public Builder setFloatingButtonOffsetFromTop(int offset) {
104+
this.offset = offset;
105+
return this;
106+
}
107+
108+
public RNInstabugReactnativePackage build() {
109+
return new RNInstabugReactnativePackage(androidApplicationToken,application,invocationEvent,primaryColor,floatingButtonEdge,offset);
110+
}
111+
112+
private InstabugFloatingButtonEdge getFloatingButtonEdge(String floatingButtonEdgeValue) {
113+
InstabugFloatingButtonEdge floatingButtonEdge = InstabugFloatingButtonEdge.RIGHT;
114+
try {
115+
if (floatingButtonEdgeValue.equals(FLOATING_BUTTON_EDGE_LEFT)) {
116+
floatingButtonEdge = InstabugFloatingButtonEdge.LEFT;
117+
} else if (floatingButtonEdgeValue.equals(FLOATING_BUTTON_EDGE_RIGHT)) {
118+
floatingButtonEdge = InstabugFloatingButtonEdge.RIGHT;
119+
}
120+
return floatingButtonEdge;
58121

122+
} catch(Exception e) {
123+
e.printStackTrace();
124+
return floatingButtonEdge;
125+
}
126+
}
59127
}
60128

61129
@Override

index.js

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -296,8 +296,7 @@ module.exports = {
296296
* intro message is enabled or not.
297297
*/
298298
setIntroMessageEnabled: function (isIntroMessageEnabled) {
299-
if (Platform.OS === 'ios')
300-
Instabug.setIntroMessageEnabled(isIntroMessageEnabled);
299+
Instabug.setIntroMessageEnabled(isIntroMessageEnabled);
301300
},
302301

303302
/**
@@ -852,11 +851,9 @@ module.exports = {
852851
* @readonly
853852
* @enum {number}
854853
*/
855-
rectEdge: {
856-
minX: Instabug.rectMinXEdge,
857-
minY: Instabug.rectMinYEdge,
858-
maxX: Instabug.rectMaxXEdge,
859-
maxY: Instabug.rectMaxYEdge
854+
floatingButtonEdge: {
855+
left: Instabug.rectMinXEdge,
856+
right: Instabug.rectMaxXEdge,
860857
},
861858

862859
/**

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"homepage": "https://github.com/Instabug/instabug-reactnative#readme",
2424
"rnpm": {
2525
"android": {
26-
"packageInstance": "new RNInstabugReactnativePackage(\"YOUR_ANDROID_APPLICATION_TOKEN\",MainApplication.this,\"shake\",\"#1D82DC\")"
26+
"packageInstance": "new RNInstabugReactnativePackage.Builder(\"YOUR_ANDROID_APPLICATION_TOKEN\",MainApplication.this)\n.setInvocationEvent(\"shake\")\n.setPrimaryColor(\"#1D82DC\")\n.setFloatingEdge(\"left\")\n.setFloatingButtonOffsetFromTop(250)\n.build()"
2727
}
2828
}
29-
}
29+
}

0 commit comments

Comments
 (0)