Skip to content

Commit

Permalink
Preview available when user clicks on thumbnail in file detail
Browse files Browse the repository at this point in the history
  • Loading branch information
fesave committed Apr 28, 2022
1 parent 62cb941 commit 08b091e
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@
import com.owncloud.android.ui.controller.TransferProgressController;
import com.owncloud.android.ui.dialog.RemoveFilesDialogFragment;
import com.owncloud.android.ui.dialog.RenameFileDialogFragment;
import com.owncloud.android.ui.preview.PreviewAudioFragment;
import com.owncloud.android.ui.preview.PreviewImageFragment;
import com.owncloud.android.ui.preview.PreviewTextFragment;
import com.owncloud.android.utils.DisplayUtils;
import com.owncloud.android.utils.MimetypeIconUtil;
import com.owncloud.android.utils.PreferenceUtils;
Expand Down Expand Up @@ -329,11 +332,33 @@ public void onClick(View v) {
((FileDisplayActivity) mContainerActivity).cancelTransference(getFile());
break;
}
case R.id.fdIcon: {
displayFile(getFile());
}
default:
Timber.e("Incorrect view clicked!");
}
}

private void displayFile(OCFile file) {
if (PreviewImageFragment.canBePreviewed(file)) {
// preview image - it handles the sync, if needed
((FileDisplayActivity) mContainerActivity).startImagePreview(file);
} else if (PreviewTextFragment.canBePreviewed(file)) {
((FileDisplayActivity) mContainerActivity).startTextPreview(file);
mContainerActivity.getFileOperationsHelper().syncFile(file);

} else if (PreviewAudioFragment.canBePreviewed(file)) {
// media preview
((FileDisplayActivity) mContainerActivity).startAudioPreview(file, 0);
mContainerActivity.getFileOperationsHelper().syncFile(file);

} else {
// sync file content, then open with external apps
((FileDisplayActivity) mContainerActivity).startSyncThenOpen(file);
}
}

/**
* Check if the fragment was created with an empty layout. An empty fragment can't show file details, must be
* replaced.
Expand Down Expand Up @@ -424,6 +449,7 @@ private void setFiletype(OCFile file) {
}

ImageView iv = getView().findViewById(R.id.fdIcon);
iv.setOnClickListener(this);

if (iv != null) {
Bitmap thumbnail;
Expand Down
2 changes: 1 addition & 1 deletion owncloudApp/src/main/res/layout/file_details_fragment.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@
android:layout_width="0dp"
android:layout_height="0dp"
android:ellipsize="end"
android:paddingStart="@dimen/standard_margin"
android:gravity="center_vertical"
android:paddingStart="@dimen/standard_margin"
android:text=""
android:textAppearance="?android:attr/textAppearanceLarge"
app:layout_constraintBottom_toBottomOf="@id/fdIcon"
Expand Down

0 comments on commit 08b091e

Please sign in to comment.