Skip to content

Commit f2c14a9

Browse files
Merge remote-tracking branch 'origin/chore/-Remove-deprecated-APIS' into feat/screen-render-tolerance
# Conflicts: # android/src/main/java/com/instabug/flutter/modules/ApmApi.java # android/src/main/java/com/instabug/flutter/modules/BugReportingApi.java # android/src/main/java/com/instabug/flutter/modules/InstabugApi.java # example/lib/main.dart # ios/Classes/Modules/ApmApi.m # pigeons/apm.api.dart
2 parents d882ac9 + d82c1d4 commit f2c14a9

30 files changed

+663
-777
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
# Changelog
22

3+
## [Unreleased](https://github.com/Instabug/Instabug-Flutter/compare/v15.0.2...dev)
4+
5+
### Changed
6+
7+
- **BREAKING** Remove deprecated APIs ([#614](https://github.com/Instabug/Instabug-Flutter/pull/614)). See migration guide for more details.
8+
### Added
9+
10+
- Add support for Advanced UI customization with comprehensive theming capabilities ([#599](https://github.com/Instabug/Instabug-Flutter/pull/599))
11+
12+
313
## [15.0.2](https://github.com/Instabug/Instabug-Flutter/compare/v14.3.0...15.0.2) (Jul 7, 2025)
414

515
### Added

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

Lines changed: 16 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import com.instabug.apm.configuration.cp.APMFeature;
1111
import com.instabug.apm.configuration.cp.FeatureAvailabilityCallback;
1212
import com.instabug.apm.configuration.cp.ToleranceValueCallback;
13-
//import com.instabug.apm.model.ExecutionTrace;
1413
import com.instabug.apm.networking.APMNetworkLogger;
1514
import com.instabug.apm.networkinterception.cp.APMCPNetworkLog;
1615
import com.instabug.apm.screenrendering.models.cp.IBGFrameData;
@@ -32,7 +31,6 @@
3231

3332
public class ApmApi implements ApmPigeon.ApmHostApi {
3433
private final String TAG = ApmApi.class.getName();
35-
// private final HashMap<String, ExecutionTrace> traces = new HashMap<>();
3634
private final Callable<Float> refreshRateCallback;
3735

3836
public ApmApi(Callable<Float> refreshRate) {
@@ -95,57 +93,22 @@ public void setAutoUITraceEnabled(@NonNull Boolean isEnabled) {
9593
}
9694
}
9795

98-
/**
99-
* Starts an execution trace and handles the result
100-
* using callbacks.
101-
*
102-
* @param id The `id` parameter is a non-null String that represents the identifier of the execution
103-
* trace.
104-
* @param name The `name` parameter in the `startExecutionTrace` method represents the name of the
105-
* execution trace that will be started. It is used as a reference to identify the trace during
106-
* execution monitoring.
107-
* @param result The `result` parameter in the `startExecutionTrace` method is an instance of
108-
* `ApmPigeon.Result<String>`. This parameter is used to provide the result of the execution trace
109-
* operation back to the caller. The `success` method of the `result` object is called with the
110-
* @deprecated see {@link #startFlow}
111-
*/
112-
@Override
113-
public void startExecutionTrace(@NonNull String id, @NonNull String name, ApmPigeon.Result<String> result) {
114-
ThreadManager.runOnBackground(new Runnable() {
115-
@Override
116-
public void run() {
117-
try {
118-
// ExecutionTrace trace = APM.startExecutionTrace(name);
119-
// if (trace != null) {
120-
// traces.put(id, trace);
121-
//
122-
// ThreadManager.runOnMainThread(new Runnable() {
123-
// @Override
124-
// public void run() {
125-
// result.success(id);
126-
// }
127-
// });
128-
// } else {
129-
// ThreadManager.runOnMainThread(new Runnable() {
130-
// @Override
131-
// public void run() {
132-
// result.success(null);
133-
// }
134-
// });
135-
// }
136-
} catch (Exception e) {
137-
e.printStackTrace();
138-
139-
ThreadManager.runOnMainThread(new Runnable() {
140-
@Override
141-
public void run() {
142-
result.success(null);
143-
}
144-
});
145-
}
146-
}
147-
});
148-
}
96+
/**
97+
* Starts an execution trace and handles the result
98+
* using callbacks.
99+
*
100+
* @param id The `id` parameter is a non-null String that represents the identifier of the execution
101+
* trace.
102+
* @param name The `name` parameter in the `startExecutionTrace` method represents the name of the
103+
* execution trace that will be started. It is used as a reference to identify the trace during
104+
* execution monitoring.
105+
* @param result The `result` parameter in the `startExecutionTrace` method is an instance of
106+
* `ApmPigeon.Result<String>`. This parameter is used to provide the result of the execution trace
107+
* operation back to the caller. The `success` method of the `result` object is called with the
108+
*
109+
* @deprecated see {@link #startFlow}
110+
*/
111+
149112

150113
/**
151114
* Starts an AppFlow with the specified name.
@@ -210,37 +173,7 @@ public void endFlow(@NonNull String name) {
210173
}
211174
}
212175

213-
/**
214-
* Adds a new attribute to trace
215-
*
216-
* @param id String id of the trace.
217-
* @param key attribute key
218-
* @param value attribute value. Null to remove attribute
219-
* @deprecated see {@link #setFlowAttribute}
220-
*/
221-
@Override
222-
public void setExecutionTraceAttribute(@NonNull String id, @NonNull String key, @NonNull String value) {
223-
try {
224-
// traces.get(id).setAttribute(key, value);
225-
} catch (Exception e) {
226-
e.printStackTrace();
227-
}
228-
}
229176

230-
/**
231-
* Ends a trace
232-
*
233-
* @param id string id of the trace.
234-
* @deprecated see {@link #endFlow}
235-
*/
236-
@Override
237-
public void endExecutionTrace(@NonNull String id) {
238-
try {
239-
// traces.get(id).end();
240-
} catch (Exception e) {
241-
e.printStackTrace();
242-
}
243-
}
244177

245178
/**
246179
* Starts a UI trace.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ public void setCommentMinimumCharacterCount(@NonNull Long limit, @Nullable List<
184184
reportTypesArray[i] = ArgsRegistry.reportTypes.get(key);
185185
}
186186
}
187-
// BugReporting.setCommentMinimumCharacterCount(limit.intValue(), reportTypesArray);
187+
BugReporting.setCommentMinimumCharacterCountForBugReportType(limit.intValue(), reportTypesArray);
188188
}
189189

190190
@Override

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

Lines changed: 154 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import android.graphics.Bitmap;
66
import android.graphics.BitmapFactory;
77
import android.net.Uri;
8+
import android.graphics.Typeface;
89
import android.util.Log;
910
import androidx.annotation.NonNull;
1011
import androidx.annotation.Nullable;
@@ -176,7 +177,6 @@ public void setWelcomeMessageMode(@NonNull String mode) {
176177

177178
@Override
178179
public void setPrimaryColor(@NonNull Long color) {
179-
180180
}
181181

182182
@Override
@@ -228,20 +228,7 @@ public void run() {
228228
);
229229
}
230230

231-
@Override
232-
public void addExperiments(@NonNull List<String> experiments) {
233-
Instabug.addExperiments(experiments);
234-
}
235-
236-
@Override
237-
public void removeExperiments(@NonNull List<String> experiments) {
238-
Instabug.removeExperiments(experiments);
239-
}
240231

241-
@Override
242-
public void clearAllExperiments() {
243-
Instabug.clearAllExperiments();
244-
}
245232

246233
@Override
247234
public void addFeatureFlags(@NonNull Map<String, String> featureFlags) {
@@ -509,4 +496,157 @@ public void setNetworkLogBodyEnabled(@NonNull Boolean isEnabled) {
509496
e.printStackTrace();
510497
}
511498
}
499+
500+
@Override
501+
public void setTheme(@NonNull Map<String, Object> themeConfig) {
502+
try {
503+
Log.d(TAG, "setTheme called with config: " + themeConfig.toString());
504+
505+
com.instabug.library.model.IBGTheme.Builder builder = new com.instabug.library.model.IBGTheme.Builder();
506+
507+
if (themeConfig.containsKey("primaryColor")) {
508+
builder.setPrimaryColor(getColor(themeConfig, "primaryColor"));
509+
}
510+
if (themeConfig.containsKey("secondaryTextColor")) {
511+
builder.setSecondaryTextColor(getColor(themeConfig, "secondaryTextColor"));
512+
}
513+
if (themeConfig.containsKey("primaryTextColor")) {
514+
builder.setPrimaryTextColor(getColor(themeConfig, "primaryTextColor"));
515+
}
516+
if (themeConfig.containsKey("titleTextColor")) {
517+
builder.setTitleTextColor(getColor(themeConfig, "titleTextColor"));
518+
}
519+
if (themeConfig.containsKey("backgroundColor")) {
520+
builder.setBackgroundColor(getColor(themeConfig, "backgroundColor"));
521+
}
522+
523+
if (themeConfig.containsKey("primaryTextStyle")) {
524+
builder.setPrimaryTextStyle(getTextStyle(themeConfig, "primaryTextStyle"));
525+
}
526+
if (themeConfig.containsKey("secondaryTextStyle")) {
527+
builder.setSecondaryTextStyle(getTextStyle(themeConfig, "secondaryTextStyle"));
528+
}
529+
if (themeConfig.containsKey("ctaTextStyle")) {
530+
builder.setCtaTextStyle(getTextStyle(themeConfig, "ctaTextStyle"));
531+
}
532+
533+
setFontIfPresent(themeConfig, builder, "primaryFontPath", "primaryFontAsset", "primary");
534+
setFontIfPresent(themeConfig, builder, "secondaryFontPath", "secondaryFontAsset", "secondary");
535+
setFontIfPresent(themeConfig, builder, "ctaFontPath", "ctaFontAsset", "CTA");
536+
537+
com.instabug.library.model.IBGTheme theme = builder.build();
538+
Instabug.setTheme(theme);
539+
Log.d(TAG, "Theme applied successfully");
540+
541+
} catch (Exception e) {
542+
Log.e(TAG, "Error in setTheme: " + e.getMessage());
543+
e.printStackTrace();
544+
}
545+
}
546+
547+
548+
549+
/**
550+
* Retrieves a color value from the Map.
551+
*
552+
* @param map The Map object.
553+
* @param key The key to look for.
554+
* @return The parsed color as an integer, or black if missing or invalid.
555+
*/
556+
private int getColor(Map<String, Object> map, String key) {
557+
try {
558+
if (map != null && map.containsKey(key) && map.get(key) != null) {
559+
String colorString = (String) map.get(key);
560+
return android.graphics.Color.parseColor(colorString);
561+
}
562+
} catch (Exception e) {
563+
e.printStackTrace();
564+
}
565+
return android.graphics.Color.BLACK;
566+
}
567+
568+
/**
569+
* Retrieves a text style from the Map.
570+
*
571+
* @param map The Map object.
572+
* @param key The key to look for.
573+
* @return The corresponding Typeface style, or Typeface.NORMAL if missing or invalid.
574+
*/
575+
private int getTextStyle(Map<String, Object> map, String key) {
576+
try {
577+
if (map != null && map.containsKey(key) && map.get(key) != null) {
578+
String style = (String) map.get(key);
579+
switch (style.toLowerCase()) {
580+
case "bold":
581+
return Typeface.BOLD;
582+
case "italic":
583+
return Typeface.ITALIC;
584+
case "bold_italic":
585+
return Typeface.BOLD_ITALIC;
586+
case "normal":
587+
default:
588+
return Typeface.NORMAL;
589+
}
590+
}
591+
} catch (Exception e) {
592+
e.printStackTrace();
593+
}
594+
return Typeface.NORMAL;
595+
}
596+
597+
/**
598+
* Sets a font on the theme builder if the font configuration is present in the theme config.
599+
*
600+
* @param themeConfig The theme configuration map
601+
* @param builder The theme builder
602+
* @param fileKey The key for font file path
603+
* @param assetKey The key for font asset path
604+
* @param fontType The type of font (for logging purposes)
605+
*/
606+
private void setFontIfPresent(Map<String, Object> themeConfig, com.instabug.library.model.IBGTheme.Builder builder,
607+
String fileKey, String assetKey, String fontType) {
608+
if (themeConfig.containsKey(fileKey) || themeConfig.containsKey(assetKey)) {
609+
Typeface typeface = getTypeface(themeConfig, fileKey, assetKey);
610+
if (typeface != null) {
611+
switch (fontType) {
612+
case "primary":
613+
builder.setPrimaryTextFont(typeface);
614+
break;
615+
case "secondary":
616+
builder.setSecondaryTextFont(typeface);
617+
break;
618+
case "CTA":
619+
builder.setCtaTextFont(typeface);
620+
break;
621+
}
622+
}
623+
}
624+
}
625+
626+
private Typeface getTypeface(Map<String, Object> map, String fileKey, String assetKey) {
627+
String fontName = null;
628+
629+
if (assetKey != null && map.containsKey(assetKey) && map.get(assetKey) != null) {
630+
fontName = (String) map.get(assetKey);
631+
} else if (fileKey != null && map.containsKey(fileKey) && map.get(fileKey) != null) {
632+
fontName = (String) map.get(fileKey);
633+
}
634+
635+
if (fontName == null) {
636+
return Typeface.DEFAULT;
637+
}
638+
639+
try {
640+
String assetPath = "fonts/" + fontName;
641+
return Typeface.createFromAsset(context.getAssets(), assetPath);
642+
} catch (Exception e) {
643+
try {
644+
return Typeface.create(fontName, Typeface.NORMAL);
645+
} catch (Exception e2) {
646+
return Typeface.DEFAULT;
647+
}
648+
}
649+
}
650+
651+
512652
}

0 commit comments

Comments
 (0)