
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.androidApplication = application;
        this.mAndroidApplicationToken = androidApplicationToken;

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

    public RNInstabugReactnativePackage(String androidApplicationToken,Application application,String invocationEventValue) {
            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;
            }

            this(androidApplicationToken,application);

    }

    public RNInstabugReactnativePackage(String androidApplicationToken,Application application,String invocationEventValue,String instabugColorThemeValue) {
        if (instabugColorThemeValue.equals("light")) {
            this.instabugColorTheme=InstabugColorTheme.InstabugColorThemeLight;
        } else if (instabugColorThemeValue.equals("dark")) {
            this.instabugColorTheme=InstabugColorTheme.InstabugColorThemeDark;
        } else {
            this.instabugColorTheme=InstabugColorTheme.InstabugColorThemeLight;
        }

        this(androidApplicationToken,application,invocationEventValue);

    }

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

}
@@ -1189,17 +1189,17 @@
     this
-.
+(
 androidA
@@ -1208,19 +1208,22 @@
 lication
- = 
+Token,
 applicat
@@ -1229,121 +1229,86 @@
 tion
-;%0A        this.mAndroidApplicationToken = androidApplicationToken;%0A%0A   
+,this.invocationEvent);%0A
     
+%7D%0A%0A
     
- mInstabug = new Instabug.Builder(
+public RNInstabugReactnativePackage(String 
 andr
@@ -1325,18 +1325,14 @@
 tion
-, mAndroid
+Token,
 Appl
@@ -1342,317 +1342,150 @@
 tion
-Token)%0A                    .setEmailFieldRequired(false)%0A                    .setFloatingButtonOffsetFromTop(400)%0A                    .setTheme(this.instabugColorTheme)%0A                    .setInvocationEvent(this.invocationEvent)%0A                    .setIntroMessageEnabled(false)%0A                    .build(
+ application,String invocationEventValue) %7B%0A        this(androidApplicationToken,application,invocationEventValue,this.instabugColorThemeValue
 );%0A 
@@ -1577,32 +1577,41 @@
 ion application,
+%0A        
 String invocatio
@@ -1613,35 +1613,219 @@
 cationEventValue
-) %7B
+,String instabugColorThemeValue) %7B%0A%0A        this.androidApplication = application;%0A        this.mAndroidApplicationToken = androidApplicationToken;%0A%0A            //setting invocation event
 %0A            if(
@@ -2628,185 +2628,14 @@
     
-this(androidApplicationToken,application);%0A%0A    %7D%0A%0A    public RNInstabugReactnativePackage(String androidApplicationToken,Application application,String invocationEventValue,Str
+//sett
 ing 
@@ -2652,25 +2652,21 @@
 lorTheme
-Value) %7B%0A
+%0A    
         
@@ -2708,24 +2708,28 @@
 %22light%22)) %7B%0A
+    
             
@@ -2796,32 +2796,36 @@
 eLight;%0A        
+  
+  
 %7D else if (insta
@@ -2857,24 +2857,28 @@
 (%22dark%22)) %7B%0A
+    
             
@@ -2944,32 +2944,36 @@
 meDark;%0A        
+   
+ 
 %7D else %7B%0A       
@@ -2957,32 +2957,36 @@
        %7D else %7B%0A
+    
             this
@@ -3049,33 +3049,38 @@
 eLight;%0A        
+   
-%7D
+ %7D%0A
 %0A%0A        this(a
@@ -3077,73 +3077,405 @@
     
-this(androidApplicationToken,application,invocationEventValue
+    mInstabug = new Instabug.Builder(this.androidApplication,this.mAndroidApplicationToken)%0A                    .setEmailFieldRequired(false)%0A                    .setFloatingButtonOffsetFromTop(400)%0A                    .setTheme(this.instabugColorTheme)%0A                    .setInvocationEvent(this.invocationEvent)%0A                    .setIntroMessageEnabled(false)%0A                    .build(
 );%0A
-%0A
     

fix RNInstabugReactnativePackage constructors order