mirror of
https://github.com/scratchfoundation/scratchjr.git
synced 2025-02-17 17:01:12 -05:00
rename CameraxView to CameraView & add more comments
This commit is contained in:
parent
8d17a76599
commit
d8760f6018
3 changed files with 12 additions and 6 deletions
|
@ -27,6 +27,9 @@ android {
|
|||
}
|
||||
}
|
||||
|
||||
// The camera-view dependency contains Java 8 bytecode,
|
||||
// we need to support java 8 to dex.
|
||||
// See https://developer.android.com/studio/write/java8-support.html for details.
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
|
|
|
@ -27,6 +27,7 @@ import android.widget.RelativeLayout;
|
|||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.camera.core.CameraInfoUnavailableException;
|
||||
import androidx.camera.core.CameraSelector;
|
||||
import androidx.camera.core.ExperimentalUseCaseGroup;
|
||||
import androidx.camera.core.ImageCapture;
|
||||
import androidx.camera.core.Preview;
|
||||
import androidx.camera.lifecycle.ProcessCameraProvider;
|
||||
|
@ -36,7 +37,7 @@ import androidx.core.content.ContextCompat;
|
|||
import com.google.common.util.concurrent.ListenableFuture;
|
||||
|
||||
@SuppressLint("ViewConstructor")
|
||||
public class CameraxView extends RelativeLayout {
|
||||
public class CameraView extends RelativeLayout {
|
||||
private static final String LOG_TAG = "ScratchJr.CameraxView";
|
||||
|
||||
private final RectF _rect;
|
||||
|
@ -52,7 +53,7 @@ public class CameraxView extends RelativeLayout {
|
|||
private final DisplayManager _displayManager;
|
||||
private int _displayId;
|
||||
|
||||
public CameraxView(AppCompatActivity context, RectF rect, float scale, boolean facingFront) {
|
||||
public CameraView(AppCompatActivity context, RectF rect, float scale, boolean facingFront) {
|
||||
super(context);
|
||||
_activity = context;
|
||||
_currentFacingFront = facingFront;
|
||||
|
@ -94,7 +95,9 @@ public class CameraxView extends RelativeLayout {
|
|||
public void onDisplayRemoved(int displayId) {
|
||||
}
|
||||
|
||||
@SuppressLint("UnsafeOptInUsageError")
|
||||
// The androidx.camera.core.Preview.setTargetRotation declaration is opt-in
|
||||
// and its usage should be marked with @androidx.camera.core.ExperimentalUseCaseGroup
|
||||
@ExperimentalUseCaseGroup
|
||||
@Override
|
||||
public void onDisplayChanged(int displayId) {
|
||||
if (displayId == _displayId) {
|
||||
|
@ -238,7 +241,7 @@ public class CameraxView extends RelativeLayout {
|
|||
// flip bitmap horizontally since front-facing camera is mirrored
|
||||
m.preScale(-1.0f, 1.0f);
|
||||
}
|
||||
int rotation = CameraxView.findDisplayRotation(getContext(), _currentFacingFront);
|
||||
int rotation = CameraView.findDisplayRotation(getContext(), _currentFacingFront);
|
||||
if (rotation == 180) {
|
||||
m.preScale(-1.0f, -1.0f);
|
||||
}
|
|
@ -49,7 +49,7 @@ public class JavaScriptDirectInterface {
|
|||
private final ScratchJrActivity _activity;
|
||||
|
||||
/** Current camera view, if active */
|
||||
private CameraxView _cameraView;
|
||||
private CameraView _cameraView;
|
||||
|
||||
/** Current camera mask, if active */
|
||||
private ImageView _cameraMask;
|
||||
|
@ -505,7 +505,7 @@ public class JavaScriptDirectInterface {
|
|||
scaleRectFromCenter(maskRect, scale);
|
||||
RelativeLayout container = _activity.getContainer();
|
||||
|
||||
_cameraView = new CameraxView(_activity, rect, scale * devicePixelRatio, true); // always start with front-facing camera
|
||||
_cameraView = new CameraView(_activity, rect, scale * devicePixelRatio, true); // always start with front-facing camera
|
||||
container.addView(_cameraView, new RelativeLayout.LayoutParams((int) (rect.width()), (int) (rect.height())));
|
||||
_cameraView.setX(rect.left);
|
||||
_cameraView.setY(rect.top);
|
||||
|
|
Loading…
Reference in a new issue