Skip to content

Commit 9741877

Browse files
committed
Add setDebugEnabled Android API
1 parent 77fce9d commit 9741877

File tree

5 files changed

+50
-0
lines changed

5 files changed

+50
-0
lines changed

android/src/main/java/com/instabug/instabugflutter/InstabugFlutterPlugin.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,15 @@ public void setSessionProfilerEnabled(boolean sessionProfilerEnabled) {
422422
}
423423
}
424424

425+
/**
426+
* Enable/disable SDK logs
427+
*
428+
* @param debugEnabled desired state of debug mode
429+
*/
430+
public void setDebugEnabled(boolean debugEnabled) {
431+
Instabug.setDebugEnabled(debugEnabled);
432+
}
433+
425434
/**
426435
* Set the primary color that the SDK will use to tint certain UI elements in
427436
* the SDK

example/android/app/src/main/kotlin/com/example/InstabugSample/OnMethodCallTests.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,15 @@ public void testSetSessionProfilerEnabled() {
9999
verify(instabugMock).setSessionProfilerEnabled(true);
100100
}
101101

102+
public void testSetDebugEnabled() {
103+
String methodName = "setDebugEnabled";
104+
ArrayList<Object> argsList = new ArrayList<>();
105+
argsList.add(true);
106+
Mockito.doNothing().when(instabugMock).setDebugEnabled(any(Boolean.class));
107+
testMethodCall(methodName,argsList);
108+
verify(instabugMock).setDebugEnabled(true);
109+
}
110+
102111
public void testSetPrimaryColor() {
103112
String methodName = "setPrimaryColor";
104113
ArrayList<Object> argsList = new ArrayList<>();

example/android/app/src/test/java/com/example/InstabugSample/InstabugFlutterPluginTest.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,14 @@ public void testSetSessionProfilerEnabled() {
5757
new OnMethodCallTests().testSetSessionProfilerEnabled();
5858
}
5959

60+
/**
61+
* (boolean)
62+
*/
63+
@Test
64+
public void testSetDebugEnabled() {
65+
new OnMethodCallTests().testSetDebugEnabled();
66+
}
67+
6068
/**
6169
* (long)
6270
*/

lib/Instabug.dart

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,16 @@ class Instabug {
225225
await _channel.invokeMethod<Object>('setSessionProfilerEnabled:', params);
226226
}
227227

228+
/// Android only
229+
/// Enable/disable SDK logs
230+
/// [debugEnabled] desired state of debug mode.
231+
static void setDebugEnabled(bool debugEnabled) async {
232+
if (PlatformManager.instance.isAndroid()) {
233+
final List<dynamic> params = <dynamic>[debugEnabled];
234+
await _channel.invokeMethod<Object>('setDebugEnabled:', params);
235+
}
236+
}
237+
228238
/// Sets the primary color of the SDK's UI.
229239
/// Sets the color of UI elements indicating interactivity or call to action.
230240
/// [color] primaryColor A color to set the UI elements of the SDK to.

test/instabug_flutter_test.dart

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,20 @@ void main() {
358358
]);
359359
});
360360

361+
test('setDebugEnabled: Test', () async {
362+
when(mockPlatform.isAndroid()).thenAnswer((_) => true);
363+
364+
const bool debugEnabled = true;
365+
final List<dynamic> args = <dynamic>[debugEnabled];
366+
Instabug.setDebugEnabled(debugEnabled);
367+
expect(log, <Matcher>[
368+
isMethodCall(
369+
'setDebugEnabled:',
370+
arguments: args,
371+
)
372+
]);
373+
});
374+
361375
test('setPrimaryColor: Test', () async {
362376
const c = Color.fromRGBO(255, 0, 255, 1.0);
363377
final List<dynamic> args = <dynamic>[c.value];

0 commit comments

Comments
 (0)