88 * @author David González Verdugo
99 * @author Shashvat Kedia
1010 * @author Abel García de Prada
11+ * @author David Crespo Rios
1112 * Copyright (C) 2011 Bartek Przybylski
12- * Copyright (C) 2020 ownCloud GmbH.
13+ * Copyright (C) 2022 ownCloud GmbH.
1314 * <p>
1415 * This program is free software: you can redistribute it and/or modify
1516 * it under the terms of the GNU General Public License version 2,
@@ -350,42 +351,39 @@ private void registerFabListeners() {
350351 * on the Upload mini FAB for the linked action an {@link Snackbar} showing the underlying action.
351352 */
352353 private void registerFabUploadListeners () {
353- getFabUpload ().setOnClickListener (new View .OnClickListener () {
354- @ Override
355- public void onClick (View v ) {
356- final View uploadBottomSheet = getLayoutInflater ().inflate (R .layout .upload_bottom_sheet_fragment , null );
357- final BottomSheetDialog dialog = new BottomSheetDialog (requireContext ());
358- dialog .setContentView (uploadBottomSheet );
359- final BottomSheetFragmentItemView uploadFromFilesItemView = uploadBottomSheet .findViewById (R .id .upload_from_files_item_view );
360- BottomSheetFragmentItemView uploadFromCameraItemView =
361- uploadBottomSheet .findViewById (R .id .upload_from_camera_item_view );
362- TextView uploadToTextView = uploadBottomSheet .findViewById (R .id .upload_to_text_view );
363- uploadFromFilesItemView .setOnTouchListener ((v13 , event ) -> {
364- Intent action = new Intent (Intent .ACTION_GET_CONTENT );
365- action = action .setType (ALL_FILES_SAF_REGEX ).addCategory (Intent .CATEGORY_OPENABLE );
366- action .putExtra (Intent .EXTRA_ALLOW_MULTIPLE , true );
367- getActivity ().startActivityForResult (
368- Intent .createChooser (action , getString (R .string .upload_chooser_title )),
369- FileDisplayActivity .REQUEST_CODE__SELECT_CONTENT_FROM_APPS
370- );
371- dialog .hide ();
372- return false ;
373- });
374- uploadFromCameraItemView .setOnTouchListener ((v12 , event ) -> {
375- ((FileDisplayActivity ) getActivity ()).getFilesUploadHelper ().uploadFromCamera (FileDisplayActivity .REQUEST_CODE__UPLOAD_FROM_CAMERA );
376- dialog .hide ();
377- return false ;
378- });
379- uploadToTextView .setText (String .format (getResources ().getString (R .string .upload_to ),
380- getResources ().getString (R .string .app_name )));
381- final BottomSheetBehavior uploadBottomSheetBehavior =
382- BottomSheetBehavior .from ((View ) uploadBottomSheet .getParent ());
383- dialog .setOnShowListener (dialog1 ->
384- uploadBottomSheetBehavior .setPeekHeight (uploadBottomSheet .getMeasuredHeight ()));
385- dialog .show ();
386- getFabMain ().collapse ();
387- recordMiniFabClick ();
388- }
354+ getFabUpload ().setOnClickListener (v -> {
355+ final View uploadBottomSheet = getLayoutInflater ().inflate (R .layout .upload_bottom_sheet_fragment , null );
356+ final BottomSheetDialog dialog = new BottomSheetDialog (requireContext ());
357+ dialog .setContentView (uploadBottomSheet );
358+ final BottomSheetFragmentItemView uploadFromFilesItemView = uploadBottomSheet .findViewById (R .id .upload_from_files_item_view );
359+ BottomSheetFragmentItemView uploadFromCameraItemView =
360+ uploadBottomSheet .findViewById (R .id .upload_from_camera_item_view );
361+ TextView uploadToTextView = uploadBottomSheet .findViewById (R .id .upload_to_text_view );
362+ uploadFromFilesItemView .setOnTouchListener ((v13 , event ) -> {
363+ Intent action = new Intent (Intent .ACTION_GET_CONTENT );
364+ action = action .setType (ALL_FILES_SAF_REGEX ).addCategory (Intent .CATEGORY_OPENABLE );
365+ action .putExtra (Intent .EXTRA_ALLOW_MULTIPLE , true );
366+ getActivity ().startActivityForResult (
367+ Intent .createChooser (action , getString (R .string .upload_chooser_title )),
368+ FileDisplayActivity .REQUEST_CODE__SELECT_CONTENT_FROM_APPS
369+ );
370+ dialog .hide ();
371+ return false ;
372+ });
373+ uploadFromCameraItemView .setOnTouchListener ((v12 , event ) -> {
374+ ((FileDisplayActivity ) getActivity ()).getFilesUploadHelper ().uploadFromCamera (FileDisplayActivity .REQUEST_CODE__UPLOAD_FROM_CAMERA );
375+ dialog .hide ();
376+ return false ;
377+ });
378+ uploadToTextView .setText (String .format (getResources ().getString (R .string .upload_to ),
379+ getResources ().getString (R .string .app_name )));
380+ final BottomSheetBehavior uploadBottomSheetBehavior =
381+ BottomSheetBehavior .from ((View ) uploadBottomSheet .getParent ());
382+ dialog .setOnShowListener (dialog1 ->
383+ uploadBottomSheetBehavior .setPeekHeight (uploadBottomSheet .getMeasuredHeight ()));
384+ dialog .show ();
385+ getFabMain ().collapse ();
386+ recordMiniFabClick ();
389387 });
390388
391389 getFabUpload ().setOnLongClickListener (v -> {
@@ -943,9 +941,7 @@ private boolean onFileActionChosen(int menuId) {
943941 case R .id .action_send_file : {
944942 // Obtain the file
945943 if (!singleFile .isDown ()) { // Download the file
946- Timber .d ("%s : File must be downloaded" , singleFile .getRemotePath ());
947944 ((FileDisplayActivity ) mContainerActivity ).startDownloadForSending (singleFile );
948-
949945 } else {
950946 mContainerActivity .getFileOperationsHelper ().sendDownloadedFile (singleFile );
951947 }
@@ -970,6 +966,12 @@ private boolean onFileActionChosen(int menuId) {
970966 }
971967 return true ;
972968 }
969+ case R .id .action_send_file : {
970+ if (checkedFiles .size () > 1 && filesAreDown (checkedFiles )) {
971+ mContainerActivity .getFileOperationsHelper ().sendDownloadedFiles (checkedFiles );
972+ }
973+ return true ;
974+ }
973975 case R .id .action_remove_file : {
974976 RemoveFilesDialogFragment dialog = RemoveFilesDialogFragment .newInstance (checkedFiles );
975977 dialog .show (getFragmentManager (), ConfirmationDialogFragment .FTAG_CONFIRMATION );
@@ -1081,6 +1083,16 @@ public void listDirectory(OCFile directory) {
10811083 }
10821084 }
10831085
1086+ private boolean filesAreDown (ArrayList <OCFile > checkedFiles ) {
1087+ for (int i = 0 ; i < checkedFiles .size (); i ++) {
1088+ if (!checkedFiles .get (i ).isDown ()) {
1089+ Timber .d ("%s : File must be downloaded" , checkedFiles .get (i ).getRemotePath ());
1090+ return false ;
1091+ }
1092+ }
1093+ return true ;
1094+ }
1095+
10841096 private void updateLayout () {
10851097 if (!isShowingJustFolders ()) {
10861098 int filesCount = 0 , foldersCount = 0 ;
0 commit comments