Skip to content
Open
Show file tree
Hide file tree
Changes from 8 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
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
-------
Expand Down Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions changelog/unreleased/3655
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,15 @@ 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);

} else {
List<Integer> toShow = new ArrayList<>();
List<Integer> toHide = new ArrayList<>();

filter(toShow, toHide, displaySelectAll, displaySelectInverse, onlyAvailableOffline, sharedByLinkFiles);
filter(toShow, toHide, displaySelectAll, displaySelectInverse, onlyAvailableOffline, sharedByLinkFiles, isFileDetailFragment);

MenuItem item;
for (int i : toShow) {
Expand Down Expand Up @@ -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<Integer> toShow, List<Integer> toHide, boolean displaySelectAll,
boolean displaySelectInverse, boolean onlyAvailableOffline, boolean sharedByLinkFiles) {
private void filter(List<Integer> toShow, List<Integer> toHide, boolean displaySelectAll, boolean displaySelectInverse,
boolean onlyAvailableOffline, boolean sharedByLinkFiles, boolean isFileDetailFragment) {

boolean synchronizing = anyFileSynchronizing();

Expand All @@ -164,7 +164,7 @@ private void filter(List<Integer> toShow, List<Integer> toHide, boolean displayS

// DOWNLOAD
if (mFiles.isEmpty() || containsFolder() || anyFileDown() || synchronizing || videoPreviewing ||
onlyAvailableOffline || sharedByLinkFiles) {
onlyAvailableOffline || sharedByLinkFiles || isFileDetailFragment) {
toHide.add(R.id.action_download_file);

} else {
Expand Down Expand Up @@ -198,7 +198,7 @@ private void filter(List<Integer> toShow, List<Integer> 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 {
Expand Down Expand Up @@ -249,7 +249,8 @@ private void filter(List<Integer> toShow, List<Integer> 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -153,6 +154,7 @@ public View onCreateView(@NotNull LayoutInflater inflater, ViewGroup container,
}

updateFileDetails(false, false);
setButtonsClickListener();
return mView;
}

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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: {
Expand All @@ -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: {
Expand All @@ -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()) {
Expand All @@ -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!");
Expand Down Expand Up @@ -426,6 +458,7 @@ private void updateFileDetails(boolean forcedTransferring, boolean refresh) {
setButtonsForRemote();
}
}
setOpenOrDownloadButtonAction();
getView().invalidate();
}

Expand Down Expand Up @@ -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);
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
5 changes: 5 additions & 0 deletions owncloudApp/src/main/res/drawable/ic_cloud_download.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<vector android:height="24dp" android:tint="#7C7C7D"
android:viewportHeight="24" android:viewportWidth="24"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="@android:color/white" android:pathData="M19.35,10.04C18.67,6.59 15.64,4 12,4 9.11,4 6.6,5.64 5.35,8.04 2.34,8.36 0,10.91 0,14c0,3.31 2.69,6 6,6h13c2.76,0 5,-2.24 5,-5 0,-2.64 -2.05,-4.78 -4.65,-4.96zM17,13l-5,5 -5,-5h3V9h4v4h3z"/>
</vector>
5 changes: 5 additions & 0 deletions owncloudApp/src/main/res/drawable/ic_open_in_new.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<vector android:height="24dp" android:tint="#7C7C7D"
android:viewportHeight="24" android:viewportWidth="24"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="@android:color/white" android:pathData="M19,19H5V5h7V3H5c-1.11,0 -2,0.9 -2,2v14c0,1.1 0.89,2 2,2h14c1.1,0 2,-0.9 2,-2v-7h-2v7zM14,3v2h3.59l-9.83,9.83 1.41,1.41L19,6.41V10h2V3h-7z"/>
</vector>
5 changes: 5 additions & 0 deletions owncloudApp/src/main/res/drawable/ic_send.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<vector android:autoMirrored="true" android:height="24dp"
android:tint="#7C7C7D" android:viewportHeight="24"
android:viewportWidth="24" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="@android:color/white" android:pathData="M2.01,21L23,12 2.01,3 2,10l15,2 -15,2z"/>
</vector>
5 changes: 5 additions & 0 deletions owncloudApp/src/main/res/drawable/ic_share.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<vector android:height="24dp" android:tint="#7C7C7D"
android:viewportHeight="24" android:viewportWidth="24"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="@android:color/white" android:pathData="M18,16.08c-0.76,0 -1.44,0.3 -1.96,0.77L8.91,12.7c0.05,-0.23 0.09,-0.46 0.09,-0.7s-0.04,-0.47 -0.09,-0.7l7.05,-4.11c0.54,0.5 1.25,0.81 2.04,0.81 1.66,0 3,-1.34 3,-3s-1.34,-3 -3,-3 -3,1.34 -3,3c0,0.24 0.04,0.47 0.09,0.7L8.04,9.81C7.5,9.31 6.79,9 6,9c-1.66,0 -3,1.34 -3,3s1.34,3 3,3c0.79,0 1.5,-0.31 2.04,-0.81l7.12,4.16c-0.05,0.21 -0.08,0.43 -0.08,0.65 0,1.61 1.31,2.92 2.92,2.92 1.61,0 2.92,-1.31 2.92,-2.92s-1.31,-2.92 -2.92,-2.92z"/>
</vector>
49 changes: 49 additions & 0 deletions owncloudApp/src/main/res/layout/file_details_fragment.xml
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,55 @@
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/fdProgressText" />

<View
android:id="@+id/view_file_detail_separator"
android:layout_width="0dp"
android:layout_height="1dp"
android:layout_marginTop="@dimen/standard_padding"
android:alpha="0.8"
android:background="@color/owncloud_blue"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@id/fdProgressBar" />

<Button
android:id="@+id/button_file_detail_download"
style="@style/Button.FileDetail"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@id/view_file_detail_separator"
tools:drawableStart="@drawable/ic_cloud_download"
tools:text="@string/filedetails_download" />

<Button
android:id="@+id/button_file_detail_open_with"
style="@style/Button.FileDetail"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:drawableStart="@drawable/ic_share"
android:text="@string/filedetails_open_with"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@id/button_file_detail_download" />

<Button
android:id="@+id/button_file_detail_send"
style="@style/Button.FileDetail"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:drawableStart="@drawable/ic_send"
android:text="@string/filedetails_send"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toLeftOf="@id/barrier"
app:layout_constraintTop_toBottomOf="@id/button_file_detail_open_with" />

<androidx.constraintlayout.widget.Barrier
android:id="@+id/barrier"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:barrierDirection="end"
app:constraint_referenced_ids="button_file_detail_download,button_file_detail_open_with" />

</androidx.constraintlayout.widget.ConstraintLayout>

</ScrollView>
3 changes: 3 additions & 0 deletions owncloudApp/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,9 @@
<string name="filedetails_created">Created:</string>
<string name="filedetails_modified">Modified:</string>
<string name="filedetails_download">Download</string>
<string name="filedetails_open_with">Open with</string>
<string name="filedetails_open">Open</string>
<string name="filedetails_send">Send</string>
<string name="filedetails_file_image_content_description">File Image</string>
<string name="filedetails_cancel_btn_content_description">Cancel download button</string>
<string name="filedetails_sync_file">Synchronize</string>
Expand Down
12 changes: 11 additions & 1 deletion owncloudApp/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<resources xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools">

<style name="Animations" />

Expand Down Expand Up @@ -298,4 +298,14 @@
<style name="Theme.ownCloud.SortBottomSheetFragment.Item">
<item name="android:textAppearance">@style/TextAppearance.OwnCloud.SortBottomSheetFragment.Item</item>
</style>

<style name="Button.FileDetail" parent="Widget.MaterialComponents.Button.TextButton">
<item name="textAllCaps">true</item>
<item name="android:textSize">12sp</item>
<item name="android:textColor">@color/owncloud_blue</item>
<item name="android:gravity">start|center_vertical</item>
<item name="android:drawableTint" tools:targetApi="m">@color/owncloud_blue</item>
<item name="android:layout_marginTop">@dimen/standard_half_margin</item>
<item name="android:drawablePadding">@dimen/standard_margin</item>
</style>
</resources>