// Path: sdk/src/main/java/io/kickflip/sdk/event/CameraOpenedEvent.java
// public class CameraOpenedEvent {
// 
//     public Parameters params;
// 
//     public CameraOpenedEvent(Parameters params) {
//         this.params = params;
//     }
// 
// }
// 
// Path: sdk/src/main/java/io/kickflip/sdk/view/GLCameraEncoderView.java
// public class GLCameraEncoderView extends GLCameraView {
//     private static final String TAG = "GLCameraEncoderView";
// 
//     protected CameraEncoder mCameraEncoder;
// 
//     public GLCameraEncoderView(Context context) {
//         super(context);
//     }
// 
//     public GLCameraEncoderView(Context context, AttributeSet attrs) {
//         super(context, attrs);
//     }
// 
//     public void setCameraEncoder(CameraEncoder encoder){
//         mCameraEncoder = encoder;
//         setCamera(mCameraEncoder.getCamera());
//     }
// 
//     @Override
//     public boolean onTouchEvent(MotionEvent ev) {
//         if(mScaleGestureDetector != null){
//             mScaleGestureDetector.onTouchEvent(ev);
//         }
//         if(mCameraEncoder != null && ev.getPointerCount() == 1 && (ev.getAction() == MotionEvent.ACTION_MOVE)){
//             mCameraEncoder.handleCameraPreviewTouchEvent(ev);
//         }else if(mCameraEncoder != null && ev.getPointerCount() == 1 && (ev.getAction() == MotionEvent.ACTION_DOWN)){
//             mCameraEncoder.handleCameraPreviewTouchEvent(ev);
//         }
//         return true;
//     }
// 
// 
// }
// 
// Path: sdk/src/main/java/io/kickflip/sdk/view/GLCameraView.java
// public class GLCameraView extends GLSurfaceView {
//     private static final String TAG = "GLCameraView";
// 
//     protected ScaleGestureDetector mScaleGestureDetector;
//     private Camera mCamera;
//     private int mMaxZoom;
// 
//     public GLCameraView(Context context) {
//         super(context);
//         init(context);
//     }
// 
//     public GLCameraView(Context context, AttributeSet attrs) {
//         super(context, attrs);
//         init(context);
//     }
// 
//     private void init(Context context){
//         mMaxZoom = 0;
// 
//     }
// 
//     public void setCamera(Camera camera){
//         mCamera = camera;
//         Camera.Parameters camParams = mCamera.getParameters();
//         if(camParams.isZoomSupported()){
//             mMaxZoom = camParams.getMaxZoom();
//             mScaleGestureDetector = new ScaleGestureDetector(getContext(), mScaleListener);
//         }
//     }
// 
//     public void releaseCamera(){
//         mCamera = null;
//         mScaleGestureDetector = null;
//     }
// 
//     private ScaleGestureDetector.SimpleOnScaleGestureListener mScaleListener = new ScaleGestureDetector.SimpleOnScaleGestureListener(){
// 
//         int mZoomWhenScaleBegan = 0;
//         int mCurrentZoom = 0;
// 
//         @Override
//         public boolean onScale(ScaleGestureDetector detector) {
//             if(mCamera != null){
//                 Camera.Parameters params = mCamera.getParameters();
//                 mCurrentZoom = (int) (mZoomWhenScaleBegan + (mMaxZoom * (detector.getScaleFactor() - 1)));
//                 mCurrentZoom = Math.min(mCurrentZoom, mMaxZoom);
//                 mCurrentZoom = Math.max(0, mCurrentZoom);
//                 params.setZoom(mCurrentZoom);
//                 mCamera.setParameters(params);
//             }
// 
//             return false;
//         }
// 
//         @Override
//         public boolean onScaleBegin(ScaleGestureDetector detector) {
//             mZoomWhenScaleBegan =  mCamera.getParameters().getZoom();
//             return true;
//         }
// 
//         @Override
//         public void onScaleEnd(ScaleGestureDetector detector) {
//         }
//     };
// 
//     @Override
//     public boolean onTouchEvent(MotionEvent ev) {
//         if(mScaleGestureDetector != null){
//             if(!mScaleGestureDetector.onTouchEvent(ev)){
//                 // No scale gesture detected
// 
//             }
//         }
//         return true;
//     }
// 
// 
// }


import android.graphics.SurfaceTexture;
import android.hardware.Camera;
import android.hardware.Camera.Parameters;
import android.opengl.EGLContext;
import android.opengl.GLSurfaceView;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.os.Trace;
import android.util.Log;
import android.view.MotionEvent;
import com.google.common.eventbus.EventBus;
import java.io.File;
import java.io.IOException;
import java.lang.ref.WeakReference;
import java.util.List;
import io.kickflip.sdk.event.CameraOpenedEvent;
import io.kickflip.sdk.view.GLCameraEncoderView;
import io.kickflip.sdk.view.GLCameraView;
import static com.google.common.base.Preconditions.checkNotNull;
                    Log.i(TAG, "Changed flash successfully!");
                }
            } catch (RuntimeException e) {
                Log.d(TAG, "Unable to set flash" + e);
            }
        }
    }

    /**
     * @param flashModes
     * @param flashMode
     * @return returns true if flashModes aren't null AND they contain the flashMode,
     * else returns false
     */
    private boolean isValidFlashMode(List<String> flashModes, String flashMode) {
        if (flashModes != null && flashModes.contains(flashMode)) {
            return true;
        }
        return false;
    }

    /**
     * @return returns the flash mode set in the camera
     */
    public String getFlashMode() {
        return (mDesiredFlash != null) ? mDesiredFlash : mCurrentFlash;
    }

    private void postCameraOpenedEvent(Parameters params) {
        if (mEventBus != null) {
// Path: sdk/src/main/java/io/kickflip/sdk/event/CameraOpenedEvent.java
// public class CameraOpenedEvent {
// 
//     public Parameters params;
// 
//     public CameraOpenedEvent(Parameters params) {
//         this.params = params;
//     }
// 
// }
// 
// Path: sdk/src/main/java/io/kickflip/sdk/view/GLCameraEncoderView.java
// public class GLCameraEncoderView extends GLCameraView {
//     private static final String TAG = "GLCameraEncoderView";
// 
//     protected CameraEncoder mCameraEncoder;
// 
//     public GLCameraEncoderView(Context context) {
//         super(context);
//     }
// 
//     public GLCameraEncoderView(Context context, AttributeSet attrs) {
//         super(context, attrs);
//     }
// 
//     public void setCameraEncoder(CameraEncoder encoder){
//         mCameraEncoder = encoder;
//         setCamera(mCameraEncoder.getCamera());
//     }
// 
//     @Override
//     public boolean onTouchEvent(MotionEvent ev) {
//         if(mScaleGestureDetector != null){
//             mScaleGestureDetector.onTouchEvent(ev);
//         }
//         if(mCameraEncoder != null && ev.getPointerCount() == 1 && (ev.getAction() == MotionEvent.ACTION_MOVE)){
//             mCameraEncoder.handleCameraPreviewTouchEvent(ev);
//         }else if(mCameraEncoder != null && ev.getPointerCount() == 1 && (ev.getAction() == MotionEvent.ACTION_DOWN)){
//             mCameraEncoder.handleCameraPreviewTouchEvent(ev);
//         }
//         return true;
//     }
// 
// 
// }
// 
// Path: sdk/src/main/java/io/kickflip/sdk/view/GLCameraView.java
// public class GLCameraView extends GLSurfaceView {
//     private static final String TAG = "GLCameraView";
// 
//     protected ScaleGestureDetector mScaleGestureDetector;
//     private Camera mCamera;
//     private int mMaxZoom;
// 
//     public GLCameraView(Context context) {
//         super(context);
//         init(context);
//     }
// 
//     public GLCameraView(Context context, AttributeSet attrs) {
//         super(context, attrs);
//         init(context);
//     }
// 
//     private void init(Context context){
//         mMaxZoom = 0;
// 
//     }
// 
//     public void setCamera(Camera camera){
//         mCamera = camera;
//         Camera.Parameters camParams = mCamera.getParameters();
//         if(camParams.isZoomSupported()){
//             mMaxZoom = camParams.getMaxZoom();
//             mScaleGestureDetector = new ScaleGestureDetector(getContext(), mScaleListener);
//         }
//     }
// 
//     public void releaseCamera(){
//         mCamera = null;
//         mScaleGestureDetector = null;
//     }
// 
//     private ScaleGestureDetector.SimpleOnScaleGestureListener mScaleListener = new ScaleGestureDetector.SimpleOnScaleGestureListener(){
// 
//         int mZoomWhenScaleBegan = 0;
//         int mCurrentZoom = 0;
// 
//         @Override
//         public boolean onScale(ScaleGestureDetector detector) {
//             if(mCamera != null){
//                 Camera.Parameters params = mCamera.getParameters();
//                 mCurrentZoom = (int) (mZoomWhenScaleBegan + (mMaxZoom * (detector.getScaleFactor() - 1)));
//                 mCurrentZoom = Math.min(mCurrentZoom, mMaxZoom);
//                 mCurrentZoom = Math.max(0, mCurrentZoom);
//                 params.setZoom(mCurrentZoom);
//                 mCamera.setParameters(params);
//             }
// 
//             return false;
//         }
// 
//         @Override
//         public boolean onScaleBegin(ScaleGestureDetector detector) {
//             mZoomWhenScaleBegan =  mCamera.getParameters().getZoom();
//             return true;
//         }
// 
//         @Override
//         public void onScaleEnd(ScaleGestureDetector detector) {
//         }
//     };
// 
//     @Override
//     public boolean onTouchEvent(MotionEvent ev) {
//         if(mScaleGestureDetector != null){
//             if(!mScaleGestureDetector.onTouchEvent(ev)){
//                 // No scale gesture detected
// 
//             }
//         }
//         return true;
//     }
// 
// 
// }


// Path: sdk/src/main/java/io/kickflip/sdk/av/CameraEncoder.java
import android.graphics.SurfaceTexture;
import android.hardware.Camera;
import android.hardware.Camera.Parameters;
import android.opengl.EGLContext;
import android.opengl.GLSurfaceView;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.os.Trace;
import android.util.Log;
import android.view.MotionEvent;
import com.google.common.eventbus.EventBus;
import java.io.File;
import java.io.IOException;
import java.lang.ref.WeakReference;
import java.util.List;
import io.kickflip.sdk.event.CameraOpenedEvent;
import io.kickflip.sdk.view.GLCameraEncoderView;
import io.kickflip.sdk.view.GLCameraView;
import static com.google.common.base.Preconditions.checkNotNull;

                    Log.i(TAG, "Changed flash successfully!");
                }
            } catch (RuntimeException e) {
                Log.d(TAG, "Unable to set flash" + e);
            }
        }
    }

    /**
     * @param flashModes
     * @param flashMode
     * @return returns true if flashModes aren't null AND they contain the flashMode,
     * else returns false
     */
    private boolean isValidFlashMode(List<String> flashModes, String flashMode) {
        if (flashModes != null && flashModes.contains(flashMode)) {
            return true;
        }
        return false;
    }

    /**
     * @return returns the flash mode set in the camera
     */
    public String getFlashMode() {
        return (mDesiredFlash != null) ? mDesiredFlash : mCurrentFlash;
    }

    private void postCameraOpenedEvent(Parameters params) {
        if (mEventBus != null) {
            mEventBus.post(new CameraOpenedEvent(params));