Skip to content

Commit a7dd999

Browse files
Merge remote-tracking branch 'refs/remotes/origin/feat/support-advanced-UI-customization' into chore/-Remove-deprecated-APIS
# Conflicts: # CHANGELOG.md # android/src/main/java/com/instabug/flutter/modules/InstabugApi.java # android/src/test/java/com/instabug/flutter/InstabugApiTest.java # example/ios/InstabugTests/InstabugApiTests.m # ios/Classes/Modules/InstabugApi.m # lib/instabug_flutter.dart # lib/src/modules/instabug.dart # pigeons/instabug.api.dart # test/instabug_test.dart
2 parents d82c1d4 + acdcda7 commit a7dd999

File tree

10 files changed

+230
-60
lines changed

10 files changed

+230
-60
lines changed

CHANGELOG.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,22 @@
22

33
## [Unreleased](https://github.com/Instabug/Instabug-Flutter/compare/v15.0.2...dev)
44

5-
### Changed
6-
7-
- **BREAKING** Remove deprecated APIs ([#614](https://github.com/Instabug/Instabug-Flutter/pull/614)). See migration guide for more details.
85
### Added
96

107
- Add support for Advanced UI customization with comprehensive theming capabilities ([#599](https://github.com/Instabug/Instabug-Flutter/pull/599))
8+
-
9+
- Add support for App variant. ([#585](https://github.com/Instabug/Instabug-Flutter/pull/585))
10+
11+
### Changed
12+
13+
- **BREAKING** Remove deprecated APIs ([#614](https://github.com/Instabug/Instabug-Flutter/pull/614)). See migration guide for more details.
1114

1215

1316
## [15.0.2](https://github.com/Instabug/Instabug-Flutter/compare/v14.3.0...15.0.2) (Jul 7, 2025)
1417

1518
### Added
1619

20+
1721
- Add support for xCode 16. ([#574](https://github.com/Instabug/Instabug-Flutter/pull/574))
1822

1923
- Add support for BugReporting user consents. ([#573](https://github.com/Instabug/Instabug-Flutter/pull/573))

android/src/main/java/com/instabug/flutter/modules/InstabugApi.java

Lines changed: 51 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@
77
import android.net.Uri;
88
import android.graphics.Typeface;
99
import android.util.Log;
10+
1011
import androidx.annotation.NonNull;
1112
import androidx.annotation.Nullable;
1213
import androidx.annotation.VisibleForTesting;
14+
1315
import com.instabug.flutter.generated.InstabugPigeon;
1416
import com.instabug.flutter.util.ArgsRegistry;
1517
import com.instabug.flutter.util.Reflection;
@@ -31,9 +33,11 @@
3133
import com.instabug.library.invocation.InstabugInvocationEvent;
3234
import com.instabug.library.model.NetworkLog;
3335
import com.instabug.library.ui.onboarding.WelcomeMessage;
36+
3437
import io.flutter.FlutterInjector;
3538
import io.flutter.embedding.engine.loader.FlutterLoader;
3639
import io.flutter.plugin.common.BinaryMessenger;
40+
3741
import org.jetbrains.annotations.NotNull;
3842
import org.json.JSONObject;
3943

@@ -103,10 +107,12 @@ public Boolean isEnabled() {
103107

104108
@NotNull
105109
@Override
106-
public Boolean isBuilt() { return Instabug.isBuilt(); }
110+
public Boolean isBuilt() {
111+
return Instabug.isBuilt();
112+
}
107113

108114
@Override
109-
public void init(@NonNull String token, @NonNull List<String> invocationEvents, @NonNull String debugLogsLevel) {
115+
public void init(@NonNull String token, @NonNull List<String> invocationEvents, @NonNull String debugLogsLevel, @Nullable String appVariant) {
110116
setCurrentPlatform();
111117

112118
InstabugInvocationEvent[] invocationEventsArray = new InstabugInvocationEvent[invocationEvents.size()];
@@ -117,11 +123,14 @@ public void init(@NonNull String token, @NonNull List<String> invocationEvents,
117123

118124
final Application application = (Application) context;
119125
final int parsedLogLevel = ArgsRegistry.sdkLogLevels.get(debugLogsLevel);
120-
121-
new Instabug.Builder(application, token)
126+
Instabug.Builder builder = new Instabug.Builder(application, token)
122127
.setInvocationEvents(invocationEventsArray)
123-
.setSdkDebugLogsLevel(parsedLogLevel)
124-
.build();
128+
.setSdkDebugLogsLevel(parsedLogLevel);
129+
if (appVariant != null) {
130+
builder.setAppVariant(appVariant);
131+
}
132+
133+
builder.build();
125134

126135
Instabug.setScreenshotProvider(screenshotProvider);
127136
}
@@ -147,6 +156,17 @@ public void setUserData(@NonNull String data) {
147156
Instabug.setUserData(data);
148157
}
149158

159+
@Override
160+
public void setAppVariant(@NonNull String appVariant) {
161+
try {
162+
Instabug.setAppVariant(appVariant);
163+
164+
} catch (Exception e) {
165+
e.printStackTrace();
166+
}
167+
168+
}
169+
150170
@Override
151171
public void logUserEvent(@NonNull String name) {
152172
Instabug.logUserEvent(name);
@@ -487,21 +507,21 @@ public void willRedirectToStore() {
487507
Instabug.willRedirectToStore();
488508
}
489509

490-
510+
491511
@Override
492512
public void setNetworkLogBodyEnabled(@NonNull Boolean isEnabled) {
493-
try {
494-
Instabug.setNetworkLogBodyEnabled(isEnabled);
495-
} catch (Exception e) {
496-
e.printStackTrace();
497-
}
513+
try {
514+
Instabug.setNetworkLogBodyEnabled(isEnabled);
515+
} catch (Exception e) {
516+
e.printStackTrace();
517+
}
498518
}
499519

500520
@Override
501521
public void setTheme(@NonNull Map<String, Object> themeConfig) {
502522
try {
503523
Log.d(TAG, "setTheme called with config: " + themeConfig.toString());
504-
524+
505525
com.instabug.library.model.IBGTheme.Builder builder = new com.instabug.library.model.IBGTheme.Builder();
506526

507527
if (themeConfig.containsKey("primaryColor")) {
@@ -548,7 +568,7 @@ public void setTheme(@NonNull Map<String, Object> themeConfig) {
548568

549569
/**
550570
* Retrieves a color value from the Map.
551-
*
571+
*
552572
* @param map The Map object.
553573
* @param key The key to look for.
554574
* @return The parsed color as an integer, or black if missing or invalid.
@@ -567,7 +587,7 @@ private int getColor(Map<String, Object> map, String key) {
567587

568588
/**
569589
* Retrieves a text style from the Map.
570-
*
590+
*
571591
* @param map The Map object.
572592
* @param key The key to look for.
573593
* @return The corresponding Typeface style, or Typeface.NORMAL if missing or invalid.
@@ -596,7 +616,7 @@ private int getTextStyle(Map<String, Object> map, String key) {
596616

597617
/**
598618
* Sets a font on the theme builder if the font configuration is present in the theme config.
599-
*
619+
*
600620
* @param themeConfig The theme configuration map
601621
* @param builder The theme builder
602622
* @param fileKey The key for font file path
@@ -625,17 +645,17 @@ private void setFontIfPresent(Map<String, Object> themeConfig, com.instabug.libr
625645

626646
private Typeface getTypeface(Map<String, Object> map, String fileKey, String assetKey) {
627647
String fontName = null;
628-
648+
629649
if (assetKey != null && map.containsKey(assetKey) && map.get(assetKey) != null) {
630650
fontName = (String) map.get(assetKey);
631651
} else if (fileKey != null && map.containsKey(fileKey) && map.get(fileKey) != null) {
632652
fontName = (String) map.get(fileKey);
633653
}
634-
654+
635655
if (fontName == null) {
636656
return Typeface.DEFAULT;
637657
}
638-
658+
639659
try {
640660
String assetPath = "fonts/" + fontName;
641661
return Typeface.createFromAsset(context.getAssets(), assetPath);
@@ -647,6 +667,17 @@ private Typeface getTypeface(Map<String, Object> map, String fileKey, String ass
647667
}
648668
}
649669
}
650-
670+
/**
671+
* Enables or disables displaying in full-screen mode, hiding the status and navigation bars.
672+
* @param isEnabled A boolean to enable/disable setFullscreen.
673+
*/
674+
@Override
675+
public void setFullscreen(@NonNull final Boolean isEnabled) {
676+
try {
677+
Instabug.setFullscreen(isEnabled);
678+
} catch (Exception e) {
679+
e.printStackTrace();
680+
}
681+
}
651682

652683
}

android/src/test/java/com/instabug/flutter/InstabugApiTest.java

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,8 @@ public void testSetCurrentPlatform() {
134134
@Test
135135
public void testSdkInit() {
136136
String token = "app-token";
137+
String appVariant = "app-variant";
138+
137139
List<String> invocationEvents = Collections.singletonList("InvocationEvent.floatingButton");
138140
String logLevel = "LogLevel.error";
139141

@@ -145,7 +147,7 @@ public void testSdkInit() {
145147
when(mock.setSdkDebugLogsLevel(anyInt())).thenReturn(mock);
146148
});
147149

148-
api.init(token, invocationEvents, logLevel);
150+
api.init(token, invocationEvents, logLevel,appVariant);
149151

150152
Instabug.Builder builder = mInstabugBuilder.constructed().get(0);
151153

@@ -157,6 +159,8 @@ public void testSdkInit() {
157159
);
158160
verify(builder).setInvocationEvents(InstabugInvocationEvent.FLOATING_BUTTON);
159161
verify(builder).setSdkDebugLogsLevel(LogLevel.ERROR);
162+
verify(builder).setAppVariant(appVariant);
163+
160164
verify(builder).build();
161165

162166
// Sets screenshot provider
@@ -625,6 +629,14 @@ public void testSetNetworkLogBodyEnabled() {
625629
mInstabug.verify(() -> Instabug.setNetworkLogBodyEnabled(true));
626630
}
627631

632+
@Test
633+
public void testSetAppVariant() {
634+
String appVariant = "app-variant";
635+
api.setAppVariant(appVariant);
636+
637+
mInstabug.verify(() -> Instabug.setAppVariant(appVariant));
638+
}
639+
628640
@Test
629641
public void testSetNetworkLogBodyDisabled() {
630642
api.setNetworkLogBodyEnabled(false);
@@ -647,7 +659,7 @@ public void testSetThemeWithAllProperties() {
647659
themeConfig.put("secondaryFontAsset", "assets/fonts/CustomFont-Bold.ttf");
648660
themeConfig.put("ctaFontAsset", "assets/fonts/CustomFont-Italic.ttf");
649661

650-
MockedConstruction<com.instabug.library.model.IBGTheme.Builder> mThemeBuilder =
662+
MockedConstruction<com.instabug.library.model.IBGTheme.Builder> mThemeBuilder =
651663
mockConstruction(com.instabug.library.model.IBGTheme.Builder.class, (mock, context) -> {
652664
when(mock.setPrimaryColor(anyInt())).thenReturn(mock);
653665
when(mock.setBackgroundColor(anyInt())).thenReturn(mock);
@@ -666,7 +678,7 @@ public void testSetThemeWithAllProperties() {
666678
api.setTheme(themeConfig);
667679

668680
com.instabug.library.model.IBGTheme.Builder builder = mThemeBuilder.constructed().get(0);
669-
681+
670682
verify(builder).setPrimaryColor(anyInt());
671683
verify(builder).setBackgroundColor(anyInt());
672684
verify(builder).setTitleTextColor(anyInt());
@@ -675,9 +687,27 @@ public void testSetThemeWithAllProperties() {
675687
verify(builder).setPrimaryTextStyle(Typeface.BOLD);
676688
verify(builder).setSecondaryTextStyle(Typeface.ITALIC);
677689
verify(builder).setCtaTextStyle(Typeface.BOLD_ITALIC);
678-
690+
679691
mInstabug.verify(() -> Instabug.setTheme(any(com.instabug.library.model.IBGTheme.class)));
680692
}
681693

694+
@Test
695+
public void testSetFullscreen() {
696+
boolean isEnabled = true;
697+
698+
api.setFullscreen(isEnabled);
699+
700+
mInstabug.verify(() -> Instabug.setFullscreen(isEnabled));
701+
}
702+
703+
@Test
704+
public void testSetFullscreenDisabled() {
705+
boolean isEnabled = false;
706+
707+
api.setFullscreen(isEnabled);
708+
709+
mInstabug.verify(() -> Instabug.setFullscreen(isEnabled));
710+
}
711+
682712

683713
}

example/ios/InstabugTests/InstabugApiTests.m

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,22 @@ - (void)testSetEnabled {
3838

3939
- (void)testInit {
4040
NSString *token = @"app-token";
41+
NSString *appVariant = @"app-variant";
42+
4143
NSArray<NSString *> *invocationEvents = @[@"InvocationEvent.floatingButton", @"InvocationEvent.screenshot"];
4244
NSString *logLevel = @"LogLevel.error";
4345
FlutterError *error;
4446

45-
[self.api initToken:token invocationEvents:invocationEvents debugLogsLevel:logLevel error:&error];
47+
[self.api initToken:token invocationEvents:invocationEvents debugLogsLevel:logLevel appVariant:appVariant error:&error];
4648

4749
OCMVerify([self.mInstabug setCurrentPlatform:IBGPlatformFlutter]);
50+
4851
OCMVerify([self.mInstabug setSdkDebugLogsLevel:IBGSDKDebugLogsLevelError]);
52+
4953
OCMVerify([self.mInstabug startWithToken:token invocationEvents:(IBGInvocationEventFloatingButton | IBGInvocationEventScreenshot)]);
54+
55+
XCTAssertEqual(Instabug.appVariant, appVariant);
56+
5057
}
5158

5259
- (void)testShow {
@@ -598,20 +605,30 @@ - (void)testSetThemeWithAllProperties {
598605
@"secondaryFontPath": @"assets/fonts/CustomFont-Bold.ttf",
599606
@"ctaFontPath": @"assets/fonts/CustomFont-Italic.ttf"
600607
};
601-
608+
602609
id mockTheme = OCMClassMock([IBGTheme class]);
603610
OCMStub([mockTheme primaryColor]).andReturn([UIColor redColor]);
604611
OCMStub([mockTheme backgroundColor]).andReturn([UIColor whiteColor]);
605612
OCMStub([mockTheme titleTextColor]).andReturn([UIColor blackColor]);
606613
OCMStub([mockTheme primaryTextColor]).andReturn([UIColor darkGrayColor]);
607614
OCMStub([mockTheme secondaryTextColor]).andReturn([UIColor grayColor]);
608615
OCMStub([mockTheme callToActionTextColor]).andReturn([UIColor redColor]);
609-
616+
610617
FlutterError *error;
611-
618+
612619
[self.api setThemeThemeConfig:themeConfig error:&error];
613-
620+
614621
OCMVerify([self.mInstabug setTheme:[OCMArg isNotNil]]);
615622
}
616623

624+
- (void)testSetFullscreen {
625+
NSNumber *isEnabled = @1;
626+
FlutterError *error;
627+
628+
[self.api setFullscreenIsEnabled:isEnabled error:&error];
629+
630+
// Since this is an empty implementation, we just verify the method can be called without error
631+
XCTAssertNil(error);
632+
}
633+
617634
@end

example/ios/Podfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ target 'Runner' do
3030

3131
use_frameworks!
3232
use_modular_headers!
33-
3433
flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
3534
end
3635

example/lib/main.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,10 @@ void main() {
4646
WidgetsFlutterBinding.ensureInitialized();
4747

4848
Instabug.init(
49-
token: 'ed6f659591566da19b67857e1b9d40ab',
50-
invocationEvents: [InvocationEvent.floatingButton],
51-
debugLogsLevel: LogLevel.verbose,
52-
);
49+
token: 'ed6f659591566da19b67857e1b9d40ab',
50+
invocationEvents: [InvocationEvent.floatingButton],
51+
debugLogsLevel: LogLevel.verbose,
52+
appVariant: 'variant 1');
5353

5454
FlutterError.onError = (FlutterErrorDetails details) {
5555
Zone.current.handleUncaughtError(details.exception, details.stack!);

0 commit comments

Comments
 (0)