
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,this.invocationEvent);
    }

    public RNInstabugReactnativePackage(String androidApplicationToken,Application application,String invocationEventValue) {
        this(androidApplicationToken,application,invocationEventValue,this.instabugColorThemeValue);
    }

    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();
    }

}
@@ -1226,36 +1226,24 @@
 ication,
-this.invocationEvent
+%22button%22
 );%0A    %7D
@@ -1444,36 +1444,15 @@
 lue,
-this.instabugColorThemeValue
+%22light%22
 );%0A 

fix RNInstabugReactnativePackage constructors params incompatible types