diff --git a/app/src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.java b/app/src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.java
index 17eaa3c75b79..5a36009fb8d8 100644
--- a/app/src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.java
+++ b/app/src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.java
@@ -198,6 +198,7 @@ public class FileDisplayActivity extends FileActivity
public static final int REQUEST_CODE__SELECT_FILES_FROM_FILE_SYSTEM = REQUEST_CODE__LAST_SHARED + 2;
public static final int REQUEST_CODE__MOVE_OR_COPY_FILES = REQUEST_CODE__LAST_SHARED + 3;
public static final int REQUEST_CODE__UPLOAD_FROM_CAMERA = REQUEST_CODE__LAST_SHARED + 5;
+ public static final int REQUEST_CODE__UPLOAD_FROM_VIDEO_CAMERA = REQUEST_CODE__LAST_SHARED + 6;
protected static final long DELAY_TO_REQUEST_REFRESH_OPERATION_LATER = DELAY_TO_REQUEST_OPERATIONS_LATER + 350;
@@ -447,7 +448,7 @@ public void onRequestPermissionsResult(int requestCode, @NonNull String[] permis
// If request is cancelled, result arrays are empty.
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
// permission was granted
- getFileOperationsHelper().uploadFromCamera(this, FileDisplayActivity.REQUEST_CODE__UPLOAD_FROM_CAMERA);
+ getOCFileListFragmentFromFile().directCameraUpload();
}
break;
default:
@@ -851,7 +852,7 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
requestUploadOfFilesFromFileSystem(data, resultCode);
- } else if (requestCode == REQUEST_CODE__UPLOAD_FROM_CAMERA && (resultCode == RESULT_OK || resultCode == UploadFilesActivity.RESULT_OK_AND_DELETE)) {
+ } else if ((requestCode == REQUEST_CODE__UPLOAD_FROM_CAMERA || requestCode == REQUEST_CODE__UPLOAD_FROM_VIDEO_CAMERA) && (resultCode == RESULT_OK || resultCode == UploadFilesActivity.RESULT_OK_AND_DELETE)) {
new CheckAvailableSpaceTask(new CheckAvailableSpaceTask.CheckAvailableSpaceListener() {
@Override
@@ -865,17 +866,22 @@ public void onCheckAvailableSpaceFinish(boolean hasEnoughSpaceAvailable, String.
if (hasEnoughSpaceAvailable) {
File file = new File(filesToUpload[0]);
- File renamedFile = new File(file.getParent() + PATH_SEPARATOR + FileOperationsHelper.getCapturedImageName());
+ File renamedFile;
+ if(requestCode == REQUEST_CODE__UPLOAD_FROM_CAMERA) {
+ renamedFile = new File(file.getParent() + PATH_SEPARATOR + FileOperationsHelper.getCapturedImageName());
+ } else {
+ renamedFile = new File(file.getParent() + PATH_SEPARATOR + FileOperationsHelper.getCapturedVideoName());
+ }
if (!file.renameTo(renamedFile)) {
- DisplayUtils.showSnackMessage(getActivity(), "Fail to upload taken image!");
+ DisplayUtils.showSnackMessage(getActivity(), R.string.error_uploading_direct_camera_upload);
return;
}
requestUploadOfFilesFromFileSystem(renamedFile.getParentFile().getAbsolutePath(), new String[]{renamedFile.getAbsolutePath()}, FileUploadWorker.LOCAL_BEHAVIOUR_DELETE);
}
}
- }, new String[]{FileOperationsHelper.createImageFile(getActivity()).getAbsolutePath()}).execute();
+ }, new String[]{FileOperationsHelper.createCameraFile(getActivity(), requestCode == REQUEST_CODE__UPLOAD_FROM_VIDEO_CAMERA).getAbsolutePath()}).execute();
} else if (requestCode == REQUEST_CODE__MOVE_OR_COPY_FILES && resultCode == RESULT_OK) {
exitSelectionMode();
} else if (requestCode == PermissionUtil.REQUEST_CODE_MANAGE_ALL_FILES) {
diff --git a/app/src/main/java/com/owncloud/android/ui/fragment/OCFileListBottomSheetDialog.java b/app/src/main/java/com/owncloud/android/ui/fragment/OCFileListBottomSheetDialog.java
index 65f45bfe4d77..2deb69e0537d 100644
--- a/app/src/main/java/com/owncloud/android/ui/fragment/OCFileListBottomSheetDialog.java
+++ b/app/src/main/java/com/owncloud/android/ui/fragment/OCFileListBottomSheetDialog.java
@@ -11,6 +11,7 @@
import com.google.android.material.bottomsheet.BottomSheetDialog;
import com.google.gson.Gson;
+import com.nextcloud.android.common.ui.theme.utils.ColorRole;
import com.nextcloud.client.account.User;
import com.nextcloud.client.device.DeviceInfo;
import com.nextcloud.client.di.Injectable;
@@ -75,12 +76,12 @@ protected void onCreate(Bundle savedInstanceState) {
binding = FileListActionsBottomSheetFragmentBinding.inflate(getLayoutInflater());
setContentView(binding.getRoot());
- viewThemeUtils.platform.colorImageView(binding.menuIconUploadFiles);
- viewThemeUtils.platform.colorImageView(binding.menuIconUploadFromApp);
- viewThemeUtils.platform.colorImageView(binding.menuIconDirectCameraUpload);
- viewThemeUtils.platform.colorImageView(binding.menuIconScanDocUpload);
- viewThemeUtils.platform.colorImageView(binding.menuIconMkdir);
- viewThemeUtils.platform.colorImageView(binding.menuIconAddFolderInfo);
+ viewThemeUtils.platform.colorImageView(binding.menuIconUploadFiles, ColorRole.PRIMARY);
+ viewThemeUtils.platform.colorImageView(binding.menuIconUploadFromApp, ColorRole.PRIMARY);
+ viewThemeUtils.platform.colorImageView(binding.menuIconDirectCameraUpload, ColorRole.PRIMARY);
+ viewThemeUtils.platform.colorImageView(binding.menuIconScanDocUpload, ColorRole.PRIMARY);
+ viewThemeUtils.platform.colorImageView(binding.menuIconMkdir, ColorRole.PRIMARY);
+ viewThemeUtils.platform.colorImageView(binding.menuIconAddFolderInfo, ColorRole.PRIMARY);
binding.addToCloud.setText(getContext().getResources().getString(R.string.add_to_cloud,
themeUtils.getDefaultDisplayNameForRootFolder(getContext())));
diff --git a/app/src/main/java/com/owncloud/android/ui/fragment/OCFileListFragment.java b/app/src/main/java/com/owncloud/android/ui/fragment/OCFileListFragment.java
index 149577e4082c..1d74f1d16ec1 100644
--- a/app/src/main/java/com/owncloud/android/ui/fragment/OCFileListFragment.java
+++ b/app/src/main/java/com/owncloud/android/ui/fragment/OCFileListFragment.java
@@ -14,6 +14,7 @@
*/
package com.owncloud.android.ui.fragment;
+import android.Manifest;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
@@ -108,6 +109,7 @@
import com.owncloud.android.utils.FileSortOrder;
import com.owncloud.android.utils.FileStorageUtils;
import com.owncloud.android.utils.MimeTypeUtil;
+import com.owncloud.android.utils.PermissionUtil;
import com.owncloud.android.utils.theme.ThemeUtils;
import com.owncloud.android.utils.theme.ViewThemeUtils;
@@ -131,6 +133,7 @@
import androidx.annotation.OptIn;
import androidx.annotation.StringRes;
import androidx.appcompat.app.ActionBar;
+import androidx.appcompat.app.AlertDialog;
import androidx.coordinatorlayout.widget.CoordinatorLayout;
import androidx.core.content.ContextCompat;
import androidx.drawerlayout.widget.DrawerLayout;
@@ -521,12 +524,29 @@ public void uploadFromApp() {
public void directCameraUpload() {
FileDisplayActivity fileDisplayActivity = (FileDisplayActivity) getActivity();
- if (fileDisplayActivity != null) {
- fileDisplayActivity.getFileOperationsHelper()
- .uploadFromCamera(fileDisplayActivity, FileDisplayActivity.REQUEST_CODE__UPLOAD_FROM_CAMERA);
- } else {
+ if (fileDisplayActivity == null) {
DisplayUtils.showSnackMessage(getView(), getString(R.string.error_starting_direct_camera_upload));
+ return;
+ }
+
+ if (!PermissionUtil.checkSelfPermission(fileDisplayActivity, Manifest.permission.CAMERA)) {
+ PermissionUtil.requestCameraPermission(fileDisplayActivity, PermissionUtil.PERMISSIONS_CAMERA);
+ return;
}
+
+ showDirectCameraUploadAlertDialog(fileDisplayActivity);
+ }
+
+ private void showDirectCameraUploadAlertDialog(FileDisplayActivity fileDisplayActivity) {
+ AlertDialog.Builder builder = new AlertDialog.Builder(fileDisplayActivity);
+ AlertDialog dialog = builder.setIcon(R.mipmap.ic_launcher)
+ .setTitle(R.string.upload_direct_camera_promt)
+ .setNegativeButton(R.string.upload_direct_camera_video, (iface, id) ->
+ fileDisplayActivity.getFileOperationsHelper().uploadFromCamera(fileDisplayActivity,FileDisplayActivity.REQUEST_CODE__UPLOAD_FROM_VIDEO_CAMERA, true))
+ .setPositiveButton(R.string.upload_direct_camera_photo, (iface, id) ->
+ fileDisplayActivity.getFileOperationsHelper().uploadFromCamera(fileDisplayActivity, FileDisplayActivity.REQUEST_CODE__UPLOAD_FROM_CAMERA, false))
+ .create();
+ dialog.show();
}
@Override
diff --git a/app/src/main/java/com/owncloud/android/ui/helpers/FileOperationsHelper.java b/app/src/main/java/com/owncloud/android/ui/helpers/FileOperationsHelper.java
index ece593b437a8..4ee3e691b7a1 100755
--- a/app/src/main/java/com/owncloud/android/ui/helpers/FileOperationsHelper.java
+++ b/app/src/main/java/com/owncloud/android/ui/helpers/FileOperationsHelper.java
@@ -13,7 +13,6 @@
*/
package com.owncloud.android.ui.helpers;
-import android.Manifest;
import android.accounts.Account;
import android.app.Activity;
import android.content.ActivityNotFoundException;
@@ -69,7 +68,6 @@
import com.owncloud.android.utils.DisplayUtils;
import com.owncloud.android.utils.EncryptionUtils;
import com.owncloud.android.utils.FileStorageUtils;
-import com.owncloud.android.utils.PermissionUtil;
import com.owncloud.android.utils.UriUtils;
import com.owncloud.android.utils.theme.ViewThemeUtils;
@@ -1058,36 +1056,44 @@ public void checkCurrentCredentials(User user) {
fileActivity.showLoadingDialog(fileActivity.getString(R.string.wait_checking_credentials));
}
- public void uploadFromCamera(Activity activity, int requestCode) {
- Intent pictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
+ public void uploadFromCamera(Activity activity, int requestCode, boolean isVideo) {
+ Intent intent;
+ if (isVideo) {
- File photoFile = createImageFile(activity);
+ // FIXME Not working on Emulator
+ intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
+ } else {
+ intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
+ }
- Uri photoUri = FileProvider.getUriForFile(activity.getApplicationContext(),
- activity.getResources().getString(R.string.file_provider_authority), photoFile);
- pictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoUri);
+ File cameraFile = createCameraFile(activity, isVideo);
- if (pictureIntent.resolveActivity(activity.getPackageManager()) != null) {
- if (PermissionUtil.checkSelfPermission(activity, Manifest.permission.CAMERA)) {
- activity.startActivityForResult(pictureIntent, requestCode);
- } else {
- PermissionUtil.requestCameraPermission(activity, PermissionUtil.PERMISSIONS_CAMERA);
- }
+ Uri cameraUri = FileProvider.getUriForFile(activity.getApplicationContext(),
+ activity.getResources().getString(R.string.file_provider_authority), cameraFile);
+ intent.putExtra(MediaStore.EXTRA_OUTPUT, cameraUri);
+
+ if (intent.resolveActivity(activity.getPackageManager()) != null) {
+ activity.startActivityForResult(intent, requestCode);
} else {
DisplayUtils.showSnackMessage(activity, "No Camera found");
}
}
- public static File createImageFile(Activity activity) {
- File storageDir = activity.getExternalFilesDir(Environment.DIRECTORY_PICTURES);
-
- return new File(storageDir + "/directCameraUpload.jpg");
+ public static File createCameraFile(Activity activity, boolean isVideo) {
+ String directory = isVideo ? Environment.DIRECTORY_MOVIES : Environment.DIRECTORY_PICTURES;
+ File storageDir = activity.getExternalFilesDir(directory);
+ String fileName = isVideo ? "/directCameraUpload.mp4" : "/directCameraUpload.jpg";
+ return new File(storageDir + fileName);
}
public static String getCapturedImageName() {
return getTimestampedFileName(".jpg");
}
+ public static String getCapturedVideoName() {
+ return getTimestampedFileName(".mp4");
+ }
+
/**
* @param extension a file extension, including the dot
* @return a filename with the given extension, based on the current date and time.
diff --git a/app/src/main/res/values-b+en+001/strings.xml b/app/src/main/res/values-b+en+001/strings.xml
index 9a0a6b856383..a853f69b613e 100644
--- a/app/src/main/res/values-b+en+001/strings.xml
+++ b/app/src/main/res/values-b+en+001/strings.xml
@@ -904,6 +904,10 @@
Upload from…
Upload content from other apps
Upload from camera
+ Do you want to take a photo or video?
+ Photo
+ Video
+ Failed to upload taken media
Filename
Filetype
Google Maps shortcut file(%s)
diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml
index 6006d82ab53b..0594fb05e41b 100644
--- a/app/src/main/res/values-de/strings.xml
+++ b/app/src/main/res/values-de/strings.xml
@@ -904,6 +904,10 @@
Dateien hochladen von…
Inhalt anderer Apps hochladen
Von Kamera hochladen
+ Möchten Sie ein Foto oder Video aufnehmen?
+ Foto
+ Video
+ Hochladen von Medien fehlgeschlagen
Dateiname
Dateityp
Google Maps Abkürzungs-Datei (%s)
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index d3bcdc8e5459..3b2bbd71bf79 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -812,6 +812,10 @@
Add to %1$s
Upload files
Upload from camera
+ Do you want to take a photo or video?
+ Photo
+ Video
+ Failed to upload taken media
Scan document from camera
Upload content from other apps
New folder