|
|
@ -151,44 +151,50 @@ public class CameraView extends FrameLayout implements LifecycleObserver { |
|
|
|
setPermissions(mPermissions); |
|
|
|
setPermissions(mPermissions); |
|
|
|
setVideoQuality(mVideoQuality); |
|
|
|
setVideoQuality(mVideoQuality); |
|
|
|
|
|
|
|
|
|
|
|
mDisplayOrientationDetector = new DisplayOrientationDetector(context) { |
|
|
|
if (!isInEditMode()) { |
|
|
|
@Override |
|
|
|
mDisplayOrientationDetector = new DisplayOrientationDetector(context) { |
|
|
|
public void onDisplayOrientationChanged(int displayOrientation) { |
|
|
|
@Override |
|
|
|
mCameraImpl.setDisplayOrientation(displayOrientation); |
|
|
|
public void onDisplayOrientationChanged(int displayOrientation) { |
|
|
|
mPreviewImpl.setDisplayOrientation(displayOrientation); |
|
|
|
mCameraImpl.setDisplayOrientation(displayOrientation); |
|
|
|
} |
|
|
|
mPreviewImpl.setDisplayOrientation(displayOrientation); |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
final FocusMarkerLayout focusMarkerLayout = new FocusMarkerLayout(getContext()); |
|
|
|
|
|
|
|
addView(focusMarkerLayout); |
|
|
|
|
|
|
|
focusMarkerLayout.setOnTouchListener(new OnTouchListener() { |
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public boolean onTouch(View v, MotionEvent motionEvent) { |
|
|
|
|
|
|
|
int action = motionEvent.getAction(); |
|
|
|
|
|
|
|
if (motionEvent.getAction() == MotionEvent.ACTION_UP && mFocus == CameraKit.Constants.FOCUS_TAP_WITH_MARKER) { |
|
|
|
|
|
|
|
focusMarkerLayout.focus(motionEvent.getX(), motionEvent.getY()); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
mPreviewImpl.getView().dispatchTouchEvent(motionEvent); |
|
|
|
final FocusMarkerLayout focusMarkerLayout = new FocusMarkerLayout(getContext()); |
|
|
|
return true; |
|
|
|
addView(focusMarkerLayout); |
|
|
|
} |
|
|
|
focusMarkerLayout.setOnTouchListener(new OnTouchListener() { |
|
|
|
}); |
|
|
|
@Override |
|
|
|
|
|
|
|
public boolean onTouch(View v, MotionEvent motionEvent) { |
|
|
|
|
|
|
|
int action = motionEvent.getAction(); |
|
|
|
|
|
|
|
if (motionEvent.getAction() == MotionEvent.ACTION_UP && mFocus == CameraKit.Constants.FOCUS_TAP_WITH_MARKER) { |
|
|
|
|
|
|
|
focusMarkerLayout.focus(motionEvent.getX(), motionEvent.getY()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mPreviewImpl.getView().dispatchTouchEvent(motionEvent); |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
mLifecycle = null; |
|
|
|
mLifecycle = null; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
protected void onAttachedToWindow() { |
|
|
|
protected void onAttachedToWindow() { |
|
|
|
super.onAttachedToWindow(); |
|
|
|
super.onAttachedToWindow(); |
|
|
|
mDisplayOrientationDetector.enable( |
|
|
|
if (!isInEditMode()) { |
|
|
|
ViewCompat.isAttachedToWindow(this) |
|
|
|
mDisplayOrientationDetector.enable( |
|
|
|
? DisplayManagerCompat.getInstance(getContext()).getDisplay(Display.DEFAULT_DISPLAY) |
|
|
|
ViewCompat.isAttachedToWindow(this) |
|
|
|
: null |
|
|
|
? DisplayManagerCompat.getInstance(getContext()).getDisplay(Display.DEFAULT_DISPLAY) |
|
|
|
); |
|
|
|
: null |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
protected void onDetachedFromWindow() { |
|
|
|
protected void onDetachedFromWindow() { |
|
|
|
mDisplayOrientationDetector.disable(); |
|
|
|
if (!isInEditMode()) { |
|
|
|
|
|
|
|
mDisplayOrientationDetector.disable(); |
|
|
|
|
|
|
|
} |
|
|
|
super.onDetachedFromWindow(); |
|
|
|
super.onDetachedFromWindow(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|