<commit_before>package com.cordovaplugincamerapreview;

import android.app.Activity;
import android.app.FragmentManager;
import android.app.FragmentTransaction;
import android.content.pm.PackageManager;
import android.hardware.Camera;
import android.Manifest;
import android.util.DisplayMetrics;
import android.util.Log;
import android.util.TypedValue;
import android.view.ViewGroup;
import android.widget.FrameLayout;

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

public class CameraPreview extends CordovaPlugin implements CameraActivity.CameraPreviewListener {

  private final String TAG = "CameraPreview";
  private final String setOnPictureTakenHandlerAction = "setOnPictureTakenHandler";
  private final String setColorEffectAction = "setColorEffect";
  private final String startCameraAction = "startCamera";
  private final String stopCameraAction = "stopCamera";
  private final String switchCameraAction = "switchCamera";
  private final String setFlashModeAction = "setFlashMode";
  private final String takePictureAction = "takePicture";
  private final String showCameraAction = "showCamera";
  private final String hideCameraAction = "hideCamera";

  private final String permission = Manifest.permission.CAMERA;

  private final int permissionsReqId = 0;
  private CallbackContext execCallback;
  private JSONArray execArgs;

  private CameraActivity fragment;
  private CallbackContext takePictureCallbackContext;
  private FrameLayout containerView;
  public CameraPreview(){
    super();
    Log.d(TAG, "Constructing");
  }

  @Override
  public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {

    if (setOnPictureTakenHandlerAction.equals(action)){
      return setOnPictureTakenHandler(args, callbackContext);
    }
    else if (startCameraAction.equals(action)){
      if (PermissionHelper.hasPermission(permission)) {
        return startCamera(args, callbackContext);
      }
      else {
        execCallback = callbackContext;
        execArgs = args;
        cordova.requestPermission(this, permissionsReqId, permission);
      }
    }
    else if (takePictureAction.equals(action)){<commit_msg>PermissionHelper.requestPermission fix<commit_after>package com.cordovaplugincamerapreview;

import android.app.Activity;
import android.app.FragmentManager;
import android.app.FragmentTransaction;
import android.content.pm.PackageManager;
import android.hardware.Camera;
import android.Manifest;
import android.util.DisplayMetrics;
import android.util.Log;
import android.util.TypedValue;
import android.view.ViewGroup;
import android.widget.FrameLayout;

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

public class CameraPreview extends CordovaPlugin implements CameraActivity.CameraPreviewListener {

  private final String TAG = "CameraPreview";
  private final String setOnPictureTakenHandlerAction = "setOnPictureTakenHandler";
  private final String setColorEffectAction = "setColorEffect";
  private final String startCameraAction = "startCamera";
  private final String stopCameraAction = "stopCamera";
  private final String switchCameraAction = "switchCamera";
  private final String setFlashModeAction = "setFlashMode";
  private final String takePictureAction = "takePicture";
  private final String showCameraAction = "showCamera";
  private final String hideCameraAction = "hideCamera";

  private final String permission = Manifest.permission.CAMERA;

  private final int permissionsReqId = 0;
  private CallbackContext execCallback;
  private JSONArray execArgs;

  private CameraActivity fragment;
  private CallbackContext takePictureCallbackContext;
  private FrameLayout containerView;
  public CameraPreview(){
    super();
    Log.d(TAG, "Constructing");
  }

  @Override
  public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {

    if (setOnPictureTakenHandlerAction.equals(action)){
      return setOnPictureTakenHandler(args, callbackContext);
    }
    else if (startCameraAction.equals(action)){
      if (PermissionHelper.hasPermission(permission)) {
        return startCamera(args, callbackContext);
      }
      else {
        execCallback = callbackContext;
        execArgs = args;
        PermissionHelper.requestPermission(this, permissionsReqId, permission);
      }
    }
    else if (takePictureAction.equals(action)){
{'fraction_non_alphanumeric': 0.07565366480925846, 'fraction_numerical': 0.0004286326618088298, 'mean_word_length': 5.384404924760602, '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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5977474', 'n_tokens_mistral': 1209, 'n_tokens_neox': 1171, 'n_words': 312}