<commit_before>package com.vessel.abplugin;

import org.apache.cordova.CallbackContext;
import org.apache.cordova.CordovaPlugin;
import org.json.JSONObject;
import org.json.JSONArray;
import org.json.JSONException;

import android.app.Activity;
import android.util.Log;
import android.content.Intent;

import com.vessel.VesselSDK;
import com.vessel.VesselAB;
import com.vessel.enums.VesselEnums.TestVariation;
import com.vessel.interfaces.ABListener;


public class VesselABPlugin extends CordovaPlugin {
    CallbackContext callbackContext;

    @Override
    public boolean execute(String action, JSONArray args, CallbackContext _callbackContext) throws JSONException {
        try {
            callbackContext = _callbackContext;
            Log.d("VesselSDK", "Action "+action);

            if ("initialize".equals(action)) {
                String SECRET_KEY = args.getString(0);

                VesselSDK.initialize(cordova.getActivity().getApplicationContext(), SECRET_KEY);
                callbackContext.success();
                return true;

            }else if ("reloadTest".equals(action)) {
                VesselAB.reloadTest();
                callbackContext.success();
                return true;
            } else if ("pause".equals(action)) {
                VesselAB.onPause();
                callbackContext.success();
                return true;
            } else if ("resume".equals(action)) {
                VesselAB.onResume();
                callbackContext.success();
                return true;
            } else if ("startSession".equals(action)) {
                String sessionName = args.getString(0);
                VesselAB.startSession(sessionName);
                callbackContext.success();
                return true;
            } else if ("endSession".equals(action)) {
                String sessionName = args.getString(0);
                VesselAB.endSession(sessionName);
                callbackContext.success();
                return true;
            }else if ("checkPointVisited".equals(action)) {
                String checkpointName = args.getString(0);
                VesselAB.checkPointVisited(checkpointName);
                callbackContext.success();
                return true;
            }else if ("setABListener".equals(action)) {
                this.cordova.setActivityResultCallback(this);
                this.cordova.getThreadPool().execute(new Runnable() {

                    @Override
                    public void run() {
                        VesselAB.setABListener(new ABListener() {

                            @Override
                            public void testNotAvailable(TestVariation arg0) {
                                callbackContext.success(arg0.toString());
                            }

                            @Override
                            public void testLoading() {
                            }

                            @Override
                            public void testLoaded(String testName, TestVariation testVariation) {
                                callbackContext.success(testVariation.toString());

                            }
                        });

                    }
                });
                return true;
            }else if("getValue".equals(action)){
                String key = args.getString(0);
                String defaultValue = args.getString(1);
                String value = VesselAB.getValue(key, defaultValue);
                callbackContext.success(value);
                return true;<commit_msg>Fix for phonegap 3.0 <commit_after>package com.vessel.abplugin;

import org.apache.cordova.CallbackContext;
import org.apache.cordova.CordovaPlugin;
import org.json.JSONArray;
import org.json.JSONException;

import android.util.Log;

import com.vessel.VesselSDK;
import com.vessel.VesselAB;
import com.vessel.enums.VesselEnums.TestVariation;
import com.vessel.interfaces.ABListener;


public class VesselABPlugin extends CordovaPlugin {
    CallbackContext callbackContext;

    @Override
    public boolean execute(String action, JSONArray args, CallbackContext _callbackContext) throws JSONException {
        try {
            callbackContext = _callbackContext;
            Log.d("VesselSDK", "Action "+action);

            if ("initialize".equals(action)) {
                final String SECRET_KEY = args.getString(0);

                this.cordova.getThreadPool().execute(new Runnable() {

                    @Override
                    public void run() {
                        VesselSDK.initialize(cordova.getActivity().getApplicationContext(), SECRET_KEY);
                        callbackContext.success();
                    }
                });
                return true;
            }else if ("reloadTest".equals(action)) {
                VesselAB.reloadTest();
                callbackContext.success();
                return true;
            } else if ("pause".equals(action)) {
                VesselAB.onPause();
                callbackContext.success();
                return true;
            } else if ("resume".equals(action)) {
                VesselAB.onResume();
                callbackContext.success();
                return true;
            } else if ("startSession".equals(action)) {
                String sessionName = args.getString(0);
                VesselAB.startSession(sessionName);
                callbackContext.success();
                return true;
            } else if ("endSession".equals(action)) {
                String sessionName = args.getString(0);
                VesselAB.endSession(sessionName);
                callbackContext.success();
                return true;
            }else if ("checkPointVisited".equals(action)) {
                String checkpointName = args.getString(0);
                VesselAB.checkPointVisited(checkpointName);
                callbackContext.success();
                return true;
            }else if ("setABListener".equals(action)) {
                this.cordova.setActivityResultCallback(this);
                this.cordova.getThreadPool().execute(new Runnable() {

                    @Override
                    public void run() {
                                        VesselAB.setABListener(new ABListener() {

                            @Override
                            public void testNotAvailable(final TestVariation testVariation) {
                                callbackContext.success(testVariation.toString());
                            }

                            @Override
                            public void testLoading() {
                            }

                            @Override
                            public void testLoaded(String testName, final TestVariation testVariation) {
                                callbackContext.success(testVariation.toString());
                            }
                        });

                    }
                });
                return true;
            }else if("getValue".equals(action)){
                String key = args.getString(0);
                String defaultValue = args.getString(1);
                String value = VesselAB.getValue(key, defaultValue);
                callbackContext.success(value);
                return true;
{'fraction_non_alphanumeric': 0.08826329389364886, 'fraction_numerical': 0.002175982592139263, 'mean_word_length': 1.5039155600953353, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5426784', 'n_tokens_mistral': 1781, 'n_tokens_neox': 1621, 'n_words': 322}