Skip to content

Commit 7e698d3

Browse files
author
Ali Abdelfattah
authored
Merge pull request #174 from Instabug/feature/add-set-debug-enabled-android-api
[MOB-4686] Feature/add setDebugEnabled Android API
2 parents de5db87 + 9741877 commit 7e698d3

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
@@ -426,6 +426,15 @@ public void setSessionProfilerEnabled(boolean sessionProfilerEnabled) {
426426
}
427427
}
428428

429+
/**
430+
* Enable/disable SDK logs
431+
*
432+
* @param debugEnabled desired state of debug mode
433+
*/
434+
public void setDebugEnabled(boolean debugEnabled) {
435+
Instabug.setDebugEnabled(debugEnabled);
436+
}
437+
429438
/**
430439
* Set the primary color that the SDK will use to tint certain UI elements in
431440
* 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
@@ -361,6 +361,20 @@ void main() {
361361
]);
362362
});
363363

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

0 commit comments

Comments
 (0)