File tree Expand file tree Collapse file tree 11 files changed +128
-0
lines changed
android/src/main/java/com/instabug/flutter/modules Expand file tree Collapse file tree 11 files changed +128
-0
lines changed Original file line number Diff line number Diff line change 1
1
## Unreleased
2
2
3
+ * Adds BugReporting.setDisclaimerText API
4
+ * Adds BugReporting.setCommentMinimumCharacterCount API
5
+ * Deprecates Instabug.enableAndroid and Instabug.disableAndroid APIs in favour of a new API Instabug.setEnabled, which works on both platforms
3
6
* Fixes main thread violation on Android
4
7
* Fixes an issue with request and response headers parameters type causing network requests not getting logged on iOS
5
8
* Uses pigeon for internal communication between Flutter and the host platform
Original file line number Diff line number Diff line change @@ -149,4 +149,21 @@ public void reply(Void reply) {
149
149
}
150
150
});
151
151
}
152
+
153
+ @ Override
154
+ public void setDisclaimerText (@ NonNull String text ) {
155
+ BugReporting .setDisclaimerText (text );
156
+ }
157
+
158
+ @ Override
159
+ public void setCommentMinimumCharacterCount (@ NonNull Long limit , @ Nullable List <String > reportTypes ) {
160
+ int [] reportTypesArray = reportTypes == null ? new int [0 ] : new int [reportTypes .size ()];
161
+ if (reportTypes != null ){
162
+ for (int i = 0 ; i < reportTypes .size (); i ++) {
163
+ String key = reportTypes .get (i );
164
+ reportTypesArray [i ] = ArgsRegistry .getDeserializedValue (key );
165
+ }
166
+ }
167
+ BugReporting .setCommentMinimumCharacterCount (limit .intValue (), reportTypesArray );
168
+ }
152
169
}
Original file line number Diff line number Diff line change @@ -73,6 +73,18 @@ private void setCurrentPlatform() {
73
73
}
74
74
}
75
75
76
+ @ Override
77
+ public void setEnabled (@ NonNull Boolean isEnabled ) {
78
+ try {
79
+ if (isEnabled )
80
+ Instabug .enable ();
81
+ else
82
+ Instabug .disable ();
83
+ } catch (Exception e ) {
84
+ e .printStackTrace ();
85
+ }
86
+ }
87
+
76
88
public void start (@ NonNull String token , @ NonNull List <String > invocationEvents ) {
77
89
setCurrentPlatform ();
78
90
Original file line number Diff line number Diff line change @@ -146,4 +146,23 @@ - (void)bindOnDismissCallbackWithError:(FlutterError *_Nullable *_Nonnull)error
146
146
};
147
147
}
148
148
149
+ - (void )setDisclaimerTextText : (NSString *)text error : (FlutterError *_Nullable *_Nonnull)error {
150
+ [IBGBugReporting setDisclaimerText: text];
151
+ }
152
+
153
+ - (void )setCommentMinimumCharacterCountLimit : (NSNumber *)limit reportTypes : (nullable NSArray <NSString *> *)reportTypes error : (FlutterError *_Nullable *_Nonnull)error {
154
+ IBGBugReportingReportType resolvedTypes = 0 ;
155
+
156
+ if (![reportTypes count ]) {
157
+ resolvedTypes = (ArgsRegistry.reportTypes [@" ReportType.bug" ]).integerValue | (ArgsRegistry.reportTypes [@" ReportType.feedback" ]).integerValue | (ArgsRegistry.reportTypes [@" ReportType.question" ]).integerValue ;
158
+ }
159
+ else {
160
+ for (NSString *reportType in reportTypes) {
161
+ resolvedTypes |= (ArgsRegistry.reportTypes [reportType]).integerValue ;
162
+ }
163
+ }
164
+
165
+ [IBGBugReporting setCommentMinimumCharacterCountForReportTypes: resolvedTypes withLimit: limit.intValue];
166
+ }
167
+
149
168
@end
Original file line number Diff line number Diff line change @@ -13,6 +13,10 @@ extern void InitInstabugApi(id<FlutterBinaryMessenger> messenger) {
13
13
14
14
@implementation InstabugApi
15
15
16
+ - (void )setEnabledIsEnabled : (NSNumber *)isEnabled error : (FlutterError *_Nullable *_Nonnull)error {
17
+ Instabug.enabled = [isEnabled boolValue ];
18
+ }
19
+
16
20
- (void )startToken : (NSString *)token invocationEvents : (NSArray <NSString *> *)invocationEvents error : (FlutterError *_Nullable *_Nonnull)error {
17
21
SEL setPrivateApiSEL = NSSelectorFromString (@" setCurrentPlatform:" );
18
22
if ([[Instabug class ] respondsToSelector: setPrivateApiSEL]) {
Original file line number Diff line number Diff line change @@ -227,4 +227,26 @@ class BugReporting implements BugReportingFlutterApi {
227
227
return _host.setShakingThresholdForAndroid (threshold);
228
228
}
229
229
}
230
+
231
+ /// Adds a disclaimer text within the bug reporting form,
232
+ /// which can include hyperlinked text.
233
+ /// [text] String text
234
+ static Future <void > setDisclaimerText (String text) async {
235
+ return _host.setDisclaimerText (text);
236
+ }
237
+
238
+ /// Sets a minimum number of characters as a requirement for
239
+ /// the comments field in the different report types.
240
+ /// [limit] int number of characters
241
+ /// [reportTypes] Optional list of ReportType. If it's not passed,
242
+ /// the limit will apply to all report types.
243
+ static Future <void > setCommentMinimumCharacterCount (
244
+ int limit, [
245
+ List <ReportType >? reportTypes,
246
+ ]) async {
247
+ return _host.setCommentMinimumCharacterCount (
248
+ limit,
249
+ reportTypes? .mapToString (),
250
+ );
251
+ }
230
252
}
Original file line number Diff line number Diff line change @@ -129,6 +129,12 @@ class Instabug {
129
129
Surveys .init ();
130
130
}
131
131
132
+ /// Enables or disables Instabug functionality.
133
+ /// [boolean] isEnabled
134
+ static Future <void > setEnabled (bool isEnabled) async {
135
+ return _host.setEnabled (isEnabled);
136
+ }
137
+
132
138
/// Starts the SDK.
133
139
/// This is the main SDK method that does all the magic. This is the only
134
140
/// method that SHOULD be called.
@@ -341,6 +347,9 @@ class Instabug {
341
347
342
348
/// Android Only
343
349
/// Enables all Instabug functionality
350
+ @Deprecated (
351
+ "Use [Instabug.setEnabled(true)] instead. This will work on both Android and iOS. " ,
352
+ )
344
353
static Future <void > enableAndroid () async {
345
354
if (IBGBuildInfo .I .isAndroid) {
346
355
return _host.enableAndroid ();
@@ -349,6 +358,9 @@ class Instabug {
349
358
350
359
/// Android Only
351
360
/// Disables all Instabug functionality
361
+ @Deprecated (
362
+ "Use [Instabug.setEnabled(false)] instead. This will work on both Android and iOS. " ,
363
+ )
352
364
static Future <void > disableAndroid () async {
353
365
if (IBGBuildInfo .I .isAndroid) {
354
366
return _host.disableAndroid ();
Original file line number Diff line number Diff line change @@ -27,4 +27,9 @@ abstract class BugReportingHostApi {
27
27
);
28
28
void bindOnInvokeCallback ();
29
29
void bindOnDismissCallback ();
30
+ void setDisclaimerText (String text);
31
+ void setCommentMinimumCharacterCount (
32
+ int limit,
33
+ List <String >? reportTypes,
34
+ );
30
35
}
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ import 'package:pigeon/pigeon.dart';
2
2
3
3
@HostApi ()
4
4
abstract class InstabugHostApi {
5
+ void setEnabled (bool isEnabled);
5
6
void start (String token, List <String > invocationEvents);
6
7
7
8
void show ();
Original file line number Diff line number Diff line change @@ -178,4 +178,25 @@ void main() {
178
178
mHost.bindOnDismissCallback (),
179
179
).called (1 );
180
180
});
181
+
182
+ test ('[setDisclaimerText] should call host method' , () async {
183
+ const text = 'This is a disclaimer text!' ;
184
+
185
+ await BugReporting .setDisclaimerText (text);
186
+
187
+ verify (
188
+ mHost.setDisclaimerText (text),
189
+ ).called (1 );
190
+ });
191
+
192
+ test ('[setCommentMinimumCharacterCount] should call host method' , () async {
193
+ const count = 20 ;
194
+ const reportTypes = [ReportType .bug];
195
+
196
+ await BugReporting .setCommentMinimumCharacterCount (count, reportTypes);
197
+
198
+ verify (
199
+ mHost.setCommentMinimumCharacterCount (count, reportTypes.mapToString ()),
200
+ ).called (1 );
201
+ });
181
202
}
You can’t perform that action at this time.
0 commit comments