|
|
@ -22,6 +22,7 @@ import android.view.View; |
|
|
|
import android.view.ViewGroup; |
|
|
|
import android.view.ViewGroup; |
|
|
|
import android.view.WindowManager; |
|
|
|
import android.view.WindowManager; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.github.florent37.camerafragment.CameraFragmentApi; |
|
|
|
import com.github.florent37.camerafragment.R; |
|
|
|
import com.github.florent37.camerafragment.R; |
|
|
|
import com.github.florent37.camerafragment.configuration.Configuration; |
|
|
|
import com.github.florent37.camerafragment.configuration.Configuration; |
|
|
|
import com.github.florent37.camerafragment.configuration.ConfigurationProvider; |
|
|
|
import com.github.florent37.camerafragment.configuration.ConfigurationProvider; |
|
|
@ -55,7 +56,7 @@ import java.io.File; |
|
|
|
* Updated by Florent37 |
|
|
|
* Updated by Florent37 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
public abstract class BaseAnncaFragment<CameraId> extends Fragment { |
|
|
|
public abstract class BaseAnncaFragment<CameraId> extends Fragment implements CameraFragmentApi { |
|
|
|
|
|
|
|
|
|
|
|
public static final String ARG_CONFIGURATION = "configuration"; |
|
|
|
public static final String ARG_CONFIGURATION = "configuration"; |
|
|
|
public static final int MIN_VERSION_ICECREAM = Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1; |
|
|
|
public static final int MIN_VERSION_ICECREAM = Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1; |
|
|
@ -191,22 +192,25 @@ public abstract class BaseAnncaFragment<CameraId> extends Fragment { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void onPhotoTaken(byte[] bytes) { |
|
|
|
public void onPhotoTaken(byte[] bytes, CameraFragmentResultListener callback) { |
|
|
|
if (cameraFragmentResultListener != null) { |
|
|
|
if (cameraFragmentResultListener != null) { |
|
|
|
final String filePath = getCameraController().getOutputFile().toString(); |
|
|
|
final String filePath = cameraController.getOutputFile().toString(); |
|
|
|
cameraFragmentResultListener.onPhotoTaken(bytes, filePath); |
|
|
|
cameraFragmentResultListener.onPhotoTaken(bytes, filePath); |
|
|
|
|
|
|
|
if (callback != null) { |
|
|
|
|
|
|
|
callback.onPhotoTaken(bytes, filePath); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void onVideoRecordStart(int width, int height) { |
|
|
|
public void onVideoRecordStart(int width, int height) { |
|
|
|
final File outputFile = getCameraController().getOutputFile(); |
|
|
|
final File outputFile = cameraController.getOutputFile(); |
|
|
|
onStartVideoRecord(outputFile); |
|
|
|
onStartVideoRecord(outputFile); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void onVideoRecordStop() { |
|
|
|
public void onVideoRecordStop(@Nullable CameraFragmentResultListener callback) { |
|
|
|
BaseAnncaFragment.this.onStopVideoRecord(); |
|
|
|
BaseAnncaFragment.this.onStopVideoRecord(callback); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
@ -252,15 +256,16 @@ public abstract class BaseAnncaFragment<CameraId> extends Fragment { |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void takePhotoOrCaptureVideo() { |
|
|
|
@Override |
|
|
|
|
|
|
|
public void takePhotoOrCaptureVideo(final CameraFragmentResultListener resultListener) { |
|
|
|
switch (currentMediaActionState) { |
|
|
|
switch (currentMediaActionState) { |
|
|
|
case MediaAction.ACTION_PHOTO: |
|
|
|
case MediaAction.ACTION_PHOTO: |
|
|
|
takePhoto(); |
|
|
|
takePhoto(resultListener); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case MediaAction.ACTION_VIDEO: |
|
|
|
case MediaAction.ACTION_VIDEO: |
|
|
|
switch (currentRecordState) { |
|
|
|
switch (currentRecordState) { |
|
|
|
case Record.RECORD_IN_PROGRESS_STATE: |
|
|
|
case Record.RECORD_IN_PROGRESS_STATE: |
|
|
|
stopRecording(); |
|
|
|
stopRecording(resultListener); |
|
|
|
break; |
|
|
|
break; |
|
|
|
default: |
|
|
|
default: |
|
|
|
startRecording(); |
|
|
|
startRecording(); |
|
|
@ -303,11 +308,11 @@ public abstract class BaseAnncaFragment<CameraId> extends Fragment { |
|
|
|
cameraController.onDestroy(); |
|
|
|
cameraController.onDestroy(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void setMaxVideoFileSize(long maxVideoFileSize) { |
|
|
|
protected void setMaxVideoFileSize(long maxVideoFileSize) { |
|
|
|
this.maxVideoFileSize = maxVideoFileSize; |
|
|
|
this.maxVideoFileSize = maxVideoFileSize; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void setMaxVideoDuration(int maxVideoDurationInMillis) { |
|
|
|
protected void setMaxVideoDuration(int maxVideoDurationInMillis) { |
|
|
|
final TimerTaskBase.Callback callback = new TimerTaskBase.Callback() { |
|
|
|
final TimerTaskBase.Callback callback = new TimerTaskBase.Callback() { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void setText(String text) { |
|
|
|
public void setText(String text) { |
|
|
@ -331,19 +336,30 @@ public abstract class BaseAnncaFragment<CameraId> extends Fragment { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public void openSettingDialog() { |
|
|
|
public void openSettingDialog() { |
|
|
|
final Context context = getContext(); |
|
|
|
final Context context = getContext(); |
|
|
|
AlertDialog.Builder builder = new AlertDialog.Builder(context); |
|
|
|
AlertDialog.Builder builder = new AlertDialog.Builder(context); |
|
|
|
|
|
|
|
|
|
|
|
if (currentMediaActionState == MediaAction.ACTION_VIDEO) { |
|
|
|
if (currentMediaActionState == MediaAction.ACTION_VIDEO) { |
|
|
|
builder.setSingleChoiceItems(videoQualities, getVideoOptionCheckedIndex(), getVideoOptionSelectedListener()); |
|
|
|
builder.setSingleChoiceItems(videoQualities, getVideoOptionCheckedIndex(), new DialogInterface.OnClickListener() { |
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void onClick(DialogInterface dialogInterface, int index) { |
|
|
|
|
|
|
|
newQuality = ((VideoQualityOption) videoQualities[index]).getMediaQuality(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
if (configurationProvider.getVideoFileSize() > 0) |
|
|
|
if (configurationProvider.getVideoFileSize() > 0) |
|
|
|
builder.setTitle(String.format(getString(R.string.settings_video_quality_title), |
|
|
|
builder.setTitle(String.format(getString(R.string.settings_video_quality_title), |
|
|
|
"(Max " + String.valueOf(configurationProvider.getVideoFileSize() / (1024 * 1024) + " MB)"))); |
|
|
|
"(Max " + String.valueOf(configurationProvider.getVideoFileSize() / (1024 * 1024) + " MB)"))); |
|
|
|
else |
|
|
|
else |
|
|
|
builder.setTitle(String.format(getString(R.string.settings_video_quality_title), "")); |
|
|
|
builder.setTitle(String.format(getString(R.string.settings_video_quality_title), "")); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
builder.setSingleChoiceItems(photoQualities, getPhotoOptionCheckedIndex(), getPhotoOptionSelectedListener()); |
|
|
|
builder.setSingleChoiceItems(photoQualities, getPhotoOptionCheckedIndex(), new DialogInterface.OnClickListener() { |
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void onClick(DialogInterface dialogInterface, int index) { |
|
|
|
|
|
|
|
newQuality = ((PhotoQualityOption) photoQualities[index]).getMediaQuality(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
builder.setTitle(R.string.settings_photo_quality_title); |
|
|
|
builder.setTitle(R.string.settings_photo_quality_title); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -356,7 +372,7 @@ public abstract class BaseAnncaFragment<CameraId> extends Fragment { |
|
|
|
if (cameraFragmentControlsListener != null) { |
|
|
|
if (cameraFragmentControlsListener != null) { |
|
|
|
cameraFragmentControlsListener.lockControls(); |
|
|
|
cameraFragmentControlsListener.lockControls(); |
|
|
|
} |
|
|
|
} |
|
|
|
getCameraController().switchQuality(); |
|
|
|
cameraController.switchQuality(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
@ -375,6 +391,7 @@ public abstract class BaseAnncaFragment<CameraId> extends Fragment { |
|
|
|
settingsDialog.getWindow().setAttributes(layoutParams); |
|
|
|
settingsDialog.getWindow().setAttributes(layoutParams); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public void switchCameraType() { |
|
|
|
public void switchCameraType() { |
|
|
|
if (cameraFragmentControlsListener != null) { |
|
|
|
if (cameraFragmentControlsListener != null) { |
|
|
|
cameraFragmentControlsListener.lockControls(); |
|
|
|
cameraFragmentControlsListener.lockControls(); |
|
|
@ -399,10 +416,11 @@ public abstract class BaseAnncaFragment<CameraId> extends Fragment { |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
getCameraController().switchCamera(cameraFace); |
|
|
|
this.cameraController.switchCamera(cameraFace); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void switchAction() { |
|
|
|
@Override |
|
|
|
|
|
|
|
public void switchActionPhotoVideo() { |
|
|
|
switch (currentMediaActionState) { |
|
|
|
switch (currentMediaActionState) { |
|
|
|
case MediaAction.ACTION_PHOTO: |
|
|
|
case MediaAction.ACTION_PHOTO: |
|
|
|
currentMediaActionState = MediaAction.ACTION_VIDEO; |
|
|
|
currentMediaActionState = MediaAction.ACTION_VIDEO; |
|
|
@ -419,6 +437,7 @@ public abstract class BaseAnncaFragment<CameraId> extends Fragment { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public void toggleFlashMode() { |
|
|
|
public void toggleFlashMode() { |
|
|
|
switch (currentFlashMode) { |
|
|
|
switch (currentFlashMode) { |
|
|
|
case Flash.FLASH_AUTO: |
|
|
|
case Flash.FLASH_AUTO: |
|
|
@ -439,17 +458,17 @@ public abstract class BaseAnncaFragment<CameraId> extends Fragment { |
|
|
|
case Flash.FLASH_AUTO: |
|
|
|
case Flash.FLASH_AUTO: |
|
|
|
if (cameraFragmentStateListener != null) cameraFragmentStateListener.onFlashAuto(); |
|
|
|
if (cameraFragmentStateListener != null) cameraFragmentStateListener.onFlashAuto(); |
|
|
|
configurationProvider.setFlashMode(Configuration.FLASH_MODE_AUTO); |
|
|
|
configurationProvider.setFlashMode(Configuration.FLASH_MODE_AUTO); |
|
|
|
getCameraController().setFlashMode(Configuration.FLASH_MODE_AUTO); |
|
|
|
this.cameraController.setFlashMode(Configuration.FLASH_MODE_AUTO); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case Flash.FLASH_ON: |
|
|
|
case Flash.FLASH_ON: |
|
|
|
if (cameraFragmentStateListener != null) cameraFragmentStateListener.onFlashOn(); |
|
|
|
if (cameraFragmentStateListener != null) cameraFragmentStateListener.onFlashOn(); |
|
|
|
configurationProvider.setFlashMode(Configuration.FLASH_MODE_ON); |
|
|
|
configurationProvider.setFlashMode(Configuration.FLASH_MODE_ON); |
|
|
|
getCameraController().setFlashMode(Configuration.FLASH_MODE_ON); |
|
|
|
this.cameraController.setFlashMode(Configuration.FLASH_MODE_ON); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case Flash.FLASH_OFF: |
|
|
|
case Flash.FLASH_OFF: |
|
|
|
if (cameraFragmentStateListener != null) cameraFragmentStateListener.onFlashOff(); |
|
|
|
if (cameraFragmentStateListener != null) cameraFragmentStateListener.onFlashOff(); |
|
|
|
configurationProvider.setFlashMode(Configuration.FLASH_MODE_OFF); |
|
|
|
configurationProvider.setFlashMode(Configuration.FLASH_MODE_OFF); |
|
|
|
getCameraController().setFlashMode(Configuration.FLASH_MODE_OFF); |
|
|
|
this.cameraController.setFlashMode(Configuration.FLASH_MODE_OFF); |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -461,12 +480,7 @@ public abstract class BaseAnncaFragment<CameraId> extends Fragment { |
|
|
|
rotateSettingsDialog(degrees); |
|
|
|
rotateSettingsDialog(degrees); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Record.RecordState |
|
|
|
protected void setRecordState(@Record.RecordState int recordState) { |
|
|
|
public int getRecordState() { |
|
|
|
|
|
|
|
return currentRecordState; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void setRecordState(@Record.RecordState int recordState) { |
|
|
|
|
|
|
|
this.currentRecordState = recordState; |
|
|
|
this.currentRecordState = recordState; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -493,12 +507,12 @@ public abstract class BaseAnncaFragment<CameraId> extends Fragment { |
|
|
|
// }
|
|
|
|
// }
|
|
|
|
//}
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
public void setFlashMode(@Flash.FlashMode int mode) { |
|
|
|
protected void setFlashMode(@Flash.FlashMode int mode) { |
|
|
|
this.currentFlashMode = mode; |
|
|
|
this.currentFlashMode = mode; |
|
|
|
onFlashModeChanged(); |
|
|
|
onFlashModeChanged(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void rotateSettingsDialog(int degrees) { |
|
|
|
protected void rotateSettingsDialog(int degrees) { |
|
|
|
if (settingsDialog != null && settingsDialog.isShowing() && Build.VERSION.SDK_INT > 10) { |
|
|
|
if (settingsDialog != null && settingsDialog.isShowing() && Build.VERSION.SDK_INT > 10) { |
|
|
|
ViewGroup dialogView = (ViewGroup) settingsDialog.getWindow().getDecorView(); |
|
|
|
ViewGroup dialogView = (ViewGroup) settingsDialog.getWindow().getDecorView(); |
|
|
|
for (int i = 0; i < dialogView.getChildCount(); i++) { |
|
|
|
for (int i = 0; i < dialogView.getChildCount(); i++) { |
|
|
@ -535,73 +549,51 @@ public abstract class BaseAnncaFragment<CameraId> extends Fragment { |
|
|
|
return checkedIndex; |
|
|
|
return checkedIndex; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected DialogInterface.OnClickListener getVideoOptionSelectedListener() { |
|
|
|
protected void takePhoto(CameraFragmentResultListener callback) { |
|
|
|
return new DialogInterface.OnClickListener() { |
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void onClick(DialogInterface dialogInterface, int index) { |
|
|
|
|
|
|
|
newQuality = ((VideoQualityOption) videoQualities[index]).getMediaQuality(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected DialogInterface.OnClickListener getPhotoOptionSelectedListener() { |
|
|
|
|
|
|
|
return new DialogInterface.OnClickListener() { |
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void onClick(DialogInterface dialogInterface, int index) { |
|
|
|
|
|
|
|
newQuality = ((PhotoQualityOption) photoQualities[index]).getMediaQuality(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void takePhoto() { |
|
|
|
|
|
|
|
if (Build.VERSION.SDK_INT > MIN_VERSION_ICECREAM) { |
|
|
|
if (Build.VERSION.SDK_INT > MIN_VERSION_ICECREAM) { |
|
|
|
new MediaActionSound().play(MediaActionSound.SHUTTER_CLICK); |
|
|
|
new MediaActionSound().play(MediaActionSound.SHUTTER_CLICK); |
|
|
|
} |
|
|
|
} |
|
|
|
setRecordState(Record.TAKE_PHOTO_STATE); |
|
|
|
setRecordState(Record.TAKE_PHOTO_STATE); |
|
|
|
getCameraController().takePhoto(); |
|
|
|
this.cameraController.takePhoto(callback); |
|
|
|
if (cameraFragmentStateListener != null) { |
|
|
|
if (cameraFragmentStateListener != null) { |
|
|
|
cameraFragmentStateListener.onRecordStatePhoto(); |
|
|
|
cameraFragmentStateListener.onRecordStatePhoto(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void startRecording() { |
|
|
|
protected void startRecording() { |
|
|
|
if (Build.VERSION.SDK_INT > MIN_VERSION_ICECREAM) { |
|
|
|
if (Build.VERSION.SDK_INT > MIN_VERSION_ICECREAM) { |
|
|
|
new MediaActionSound().play(MediaActionSound.START_VIDEO_RECORDING); |
|
|
|
new MediaActionSound().play(MediaActionSound.START_VIDEO_RECORDING); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
setRecordState(Record.RECORD_IN_PROGRESS_STATE); |
|
|
|
setRecordState(Record.RECORD_IN_PROGRESS_STATE); |
|
|
|
getCameraController().startVideoRecord(); |
|
|
|
this.cameraController.startVideoRecord(); |
|
|
|
|
|
|
|
|
|
|
|
if (cameraFragmentStateListener != null) { |
|
|
|
if (cameraFragmentStateListener != null) { |
|
|
|
cameraFragmentStateListener.onRecordStateVideoInProgress(); |
|
|
|
cameraFragmentStateListener.onRecordStateVideoInProgress(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void stopRecording() { |
|
|
|
protected void stopRecording(CameraFragmentResultListener callback) { |
|
|
|
if (Build.VERSION.SDK_INT > MIN_VERSION_ICECREAM) { |
|
|
|
if (Build.VERSION.SDK_INT > MIN_VERSION_ICECREAM) { |
|
|
|
new MediaActionSound().play(MediaActionSound.STOP_VIDEO_RECORDING); |
|
|
|
new MediaActionSound().play(MediaActionSound.STOP_VIDEO_RECORDING); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
setRecordState(Record.READY_FOR_RECORD_STATE); |
|
|
|
setRecordState(Record.READY_FOR_RECORD_STATE); |
|
|
|
getCameraController().stopVideoRecord(); |
|
|
|
this.cameraController.stopVideoRecord(callback); |
|
|
|
|
|
|
|
|
|
|
|
this.onStopVideoRecord(); |
|
|
|
this.onStopVideoRecord(callback); |
|
|
|
|
|
|
|
|
|
|
|
if (cameraFragmentStateListener != null) { |
|
|
|
if (cameraFragmentStateListener != null) { |
|
|
|
cameraFragmentStateListener.onRecordStateVideoReadyForRecord(); |
|
|
|
cameraFragmentStateListener.onRecordStateVideoReadyForRecord(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public CameraController<CameraId> getCameraController() { |
|
|
|
protected void clearCameraPreview() { |
|
|
|
return cameraController; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void clearCameraPreview() { |
|
|
|
|
|
|
|
if (previewContainer != null) |
|
|
|
if (previewContainer != null) |
|
|
|
previewContainer.removeAllViews(); |
|
|
|
previewContainer.removeAllViews(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void setCameraPreview(View preview, Size previewSize) { |
|
|
|
protected void setCameraPreview(View preview, Size previewSize) { |
|
|
|
//onCameraControllerReady()
|
|
|
|
//onCameraControllerReady()
|
|
|
|
videoQualities = cameraController.getVideoQualityOptions(); |
|
|
|
videoQualities = cameraController.getVideoQualityOptions(); |
|
|
|
photoQualities = cameraController.getPhotoQualityOptions(); |
|
|
|
photoQualities = cameraController.getPhotoQualityOptions(); |
|
|
@ -613,11 +605,11 @@ public abstract class BaseAnncaFragment<CameraId> extends Fragment { |
|
|
|
previewContainer.setAspectRatio(previewSize.getHeight() / (double) previewSize.getWidth()); |
|
|
|
previewContainer.setAspectRatio(previewSize.getHeight() / (double) previewSize.getWidth()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void setMediaFilePath(final File mediaFile) { |
|
|
|
protected void setMediaFilePath(final File mediaFile) { |
|
|
|
this.mediaFilePath = mediaFile.toString(); |
|
|
|
this.mediaFilePath = mediaFile.toString(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void onStartVideoRecord(final File mediaFile) { |
|
|
|
protected void onStartVideoRecord(final File mediaFile) { |
|
|
|
setMediaFilePath(mediaFile); |
|
|
|
setMediaFilePath(mediaFile); |
|
|
|
if (maxVideoFileSize > 0) { |
|
|
|
if (maxVideoFileSize > 0) { |
|
|
|
|
|
|
|
|
|
|
@ -657,7 +649,7 @@ public abstract class BaseAnncaFragment<CameraId> extends Fragment { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void onStopVideoRecord() { |
|
|
|
protected void onStopVideoRecord(@Nullable CameraFragmentResultListener callback) { |
|
|
|
if (cameraFragmentControlsListener != null) { |
|
|
|
if (cameraFragmentControlsListener != null) { |
|
|
|
cameraFragmentControlsListener.allowRecord(false); |
|
|
|
cameraFragmentControlsListener.allowRecord(false); |
|
|
|
} |
|
|
|
} |
|
|
@ -679,24 +671,32 @@ public abstract class BaseAnncaFragment<CameraId> extends Fragment { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
final String filePath = this.cameraController.getOutputFile().toString(); |
|
|
|
if (cameraFragmentResultListener != null) { |
|
|
|
if (cameraFragmentResultListener != null) { |
|
|
|
final String filePath = getCameraController().getOutputFile().toString(); |
|
|
|
|
|
|
|
cameraFragmentResultListener.onVideoRecorded(filePath); |
|
|
|
cameraFragmentResultListener.onVideoRecorded(filePath); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (callback != null) { |
|
|
|
|
|
|
|
callback.onVideoRecorded(filePath); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public void setStateListener(CameraFragmentStateListener cameraFragmentStateListener) { |
|
|
|
public void setStateListener(CameraFragmentStateListener cameraFragmentStateListener) { |
|
|
|
this.cameraFragmentStateListener = cameraFragmentStateListener; |
|
|
|
this.cameraFragmentStateListener = cameraFragmentStateListener; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public void setTextListener(CameraFragmentVideoRecordTextListener cameraFragmentVideoRecordTextListener) { |
|
|
|
public void setTextListener(CameraFragmentVideoRecordTextListener cameraFragmentVideoRecordTextListener) { |
|
|
|
this.cameraFragmentVideoRecordTextListener = cameraFragmentVideoRecordTextListener; |
|
|
|
this.cameraFragmentVideoRecordTextListener = cameraFragmentVideoRecordTextListener; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public void setControlsListener(CameraFragmentControlsListener cameraFragmentControlsListener) { |
|
|
|
public void setControlsListener(CameraFragmentControlsListener cameraFragmentControlsListener) { |
|
|
|
this.cameraFragmentControlsListener = cameraFragmentControlsListener; |
|
|
|
this.cameraFragmentControlsListener = cameraFragmentControlsListener; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public void setResultListener(CameraFragmentResultListener cameraFragmentResultListener) { |
|
|
|
public void setResultListener(CameraFragmentResultListener cameraFragmentResultListener) { |
|
|
|
this.cameraFragmentResultListener = cameraFragmentResultListener; |
|
|
|
this.cameraFragmentResultListener = cameraFragmentResultListener; |
|
|
|
} |
|
|
|
} |
|
|
|