Skip to content

Commit 0393764

Browse files
authored
Merge pull request #3653 from owncloud/feature/thumbnail_click_action
Preview available when user clicks on thumbnail in file detail
2 parents c62afdd + 3c95e01 commit 0393764

4 files changed

Lines changed: 57 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ Summary
2323
* Enhancement - New option to show or not hidden files: [#2578](https://github.com/owncloud/android/issues/2578)
2424
* Enhancement - Option to allow screenshots or not in Android Enterprise: [#3625](https://github.com/owncloud/android/issues/3625)
2525
* Enhancement - Full name is shown in shares: [#1106](https://github.com/owncloud/android/issues/1106)
26+
* Enhancement - Thumbnail click action in file detail: [#3653](https://github.com/owncloud/android/pull/3653)
2627

2728
Details
2829
-------
@@ -143,6 +144,13 @@ Details
143144
https://github.com/owncloud/android/issues/1106
144145
https://github.com/owncloud/android/pull/3636
145146

147+
* Enhancement - Thumbnail click action in file detail: [#3653](https://github.com/owncloud/android/pull/3653)
148+
149+
When a user clicks on a file's detail view thumbnail, the file is automatically downloaded and
150+
previewed.
151+
152+
https://github.com/owncloud/android/pull/3653
153+
146154
Changelog for ownCloud Android Client [2.20.0] (2022-02-16)
147155
=======================================
148156
The following sections list the changes in ownCloud Android Client 2.20.0 relevant to

changelog/unreleased/3653

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Enhancement: Thumbnail click action in file detail
2+
3+
When a user clicks on a file's detail view thumbnail,
4+
the file is automatically downloaded and previewed.
5+
6+
https://github.com/owncloud/android/pull/3653

owncloudApp/src/main/java/com/owncloud/android/ui/fragment/FileDetailFragment.java

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@
5353
import com.owncloud.android.ui.controller.TransferProgressController;
5454
import com.owncloud.android.ui.dialog.RemoveFilesDialogFragment;
5555
import com.owncloud.android.ui.dialog.RenameFileDialogFragment;
56+
import com.owncloud.android.ui.preview.PreviewAudioFragment;
57+
import com.owncloud.android.ui.preview.PreviewImageFragment;
58+
import com.owncloud.android.ui.preview.PreviewTextFragment;
59+
import com.owncloud.android.ui.preview.PreviewVideoFragment;
5660
import com.owncloud.android.utils.DisplayUtils;
5761
import com.owncloud.android.utils.MimetypeIconUtil;
5862
import com.owncloud.android.utils.PreferenceUtils;
@@ -329,11 +333,48 @@ public void onClick(View v) {
329333
((FileDisplayActivity) mContainerActivity).cancelTransference(getFile());
330334
break;
331335
}
336+
case R.id.fdIcon: {
337+
displayFile(getFile());
338+
}
332339
default:
333340
Timber.e("Incorrect view clicked!");
334341
}
335342
}
336343

344+
private void displayFile(OCFile file) {
345+
if (PreviewImageFragment.canBePreviewed(file)) {
346+
// preview image - it handles the sync, if needed
347+
((FileDisplayActivity) mContainerActivity).startImagePreview(file);
348+
} else if (PreviewTextFragment.canBePreviewed(file)) {
349+
((FileDisplayActivity) mContainerActivity).startTextPreview(file);
350+
mContainerActivity.getFileOperationsHelper().syncFile(file);
351+
352+
} else if (PreviewAudioFragment.canBePreviewed(file)) {
353+
// media preview
354+
((FileDisplayActivity) mContainerActivity).startAudioPreview(file, 0);
355+
mContainerActivity.getFileOperationsHelper().syncFile(file);
356+
357+
} else if (PreviewVideoFragment.canBePreviewed(file) && !file.isDownloading()) {
358+
// Available offline exception, don't initialize streaming
359+
if (!file.isDown() && file.isAvailableOffline()) {
360+
// sync file content, then open with external apps
361+
((FileDisplayActivity) mContainerActivity).startSyncThenOpen(file);
362+
} else {
363+
// media preview
364+
((FileDisplayActivity) mContainerActivity).startVideoPreview(file, 0);
365+
}
366+
367+
// If the file is already downloaded sync it, just to update it if there is a
368+
// new available file version
369+
if (file.isDown()) {
370+
mContainerActivity.getFileOperationsHelper().syncFile(file);
371+
}
372+
} else {
373+
// sync file content, then open with external apps
374+
((FileDisplayActivity) mContainerActivity).startSyncThenOpen(file);
375+
}
376+
}
377+
337378
/**
338379
* Check if the fragment was created with an empty layout. An empty fragment can't show file details, must be
339380
* replaced.
@@ -424,6 +465,7 @@ private void setFiletype(OCFile file) {
424465
}
425466

426467
ImageView iv = getView().findViewById(R.id.fdIcon);
468+
iv.setOnClickListener(this);
427469

428470
if (iv != null) {
429471
Bitmap thumbnail;

owncloudApp/src/main/res/layout/file_details_fragment.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@
4545
android:layout_width="0dp"
4646
android:layout_height="0dp"
4747
android:ellipsize="end"
48-
android:paddingStart="@dimen/standard_margin"
4948
android:gravity="center_vertical"
49+
android:paddingStart="@dimen/standard_margin"
5050
android:text=""
5151
android:textAppearance="?android:attr/textAppearanceLarge"
5252
app:layout_constraintBottom_toBottomOf="@id/fdIcon"

0 commit comments

Comments
 (0)