
package com.instabug.reactlibrary;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.ArrayList;
import android.app.Application;

import com.facebook.react.ReactPackage;
import com.facebook.react.bridge.NativeModule;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.uimanager.ViewManager;
import com.facebook.react.bridge.JavaScriptModule;


import com.instabug.library.Instabug;
import com.instabug.library.InstabugColorTheme;
import com.instabug.library.invocation.InstabugInvocationEvent;


public class RNInstabugReactnativePackage implements ReactPackage {

    Application androidApplication;
    private String mAndroidApplicationToken;
    private Instabug mInstabug;
    private Instabug.Builder mBuilder;
    private InstabugInvocationEvent invocationEvent=InstabugInvocationEvent.FLOATING_BUTTON;
    private InstabugColorTheme instabugColorTheme=InstabugColorTheme.InstabugColorThemeLight;
    public RNInstabugReactnativePackage(Instabug instabug) {
        this.mInstabug = instabug;
    }

    public RNInstabugReactnativePackage(String androidApplicationToken,Application application) {
        this(androidApplicationToken,application,"button");
    }

    public RNInstabugReactnativePackage(String androidApplicationToken,Application application,String invocationEventValue) {
        this(androidApplicationToken,application,invocationEventValue,"light");
    }

    public RNInstabugReactnativePackage(String androidApplicationToken,Application application,
        String invocationEventValue,String instabugColorThemeValue) {

        this.androidApplication = application;
        this.mAndroidApplicationToken = androidApplicationToken;

            //setting invocation event
            if(invocationEventValue.equals("button")) {
                this.invocationEvent=InstabugInvocationEvent.FLOATING_BUTTON;
            } else if(invocationEventValue.equals("swipe")) {
                this.invocationEvent=InstabugInvocationEvent.TWO_FINGER_SWIPE_LEFT;

            } else if(invocationEventValue.equals("shake")) {
                this.invocationEvent=InstabugInvocationEvent.SHAKE;

            } else if(invocationEventValue.equals("screenshot")){
                this.invocationEvent=InstabugInvocationEvent.SCREENSHOT_GESTURE;

            } else if(invocationEventValue.equals("none")) {
                this.invocationEvent=InstabugInvocationEvent.NONE;

            } else {
                this.invocationEvent=InstabugInvocationEvent.FLOATING_BUTTON;
            }

            //setting instabugColorTheme
            if (instabugColorThemeValue.equals("light")) {
                this.instabugColorTheme=InstabugColorTheme.InstabugColorThemeLight;
            } else if (instabugColorThemeValue.equals("dark")) {
                this.instabugColorTheme=InstabugColorTheme.InstabugColorThemeDark;
            } else {
                this.instabugColorTheme=InstabugColorTheme.InstabugColorThemeLight;
            }


            mInstabug = new Instabug.Builder(this.androidApplication,this.mAndroidApplicationToken)
                    .setEmailFieldRequired(false)
                    .setFloatingButtonOffsetFromTop(400)
                    .setTheme(this.instabugColorTheme)
                    .setInvocationEvent(this.invocationEvent)
                    .setIntroMessageEnabled(false)
                    .build();
    }

    @Override
    public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
        List<NativeModule> modules = new ArrayList<>();
        modules.add(new RNInstabugReactnativeModule(reactContext, this.mInstabug));
        return modules;
    }

    @Override
    public List<Class<? extends JavaScriptModule>> createJSModules() {
      return Collections.emptyList();
    }

    @Override
    public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
      return Collections.emptyList();
    }

}
@@ -30,16 +30,39 @@
 brary;%0A%0A
+import java.util.List;%0A
 import j
@@ -95,27 +95,22 @@
 va.util.
-Collections
+Locale
 ;%0Aimport
@@ -112,32 +112,37 @@
 mport java.util.
+Array
 List;%0Aimport jav
@@ -144,33 +144,35 @@
 t java.util.
-ArrayList
+Collections
 ;%0Aimport and
@@ -285,66 +285,8 @@
 le;%0A
-import com.facebook.react.bridge.ReactApplicationContext;%0A
 impo
@@ -381,16 +381,74 @@
 Module;%0A
+import com.facebook.react.bridge.ReactApplicationContext;%0A
 %0A%0Aimport
@@ -527,16 +527,76 @@
 rTheme;%0A
+import com.instabug.library.internal.module.InstabugLocale;%0A
 import c
@@ -651,16 +651,87 @@
 nEvent;%0A
+import com.instabug.library.invocation.util.InstabugFloatingButtonEdge;
 %0A%0Apublic
@@ -3292,58 +3292,8 @@
 en)%0A
-                    .setEmailFieldRequired(false)%0A
     
@@ -3345,16 +3345,16 @@
 op(400)%0A
+
         
@@ -3462,16 +3462,16 @@
 nEvent)%0A
-
         
@@ -3513,16 +3513,585 @@
 (false)%0A
+                    .setAttachmentTypesEnabled(true, true, true, true, true)%0A                    .setShouldPlayConversationSounds(true)%0A                    .setEnableInAppNotificationSound(true)%0A                    .setEnableSystemNotificationSound(false)%0A                    .setPromptOptionsEnabled(true, true, true)%0A                    .setWillSkipScreenshotAnnotation(false)%0A                    .setFloatingButtonEdge(InstabugFloatingButtonEdge.LEFT)%0A                    .setLocale(new Locale(InstabugLocale.ENGLISH.getCode(), InstabugLocale.ENGLISH.getCountry()))%0A
         

add default configuration