diff --git a/CHANGELOG.md b/CHANGELOG.md index 1e804f872a5..b7a0648d4ec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,6 +29,7 @@ Summary * Enhancement - Support for SVG files added: [#1033](https://github.com/owncloud/android/issues/1033) * Enhancement - Improved copy/move dialog: [#1414](https://github.com/owncloud/android/issues/1414) * Enhancement - Thumbnail click action in file detail: [#3653](https://github.com/owncloud/android/pull/3653) +* Enhancement - Adding action buttons to the detail view of file: [#3641](https://github.com/owncloud/android/issues/3641) Details ------- @@ -194,6 +195,13 @@ Details https://github.com/owncloud/android/pull/3653 +* Enhancement - Adding action buttons to the detail view of file: [#3641](https://github.com/owncloud/android/issues/3641) + + Three new buttons have been added to the file details view and removed from the toolbar menu. + + https://github.com/owncloud/android/issues/3641 + https://github.com/owncloud/android/pull/3655 + Changelog for ownCloud Android Client [2.20.0] (2022-02-16) ======================================= The following sections list the changes in ownCloud Android Client 2.20.0 relevant to diff --git a/changelog/unreleased/3655 b/changelog/unreleased/3655 new file mode 100644 index 00000000000..264450cc1b5 --- /dev/null +++ b/changelog/unreleased/3655 @@ -0,0 +1,7 @@ +Enhancement: Adding action buttons to the detail view of file + +Three new buttons have been added to the file details view +and removed from the toolbar menu. + +https://github.com/owncloud/android/issues/3641 +https://github.com/owncloud/android/pull/3655 diff --git a/owncloudApp/src/main/java/com/owncloud/android/files/FileMenuFilter.java b/owncloudApp/src/main/java/com/owncloud/android/files/FileMenuFilter.java index 65d5a0ec31c..b61c1ae75e5 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/files/FileMenuFilter.java +++ b/owncloudApp/src/main/java/com/owncloud/android/files/FileMenuFilter.java @@ -93,7 +93,7 @@ public FileMenuFilter(OCFile targetFile, Account account, ComponentsGetter cg, * @param menu Options or context menu to filter. */ public void filter(Menu menu, boolean displaySelectAll, boolean displaySelectInverse, - boolean onlyAvailableOffline, boolean sharedByLinkFiles) { + boolean onlyAvailableOffline, boolean sharedByLinkFiles, boolean isFileDetailFragment) { if (mFiles == null || mFiles.size() <= 0) { hideAll(menu); @@ -101,7 +101,7 @@ public void filter(Menu menu, boolean displaySelectAll, boolean displaySelectInv List toShow = new ArrayList<>(); List toHide = new ArrayList<>(); - filter(toShow, toHide, displaySelectAll, displaySelectInverse, onlyAvailableOffline, sharedByLinkFiles); + filter(toShow, toHide, displaySelectAll, displaySelectInverse, onlyAvailableOffline, sharedByLinkFiles, isFileDetailFragment); MenuItem item; for (int i : toShow) { @@ -140,8 +140,8 @@ private void hideAll(Menu menu) { * @param toHide List to save the options that must be shown in the menu. */ - private void filter(List toShow, List toHide, boolean displaySelectAll, - boolean displaySelectInverse, boolean onlyAvailableOffline, boolean sharedByLinkFiles) { + private void filter(List toShow, List toHide, boolean displaySelectAll, boolean displaySelectInverse, + boolean onlyAvailableOffline, boolean sharedByLinkFiles, boolean isFileDetailFragment) { boolean synchronizing = anyFileSynchronizing(); @@ -164,7 +164,7 @@ private void filter(List toShow, List toHide, boolean displayS // DOWNLOAD if (mFiles.isEmpty() || containsFolder() || anyFileDown() || synchronizing || videoPreviewing || - onlyAvailableOffline || sharedByLinkFiles) { + onlyAvailableOffline || sharedByLinkFiles || isFileDetailFragment) { toHide.add(R.id.action_download_file); } else { @@ -198,7 +198,7 @@ private void filter(List toShow, List toHide, boolean displayS } // OPEN WITH (different to preview!) - if (!isSingleFile() || !anyFileDown() || synchronizing) { + if (!isSingleFile() || !anyFileDown() || synchronizing || isFileDetailFragment) { toHide.add(R.id.action_open_file_with); } else { @@ -249,7 +249,8 @@ private void filter(List toShow, List toHide, boolean displayS // SEND boolean sendAllowed = (mContext != null && mContext.getString(R.string.send_files_to_other_apps).equalsIgnoreCase("on")); - if (containsFolder() || (!areDownloaded() && !isSingleFile()) || !sendAllowed || synchronizing || videoStreaming || onlyAvailableOffline) { + + if (containsFolder() || (!areDownloaded() && !isSingleFile()) || !sendAllowed || synchronizing || videoStreaming || onlyAvailableOffline || isFileDetailFragment) { toHide.add(R.id.action_send_file); } else { toShow.add(R.id.action_send_file); diff --git a/owncloudApp/src/main/java/com/owncloud/android/ui/fragment/FileDetailFragment.java b/owncloudApp/src/main/java/com/owncloud/android/ui/fragment/FileDetailFragment.java index 5dd81b7baa1..1a9325d974b 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/ui/fragment/FileDetailFragment.java +++ b/owncloudApp/src/main/java/com/owncloud/android/ui/fragment/FileDetailFragment.java @@ -33,6 +33,7 @@ import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; +import android.widget.Button; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.ProgressBar; @@ -153,6 +154,7 @@ public View onCreateView(@NotNull LayoutInflater inflater, ViewGroup container, } updateFileDetails(false, false); + setButtonsClickListener(); return mView; } @@ -239,7 +241,7 @@ public void onPrepareOptionsMenu(Menu menu) { mContainerActivity, getActivity() ); - mf.filter(menu, false, false, false, false); + mf.filter(menu, false, false, false, false, true); } // additional restriction for this fragment @@ -281,7 +283,7 @@ public boolean onOptionsItemSelected(MenuItem item) { return true; } case R.id.action_open_file_with: { - mContainerActivity.getFileOperationsHelper().openFile(getFile()); + openWith(); return true; } case R.id.action_remove_file: { @@ -300,17 +302,11 @@ public boolean onOptionsItemSelected(MenuItem item) { } case R.id.action_download_file: case R.id.action_sync_file: { - mContainerActivity.getFileOperationsHelper().syncFile(getFile()); + downloadFile(); return true; } case R.id.action_send_file: { - // Obtain the file - if (!getFile().isDown()) { // Download the file - Timber.d("%s : File must be downloaded", getFile().getRemotePath()); - ((FileDisplayActivity) mContainerActivity).startDownloadForSending(getFile()); - } else { - mContainerActivity.getFileOperationsHelper().sendDownloadedFile(getFile()); - } + sendFile(); return true; } case R.id.action_set_available_offline: { @@ -326,6 +322,24 @@ public boolean onOptionsItemSelected(MenuItem item) { } } + private void openWith() { + mContainerActivity.getFileOperationsHelper().openFile(getFile()); + } + + private void downloadFile() { + mContainerActivity.getFileOperationsHelper().syncFile(getFile()); + } + + private void sendFile() { + // Obtain the file + if (!getFile().isDown()) { // Download the file + Timber.d("%s : File must be downloaded", getFile().getRemotePath()); + ((FileDisplayActivity) mContainerActivity).startDownloadForSending(getFile()); + } else { + mContainerActivity.getFileOperationsHelper().sendDownloadedFile(getFile()); + } + } + @Override public void onClick(View v) { switch (v.getId()) { @@ -335,6 +349,24 @@ public void onClick(View v) { } case R.id.fdIcon: { displayFile(getFile()); + break; + } + case R.id.button_file_detail_download: { + OCFile file = getFile(); + if (file.isDown()) { + displayFile(getFile()); + } else { + downloadFile(); + } + break; + } + case R.id.button_file_detail_open_with: { + openWith(); + break; + } + case R.id.button_file_detail_send: { + sendFile(); + break; } default: Timber.e("Incorrect view clicked!"); @@ -426,6 +458,7 @@ private void updateFileDetails(boolean forcedTransferring, boolean refresh) { setButtonsForRemote(); } } + setOpenOrDownloadButtonAction(); getView().invalidate(); } @@ -575,4 +608,29 @@ private void setButtonsForRemote() { } } + private void setButtonsClickListener() { + Button buttonDownload = getView().findViewById(R.id.button_file_detail_download); + Button buttonOpenWith = getView().findViewById(R.id.button_file_detail_open_with); + Button buttonSend = getView().findViewById(R.id.button_file_detail_send); + + buttonDownload.setOnClickListener(this); + buttonOpenWith.setOnClickListener(this); + buttonSend.setOnClickListener(this); + + setOpenOrDownloadButtonAction(); + } + + private void setOpenOrDownloadButtonAction() { + OCFile file = getFile(); + Button button = getView().findViewById(R.id.button_file_detail_download); + + if (file.isDown()) { + button.setText(getString(R.string.filedetails_open)); + button.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_open_in_new, 0, 0, 0); + } else { + button.setText(getString(R.string.filedetails_download)); + button.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_cloud_download, 0, 0, 0); + } + } + } diff --git a/owncloudApp/src/main/java/com/owncloud/android/ui/fragment/OCFileListFragment.java b/owncloudApp/src/main/java/com/owncloud/android/ui/fragment/OCFileListFragment.java index d02e0eae38a..2a9b1dfb830 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/ui/fragment/OCFileListFragment.java +++ b/owncloudApp/src/main/java/com/owncloud/android/ui/fragment/OCFileListFragment.java @@ -636,7 +636,7 @@ public boolean onPrepareActionMode(ActionMode mode, Menu menu) { getActivity() ); mf.filter(menu, mEnableSelectAll, true, mFileListOption.isAvailableOffline(), - mFileListOption.isSharedByLink()); + mFileListOption.isSharedByLink(),false); return true; } diff --git a/owncloudApp/src/main/java/com/owncloud/android/ui/helpers/FileOperationsHelper.java b/owncloudApp/src/main/java/com/owncloud/android/ui/helpers/FileOperationsHelper.java index 0525d215fca..e3156935ef4 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/ui/helpers/FileOperationsHelper.java +++ b/owncloudApp/src/main/java/com/owncloud/android/ui/helpers/FileOperationsHelper.java @@ -88,7 +88,7 @@ private Intent getIntentForGuessedMimeType(String storagePath, String type, Uri } public void openFile(OCFile ocFile) { - if (ocFile != null) { + if (ocFile != null && ocFile.isDown()) { Intent intentForSavedMimeType = getIntentForSavedMimeType(ocFile.getExposedFileUri(mFileActivity), ocFile.getMimetype()); Intent intentForGuessedMimeType = getIntentForGuessedMimeType(ocFile.getStoragePath(), ocFile.getMimetype(), @@ -97,7 +97,7 @@ public void openFile(OCFile ocFile) { openFileWithIntent(intentForSavedMimeType, intentForGuessedMimeType); } else { - Timber.e("Trying to open a NULL OCFile"); + Timber.e("Trying to open a NULL or not down OCFile"); } } diff --git a/owncloudApp/src/main/java/com/owncloud/android/ui/preview/PreviewAudioFragment.java b/owncloudApp/src/main/java/com/owncloud/android/ui/preview/PreviewAudioFragment.java index bce42db4532..c64b800f635 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/ui/preview/PreviewAudioFragment.java +++ b/owncloudApp/src/main/java/com/owncloud/android/ui/preview/PreviewAudioFragment.java @@ -315,7 +315,7 @@ public void onPrepareOptionsMenu(Menu menu) { mContainerActivity, getActivity() ); - mf.filter(menu, false, false, false, false); + mf.filter(menu, false, false, false, false,false); // additional restriction for this fragment // TODO allow renaming in PreviewAudioFragment diff --git a/owncloudApp/src/main/java/com/owncloud/android/ui/preview/PreviewImageFragment.kt b/owncloudApp/src/main/java/com/owncloud/android/ui/preview/PreviewImageFragment.kt index ce613c0e776..9bbec273ebe 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/ui/preview/PreviewImageFragment.kt +++ b/owncloudApp/src/main/java/com/owncloud/android/ui/preview/PreviewImageFragment.kt @@ -199,7 +199,7 @@ class PreviewImageFragment : FileFragment() { mContainerActivity, activity ) - fileMenuFilter.filter(menu, false, false, false, false) + fileMenuFilter.filter(menu, false, false, false, false, false) } // additional restriction for this fragment diff --git a/owncloudApp/src/main/java/com/owncloud/android/ui/preview/PreviewTextFragment.java b/owncloudApp/src/main/java/com/owncloud/android/ui/preview/PreviewTextFragment.java index 5abfa87ac53..c9cf9460f25 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/ui/preview/PreviewTextFragment.java +++ b/owncloudApp/src/main/java/com/owncloud/android/ui/preview/PreviewTextFragment.java @@ -301,7 +301,7 @@ public void onPrepareOptionsMenu(Menu menu) { mContainerActivity, getActivity() ); - mf.filter(menu, false, false, false, false); + mf.filter(menu, false, false, false, false,false); } // additional restriction for this fragment diff --git a/owncloudApp/src/main/java/com/owncloud/android/ui/preview/PreviewVideoFragment.java b/owncloudApp/src/main/java/com/owncloud/android/ui/preview/PreviewVideoFragment.java index 3eb79085164..0386d9d2f9a 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/ui/preview/PreviewVideoFragment.java +++ b/owncloudApp/src/main/java/com/owncloud/android/ui/preview/PreviewVideoFragment.java @@ -321,7 +321,7 @@ public void onPrepareOptionsMenu(@NonNull Menu menu) { mContainerActivity, getActivity() ); - mf.filter(menu, false, false, false, false); + mf.filter(menu, false, false, false, false, false); // additional restrictions for this fragment diff --git a/owncloudApp/src/main/res/drawable/ic_cloud_download.xml b/owncloudApp/src/main/res/drawable/ic_cloud_download.xml new file mode 100644 index 00000000000..164165211c7 --- /dev/null +++ b/owncloudApp/src/main/res/drawable/ic_cloud_download.xml @@ -0,0 +1,5 @@ + + + diff --git a/owncloudApp/src/main/res/drawable/ic_open_in_new.xml b/owncloudApp/src/main/res/drawable/ic_open_in_new.xml new file mode 100644 index 00000000000..54837f97419 --- /dev/null +++ b/owncloudApp/src/main/res/drawable/ic_open_in_new.xml @@ -0,0 +1,5 @@ + + + diff --git a/owncloudApp/src/main/res/drawable/ic_send.xml b/owncloudApp/src/main/res/drawable/ic_send.xml new file mode 100644 index 00000000000..35452a519fb --- /dev/null +++ b/owncloudApp/src/main/res/drawable/ic_send.xml @@ -0,0 +1,5 @@ + + + diff --git a/owncloudApp/src/main/res/drawable/ic_share.xml b/owncloudApp/src/main/res/drawable/ic_share.xml new file mode 100644 index 00000000000..a25f642592b --- /dev/null +++ b/owncloudApp/src/main/res/drawable/ic_share.xml @@ -0,0 +1,5 @@ + + + diff --git a/owncloudApp/src/main/res/layout/file_details_fragment.xml b/owncloudApp/src/main/res/layout/file_details_fragment.xml index 2d170bf6a2d..144a1fc00cd 100644 --- a/owncloudApp/src/main/res/layout/file_details_fragment.xml +++ b/owncloudApp/src/main/res/layout/file_details_fragment.xml @@ -154,6 +154,55 @@ app:layout_constraintEnd_toEndOf="parent" app:layout_constraintTop_toBottomOf="@id/fdProgressText" /> + + +