control commit
This commit is contained in:
parent
2f449a55c8
commit
51bd224ce5
2 changed files with 19 additions and 19 deletions
|
@ -1,6 +1,6 @@
|
|||
package com.example.cameraxtestappjava;
|
||||
|
||||
import static com.example.cameraxtestappjava.segpass.CustomCamera.REQUEST_CAMERA_PERMISSION;
|
||||
import static com.example.cameraxtestappjava.segpass.SegpassCamera.REQUEST_CAMERA_PERMISSION;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.pm.ActivityInfo;
|
||||
|
@ -23,12 +23,12 @@ import com.example.cameraxtestappjava.segpass.camera.utils.SegpassCameraCallback
|
|||
import com.example.cameraxtestappjava.segpass.camera.utils.SegpassCameraStateCallback;
|
||||
import com.example.cameraxtestappjava.segpass.camera.utils.SegpassPermissionListener;
|
||||
import com.example.cameraxtestappjava.databinding.ActivityCameraNewBinding;
|
||||
import com.example.cameraxtestappjava.segpass.CustomCamera;
|
||||
import com.example.cameraxtestappjava.segpass.SegpassCamera;
|
||||
|
||||
public class CameraActivityNew extends AppCompatActivity implements ActivityCompat.OnRequestPermissionsResultCallback, SegpassCameraCallback, SegpassCameraStateCallback, SegpassPermissionListener {
|
||||
|
||||
ActivityCameraNewBinding binding;
|
||||
CustomCamera mCustomCamera;
|
||||
SegpassCamera mSegpassCamera;
|
||||
AutoFitTextureView mTextureView;
|
||||
|
||||
@SuppressLint("SourceLockedOrientationActivity")
|
||||
|
@ -41,8 +41,8 @@ public class CameraActivityNew extends AppCompatActivity implements ActivityComp
|
|||
setContentView(binding.getRoot());
|
||||
|
||||
mTextureView = binding.inCamera2.tvCameraTextureView;
|
||||
mCustomCamera = new CustomCamera(this, mTextureView, this, this);
|
||||
mCustomCamera.init();
|
||||
mSegpassCamera = new SegpassCamera(this, mTextureView, this, this);
|
||||
mSegpassCamera.init();
|
||||
setUpListeners();
|
||||
|
||||
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main), (v, insets) -> {
|
||||
|
@ -55,12 +55,12 @@ public class CameraActivityNew extends AppCompatActivity implements ActivityComp
|
|||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
mCustomCamera.resumeCamera();
|
||||
mSegpassCamera.resumeCamera();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
mCustomCamera.pauseCamera();
|
||||
mSegpassCamera.pauseCamera();
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
|
@ -78,7 +78,7 @@ public class CameraActivityNew extends AppCompatActivity implements ActivityComp
|
|||
|
||||
private void setUpListeners() {
|
||||
binding.inCamera2.btnTakepicture.setOnClickListener(v -> {
|
||||
mCustomCamera.takePicture(this);
|
||||
mSegpassCamera.takePicture(this);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -88,12 +88,12 @@ public class CameraActivityNew extends AppCompatActivity implements ActivityComp
|
|||
|
||||
@Override
|
||||
public void onPictureTakenSuccess(String message) {
|
||||
mCustomCamera.showToast(message);
|
||||
mSegpassCamera.showToast(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPictureTakenFailError(String error) {
|
||||
mCustomCamera.showToast(error);
|
||||
mSegpassCamera.showToast(error);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -102,7 +102,7 @@ public class CameraActivityNew extends AppCompatActivity implements ActivityComp
|
|||
|
||||
@Override
|
||||
public void onCameraInitError(String errorMessage) {
|
||||
mCustomCamera.showToast(errorMessage);
|
||||
mSegpassCamera.showToast(errorMessage);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -121,7 +121,7 @@ public class CameraActivityNew extends AppCompatActivity implements ActivityComp
|
|||
|
||||
@Override
|
||||
public void onPermissionDenied() {
|
||||
mCustomCamera.showToast("No permissions granted, closing camera.");
|
||||
mSegpassCamera.showToast("No permissions granted, closing camera.");
|
||||
finish();
|
||||
}
|
||||
}
|
|
@ -51,7 +51,7 @@ import java.util.List;
|
|||
import java.util.concurrent.Semaphore;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class CustomCamera {
|
||||
public class SegpassCamera {
|
||||
|
||||
/**
|
||||
* Tag for the {@link Log}.
|
||||
|
@ -163,7 +163,7 @@ public class CustomCamera {
|
|||
* @param textureView: The View used to show the Camera preview.
|
||||
* @param listener: Custom listener to deal with camera and storage permissions.
|
||||
*/
|
||||
public CustomCamera(AppCompatActivity activity, AutoFitTextureView textureView, SegpassPermissionListener listener) {
|
||||
public SegpassCamera(AppCompatActivity activity, AutoFitTextureView textureView, SegpassPermissionListener listener) {
|
||||
mActivity = activity;
|
||||
mTextureView = textureView;
|
||||
mPermissionListener = listener;
|
||||
|
@ -176,7 +176,7 @@ public class CustomCamera {
|
|||
* @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 CustomCamera(AppCompatActivity activity, AutoFitTextureView textureView, SegpassPermissionListener listener, @Nullable SegpassCameraStateCallback stateCallback) {
|
||||
public SegpassCamera(AppCompatActivity activity, AutoFitTextureView textureView, SegpassPermissionListener listener, @Nullable SegpassCameraStateCallback stateCallback) {
|
||||
mActivity = activity;
|
||||
mTextureView = textureView;
|
||||
mPermissionListener = listener;
|
||||
|
@ -376,7 +376,6 @@ public class CustomCamera {
|
|||
* @param width The width of available size for camera preview
|
||||
* @param height The height of available size for camera preview
|
||||
*/
|
||||
@SuppressWarnings("SuspiciousNameCombination")
|
||||
private void setUpCameraOutputs(int width, int height) {
|
||||
CameraManager manager = (CameraManager) mActivity.getSystemService(Context.CAMERA_SERVICE);
|
||||
try {
|
||||
|
@ -478,7 +477,7 @@ public class CustomCamera {
|
|||
}
|
||||
|
||||
/**
|
||||
* Opens the camera specified by {@link CustomCamera#mCameraId}.
|
||||
* Opens the camera specified by {@link SegpassCamera#mCameraId}.
|
||||
*/
|
||||
private void openCamera(int width, int height) {
|
||||
// Check permissions
|
||||
|
@ -669,7 +668,8 @@ public class CustomCamera {
|
|||
|
||||
// Pre-set file
|
||||
String fileName = "IMG_" + System.currentTimeMillis() + ".jpg";
|
||||
mFile = new File(mFileFolder + "/" + fileName); // Ver como hacer para guardar en la carpeta de la app
|
||||
String base64FileName = "IMG_" + System.currentTimeMillis() + "_64.txt";
|
||||
mFile = new File(mFileFolder + "/" + base64FileName); // Ver como hacer para guardar en la carpeta de la app
|
||||
|
||||
mReader.setOnImageAvailableListener(mOnImageAvailableListener, mBackgroundHandler);
|
||||
final CameraCaptureSession.CaptureCallback captureListener = new CameraCaptureSession.CaptureCallback() {
|
||||
|
@ -712,7 +712,7 @@ public class CustomCamera {
|
|||
}
|
||||
|
||||
/**
|
||||
* Creates the custom folder {@link CustomCamera#mFileFolder} where pictures are saved.
|
||||
* Creates the custom folder {@link SegpassCamera#mFileFolder} where pictures are saved.
|
||||
*/
|
||||
public void createFolder() {
|
||||
PackageManager pm = mActivity.getPackageManager();
|
Loading…
Reference in a new issue