mirror of
https://github.com/status-im/instabug-reactnative.git
synced 2025-03-03 06:30:41 +00:00
Enable setting Theme Color in android
This commit is contained in:
parent
57f716367b
commit
5c255c176c
@ -13,6 +13,7 @@ import com.instabug.library.Instabug;
|
||||
import com.instabug.library.internal.module.InstabugLocale;
|
||||
import com.instabug.library.invocation.InstabugInvocationEvent;
|
||||
import com.instabug.library.invocation.InstabugInvocationMode;
|
||||
import com.instabug.library.InstabugColorTheme;
|
||||
import com.instabug.library.logging.InstabugLog;
|
||||
import com.instabug.library.bugreporting.model.ReportCategory;
|
||||
|
||||
@ -56,6 +57,10 @@ public class RNInstabugReactnativeModule extends ReactContextBaseJavaModule {
|
||||
private final String LOCALE_SWEDISH = "swedish";
|
||||
private final String LOCALE_TURKISH = "turkish";
|
||||
|
||||
//Theme colors
|
||||
private final String COLOR_THEME_LIGHT = "light";
|
||||
private final String COLOR_THEME_DARK = "dark";
|
||||
|
||||
private Application androidApplication;
|
||||
private Instabug mInstabug;
|
||||
private InstabugInvocationEvent invocationEvent;
|
||||
@ -627,6 +632,25 @@ public class RNInstabugReactnativeModule extends ReactContextBaseJavaModule {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets InstabugSDK theme color.
|
||||
*
|
||||
* @param theme which is a constant String "light" or "dark"
|
||||
*/
|
||||
@ReactMethod
|
||||
public void setColorTheme(String theme) {
|
||||
try {
|
||||
if (theme.equals(COLOR_THEME_LIGHT)) {
|
||||
mInstabug.setTheme(InstabugColorTheme.InstabugColorThemeLight);
|
||||
|
||||
} else if (theme.equals(COLOR_THEME_DARK)) {
|
||||
mInstabug.setTheme(InstabugColorTheme.InstabugColorThemeDark);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows you to show a predefined set of categories for users to choose
|
||||
* from when reporting a bug or sending feedback. Selected category
|
||||
@ -642,7 +666,8 @@ public class RNInstabugReactnativeModule extends ReactContextBaseJavaModule {
|
||||
int size = categoriesTitles != null ? categoriesTitles.size() : 0;
|
||||
if (size == 0) return;
|
||||
for (int i = 0; i < size; i++) {
|
||||
bugCategories.add(ReportCategory.getInstance().withLabel(categoriesTitles.getString(i)));
|
||||
bugCategories.add(ReportCategory.getInstance().withLabel(categoriesTitles
|
||||
.getString(i)));
|
||||
}
|
||||
|
||||
Instabug.setReportCategories(bugCategories);
|
||||
@ -717,6 +742,9 @@ public class RNInstabugReactnativeModule extends ReactContextBaseJavaModule {
|
||||
constants.put("invocationEventTwoFingersSwipe", INVOCATION_EVENT_TWO_FINGERS_SWIPE);
|
||||
constants.put("invocationEventFloatingButton", INVOCATION_EVENT_FLOATING_BUTTON);
|
||||
|
||||
constants.put("colorThemeLight", COLOR_THEME_LIGHT);
|
||||
constants.put("colorThemeDark", COLOR_THEME_DARK);
|
||||
|
||||
constants.put("invocationModeNewBug", INVOCATION_MODE_NEW_BUG);
|
||||
constants.put("invocationModeNewFeedback", INVOCATION_MODE_NEW_FEEDBACK);
|
||||
constants.put("invocationModeNewChat", INVOCATION_MODE_NEW_CHAT);
|
||||
|
5
index.js
5
index.js
@ -311,8 +311,7 @@ module.exports = {
|
||||
* @param colorTheme
|
||||
*/
|
||||
setColorTheme: function (colorTheme) {
|
||||
if (Platform.OS === 'ios')
|
||||
Instabug.setColorTheme(colorTheme);
|
||||
Instabug.setColorTheme(colorTheme);
|
||||
},
|
||||
|
||||
/**
|
||||
@ -458,7 +457,7 @@ module.exports = {
|
||||
* to. Selected category will be shown as a tag on your dashboard.
|
||||
* @param {array} titles titles to be shown in the list.
|
||||
*/
|
||||
setReportCategories: function (... titles) {
|
||||
setReportCategories: function (...titles) {
|
||||
if (Platform.OS == 'ios') {
|
||||
Instabug.setReportCategories(titles, null);
|
||||
} else if (Platform.OS == 'android') {
|
||||
|
Loading…
x
Reference in New Issue
Block a user