// Path: faceSwap/src/main/java/com/tunaemre/opencv/faceswap/app/ExtendedCompatActivity.java
// @SuppressLint("InlinedApi")
// public abstract class ExtendedCompatActivity extends AppCompatActivity
// {
// 	
// 	@Override
// 	public void setContentView(int layoutResID)
// 	{
// 		super.setContentView(layoutResID);
// 		
// 		prepareActivity();
// 	}
// 	
// 	protected abstract void prepareActivity();
// 
// }
// 
// Path: faceSwap/src/main/java/com/tunaemre/opencv/faceswap/constant/Constant.java
// public class Constant
// {	
// 	public static String FaceLandmarksURL = "https://github.com/tzutalin/dlib-android/raw/master/data/shape_predictor_68_face_landmarks.dat";
// 	
// 	public static String FaceLandmarksDownloadPath = "PoseModel";
// 	
// 	public static String FaceLandmarksFileName = "face_landmarks.dat";
// }
// 
// Path: faceSwap/src/main/java/com/tunaemre/opencv/faceswap/util/CacheOperator.java
// public class CacheOperator
// {
// 	private static CacheOperator instance = null;
// 	
// 	String PREF_NAME = "PREF_FACESWAP_CACHE";
// 	
// 	String IS_FACELANDMARKS_DOWNLOADED= "ISFACELANDMARKSDOWNLOADED";
// 	
// 	SharedPreferences mPreference;
// 	Editor mEditor;
// 	
// 	public static CacheOperator getInstance(Context context)
// 	{
// 		if (instance != null)
// 			return instance;
// 		
// 		instance = new CacheOperator(context);
// 		return instance;
// 	}
// 	
// 	private CacheOperator(Context context)
// 	{
// 		mPreference = context.getApplicationContext().getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE);
// 	}
// 
// 	public void setFaceLandmarksDownloaded(boolean value)
// 	{
// 		mEditor = mPreference.edit();
// 		mEditor.putBoolean(IS_FACELANDMARKS_DOWNLOADED, value);
// 		mEditor.commit();
// 	}
// 
// 	public boolean getFaceLandmarksDownloaded()
// 	{
// 		return mPreference.getBoolean(IS_FACELANDMARKS_DOWNLOADED, false);
// 	}
// }
// 
// Path: faceSwap/src/main/java/com/tunaemre/opencv/faceswap/util/PermissionOperator.java
// public class PermissionOperator
// {
// 	public static int REQUEST_STORAGE_PERMISSION = 11;
// 	public static int REQUEST_CAMERA_PERMISSION = 12;
// 
// 	
// 	public boolean isStoragePermissionGranded(Context context)
// 	{
// 		if (Build.VERSION.SDK_INT < 23) return true;
// 		
// 		if (ContextCompat.checkSelfPermission(context, Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) return true;
// 		
// 		return false;
// 	}
// 	
// 	public boolean requestStoragePermission(Activity context)
// 	{
// 		if (isStoragePermissionGranded(context)) return true;
// 		
// 		ActivityCompat.requestPermissions(context, new String[] {Manifest.permission.WRITE_EXTERNAL_STORAGE}, REQUEST_STORAGE_PERMISSION);
// 		
// 		return true;
// 	}
// 	
// 	public boolean isCameraPermissionGranded(Context context)
// 	{
// 		if (Build.VERSION.SDK_INT < 23) return true;
// 		
// 		if (ContextCompat.checkSelfPermission(context, Manifest.permission.CAMERA) == PackageManager.PERMISSION_GRANTED) return true;
// 		
// 		return false;
// 	}
// 	
// 	public boolean requestCameraPermission(Activity context)
// 	{
// 		if (isCameraPermissionGranded(context)) return true;
// 		
// 		ActivityCompat.requestPermissions(context, new String[] {Manifest.permission.CAMERA}, REQUEST_CAMERA_PERMISSION);
// 		
// 		return true;
// 	}
// }


import java.io.File;
import com.tunaemre.opencv.faceswap.app.ExtendedCompatActivity;
import com.tunaemre.opencv.faceswap.constant.Constant;
import com.tunaemre.opencv.faceswap.util.CacheOperator;
import com.tunaemre.opencv.faceswap.util.PermissionOperator;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Toast;
		findViewById(R.id.btnMainPhotoMask).setOnClickListener(new OnClickListener()
		{
			@Override
			public void onClick(View v)
			{
				if (!checkPermission())
					return;
				//TODO

				Toast.makeText(MainActivity.this, "In development.", Toast.LENGTH_SHORT).show();
			}
		});
		
		checkPermission();
	}
	
	private boolean checkPermission()
	{
		if (!permissionOperator.isCameraPermissionGranded(this))
		{
			permissionOperator.requestCameraPermission(this);
			return false;
		}
		
		return true;
	}
	
	private boolean checkFaceLandmarkFile()
	{
		File localFile = new File(MainActivity.this.getDir(Constant.FaceLandmarksDownloadPath, Context.MODE_PRIVATE), Constant.FaceLandmarksFileName);
// Path: faceSwap/src/main/java/com/tunaemre/opencv/faceswap/app/ExtendedCompatActivity.java
// @SuppressLint("InlinedApi")
// public abstract class ExtendedCompatActivity extends AppCompatActivity
// {
// 	
// 	@Override
// 	public void setContentView(int layoutResID)
// 	{
// 		super.setContentView(layoutResID);
// 		
// 		prepareActivity();
// 	}
// 	
// 	protected abstract void prepareActivity();
// 
// }
// 
// Path: faceSwap/src/main/java/com/tunaemre/opencv/faceswap/constant/Constant.java
// public class Constant
// {	
// 	public static String FaceLandmarksURL = "https://github.com/tzutalin/dlib-android/raw/master/data/shape_predictor_68_face_landmarks.dat";
// 	
// 	public static String FaceLandmarksDownloadPath = "PoseModel";
// 	
// 	public static String FaceLandmarksFileName = "face_landmarks.dat";
// }
// 
// Path: faceSwap/src/main/java/com/tunaemre/opencv/faceswap/util/CacheOperator.java
// public class CacheOperator
// {
// 	private static CacheOperator instance = null;
// 	
// 	String PREF_NAME = "PREF_FACESWAP_CACHE";
// 	
// 	String IS_FACELANDMARKS_DOWNLOADED= "ISFACELANDMARKSDOWNLOADED";
// 	
// 	SharedPreferences mPreference;
// 	Editor mEditor;
// 	
// 	public static CacheOperator getInstance(Context context)
// 	{
// 		if (instance != null)
// 			return instance;
// 		
// 		instance = new CacheOperator(context);
// 		return instance;
// 	}
// 	
// 	private CacheOperator(Context context)
// 	{
// 		mPreference = context.getApplicationContext().getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE);
// 	}
// 
// 	public void setFaceLandmarksDownloaded(boolean value)
// 	{
// 		mEditor = mPreference.edit();
// 		mEditor.putBoolean(IS_FACELANDMARKS_DOWNLOADED, value);
// 		mEditor.commit();
// 	}
// 
// 	public boolean getFaceLandmarksDownloaded()
// 	{
// 		return mPreference.getBoolean(IS_FACELANDMARKS_DOWNLOADED, false);
// 	}
// }
// 
// Path: faceSwap/src/main/java/com/tunaemre/opencv/faceswap/util/PermissionOperator.java
// public class PermissionOperator
// {
// 	public static int REQUEST_STORAGE_PERMISSION = 11;
// 	public static int REQUEST_CAMERA_PERMISSION = 12;
// 
// 	
// 	public boolean isStoragePermissionGranded(Context context)
// 	{
// 		if (Build.VERSION.SDK_INT < 23) return true;
// 		
// 		if (ContextCompat.checkSelfPermission(context, Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) return true;
// 		
// 		return false;
// 	}
// 	
// 	public boolean requestStoragePermission(Activity context)
// 	{
// 		if (isStoragePermissionGranded(context)) return true;
// 		
// 		ActivityCompat.requestPermissions(context, new String[] {Manifest.permission.WRITE_EXTERNAL_STORAGE}, REQUEST_STORAGE_PERMISSION);
// 		
// 		return true;
// 	}
// 	
// 	public boolean isCameraPermissionGranded(Context context)
// 	{
// 		if (Build.VERSION.SDK_INT < 23) return true;
// 		
// 		if (ContextCompat.checkSelfPermission(context, Manifest.permission.CAMERA) == PackageManager.PERMISSION_GRANTED) return true;
// 		
// 		return false;
// 	}
// 	
// 	public boolean requestCameraPermission(Activity context)
// 	{
// 		if (isCameraPermissionGranded(context)) return true;
// 		
// 		ActivityCompat.requestPermissions(context, new String[] {Manifest.permission.CAMERA}, REQUEST_CAMERA_PERMISSION);
// 		
// 		return true;
// 	}
// }


// Path: faceSwap/src/main/java/com/tunaemre/opencv/faceswap/MainActivity.java
import java.io.File;
import com.tunaemre.opencv.faceswap.app.ExtendedCompatActivity;
import com.tunaemre.opencv.faceswap.constant.Constant;
import com.tunaemre.opencv.faceswap.util.CacheOperator;
import com.tunaemre.opencv.faceswap.util.PermissionOperator;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Toast;

		findViewById(R.id.btnMainPhotoMask).setOnClickListener(new OnClickListener()
		{
			@Override
			public void onClick(View v)
			{
				if (!checkPermission())
					return;
				//TODO

				Toast.makeText(MainActivity.this, "In development.", Toast.LENGTH_SHORT).show();
			}
		});
		
		checkPermission();
	}
	
	private boolean checkPermission()
	{
		if (!permissionOperator.isCameraPermissionGranded(this))
		{
			permissionOperator.requestCameraPermission(this);
			return false;
		}
		
		return true;
	}
	
	private boolean checkFaceLandmarkFile()
	{
		File localFile = new File(MainActivity.this.getDir(Constant.FaceLandmarksDownloadPath, Context.MODE_PRIVATE), Constant.FaceLandmarksFileName);
		return localFile.exists() && CacheOperator.getInstance(MainActivity.this).getFaceLandmarksDownloaded();