Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New feature: Capture Video #603

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1077,6 +1077,8 @@ else if (which == 2) // upload file
pickFile();
else if (which == 3) // take a photo
CameraTakePhoto();
else if (which == 4) // capture a video
CameraCaptureVideo();
}
}).show();
}
Expand Down Expand Up @@ -1153,6 +1155,26 @@ private void CameraTakePhoto() {
}
}

private File captureCameraVideoTempFile;

private void CameraCaptureVideo() {
Intent videoCaptureIntent = new Intent("android.media.action.VIDEO_CAPTURE");

try {
File VideoDir = DataManager.createTempDir();

String fileName = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date()) + ".mp4";
captureCameraVideoTempFile = new File(VideoDir, fileName);

Uri video = Uri.fromFile(captureCameraVideoTempFile);
videoCaptureIntent.putExtra(MediaStore.EXTRA_OUTPUT, video);
startActivityForResult(videoCaptureIntent, CAPTURE_VIDEO_REQUEST);

} catch (IOException e) {
showShortToast(BrowserActivity.this, R.string.unknow_error);
}
}

public void enableUpButton() {
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
setSupportActionBar(getActionBarToolbar());
Expand Down Expand Up @@ -1219,6 +1241,7 @@ private void refreshViewOnSlideTabs(int position) {
public static final int TAKE_PHOTO_REQUEST = 4;
public static final int CHOOSE_COPY_MOVE_DEST_REQUEST = 5;
public static final int DOWNLOAD_FILE_REQUEST = 6;
public static final int CAPTURE_VIDEO_REQUEST = 7;

public boolean hasRepoWritePermission() {
if (navContext == null) {
Expand Down Expand Up @@ -1359,6 +1382,29 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {

}
break;
case CAPTURE_VIDEO_REQUEST:
if (resultCode == RESULT_OK) {
showShortToast(this, getString(R.string.capture_video_successfully));
if (!Utils.isNetworkOn()) {
showShortToast(this, R.string.network_down);
return;
}

if(captureCameraVideoTempFile == null) {
showShortToast(this, getString(R.string.saf_upload_path_not_available));
Log.i(DEBUG_TAG, "Pick file request did not return a path");
return;
}
showShortToast(this, getString(R.string.added_to_upload_tasks));
final SeafRepo repo = dataManager.getCachedRepoByID(navContext.getRepoID());
if (repo != null && repo.canLocalDecrypt()) {
addUploadBlocksTask(navContext.getRepoID(), navContext.getRepoName(), navContext.getDirPath(), captureCameraVideoTempFile.getAbsolutePath(), repo.encVersion);
} else {
addUploadTask(navContext.getRepoID(), navContext.getRepoName(), navContext.getDirPath(), captureCameraVideoTempFile.getAbsolutePath());
}

}
break;
case DOWNLOAD_FILE_REQUEST:
if (resultCode == RESULT_OK) {
File file = new File(data.getStringExtra("path"));
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@
<item>Create folder</item>
<item>Upload file</item>
<item>Take a photo</item>
<item>Capture a video</item>
</string-array>
<string name="create_new_repo">Create a new library</string>
<string name="create_new_repo_success">Successfully created library %s</string>
Expand Down Expand Up @@ -186,6 +187,7 @@
<string name="added_to_upload_tasks">Uploading started</string>
<string name="added_photo_to_upload_tasks">Photo uploading started</string>
<string name="take_photo_successfully">Take photo successfully</string>
<string name="capture_video_successfully">Capture video successfully</string>
<string name="tabs_library">Libraries</string>
<string name="tabs_activity">Activities</string>
<string name="tabs_starred">Starred</string>
Expand Down