[
  {
    "path": ".gitignore",
    "content": "*.iml\n.gradle\n/local.properties\n.idea\n.DS_Store\n/build\n/captures\n.externalNativeBuild\n.cxx\nlocal.properties\n"
  },
  {
    "path": "build.gradle",
    "content": "// Top-level build file where you can add configuration options common to all sub-projects/modules.\n\nbuildscript {\n    repositories {\n        google()\n        mavenCentral()\n    }\n\n    dependencies {\n        classpath 'com.android.tools.build:gradle:7.0.0'\n        classpath 'org.jetbrains.dokka:dokka-gradle-plugin:1.5.0'\n        classpath 'com.vanniktech:gradle-maven-publish-plugin:0.17.0'\n    }\n}\n\nallprojects {\n    repositories {\n        google()\n        mavenCentral()\n    }\n    plugins.withId(\"com.vanniktech.maven.publish\") {\n        mavenPublish {\n            sonatypeHost = \"S01\"\n        }\n    }\n}\n\ntask clean(type: Delete) {\n    delete rootProject.buildDir\n}\n"
  },
  {
    "path": "demo/.gitignore",
    "content": "/build\n"
  },
  {
    "path": "demo/build.gradle",
    "content": "plugins {\n    id 'com.android.application'\n}\n\nandroid {\n    compileSdk 30\n\n    defaultConfig {\n        applicationId \"io.github.muddz.quickshot.demo\"\n        minSdk 19\n        targetSdk 30\n        versionCode 1\n        versionName \"1.0\"\n    }\n    buildTypes {\n        release {\n            minifyEnabled false\n            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'\n        }\n    }\n}\n\ndependencies {\n    implementation 'androidx.appcompat:appcompat:1.3.1'\n    implementation 'com.google.android.material:material:1.4.0'\n//    implementation 'io.github.muddz:quickshot:1.4.0'\n    implementation project(':quickshot')\n}\n"
  },
  {
    "path": "demo/proguard-rules.pro",
    "content": "# Add project specific ProGuard rules here.\n# You can control the set of applied configuration files using the\n# proguardFiles setting in build.gradle.\n#\n# For more details, see\n#   http://developer.android.com/guide/developing/tools/proguard.html\n\n# If your project uses WebView with JS, uncomment the following\n# and specify the fully qualified class name to the JavaScript interface\n# class:\n#-keepclassmembers class fqcn.of.javascript.interface.for.webview {\n#   public *;\n#}\n\n# Uncomment this to preserve the line number information for\n# debugging stack traces.\n#-keepattributes SourceFile,LineNumberTable\n\n# If you keep the line number information, uncomment this to\n# hide the original source file name.\n#-renamesourcefileattribute SourceFile\n"
  },
  {
    "path": "demo/src/main/AndroidManifest.xml",
    "content": "<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    xmlns:tools=\"http://schemas.android.com/tools\"\n    package=\"io.github.muddz.quickshot.demo\">\n\n    <uses-permission android:name=\"android.permission.VIBRATE\" />\n    <uses-permission android:name=\"android.permission.WRITE_EXTERNAL_STORAGE\" />\n    <uses-permission android:name=\"android.permission.CAMERA\" />\n\n    <uses-feature\n        android:name=\"android.hardware.camera\"\n        android:required=\"false\" />\n\n    <application\n        android:label=\"@string/app_name\"\n        android:supportsRtl=\"true\"\n        android:theme=\"@style/AppTheme\"\n        tools:ignore=\"AllowBackup,GoogleAppIndexingWarning,MissingApplicationIcon\">\n        <activity\n            android:name=\"io.github.muddz.quickshot.demo.MainActivity\"\n            android:screenOrientation=\"portrait\">\n            <intent-filter>\n                <action android:name=\"android.intent.action.MAIN\" />\n                <category android:name=\"android.intent.category.LAUNCHER\" />\n            </intent-filter>\n        </activity>\n    </application>\n</manifest>\n"
  },
  {
    "path": "demo/src/main/java/io/github/muddz/quickshot/demo/DrawingBoardView.java",
    "content": "package io.github.muddz.quickshot.demo;\n\nimport android.annotation.SuppressLint;\nimport android.content.Context;\nimport android.graphics.Canvas;\nimport android.graphics.Color;\nimport android.graphics.Paint;\nimport android.graphics.Path;\nimport android.util.AttributeSet;\nimport android.util.TypedValue;\nimport android.view.MotionEvent;\nimport android.view.View;\n\nimport androidx.annotation.Nullable;\n\n\npublic class DrawingBoardView extends View {\n\n    private OnDrawingListener listener;\n    private Paint drawingPaint;\n    private Path path = new Path();\n\n    public DrawingBoardView(Context context) {\n        super(context);\n        setup();\n    }\n\n    public DrawingBoardView(Context context, @Nullable AttributeSet attrs) {\n        super(context, attrs);\n        setup();\n    }\n\n    private void setup() {\n        setFocusableInTouchMode(true);\n        setFocusable(true);\n        drawingPaint = new Paint();\n        drawingPaint.setColor(Color.BLACK);\n        drawingPaint.setAntiAlias(true);\n        drawingPaint.setStrokeWidth(convertToDP(5));\n        drawingPaint.setStyle(Paint.Style.STROKE);\n        drawingPaint.setStrokeJoin(Paint.Join.ROUND);\n        drawingPaint.setStrokeCap(Paint.Cap.ROUND);\n    }\n\n    @Override\n    protected void onDraw(Canvas canvas) {\n        canvas.drawPath(path, drawingPaint);\n    }\n\n    @SuppressLint(\"ClickableViewAccessibility\")\n    @Override\n    public boolean onTouchEvent(MotionEvent event) {\n        float xTouchPos = event.getX();\n        float yTouchPos = event.getY();\n\n        switch (event.getAction()) {\n            case MotionEvent.ACTION_DOWN:\n                path.moveTo(xTouchPos, yTouchPos);\n                path.lineTo(xTouchPos, yTouchPos);\n                if (listener != null) {\n                    listener.onDrawingStarted();\n                }\n                break;\n            case MotionEvent.ACTION_MOVE:\n                path.lineTo(xTouchPos, yTouchPos);\n                break;\n            default:\n                return false;\n        }\n        postInvalidate();\n        return true;\n    }\n\n\n    public void setOnDrawingListener(OnDrawingListener listener) {\n        this.listener = listener;\n    }\n\n    private float convertToDP(int value) {\n        return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, value, getResources().getDisplayMetrics());\n    }\n\n    public interface OnDrawingListener {\n        void onDrawingStarted();\n    }\n}\n"
  },
  {
    "path": "demo/src/main/java/io/github/muddz/quickshot/demo/MainActivity.java",
    "content": "package io.github.muddz.quickshot.demo;\n\nimport android.Manifest;\nimport android.os.Bundle;\nimport android.view.Menu;\nimport android.view.MenuItem;\nimport android.view.View;\nimport android.widget.Toast;\n\nimport androidx.appcompat.app.AppCompatActivity;\nimport androidx.appcompat.widget.Toolbar;\nimport androidx.core.app.ActivityCompat;\nimport androidx.core.content.ContextCompat;\nimport androidx.core.content.PermissionChecker;\n\nimport com.google.android.material.tabs.TabLayout;\n\nimport io.github.muddz.quickshot.QuickShot;\nimport io.github.muddz.quickshot.demo.fragments.BaseFragment;\n\n\npublic class MainActivity extends AppCompatActivity implements QuickShot.QuickShotListener {\n\n    private NonSwipeViewPager viewPager;\n    private ViewPagerAdapter viewPagerAdapter;\n\n    @Override\n    protected void onCreate(Bundle savedInstanceState) {\n        super.onCreate(savedInstanceState);\n        setContentView(R.layout.activity_main);\n        askPermissions();\n        setupToolbar();\n        setupViewPager();\n    }\n\n    private void setupToolbar() {\n        Toolbar toolbar = findViewById(R.id.toolbar);\n        toolbar.setOverflowIcon(ContextCompat.getDrawable(this, R.drawable.ic_save_black_24dp));\n        setSupportActionBar(toolbar);\n    }\n\n    private void setupViewPager() {\n        viewPager = findViewById(R.id.viewpager);\n        viewPagerAdapter = new ViewPagerAdapter(getSupportFragmentManager());\n        viewPager.setAdapter(viewPagerAdapter);\n        viewPager.setOffscreenPageLimit(0);\n        TabLayout tabLayout = findViewById(R.id.tablayout);\n        tabLayout.setupWithViewPager(viewPager);\n    }\n\n    @Override\n    public boolean onCreateOptionsMenu(Menu menu) {\n        getMenuInflater().inflate(R.menu.menu_toolbar, menu);\n        return true;\n    }\n\n    @Override\n    public boolean onOptionsItemSelected(MenuItem item) {\n        switch (item.getItemId()) {\n            case R.id.menu_jpg:\n                QuickShot.of(getTargetView()).setFilename(\"QuickShotJPG\").setResultListener(this).toJPG().save();\n                break;\n            case R.id.menu_pgn:\n                QuickShot.of(getTargetView()).setResultListener(this).toPNG().enableLogging().save();\n                break;\n            case R.id.menu_nomedia:\n                QuickShot.of(getTargetView()).setResultListener(this).toNomedia().save();\n                break;\n        }\n        return true;\n    }\n\n    private View getTargetView() {\n        int currentItem = viewPager.getCurrentItem();\n        BaseFragment fragment = (BaseFragment) viewPagerAdapter.getItem(currentItem);\n        return fragment.getTargetView();\n    }\n\n    @Override\n    public void onQuickShotSuccess(String path) {\n        Toast.makeText(this, \"Image saved at: \" + path, Toast.LENGTH_LONG).show();\n    }\n\n    @Override\n    public void onQuickShotFailed(String path, String errorMsg) {\n        Toast.makeText(this, errorMsg, Toast.LENGTH_LONG).show();\n    }\n\n    private void askPermissions() {\n        int requestCode = 232;\n        String[] permissions = {Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.CAMERA};\n        for (String permission : permissions) {\n            if (ContextCompat.checkSelfPermission(this, permission) != PermissionChecker.PERMISSION_GRANTED) {\n                ActivityCompat.requestPermissions(this, permissions, requestCode);\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "demo/src/main/java/io/github/muddz/quickshot/demo/NonSwipeViewPager.java",
    "content": "package io.github.muddz.quickshot.demo;\n\nimport android.content.Context;\nimport android.util.AttributeSet;\nimport android.view.MotionEvent;\n\nimport androidx.annotation.NonNull;\nimport androidx.annotation.Nullable;\nimport androidx.viewpager.widget.ViewPager;\n\npublic class NonSwipeViewPager extends ViewPager {\n\n    public NonSwipeViewPager(@NonNull Context context, @Nullable AttributeSet attrs) {\n        super(context, attrs);\n    }\n\n    @Override\n    public boolean onTouchEvent(MotionEvent ev) {\n        return false;\n    }\n\n    @Override\n    public boolean onInterceptTouchEvent(MotionEvent ev) {\n        return false;\n    }\n\n\n}\n"
  },
  {
    "path": "demo/src/main/java/io/github/muddz/quickshot/demo/ViewPagerAdapter.java",
    "content": "package io.github.muddz.quickshot.demo;\n\nimport androidx.annotation.NonNull;\nimport androidx.fragment.app.Fragment;\nimport androidx.fragment.app.FragmentManager;\nimport androidx.fragment.app.FragmentPagerAdapter;\n\nimport io.github.muddz.quickshot.demo.fragments.SurfaceViewFragment;\nimport io.github.muddz.quickshot.demo.fragments.TextureViewFragment;\nimport io.github.muddz.quickshot.demo.fragments.ViewFragment;\n\npublic class ViewPagerAdapter extends FragmentPagerAdapter {\n\n    private String[] titles = {\"View\", \"SurfaceView\", \"TextureView\"};\n    private Fragment[] fragments = {new ViewFragment(), new SurfaceViewFragment(), new TextureViewFragment()};\n\n    public ViewPagerAdapter(FragmentManager fm) {\n        super(fm);\n    }\n\n    @Override\n    public CharSequence getPageTitle(int position) {\n        return titles[position];\n    }\n\n    @NonNull\n    @Override\n    public Fragment getItem(int position) {\n        return fragments[position];\n    }\n\n    @Override\n    public int getCount() {\n        return fragments.length;\n    }\n\n\n}\n"
  },
  {
    "path": "demo/src/main/java/io/github/muddz/quickshot/demo/fragments/BaseFragment.java",
    "content": "package io.github.muddz.quickshot.demo.fragments;\n\nimport android.view.View;\n\nimport androidx.fragment.app.Fragment;\n\npublic abstract class BaseFragment extends Fragment {\n\n    /**\n     * @return The View we want to save as an image.\n     */\n    public abstract View getTargetView();\n\n}\n"
  },
  {
    "path": "demo/src/main/java/io/github/muddz/quickshot/demo/fragments/SurfaceViewFragment.java",
    "content": "package io.github.muddz.quickshot.demo.fragments;\n\nimport android.media.MediaPlayer;\nimport android.net.Uri;\nimport android.os.Bundle;\nimport android.view.LayoutInflater;\nimport android.view.SurfaceHolder;\nimport android.view.SurfaceView;\nimport android.view.View;\nimport android.view.ViewGroup;\n\nimport androidx.annotation.NonNull;\nimport androidx.annotation.Nullable;\n\nimport io.github.muddz.quickshot.demo.R;\n\n\n/**\n * Created by Muddz on 23-08-2017.\n */\n\npublic class SurfaceViewFragment extends BaseFragment implements SurfaceHolder.Callback {\n\n    private SurfaceView surfaceView;\n    private MediaPlayer mediaPlayer;\n\n    @Nullable\n    @Override\n    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {\n        View v = inflater.inflate(R.layout.surface_fragment, container, false);\n        surfaceView = v.findViewById(R.id.surfaceview);\n        surfaceView.getHolder().addCallback(this);\n        Uri uri = Uri.parse(\"android.resource://\" + getActivity().getApplicationContext().getPackageName() + \"/raw/\" + \"numbers\");\n        mediaPlayer = MediaPlayer.create(getContext(), uri);\n        return v;\n    }\n\n    @Override\n    public View getTargetView() {\n        return surfaceView;\n    }\n\n    @Override\n    public void surfaceCreated(SurfaceHolder holder) {\n        mediaPlayer.setSurface(holder.getSurface());\n        mediaPlayer.setLooping(true);\n        mediaPlayer.start();\n    }\n\n    @Override\n    public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {\n    }\n\n    @Override\n    public void surfaceDestroyed(SurfaceHolder holder) {\n    }\n}\n"
  },
  {
    "path": "demo/src/main/java/io/github/muddz/quickshot/demo/fragments/TextureViewFragment.java",
    "content": "package io.github.muddz.quickshot.demo.fragments;\n\nimport android.graphics.SurfaceTexture;\nimport android.hardware.Camera;\nimport android.os.Bundle;\nimport android.view.LayoutInflater;\nimport android.view.TextureView;\nimport android.view.View;\nimport android.view.ViewGroup;\n\nimport androidx.annotation.NonNull;\nimport androidx.annotation.Nullable;\n\nimport java.io.IOException;\nimport java.util.List;\n\nimport io.github.muddz.quickshot.demo.R;\n\n/**\n * Created by Muddz on 23-08-2017.\n */\n\npublic class TextureViewFragment extends BaseFragment implements TextureView.SurfaceTextureListener {\n\n    private Camera camera;\n    private TextureView textureView;\n\n\n    @Nullable\n    @Override\n    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {\n        View v = inflater.inflate(R.layout.texture_fragment, container, false);\n        textureView = v.findViewById(R.id.textureview);\n        textureView.setSurfaceTextureListener(this);\n        return v;\n    }\n\n    @Override\n    public View getTargetView() {\n        return textureView;\n    }\n\n\n    @Override\n    public void onSurfaceTextureAvailable(SurfaceTexture surface, int width, int height) {\n        camera = Camera.open();\n        camera.setDisplayOrientation(90);\n\n        Camera.Parameters parameters = camera.getParameters();\n        List<Camera.Size> previewSizes = parameters.getSupportedPreviewSizes();\n        Camera.Size cameraSize = getOptimalPreviewSize(previewSizes, width, height);\n\n        if (isAutoFocusSupported(camera)) {\n            parameters.setFocusMode(Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE);\n        }\n\n        parameters.setPreviewSize(cameraSize.width, cameraSize.height);\n        camera.setParameters(parameters);\n\n        try {\n            camera.setPreviewTexture(surface);\n            camera.startPreview();\n        } catch (IOException e) {\n            e.printStackTrace();\n        }\n    }\n\n    /*\n    Solution credit: https://stackoverflow.com/a/19592492/9591909\n     */\n\n\n    private boolean isAutoFocusSupported(Camera camera) {\n        if (camera != null) {\n            for (String supportedMode : camera.getParameters().getSupportedFocusModes()) {\n                if (supportedMode.equals(Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE)) {\n                    return true;\n                }\n            }\n        }\n        return false;\n    }\n\n    private Camera.Size getOptimalPreviewSize(List<Camera.Size> sizes, int w, int h) {\n        final double ASPECT_TOLERANCE = 0.1;\n        double targetRatio = (double) h / w;\n\n        if (sizes == null) return null;\n\n        Camera.Size optimalSize = null;\n        double minDiff = Double.MAX_VALUE;\n\n        for (Camera.Size size : sizes) {\n            double ratio = (double) size.width / size.height;\n            if (Math.abs(ratio - targetRatio) > ASPECT_TOLERANCE) continue;\n            if (Math.abs(size.height - h) < minDiff) {\n                optimalSize = size;\n                minDiff = Math.abs(size.height - h);\n            }\n        }\n\n        if (optimalSize == null) {\n            minDiff = Double.MAX_VALUE;\n            for (Camera.Size size : sizes) {\n                if (Math.abs(size.height - h) < minDiff) {\n                    optimalSize = size;\n                    minDiff = Math.abs(size.height - h);\n                }\n            }\n        }\n        return optimalSize;\n    }\n\n    @Override\n    public boolean onSurfaceTextureDestroyed(SurfaceTexture surface) {\n        camera.stopPreview();\n        camera.release();\n        return true;\n    }\n\n    @Override\n    public void onSurfaceTextureSizeChanged(SurfaceTexture surface, int width, int height) {\n\n    }\n\n    @Override\n    public void onSurfaceTextureUpdated(SurfaceTexture surface) {\n\n    }\n\n\n}\n"
  },
  {
    "path": "demo/src/main/java/io/github/muddz/quickshot/demo/fragments/ViewFragment.java",
    "content": "package io.github.muddz.quickshot.demo.fragments;\n\nimport android.os.Bundle;\nimport android.view.LayoutInflater;\nimport android.view.View;\nimport android.view.ViewGroup;\nimport android.widget.LinearLayout;\n\nimport androidx.annotation.NonNull;\nimport androidx.annotation.Nullable;\n\nimport io.github.muddz.quickshot.demo.DrawingBoardView;\nimport io.github.muddz.quickshot.demo.R;\n\n\n/**\n * Created by Muddz on 23-08-2017.\n */\n\npublic class ViewFragment extends BaseFragment implements DrawingBoardView.OnDrawingListener {\n\n    private DrawingBoardView drawingBoardView;\n    private LinearLayout drawHint;\n\n    @Nullable\n    @Override\n    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {\n        View v = inflater.inflate(R.layout.view_fragment, container, false);\n        drawingBoardView = v.findViewById(R.id.drawingview);\n        drawingBoardView.setOnDrawingListener(this);\n        drawHint = v.findViewById(R.id.drawhint);\n        return v;\n    }\n\n\n    @Override\n    public View getTargetView() {\n        return drawingBoardView;\n    }\n\n    @Override\n    public void onDrawingStarted() {\n        drawHint.setVisibility(View.GONE);\n    }\n}\n"
  },
  {
    "path": "demo/src/main/res/drawable/ic_launcher_background.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<vector xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    android:width=\"108dp\"\n    android:height=\"108dp\"\n    android:viewportWidth=\"108\"\n    android:viewportHeight=\"108\">\n    <path\n        android:fillColor=\"#008577\"\n        android:pathData=\"M0,0h108v108h-108z\" />\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M9,0L9,108\"\n        android:strokeWidth=\"0.8\"\n        android:strokeColor=\"#33FFFFFF\" />\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M19,0L19,108\"\n        android:strokeWidth=\"0.8\"\n        android:strokeColor=\"#33FFFFFF\" />\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M29,0L29,108\"\n        android:strokeWidth=\"0.8\"\n        android:strokeColor=\"#33FFFFFF\" />\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M39,0L39,108\"\n        android:strokeWidth=\"0.8\"\n        android:strokeColor=\"#33FFFFFF\" />\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M49,0L49,108\"\n        android:strokeWidth=\"0.8\"\n        android:strokeColor=\"#33FFFFFF\" />\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M59,0L59,108\"\n        android:strokeWidth=\"0.8\"\n        android:strokeColor=\"#33FFFFFF\" />\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M69,0L69,108\"\n        android:strokeWidth=\"0.8\"\n        android:strokeColor=\"#33FFFFFF\" />\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M79,0L79,108\"\n        android:strokeWidth=\"0.8\"\n        android:strokeColor=\"#33FFFFFF\" />\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M89,0L89,108\"\n        android:strokeWidth=\"0.8\"\n        android:strokeColor=\"#33FFFFFF\" />\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M99,0L99,108\"\n        android:strokeWidth=\"0.8\"\n        android:strokeColor=\"#33FFFFFF\" />\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M0,9L108,9\"\n        android:strokeWidth=\"0.8\"\n        android:strokeColor=\"#33FFFFFF\" />\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M0,19L108,19\"\n        android:strokeWidth=\"0.8\"\n        android:strokeColor=\"#33FFFFFF\" />\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M0,29L108,29\"\n        android:strokeWidth=\"0.8\"\n        android:strokeColor=\"#33FFFFFF\" />\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M0,39L108,39\"\n        android:strokeWidth=\"0.8\"\n        android:strokeColor=\"#33FFFFFF\" />\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M0,49L108,49\"\n        android:strokeWidth=\"0.8\"\n        android:strokeColor=\"#33FFFFFF\" />\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M0,59L108,59\"\n        android:strokeWidth=\"0.8\"\n        android:strokeColor=\"#33FFFFFF\" />\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M0,69L108,69\"\n        android:strokeWidth=\"0.8\"\n        android:strokeColor=\"#33FFFFFF\" />\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M0,79L108,79\"\n        android:strokeWidth=\"0.8\"\n        android:strokeColor=\"#33FFFFFF\" />\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M0,89L108,89\"\n        android:strokeWidth=\"0.8\"\n        android:strokeColor=\"#33FFFFFF\" />\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M0,99L108,99\"\n        android:strokeWidth=\"0.8\"\n        android:strokeColor=\"#33FFFFFF\" />\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M19,29L89,29\"\n        android:strokeWidth=\"0.8\"\n        android:strokeColor=\"#33FFFFFF\" />\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M19,39L89,39\"\n        android:strokeWidth=\"0.8\"\n        android:strokeColor=\"#33FFFFFF\" />\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M19,49L89,49\"\n        android:strokeWidth=\"0.8\"\n        android:strokeColor=\"#33FFFFFF\" />\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M19,59L89,59\"\n        android:strokeWidth=\"0.8\"\n        android:strokeColor=\"#33FFFFFF\" />\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M19,69L89,69\"\n        android:strokeWidth=\"0.8\"\n        android:strokeColor=\"#33FFFFFF\" />\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M19,79L89,79\"\n        android:strokeWidth=\"0.8\"\n        android:strokeColor=\"#33FFFFFF\" />\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M29,19L29,89\"\n        android:strokeWidth=\"0.8\"\n        android:strokeColor=\"#33FFFFFF\" />\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M39,19L39,89\"\n        android:strokeWidth=\"0.8\"\n        android:strokeColor=\"#33FFFFFF\" />\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M49,19L49,89\"\n        android:strokeWidth=\"0.8\"\n        android:strokeColor=\"#33FFFFFF\" />\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M59,19L59,89\"\n        android:strokeWidth=\"0.8\"\n        android:strokeColor=\"#33FFFFFF\" />\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M69,19L69,89\"\n        android:strokeWidth=\"0.8\"\n        android:strokeColor=\"#33FFFFFF\" />\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M79,19L79,89\"\n        android:strokeWidth=\"0.8\"\n        android:strokeColor=\"#33FFFFFF\" />\n</vector>\n"
  },
  {
    "path": "demo/src/main/res/drawable/ic_save_black_24dp.xml",
    "content": "<vector xmlns:android=\"http://schemas.android.com/apk/res/android\"\n        android:width=\"30dp\"\n        android:height=\"30dp\"\n        android:viewportWidth=\"24.0\"\n        android:viewportHeight=\"24.0\">\n    <path\n        android:fillColor=\"#FF000000\"\n        android:pathData=\"M17,3L5,3c-1.11,0 -2,0.9 -2,2v14c0,1.1 0.89,2 2,2h14c1.1,0 2,-0.9 2,-2L21,7l-4,-4zM12,19c-1.66,0 -3,-1.34 -3,-3s1.34,-3 3,-3 3,1.34 3,3 -1.34,3 -3,3zM15,9L5,9L5,5h10v4z\"/>\n</vector>\n"
  },
  {
    "path": "demo/src/main/res/drawable/ic_select.xml",
    "content": "<vector android:height=\"24dp\" android:viewportHeight=\"512\"\n    android:viewportWidth=\"512\" android:width=\"24dp\" xmlns:android=\"http://schemas.android.com/apk/res/android\">\n    <path android:fillColor=\"#FF000000\" android:pathData=\"M416,149.333c-8.768,0 -16.939,2.667 -23.723,7.211C386.432,139.947 370.581,128 352,128c-8.768,0 -16.939,2.667 -23.723,7.211c-5.845,-16.597 -21.696,-28.544 -40.277,-28.544c-7.765,0 -15.061,2.091 -21.333,5.739V42.667C266.667,19.136 247.531,0 224,0s-42.667,19.136 -42.667,42.667v249.408l-58.645,-29.333C113.856,258.325 103.957,256 94.08,256c-22.485,0 -40.747,18.283 -40.747,40.875c0,10.901 4.245,21.12 11.947,28.821l137.941,137.941C234.389,494.827 275.883,512 320,512c76.459,0 138.667,-62.208 138.667,-138.667V192C458.667,168.469 439.531,149.333 416,149.333zM437.333,373.333c0,64.704 -52.651,117.333 -117.355,117.333c-38.421,0 -74.517,-14.955 -101.653,-42.133L80.363,310.592c-3.669,-3.648 -5.696,-8.533 -5.696,-13.845c0,-10.709 8.704,-19.413 19.413,-19.413c6.592,0 13.163,1.557 19.072,4.501l74.091,37.035c3.307,1.643 7.253,1.472 10.368,-0.469c3.136,-1.941 5.056,-5.376 5.056,-9.067V42.667c0,-11.755 9.557,-21.333 21.333,-21.333s21.333,9.579 21.333,21.333v202.667c0,5.888 4.779,10.667 10.667,10.667c5.888,0 10.667,-4.779 10.667,-10.667v-96c0,-11.755 9.557,-21.333 21.333,-21.333s21.333,9.579 21.333,21.333v96c0,5.888 4.779,10.667 10.667,10.667s10.667,-4.779 10.667,-10.667v-74.667c0,-11.755 9.557,-21.333 21.333,-21.333s21.333,9.579 21.333,21.333v74.667c0,5.888 4.779,10.667 10.667,10.667c5.888,0 10.667,-4.779 10.667,-10.667V192c0,-11.755 9.557,-21.333 21.333,-21.333s21.333,9.579 21.333,21.333V373.333z\"/>\n</vector>\n"
  },
  {
    "path": "demo/src/main/res/drawable-v24/ic_launcher_foreground.xml",
    "content": "<vector xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    xmlns:aapt=\"http://schemas.android.com/aapt\"\n    android:width=\"108dp\"\n    android:height=\"108dp\"\n    android:viewportWidth=\"108\"\n    android:viewportHeight=\"108\">\n    <path\n        android:fillType=\"evenOdd\"\n        android:pathData=\"M32,64C32,64 38.39,52.99 44.13,50.95C51.37,48.37 70.14,49.57 70.14,49.57L108.26,87.69L108,109.01L75.97,107.97L32,64Z\"\n        android:strokeWidth=\"1\"\n        android:strokeColor=\"#00000000\">\n        <aapt:attr name=\"android:fillColor\">\n            <gradient\n                android:endX=\"78.5885\"\n                android:endY=\"90.9159\"\n                android:startX=\"48.7653\"\n                android:startY=\"61.0927\"\n                android:type=\"linear\">\n                <item\n                    android:color=\"#44000000\"\n                    android:offset=\"0.0\" />\n                <item\n                    android:color=\"#00000000\"\n                    android:offset=\"1.0\" />\n            </gradient>\n        </aapt:attr>\n    </path>\n    <path\n        android:fillColor=\"#FFFFFF\"\n        android:fillType=\"nonZero\"\n        android:pathData=\"M66.94,46.02L66.94,46.02C72.44,50.07 76,56.61 76,64L32,64C32,56.61 35.56,50.11 40.98,46.06L36.18,41.19C35.45,40.45 35.45,39.3 36.18,38.56C36.91,37.81 38.05,37.81 38.78,38.56L44.25,44.05C47.18,42.57 50.48,41.71 54,41.71C57.48,41.71 60.78,42.57 63.68,44.05L69.11,38.56C69.84,37.81 70.98,37.81 71.71,38.56C72.44,39.3 72.44,40.45 71.71,41.19L66.94,46.02ZM62.94,56.92C64.08,56.92 65,56.01 65,54.88C65,53.76 64.08,52.85 62.94,52.85C61.8,52.85 60.88,53.76 60.88,54.88C60.88,56.01 61.8,56.92 62.94,56.92ZM45.06,56.92C46.2,56.92 47.13,56.01 47.13,54.88C47.13,53.76 46.2,52.85 45.06,52.85C43.92,52.85 43,53.76 43,54.88C43,56.01 43.92,56.92 45.06,56.92Z\"\n        android:strokeWidth=\"1\"\n        android:strokeColor=\"#00000000\" />\n</vector>\n"
  },
  {
    "path": "demo/src/main/res/layout/activity_main.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<RelativeLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    xmlns:app=\"http://schemas.android.com/apk/res-auto\"\n    android:layout_width=\"match_parent\"\n    android:layout_height=\"match_parent\">\n\n    <androidx.appcompat.widget.Toolbar\n        android:id=\"@+id/toolbar\"\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"wrap_content\"\n        android:layout_alignParentTop=\"true\"\n        app:title=\"@string/app_name\" />\n\n    <com.google.android.material.tabs.TabLayout\n        android:id=\"@+id/tablayout\"\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"wrap_content\"\n        android:layout_alignParentBottom=\"true\"\n        android:background=\"#f4f3f3\"\n        app:tabMode=\"fixed\" />\n\n    <com.muddzdev.quickshot.demo.NonSwipeViewPager\n        android:id=\"@+id/viewpager\"\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"match_parent\"\n        android:layout_above=\"@id/tablayout\"\n        android:layout_below=\"@id/toolbar\" />\n\n</RelativeLayout>\n"
  },
  {
    "path": "demo/src/main/res/layout/surface_fragment.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<LinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    android:layout_width=\"match_parent\"\n    android:layout_height=\"match_parent\"\n    android:orientation=\"vertical\">\n\n    <SurfaceView\n        android:id=\"@+id/surfaceview\"\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"match_parent\"/>\n\n\n</LinearLayout>"
  },
  {
    "path": "demo/src/main/res/layout/texture_fragment.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<FrameLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    android:layout_width=\"match_parent\"\n    android:layout_height=\"match_parent\">\n\n    <TextureView\n        android:id=\"@+id/textureview\"\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"match_parent\"/>\n\n</FrameLayout>"
  },
  {
    "path": "demo/src/main/res/layout/view_fragment.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<FrameLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    android:layout_width=\"match_parent\"\n    android:layout_height=\"match_parent\">\n\n    <com.muddzdev.quickshot.demo.DrawingBoardView\n        android:id=\"@+id/drawingview\"\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"match_parent\"\n        android:background=\"#ffe522\" />\n\n    <LinearLayout\n        android:id=\"@+id/drawhint\"\n        android:layout_width=\"wrap_content\"\n        android:layout_height=\"wrap_content\"\n        android:layout_gravity=\"center\"\n        android:gravity=\"center\"\n        android:orientation=\"vertical\">\n\n        <ImageView\n            android:layout_width=\"wrap_content\"\n            android:layout_height=\"wrap_content\"\n            android:minHeight=\"30dp\"\n            android:minWidth=\"30dp\"\n            android:src=\"@drawable/ic_select\" />\n\n        <TextView\n            android:layout_width=\"wrap_content\"\n            android:layout_height=\"wrap_content\"\n            android:text=\"Draw on the screen\"\n            android:textColor=\"#000\"\n            android:textSize=\"18sp\" />\n    </LinearLayout>\n\n</FrameLayout>"
  },
  {
    "path": "demo/src/main/res/menu/menu_toolbar.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<menu xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    xmlns:app=\"http://schemas.android.com/apk/res-auto\">\n\n    <item\n        android:id=\"@+id/menu_jpg\"\n        android:title=\"JPG\"\n        app:showAsAction=\"collapseActionView\" />\n    <item\n        android:id=\"@+id/menu_pgn\"\n        android:title=\"PNG\"\n        app:showAsAction=\"collapseActionView\" />\n    <item\n        android:id=\"@+id/menu_nomedia\"\n        android:title=\"NOMEDIA\"\n        app:showAsAction=\"collapseActionView\" />\n</menu>"
  },
  {
    "path": "demo/src/main/res/mipmap-anydpi-v26/ic_launcher.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<adaptive-icon xmlns:android=\"http://schemas.android.com/apk/res/android\">\n    <background android:drawable=\"@drawable/ic_launcher_background\" />\n    <foreground android:drawable=\"@drawable/ic_launcher_foreground\" />\n</adaptive-icon>"
  },
  {
    "path": "demo/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<adaptive-icon xmlns:android=\"http://schemas.android.com/apk/res/android\">\n    <background android:drawable=\"@drawable/ic_launcher_background\" />\n    <foreground android:drawable=\"@drawable/ic_launcher_foreground\" />\n</adaptive-icon>"
  },
  {
    "path": "demo/src/main/res/values/colors.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<resources>\n    <color name=\"colorPrimary\">#3F51B5</color>\n    <color name=\"colorPrimaryDark\">#303F9F</color>\n    <color name=\"colorAccent\">#8f8f8f</color>\n</resources>\n"
  },
  {
    "path": "demo/src/main/res/values/strings.xml",
    "content": "<resources>\n    <string name=\"app_name\">QuickShot demo</string>\n</resources>\n"
  },
  {
    "path": "demo/src/main/res/values/styles.xml",
    "content": "<resources>\n\n    <!-- Base application theme. -->\n    <style name=\"AppTheme\" parent=\"Theme.AppCompat.Light.NoActionBar\">\n        <!-- Customize your theme here. -->\n        <item name=\"colorPrimary\">@color/colorPrimary</item>\n        <item name=\"colorPrimaryDark\">@color/colorPrimaryDark</item>\n        <item name=\"colorAccent\">@color/colorAccent</item>\n    </style>\n\n</resources>\n"
  },
  {
    "path": "gradle/wrapper/gradle-wrapper.properties",
    "content": "#Sun Aug 01 22:32:07 CEST 2021\ndistributionBase=GRADLE_USER_HOME\ndistributionUrl=https\\://services.gradle.org/distributions/gradle-7.0.2-bin.zip\ndistributionPath=wrapper/dists\nzipStorePath=wrapper/dists\nzipStoreBase=GRADLE_USER_HOME\n"
  },
  {
    "path": "gradle.properties",
    "content": "android.enableJetifier=true\nandroid.useAndroidX=true\n\n#MavenCentral publish informations\n#Publish plugin: https://github.com/vanniktech/gradle-maven-publish-plugin\nGROUP=io.github.muddz\nPOM_ARTIFACT_ID=quickshot\nVERSION_NAME=1.4.0\n\nPOM_NAME=quickshot\nPOM_DESCRIPTION=Capture images of any View, SurfaceView or Bitmap from your Android app in: .jpg .png or .nomedia with simple oneliner codes.\nPOM_INCEPTION_YEAR=2021\nPOM_URL=https://github.com/Muddz/QuickShot\n\nPOM_LICENSE_NAME=The Apache Software License, Version 2.0\nPOM_LICENSE_URL=https://www.apache.org/licenses/LICENSE-2.0.txt\nPOM_LICENSE_DIST=repo\n\nPOM_SCM_URL=https://github.com/Muddz/Quickshot\nPOM_SCM_CONNECTION=scm:git:git://github.com/Muddz/Quickshot.git\nPOM_SCM_DEV_CONNECTION=scm:git:ssh://git@github.com/Muddz/Quickshot.git\n\nPOM_DEVELOPER_ID=Muddz\nPOM_DEVELOPER_NAME=Muddi Walid"
  },
  {
    "path": "gradlew",
    "content": "#!/usr/bin/env sh\n\n#\n# Copyright 2015 the original author or authors.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#      https://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n#\n\n##############################################################################\n##\n##  Gradle start up script for UN*X\n##\n##############################################################################\n\n# Attempt to set APP_HOME\n# Resolve links: $0 may be a link\nPRG=\"$0\"\n# Need this for relative symlinks.\nwhile [ -h \"$PRG\" ] ; do\n    ls=`ls -ld \"$PRG\"`\n    link=`expr \"$ls\" : '.*-> \\(.*\\)$'`\n    if expr \"$link\" : '/.*' > /dev/null; then\n        PRG=\"$link\"\n    else\n        PRG=`dirname \"$PRG\"`\"/$link\"\n    fi\ndone\nSAVED=\"`pwd`\"\ncd \"`dirname \\\"$PRG\\\"`/\" >/dev/null\nAPP_HOME=\"`pwd -P`\"\ncd \"$SAVED\" >/dev/null\n\nAPP_NAME=\"Gradle\"\nAPP_BASE_NAME=`basename \"$0\"`\n\n# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.\nDEFAULT_JVM_OPTS='\"-Xmx64m\" \"-Xms64m\"'\n\n# Use the maximum available, or set MAX_FD != -1 to use that value.\nMAX_FD=\"maximum\"\n\nwarn () {\n    echo \"$*\"\n}\n\ndie () {\n    echo\n    echo \"$*\"\n    echo\n    exit 1\n}\n\n# OS specific support (must be 'true' or 'false').\ncygwin=false\nmsys=false\ndarwin=false\nnonstop=false\ncase \"`uname`\" in\n  CYGWIN* )\n    cygwin=true\n    ;;\n  Darwin* )\n    darwin=true\n    ;;\n  MINGW* )\n    msys=true\n    ;;\n  NONSTOP* )\n    nonstop=true\n    ;;\nesac\n\nCLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar\n\n\n# Determine the Java command to use to start the JVM.\nif [ -n \"$JAVA_HOME\" ] ; then\n    if [ -x \"$JAVA_HOME/jre/sh/java\" ] ; then\n        # IBM's JDK on AIX uses strange locations for the executables\n        JAVACMD=\"$JAVA_HOME/jre/sh/java\"\n    else\n        JAVACMD=\"$JAVA_HOME/bin/java\"\n    fi\n    if [ ! -x \"$JAVACMD\" ] ; then\n        die \"ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME\n\nPlease set the JAVA_HOME variable in your environment to match the\nlocation of your Java installation.\"\n    fi\nelse\n    JAVACMD=\"java\"\n    which java >/dev/null 2>&1 || die \"ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.\n\nPlease set the JAVA_HOME variable in your environment to match the\nlocation of your Java installation.\"\nfi\n\n# Increase the maximum file descriptors if we can.\nif [ \"$cygwin\" = \"false\" -a \"$darwin\" = \"false\" -a \"$nonstop\" = \"false\" ] ; then\n    MAX_FD_LIMIT=`ulimit -H -n`\n    if [ $? -eq 0 ] ; then\n        if [ \"$MAX_FD\" = \"maximum\" -o \"$MAX_FD\" = \"max\" ] ; then\n            MAX_FD=\"$MAX_FD_LIMIT\"\n        fi\n        ulimit -n $MAX_FD\n        if [ $? -ne 0 ] ; then\n            warn \"Could not set maximum file descriptor limit: $MAX_FD\"\n        fi\n    else\n        warn \"Could not query maximum file descriptor limit: $MAX_FD_LIMIT\"\n    fi\nfi\n\n# For Darwin, add options to specify how the application appears in the dock\nif $darwin; then\n    GRADLE_OPTS=\"$GRADLE_OPTS \\\"-Xdock:name=$APP_NAME\\\" \\\"-Xdock:icon=$APP_HOME/media/gradle.icns\\\"\"\nfi\n\n# For Cygwin or MSYS, switch paths to Windows format before running java\nif [ \"$cygwin\" = \"true\" -o \"$msys\" = \"true\" ] ; then\n    APP_HOME=`cygpath --path --mixed \"$APP_HOME\"`\n    CLASSPATH=`cygpath --path --mixed \"$CLASSPATH\"`\n\n    JAVACMD=`cygpath --unix \"$JAVACMD\"`\n\n    # We build the pattern for arguments to be converted via cygpath\n    ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`\n    SEP=\"\"\n    for dir in $ROOTDIRSRAW ; do\n        ROOTDIRS=\"$ROOTDIRS$SEP$dir\"\n        SEP=\"|\"\n    done\n    OURCYGPATTERN=\"(^($ROOTDIRS))\"\n    # Add a user-defined pattern to the cygpath arguments\n    if [ \"$GRADLE_CYGPATTERN\" != \"\" ] ; then\n        OURCYGPATTERN=\"$OURCYGPATTERN|($GRADLE_CYGPATTERN)\"\n    fi\n    # Now convert the arguments - kludge to limit ourselves to /bin/sh\n    i=0\n    for arg in \"$@\" ; do\n        CHECK=`echo \"$arg\"|egrep -c \"$OURCYGPATTERN\" -`\n        CHECK2=`echo \"$arg\"|egrep -c \"^-\"`                                 ### Determine if an option\n\n        if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then                    ### Added a condition\n            eval `echo args$i`=`cygpath --path --ignore --mixed \"$arg\"`\n        else\n            eval `echo args$i`=\"\\\"$arg\\\"\"\n        fi\n        i=`expr $i + 1`\n    done\n    case $i in\n        0) set -- ;;\n        1) set -- \"$args0\" ;;\n        2) set -- \"$args0\" \"$args1\" ;;\n        3) set -- \"$args0\" \"$args1\" \"$args2\" ;;\n        4) set -- \"$args0\" \"$args1\" \"$args2\" \"$args3\" ;;\n        5) set -- \"$args0\" \"$args1\" \"$args2\" \"$args3\" \"$args4\" ;;\n        6) set -- \"$args0\" \"$args1\" \"$args2\" \"$args3\" \"$args4\" \"$args5\" ;;\n        7) set -- \"$args0\" \"$args1\" \"$args2\" \"$args3\" \"$args4\" \"$args5\" \"$args6\" ;;\n        8) set -- \"$args0\" \"$args1\" \"$args2\" \"$args3\" \"$args4\" \"$args5\" \"$args6\" \"$args7\" ;;\n        9) set -- \"$args0\" \"$args1\" \"$args2\" \"$args3\" \"$args4\" \"$args5\" \"$args6\" \"$args7\" \"$args8\" ;;\n    esac\nfi\n\n# Escape application args\nsave () {\n    for i do printf %s\\\\n \"$i\" | sed \"s/'/'\\\\\\\\''/g;1s/^/'/;\\$s/\\$/' \\\\\\\\/\" ; done\n    echo \" \"\n}\nAPP_ARGS=`save \"$@\"`\n\n# Collect all arguments for the java command, following the shell quoting and substitution rules\neval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS \"\\\"-Dorg.gradle.appname=$APP_BASE_NAME\\\"\" -classpath \"\\\"$CLASSPATH\\\"\" org.gradle.wrapper.GradleWrapperMain \"$APP_ARGS\"\n\nexec \"$JAVACMD\" \"$@\"\n"
  },
  {
    "path": "gradlew.bat",
    "content": "@rem\n@rem Copyright 2015 the original author or authors.\n@rem\n@rem Licensed under the Apache License, Version 2.0 (the \"License\");\n@rem you may not use this file except in compliance with the License.\n@rem You may obtain a copy of the License at\n@rem\n@rem      https://www.apache.org/licenses/LICENSE-2.0\n@rem\n@rem Unless required by applicable law or agreed to in writing, software\n@rem distributed under the License is distributed on an \"AS IS\" BASIS,\n@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n@rem See the License for the specific language governing permissions and\n@rem limitations under the License.\n@rem\n\n@if \"%DEBUG%\" == \"\" @echo off\n@rem ##########################################################################\n@rem\n@rem  Gradle startup script for Windows\n@rem\n@rem ##########################################################################\n\n@rem Set local scope for the variables with windows NT shell\nif \"%OS%\"==\"Windows_NT\" setlocal\n\nset DIRNAME=%~dp0\nif \"%DIRNAME%\" == \"\" set DIRNAME=.\nset APP_BASE_NAME=%~n0\nset APP_HOME=%DIRNAME%\n\n@rem Resolve any \".\" and \"..\" in APP_HOME to make it shorter.\nfor %%i in (\"%APP_HOME%\") do set APP_HOME=%%~fi\n\n@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.\nset DEFAULT_JVM_OPTS=\"-Xmx64m\" \"-Xms64m\"\n\n@rem Find java.exe\nif defined JAVA_HOME goto findJavaFromJavaHome\n\nset JAVA_EXE=java.exe\n%JAVA_EXE% -version >NUL 2>&1\nif \"%ERRORLEVEL%\" == \"0\" goto execute\n\necho.\necho ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.\necho.\necho Please set the JAVA_HOME variable in your environment to match the\necho location of your Java installation.\n\ngoto fail\n\n:findJavaFromJavaHome\nset JAVA_HOME=%JAVA_HOME:\"=%\nset JAVA_EXE=%JAVA_HOME%/bin/java.exe\n\nif exist \"%JAVA_EXE%\" goto execute\n\necho.\necho ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%\necho.\necho Please set the JAVA_HOME variable in your environment to match the\necho location of your Java installation.\n\ngoto fail\n\n:execute\n@rem Setup the command line\n\nset CLASSPATH=%APP_HOME%\\gradle\\wrapper\\gradle-wrapper.jar\n\n\n@rem Execute Gradle\n\"%JAVA_EXE%\" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% \"-Dorg.gradle.appname=%APP_BASE_NAME%\" -classpath \"%CLASSPATH%\" org.gradle.wrapper.GradleWrapperMain %*\n\n:end\n@rem End local scope for the variables with windows NT shell\nif \"%ERRORLEVEL%\"==\"0\" goto mainEnd\n\n:fail\nrem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of\nrem the _cmd.exe /c_ return code!\nif  not \"\" == \"%GRADLE_EXIT_CONSOLE%\" exit 1\nexit /b 1\n\n:mainEnd\nif \"%OS%\"==\"Windows_NT\" endlocal\n\n:omega\n"
  },
  {
    "path": "license",
    "content": "                                 Apache License\n                           Version 2.0, January 2004\n                        http://www.apache.org/licenses/\n\n   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\n\n   1. Definitions.\n\n      \"License\" shall mean the terms and conditions for use, reproduction,\n      and distribution as defined by Sections 1 through 9 of this document.\n\n      \"Licensor\" shall mean the copyright owner or entity authorized by\n      the copyright owner that is granting the License.\n\n      \"Legal Entity\" shall mean the union of the acting entity and all\n      other entities that control, are controlled by, or are under common\n      control with that entity. For the purposes of this definition,\n      \"control\" means (i) the power, direct or indirect, to cause the\n      direction or management of such entity, whether by contract or\n      otherwise, or (ii) ownership of fifty percent (50%) or more of the\n      outstanding shares, or (iii) beneficial ownership of such entity.\n\n      \"You\" (or \"Your\") shall mean an individual or Legal Entity\n      exercising permissions granted by this License.\n\n      \"Source\" form shall mean the preferred form for making modifications,\n      including but not limited to software source code, documentation\n      source, and configuration files.\n\n      \"Object\" form shall mean any form resulting from mechanical\n      transformation or translation of a Source form, including but\n      not limited to compiled object code, generated documentation,\n      and conversions to other media types.\n\n      \"Work\" shall mean the work of authorship, whether in Source or\n      Object form, made available under the License, as indicated by a\n      copyright notice that is included in or attached to the work\n      (an example is provided in the Appendix below).\n\n      \"Derivative Works\" shall mean any work, whether in Source or Object\n      form, that is based on (or derived from) the Work and for which the\n      editorial revisions, annotations, elaborations, or other modifications\n      represent, as a whole, an original work of authorship. For the purposes\n      of this License, Derivative Works shall not include works that remain\n      separable from, or merely link (or bind by name) to the interfaces of,\n      the Work and Derivative Works thereof.\n\n      \"Contribution\" shall mean any work of authorship, including\n      the original version of the Work and any modifications or additions\n      to that Work or Derivative Works thereof, that is intentionally\n      submitted to Licensor for inclusion in the Work by the copyright owner\n      or by an individual or Legal Entity authorized to submit on behalf of\n      the copyright owner. For the purposes of this definition, \"submitted\"\n      means any form of electronic, verbal, or written communication sent\n      to the Licensor or its representatives, including but not limited to\n      communication on electronic mailing lists, source code control systems,\n      and issue tracking systems that are managed by, or on behalf of, the\n      Licensor for the purpose of discussing and improving the Work, but\n      excluding communication that is conspicuously marked or otherwise\n      designated in writing by the copyright owner as \"Not a Contribution.\"\n\n      \"Contributor\" shall mean Licensor and any individual or Legal Entity\n      on behalf of whom a Contribution has been received by Licensor and\n      subsequently incorporated within the Work.\n\n   2. Grant of Copyright License. Subject to the terms and conditions of\n      this License, each Contributor hereby grants to You a perpetual,\n      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n      copyright license to reproduce, prepare Derivative Works of,\n      publicly display, publicly perform, sublicense, and distribute the\n      Work and such Derivative Works in Source or Object form.\n\n   3. Grant of Patent License. Subject to the terms and conditions of\n      this License, each Contributor hereby grants to You a perpetual,\n      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n      (except as stated in this section) patent license to make, have made,\n      use, offer to sell, sell, import, and otherwise transfer the Work,\n      where such license applies only to those patent claims licensable\n      by such Contributor that are necessarily infringed by their\n      Contribution(s) alone or by combination of their Contribution(s)\n      with the Work to which such Contribution(s) was submitted. If You\n      institute patent litigation against any entity (including a\n      cross-claim or counterclaim in a lawsuit) alleging that the Work\n      or a Contribution incorporated within the Work constitutes direct\n      or contributory patent infringement, then any patent licenses\n      granted to You under this License for that Work shall terminate\n      as of the date such litigation is filed.\n\n   4. Redistribution. You may reproduce and distribute copies of the\n      Work or Derivative Works thereof in any medium, with or without\n      modifications, and in Source or Object form, provided that You\n      meet the following conditions:\n\n      (a) You must give any other recipients of the Work or\n          Derivative Works a copy of this License; and\n\n      (b) You must cause any modified files to carry prominent notices\n          stating that You changed the files; and\n\n      (c) You must retain, in the Source form of any Derivative Works\n          that You distribute, all copyright, patent, trademark, and\n          attribution notices from the Source form of the Work,\n          excluding those notices that do not pertain to any part of\n          the Derivative Works; and\n\n      (d) If the Work includes a \"NOTICE\" text file as part of its\n          distribution, then any Derivative Works that You distribute must\n          include a readable copy of the attribution notices contained\n          within such NOTICE file, excluding those notices that do not\n          pertain to any part of the Derivative Works, in at least one\n          of the following places: within a NOTICE text file distributed\n          as part of the Derivative Works; within the Source form or\n          documentation, if provided along with the Derivative Works; or,\n          within a display generated by the Derivative Works, if and\n          wherever such third-party notices normally appear. The contents\n          of the NOTICE file are for informational purposes only and\n          do not modify the License. You may add Your own attribution\n          notices within Derivative Works that You distribute, alongside\n          or as an addendum to the NOTICE text from the Work, provided\n          that such additional attribution notices cannot be construed\n          as modifying the License.\n\n      You may add Your own copyright statement to Your modifications and\n      may provide additional or different license terms and conditions\n      for use, reproduction, or distribution of Your modifications, or\n      for any such Derivative Works as a whole, provided Your use,\n      reproduction, and distribution of the Work otherwise complies with\n      the conditions stated in this License.\n\n   5. Submission of Contributions. Unless You explicitly state otherwise,\n      any Contribution intentionally submitted for inclusion in the Work\n      by You to the Licensor shall be under the terms and conditions of\n      this License, without any additional terms or conditions.\n      Notwithstanding the above, nothing herein shall supersede or modify\n      the terms of any separate license agreement you may have executed\n      with Licensor regarding such Contributions.\n\n   6. Trademarks. This License does not grant permission to use the trade\n      names, trademarks, service marks, or product names of the Licensor,\n      except as required for reasonable and customary use in describing the\n      origin of the Work and reproducing the content of the NOTICE file.\n\n   7. Disclaimer of Warranty. Unless required by applicable law or\n      agreed to in writing, Licensor provides the Work (and each\n      Contributor provides its Contributions) on an \"AS IS\" BASIS,\n      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\n      implied, including, without limitation, any warranties or conditions\n      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A\n      PARTICULAR PURPOSE. You are solely responsible for determining the\n      appropriateness of using or redistributing the Work and assume any\n      risks associated with Your exercise of permissions under this License.\n\n   8. Limitation of Liability. In no event and under no legal theory,\n      whether in tort (including negligence), contract, or otherwise,\n      unless required by applicable law (such as deliberate and grossly\n      negligent acts) or agreed to in writing, shall any Contributor be\n      liable to You for damages, including any direct, indirect, special,\n      incidental, or consequential damages of any character arising as a\n      result of this License or out of the use or inability to use the\n      Work (including but not limited to damages for loss of goodwill,\n      work stoppage, computer failure or malfunction, or any and all\n      other commercial damages or losses), even if such Contributor\n      has been advised of the possibility of such damages.\n\n   9. Accepting Warranty or Additional Liability. While redistributing\n      the Work or Derivative Works thereof, You may choose to offer,\n      and charge a fee for, acceptance of support, warranty, indemnity,\n      or other liability obligations and/or rights consistent with this\n      License. However, in accepting such obligations, You may act only\n      on Your own behalf and on Your sole responsibility, not on behalf\n      of any other Contributor, and only if You agree to indemnify,\n      defend, and hold each Contributor harmless for any liability\n      incurred by, or claims asserted against, such Contributor by reason\n      of your accepting any such warranty or additional liability.\n\n   END OF TERMS AND CONDITIONS\n\n   Copyright 2018 Muddi Walid.\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n       http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n"
  },
  {
    "path": "quickshot/.gitignore",
    "content": "/build\n"
  },
  {
    "path": "quickshot/build.gradle",
    "content": "plugins {\n    id 'com.android.library'\n    id 'com.vanniktech.maven.publish'\n}\nandroid {\n    compileSdk 30\n\n    defaultConfig {\n        minSdk 19\n        targetSdk 30\n    }\n\n    buildTypes {\n        release {\n            minifyEnabled false\n            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'\n        }\n    }\n}\n\ndependencies {\n    implementation 'androidx.appcompat:appcompat:1.3.1'\n    implementation 'com.google.android.material:material:1.4.0'\n    androidTestImplementation 'androidx.test:runner:1.4.0'\n    androidTestImplementation 'androidx.test:rules:1.4.0'\n}\n"
  },
  {
    "path": "quickshot/consumer-rules.pro",
    "content": ""
  },
  {
    "path": "quickshot/proguard-rules.pro",
    "content": "# Add project specific ProGuard rules here.\n# You can control the set of applied configuration files using the\n# proguardFiles setting in build.gradle.\n#\n# For more details, see\n#   http://developer.android.com/guide/developing/tools/proguard.html\n\n# If your project uses WebView with JS, uncomment the following\n# and specify the fully qualified class name to the JavaScript interface\n# class:\n#-keepclassmembers class fqcn.of.javascript.interface.for.webview {\n#   public *;\n#}\n\n# Uncomment this to preserve the line number information for\n# debugging stack traces.\n#-keepattributes SourceFile,LineNumberTable\n\n# If you keep the line number information, uncomment this to\n# hide the original source file name.\n#-renamesourcefileattribute SourceFile\n"
  },
  {
    "path": "quickshot/src/androidTest/java/io/github/muddz/quickshot/QuickShotTest.java",
    "content": "package io.github.muddz.quickshot;\n\nimport static android.view.View.MeasureSpec.EXACTLY;\n\nimport android.content.Context;\nimport android.graphics.Color;\nimport android.view.View;\n\nimport androidx.test.InstrumentationRegistry;\nimport androidx.test.runner.AndroidJUnit4;\n\nimport org.junit.Assert;\nimport org.junit.Before;\nimport org.junit.Test;\nimport org.junit.runner.RunWith;\n\nimport java.io.File;\n\n\n@RunWith(AndroidJUnit4.class)\npublic class QuickShotTest {\n\n    private Context context;\n    private View testView;\n\n    @Before\n    public void setup() {\n        testView = generateTestView();\n        context = androidx.test.platform.app.InstrumentationRegistry.getInstrumentation().getContext();\n    }\n\n\n    @Test\n    public void testCallbackPathNotNull() {\n        QuickShot.of(testView).setResultListener(new QuickShot.QuickShotListener() {\n            @Override\n            public void onQuickShotSuccess(String path) {\n                Assert.assertNotNull(path);\n            }\n\n            @Override\n            public void onQuickShotFailed(String path, String errorMsg) {\n\n            }\n        }).save();\n        sleepThread();\n    }\n\n\n    @Test\n    public void testIfSavedInJPG() {\n        QuickShot.of(testView).setResultListener(new QuickShot.QuickShotListener() {\n            @Override\n            public void onQuickShotSuccess(String path) {\n                Assert.assertTrue(path.contains(\".jpg\"));\n            }\n\n            @Override\n            public void onQuickShotFailed(String path, String errorMsg) {\n\n            }\n\n        }).save();\n        sleepThread();\n    }\n\n    @Test\n    public void testIfSavedInPNG() {\n        QuickShot.of(testView).toPNG().setResultListener(new QuickShot.QuickShotListener() {\n            @Override\n            public void onQuickShotSuccess(String path) {\n                Assert.assertTrue(path.contains(\".png\"));\n            }\n\n            @Override\n            public void onQuickShotFailed(String path, String errorMsg) {\n\n            }\n        }).save();\n        sleepThread();\n    }\n\n    @Test\n    public void testIfSavedInNomedia() {\n        QuickShot.of(testView).toNomedia().setResultListener(new QuickShot.QuickShotListener() {\n            @Override\n            public void onQuickShotSuccess(String path) {\n                Assert.assertTrue(path.contains(\".nomedia\"));\n            }\n\n            @Override\n            public void onQuickShotFailed(String path, String errorMsg) {\n\n            }\n        }).save();\n        sleepThread();\n    }\n\n\n    @Test\n    public void testIfDirectoryWasCreated() {\n        QuickShot.of(testView).setPath(\"QuickShotTestDirectory\").setResultListener(new QuickShot.QuickShotListener() {\n            @Override\n            public void onQuickShotSuccess(String path) {\n                if (QuickShotUtils.isAboveAPI29()) {\n                    Assert.assertTrue(path.contains(\"QuickShotTestDirectory\"));\n                } else {\n                    File file = new File(path);\n                    File directory = new File(file.getParent());\n                    boolean isDirectory = directory.exists() && directory.isDirectory();\n                    Assert.assertTrue(isDirectory);\n                }\n            }\n\n            @Override\n            public void onQuickShotFailed(String path, String errorMsg) {\n\n            }\n        }).save();\n        sleepThread();\n    }\n\n\n    @Test\n    public void testIfFileExist() {\n        QuickShot.of(testView).setPath(\"QuickShotTestDirectory\").setResultListener(new QuickShot.QuickShotListener() {\n            @Override\n            public void onQuickShotSuccess(String path) {\n                if (QuickShotUtils.isAboveAPI29()) {\n                    Assert.assertTrue(path != null && path.length() > 0);\n                } else {\n                    File file = new File(path);\n                    Assert.assertTrue(file.exists());\n                }\n            }\n\n            @Override\n            public void onQuickShotFailed(String path, String errorMsg) {\n\n            }\n        }).save();\n        sleepThread();\n    }\n\n    private View generateTestView() {\n        int width = 950;\n        int height = 950;\n\n        int widthMS = View.MeasureSpec.makeMeasureSpec(width, EXACTLY);\n        int heightMS = View.MeasureSpec.makeMeasureSpec(height, EXACTLY);\n\n        View view = new View(InstrumentationRegistry.getTargetContext());\n        view.measure(widthMS, heightMS);\n        view.layout(0, 0, view.getMeasuredWidth(), view.getMeasuredHeight());\n        view.setBackgroundColor(Color.GRAY);\n\n        return view;\n    }\n\n    private void sleepThread() {\n        try {\n            Thread.sleep(1500);\n        } catch (InterruptedException e) {\n            e.printStackTrace();\n        }\n    }\n}\n"
  },
  {
    "path": "quickshot/src/main/AndroidManifest.xml",
    "content": "<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    package=\"io.github.muddz.quickshot\">\n\n    <!--The permission must be added here for Instrumental tests purposes-->\n    <uses-permission android:name=\"android.permission.WRITE_EXTERNAL_STORAGE\" />\n</manifest>\n"
  },
  {
    "path": "quickshot/src/main/java/io/github/muddz/quickshot/PixelCopyHelper.java",
    "content": "package io.github.muddz.quickshot;\n\nimport android.graphics.Bitmap;\nimport android.os.Build;\nimport android.os.Handler;\nimport android.os.HandlerThread;\nimport android.view.PixelCopy;\nimport android.view.SurfaceView;\n\nimport androidx.annotation.NonNull;\n\nclass PixelCopyHelper {\n\n    static void getSurfaceBitmap(@NonNull SurfaceView surfaceView, @NonNull final PixelCopyListener listener) {\n        final Bitmap bitmap = Bitmap.createBitmap(surfaceView.getWidth(), surfaceView.getHeight(), Bitmap.Config.ARGB_8888);\n        final HandlerThread handlerThread = new HandlerThread(PixelCopyHelper.class.getSimpleName());\n        handlerThread.start();\n\n        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {\n            PixelCopy.request(surfaceView, bitmap, new PixelCopy.OnPixelCopyFinishedListener() {\n                @Override\n                public void onPixelCopyFinished(int copyResult) {\n                    if (copyResult == PixelCopy.SUCCESS) {\n                        listener.onSurfaceBitmapReady(bitmap);\n                    } else {\n                        listener.onSurfaceBitmapError(\"Couldn't create bitmap of the SurfaceView\");\n                    }\n                    handlerThread.quitSafely();\n                }\n            }, new Handler(handlerThread.getLooper()));\n        } else {\n            listener.onSurfaceBitmapError(\"Saving an image of a SurfaceView is only supported for API 24 and above\");\n        }\n    }\n\n    interface PixelCopyListener {\n        void onSurfaceBitmapReady(Bitmap bitmap);\n\n        void onSurfaceBitmapError(String errorMsg);\n    }\n}\n"
  },
  {
    "path": "quickshot/src/main/java/io/github/muddz/quickshot/QuickShot.java",
    "content": "package io.github.muddz.quickshot;\n\nimport android.content.ContentResolver;\nimport android.content.ContentValues;\nimport android.content.Context;\nimport android.graphics.Bitmap;\nimport android.graphics.Canvas;\nimport android.media.MediaScannerConnection;\nimport android.net.Uri;\nimport android.os.AsyncTask;\nimport android.os.Build;\nimport android.os.Environment;\nimport android.os.Handler;\nimport android.os.Looper;\nimport android.provider.MediaStore;\nimport android.util.Log;\nimport android.view.SurfaceView;\nimport android.view.TextureView;\nimport android.view.View;\n\nimport androidx.annotation.NonNull;\nimport androidx.annotation.RequiresApi;\n\nimport java.io.BufferedOutputStream;\nimport java.io.File;\nimport java.io.FileOutputStream;\nimport java.io.OutputStream;\nimport java.lang.ref.WeakReference;\n\nimport static android.os.Environment.DIRECTORY_PICTURES;\n\npublic class QuickShot {\n\n    private static final String EXTENSION_JPG = \".jpg\";\n    private static final String EXTENSION_PNG = \".png\";\n    private static final String EXTENSION_NOMEDIA = \".nomedia\";\n    private static final int JPG_MAX_QUALITY = 100;\n\n    private boolean printStackTrace;\n    private int jpgQuality = JPG_MAX_QUALITY;\n    private String fileExtension = EXTENSION_JPG;\n    private String filename = String.valueOf(System.currentTimeMillis());\n    private String path;\n    private Bitmap bitmap;\n    private View view;\n    private Context context;\n    private QuickShotListener listener;\n\n\n    private QuickShot(@NonNull View view) {\n        this.view = view;\n        this.context = view.getContext();\n    }\n\n    private QuickShot(@NonNull Bitmap bitmap, @NonNull Context context) {\n        this.bitmap = bitmap;\n        this.context = context;\n    }\n\n    public static QuickShot of(@NonNull View view) {\n        return new QuickShot(view);\n    }\n\n    public static QuickShot of(@NonNull Bitmap bitmap, @NonNull Context context) {\n        return new QuickShot(bitmap, context);\n    }\n\n    /**\n     * @param filename if not set, filename defaults to a timestamp from {@link System#currentTimeMillis}\n     */\n    public QuickShot setFilename(String filename) {\n        this.filename = filename;\n        return this;\n    }\n\n    /**\n     * <i>NOTE: For devices running Android 10 (+API 29) and above image files will now be saved relative to /Internal storage/Pictures/ due to 'Scoped storage'</i><br><br>\n     * <p>Directories which don't already exist will be automatically created.</p>\n     *\n     * @param path if not set, path defaults to /Pictures/ regardless of any API level\n     */\n    public QuickShot setPath(String path) {\n        this.path = path;\n        return this;\n    }\n\n    private void setFileExtension(String fileExtension) {\n        this.fileExtension = fileExtension;\n    }\n\n    /**\n     * Save as .jpg format in highest quality\n     * default is .jpg\n     */\n    public QuickShot toJPG() {\n        jpgQuality = JPG_MAX_QUALITY;\n        setFileExtension(EXTENSION_JPG);\n        return this;\n    }\n\n    /**\n     * Save as .jpg format in a custom quality between 0-100\n     * default is 100\n     */\n    public QuickShot toJPG(int jpgQuality) {\n        this.jpgQuality = jpgQuality;\n        setFileExtension(EXTENSION_JPG);\n        return this;\n    }\n\n    /**\n     * Save as .png format for lossless compression\n     * default is .jpg\n     */\n    public QuickShot toPNG() {\n        setFileExtension(EXTENSION_PNG);\n        return this;\n    }\n\n    /**\n     * Save as .nomedia for making the picture invisible for photo viewer apps and galleries.\n     */\n    public QuickShot toNomedia() {\n        setFileExtension(EXTENSION_NOMEDIA);\n        return this;\n    }\n\n    /**\n     * Enable QuickShot to log and print exception stacks\n     */\n    public QuickShot enableLogging() {\n        printStackTrace = true;\n        return this;\n    }\n\n    /**\n     * Listen for successive or failure results when calling save()\n     */\n    public QuickShot setResultListener(@NonNull QuickShotListener listener) {\n        this.listener = listener;\n        if (listener == null) {\n            throw new NullPointerException(\"QuickShot.setResultListener() was provided with a null object reference\");\n        }\n        return this;\n    }\n\n    private Context getContext() {\n        if (context == null) {\n            throw new NullPointerException(\"Attempt to save the picture failed: View or Context was null\");\n        }\n        return context;\n    }\n\n    private Bitmap getBitmap() {\n        if (bitmap != null) {\n            return bitmap;\n        } else if (view instanceof TextureView) {\n            bitmap = ((TextureView) view).getBitmap();\n            Canvas canvas = new Canvas(bitmap);\n            view.draw(canvas);\n            canvas.setBitmap(null);\n            return bitmap;\n        } else {\n            bitmap = Bitmap.createBitmap(view.getWidth(), view.getHeight(), Bitmap.Config.ARGB_8888);\n            Canvas canvas = new Canvas(bitmap);\n            view.draw(canvas);\n            canvas.setBitmap(null);\n            return bitmap;\n        }\n    }\n\n\n    /**\n     * save() runs in a asynchronous thread\n     *\n     * @throws NullPointerException if View is null.\n     */\n    public void save() throws NullPointerException {\n        if (view instanceof SurfaceView) {\n            PixelCopyHelper.getSurfaceBitmap((SurfaceView) view, new PixelCopyHelper.PixelCopyListener() {\n                @Override\n                public void onSurfaceBitmapReady(Bitmap surfaceBitmap) {\n                    new BitmapSaver(getContext(), surfaceBitmap, printStackTrace, path, filename, fileExtension, jpgQuality, listener).execute();\n                }\n\n                @Override\n                public void onSurfaceBitmapError(String errorMsg) {\n                    listener.onQuickShotFailed(path, errorMsg);\n                }\n            });\n        } else {\n            new BitmapSaver(getContext(), getBitmap(), printStackTrace, path, filename, fileExtension, jpgQuality, listener).execute();\n        }\n    }\n\n    public interface QuickShotListener {\n        void onQuickShotSuccess(String path);\n\n        void onQuickShotFailed(String path, String errorMsg);\n    }\n\n    static class BitmapSaver extends AsyncTask<Void, Void, Void> {\n\n        private final WeakReference<Context> weakContext;\n        private Handler mainThreadHandler = new Handler(Looper.getMainLooper());\n        private boolean printStacktrace;\n        private int jpgQuality;\n        private String errorMsg;\n        private String path;\n        private String filename;\n        private String fileExtension;\n        private Bitmap bitmap;\n        private File file;\n        private QuickShotListener listener;\n\n        BitmapSaver(Context context, Bitmap bitmap, boolean printStacktrace, String path, String filename, String fileExtension, int jpgQuality, QuickShotListener listener) {\n            this.weakContext = new WeakReference<>(context);\n            this.bitmap = bitmap;\n            this.printStacktrace = printStacktrace;\n            this.path = path;\n            this.filename = filename;\n            this.fileExtension = fileExtension;\n            this.jpgQuality = jpgQuality;\n            this.listener = listener;\n        }\n\n        /**\n         * @deprecated\n         */\n        private void saveLegacy() {\n            if (path == null) {\n                path = Environment.getExternalStorageDirectory() + File.separator + DIRECTORY_PICTURES;\n            }\n            File directory = new File(path);\n            directory.mkdirs();\n            file = new File(directory, filename + fileExtension);\n            try (OutputStream out = new BufferedOutputStream(new FileOutputStream(file))) {\n                switch (fileExtension) {\n                    case EXTENSION_JPG:\n                        bitmap.compress(Bitmap.CompressFormat.JPEG, jpgQuality, out);\n                        break;\n                    case EXTENSION_PNG:\n                        bitmap.compress(Bitmap.CompressFormat.PNG, 0, out);\n                        break;\n                }\n            } catch (Exception e) {\n                if (printStacktrace) {\n                    e.printStackTrace();\n                }\n                errorMsg = e.toString();\n                cancel(true);\n            } finally {\n                bitmap = null;\n            }\n        }\n\n        @RequiresApi(Build.VERSION_CODES.Q)\n        private void saveScopedStorage() {\n            path = path != null ? (DIRECTORY_PICTURES + File.separator + path) : DIRECTORY_PICTURES;\n            ContentValues contentValues = new ContentValues();\n            contentValues.put(MediaStore.MediaColumns.DISPLAY_NAME, filename);\n            contentValues.put(MediaStore.MediaColumns.RELATIVE_PATH, path);\n            contentValues.put(MediaStore.MediaColumns.MIME_TYPE, QuickShotUtils.getMimeType(fileExtension));\n            ContentResolver resolver = weakContext.get().getContentResolver();\n            Uri imageUri = resolver.insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, contentValues);\n            if (imageUri == null) {\n                errorMsg = String.format(\"Couldn't insert ContentValues with data: [%s] into the ContentResolver\", contentValues.toString());\n                cancel(true);\n                return;\n            }\n            try (OutputStream out = resolver.openOutputStream(imageUri)) {\n                switch (fileExtension) {\n                    case EXTENSION_JPG:\n                        bitmap.compress(Bitmap.CompressFormat.JPEG, jpgQuality, out);\n                        break;\n                    case EXTENSION_PNG:\n                        bitmap.compress(Bitmap.CompressFormat.PNG, 0, out);\n                        break;\n                }\n                file = new File(path, filename + fileExtension);\n            } catch (Exception e) {\n                if (printStacktrace) {\n                    e.printStackTrace();\n                }\n                errorMsg = e.toString();\n                resolver.delete(imageUri, null, null);\n                cancel(true);\n            } finally {\n                bitmap = null;\n            }\n        }\n\n        @Override\n        protected Void doInBackground(Void... voids) {\n            if (QuickShotUtils.isAboveAPI29()) {\n                saveScopedStorage();\n            } else {\n                saveLegacy();\n            }\n            return null;\n        }\n\n        @Override\n        protected void onPostExecute(Void v) {\n            listener.onQuickShotSuccess(file.getAbsolutePath());\n            if (!QuickShotUtils.isAboveAPI29()) {\n                MediaScannerConnection.scanFile(weakContext.get(), new String[]{file.getAbsolutePath()}, null, null);\n            }\n        }\n\n        @Override\n        protected void onCancelled() {\n            mainThreadHandler.post(new Runnable() {\n                @Override\n                public void run() {\n                    listener.onQuickShotFailed(file.getAbsolutePath(), errorMsg);\n                }\n            });\n        }\n    }\n}\n\n"
  },
  {
    "path": "quickshot/src/main/java/io/github/muddz/quickshot/QuickShotUtils.java",
    "content": "package io.github.muddz.quickshot;\n\nimport android.graphics.Bitmap;\nimport android.graphics.Canvas;\nimport android.graphics.drawable.Drawable;\nimport android.os.Build;\nimport android.view.View;\n\nimport androidx.recyclerview.widget.RecyclerView;\n\nimport java.io.File;\n\nclass QuickShotUtils {\n\n    static String getMimeType(String src) {\n        src = src.substring(1);\n        if (src.equals(\"jpg\")) {\n            src = \"jpeg\";\n        }\n        return \"image\" + File.separator + src;\n    }\n\n    static boolean isAboveAPI29() {\n        return Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q;\n    }\n\n\n    private Bitmap generateLongBitmap(RecyclerView recyclerView) {\n        int itemCount = recyclerView.getAdapter().getItemCount();\n        RecyclerView.ViewHolder viewHolder = recyclerView.getAdapter().createViewHolder(recyclerView, 0);\n\n        //Measure the sizes of list item views to find out how big itemView should be\n        viewHolder.itemView.measure(View.MeasureSpec.makeMeasureSpec(recyclerView.getWidth(), View.MeasureSpec.EXACTLY), View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED));\n\n        // Define measured widths/heights\n        int measuredItemHeight = viewHolder.itemView.getMeasuredHeight();\n        int measuredItemWidth = viewHolder.itemView.getMeasuredWidth();\n\n        //Set width/height of list item views\n        viewHolder.itemView.layout(0, 0, measuredItemWidth, measuredItemHeight);\n\n        //Create the Bitmap and Canvas to draw on\n        Bitmap recyclerViewBitmap = Bitmap.createBitmap(recyclerView.getMeasuredWidth(), measuredItemHeight * itemCount, Bitmap.Config.ARGB_8888);\n        Canvas canvas = new Canvas(recyclerViewBitmap);\n\n        //Draw RecyclerView Background:\n        if (recyclerView.getBackground() != null) {\n            Drawable drawable = recyclerView.getBackground().mutate();\n            drawable.setBounds(measuredItemWidth, measuredItemHeight * itemCount, 0, 0);\n            drawable.draw(canvas);\n        }\n\n        //Draw all list item views\n        int viewHolderTopPadding = 0;\n        for (int i = 0; i < itemCount; i++) {\n            recyclerView.getAdapter().onBindViewHolder(viewHolder, i);\n            viewHolder.itemView.setDrawingCacheEnabled(true);\n            viewHolder.itemView.buildDrawingCache();\n            canvas.drawBitmap(viewHolder.itemView.getDrawingCache(), 0f, viewHolderTopPadding, null);\n            viewHolderTopPadding += measuredItemHeight;\n            viewHolder.itemView.setDrawingCacheEnabled(false);\n            viewHolder.itemView.destroyDrawingCache();\n\n//            //TODO This should work but doesn't\n//            recyclerView.getAdapter().onBindViewHolder(viewHolder, i);\n//            viewHolder.itemView.draw(canvas);\n//            canvas.drawBitmap(recyclerViewBitmap, 0f, viewHolderTopPadding, null);\n//            viewHolderTopPadding += measuredItemHeight;\n        }\n        return recyclerViewBitmap;\n    }\n\n}\n\n"
  },
  {
    "path": "readme.md",
    "content": "# QuickShot\n[![](https://img.shields.io/badge/API-19%2B-brightgreen.svg?style=flat)](https://android-arsenal.com/api?level=19)\n[![APK](https://img.shields.io/badge/Download-Demo-brightgreen.svg)](https://github.com/Muddz/QuickShot/blob/master/QuickShotDemo.apk?raw=true)\n\nAn Android library that saves any `View`, `SurfaceView` or `Bitmap` as an image in `JPG`,`PNG` or `.nomedia`.\nThe library works on a asynchronous thread and handles errors and memory for you. \n\n### Features\n- Support for Android API 29+ and scoped storage\n- Save in `JPG`,`PNG` or `.nomedia`.\n- Save `Bitmap`, `View` or `SurfaceView` objects as images\n- Set a path and filename for your captures or resort to auto defaults \n- Asynchronous saving\n\n\n## Example of simplest usage with defaults\n<i>You can use a simple one-liner and let QuickShot set default values like in the following example:</i>\n\nFilename defaults to a timestamp.   \nPath defaults to `/Pictures` in internal storage.  \nImage format defaults to `.JPG`\n\n```java\n   QuickShot.of(view).setResultListener(this).save();\n```\n\n## Example of a detailed usage\n```java\n    QuickShot.of(view).setResultListener(this)\n                      .enableLogging()\n                      .setFilename(\"QuickShot\")\n                      .setPath(\"MyApp\")\n                      .toPNG()\n                      .save();\n```\n\n## Installation\n\nAdd the dependency in your `build.gradle`\n```groovy\ndependencies {\n    implementation 'io.github.muddz:quickshot:1.4.0'  \n}\n```\n ----\n\n## License\n\n    Copyright 2018 Muddi Walid\n\n    Licensed under the Apache License, Version 2.0 (the \"License\");\n    you may not use this file except in compliance with the License\n    You may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\n    Unless required by applicable law or agreed to in writing, software\n    distributed under the License is distributed on an \"AS IS\" BASIS,\n    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n    See the License for the specific language governing permissions and\n    limitations under the License.\n"
  },
  {
    "path": "settings.gradle",
    "content": "include ':demo', ':quickshot'\n"
  }
]