diff --git a/app/src/main/java/com/example/cameraxtestappjava/segpasscamerra/Camera2NewLib.java b/app/src/main/java/com/example/cameraxtestappjava/segpasscamerra/Camera2NewLib.java index 9a4031a..c9c4bbf 100644 --- a/app/src/main/java/com/example/cameraxtestappjava/segpasscamerra/Camera2NewLib.java +++ b/app/src/main/java/com/example/cameraxtestappjava/segpasscamerra/Camera2NewLib.java @@ -3,6 +3,7 @@ package com.example.cameraxtestappjava.segpasscamerra; import android.Manifest; import android.app.Activity; import android.content.Context; +import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; import android.content.res.Configuration; import android.graphics.ImageFormat; @@ -156,10 +157,9 @@ public class Camera2NewLib { private int mSensorOrientation; /** - * - * @param activity: The (containing) activity where the Camera is invoked from. + * @param activity: The (containing) activity where the Camera is invoked from. * @param textureView: The View used to show the Camera preview. - * @param listener: Custom listener to deal with camera and storage permissions. + * @param listener: Custom listener to deal with camera and storage permissions. */ public Camera2NewLib(AppCompatActivity activity, AutoFitTextureView textureView, SegpassPermissionListener listener) { mActivity = activity; @@ -169,10 +169,9 @@ public class Camera2NewLib { } /** - * - * @param activity: The (containing) activity where the Camera is invoked from. - * @param textureView: The View used to show the Camera preview. - * @param listener: Custom listener to deal with camera and storage permissions. + * @param activity: The (containing) activity where the Camera is invoked from. + * @param textureView: The View used to show the Camera preview. + * @param listener: Custom listener to deal with camera and storage permissions. * @param stateCallback: Custom listener to deal with camera states in case it's deemed necessary. */ public Camera2NewLib(AppCompatActivity activity, AutoFitTextureView textureView, SegpassPermissionListener listener, @Nullable SegpassCameraStateCallback stateCallback) { @@ -714,8 +713,19 @@ public class Camera2NewLib { * Creates the custom folder {@link Camera2NewLib#mFileFolder} where pictures are saved. */ public void createFolder() { + PackageManager pm = mActivity.getPackageManager(); + String folderName; + + try { + ApplicationInfo ai = pm.getApplicationInfo(mActivity.getPackageName(), 0); + folderName = pm.getApplicationLabel(ai).toString(); + } catch (Exception e) { + Log.e(TAG, "Can't find the package name."); + folderName = "CustomCameraLibraryFolder"; + } + File folder = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES); - mFileFolder = new File(folder, "Camera2TestAppAgain"); + mFileFolder = new File(folder, folderName); if (!mFileFolder.exists()) { mFileFolder.mkdirs(); }