use of com.owncloud.android.ui.preview.PreviewTextFileFragment in project android by nextcloud.
the class FileDisplayActivity method startTextPreview.
/**
* Starts the preview of a text file {@link OCFile}.
*
* @param file Text {@link OCFile} to preview.
*/
public void startTextPreview(OCFile file, boolean showPreview) {
Optional<User> optUser = getUser();
if (!optUser.isPresent()) {
// remnants of old unsafe system; do not crash, silently stop
return;
}
User user = optUser.get();
if (showPreview) {
showSortListGroup(false);
PreviewTextFileFragment fragment = PreviewTextFileFragment.create(user, file, searchOpen, searchQuery);
setLeftFragment(fragment);
binding.rightFragmentContainer.setVisibility(View.GONE);
super.updateActionBarTitleAndHomeButton(file);
} else {
Intent previewIntent = new Intent();
previewIntent.putExtra(EXTRA_FILE, file);
previewIntent.putExtra(TEXT_PREVIEW, true);
FileOperationsHelper fileOperationsHelper = new FileOperationsHelper(this, getUserAccountManager(), connectivityService);
fileOperationsHelper.startSyncForFileAndIntent(file, previewIntent);
}
}
use of com.owncloud.android.ui.preview.PreviewTextFileFragment in project android by nextcloud.
the class FileDisplayActivity method refreshShowDetails.
private void refreshShowDetails() {
Fragment details = getLeftFragment();
if (details instanceof FileFragment) {
OCFile file = ((FileFragment) details).getFile();
if (file != null) {
file = getStorageManager().getFileByPath(file.getRemotePath());
if (details instanceof PreviewMediaFragment) {
// Refresh OCFile of the fragment
((PreviewMediaFragment) details).updateFile(file);
} else if (details instanceof PreviewTextFragment) {
// Refresh OCFile of the fragment
((PreviewTextFileFragment) details).updateFile(file);
} else {
showDetails(file);
}
}
supportInvalidateOptionsMenu();
}
}
use of com.owncloud.android.ui.preview.PreviewTextFileFragment in project android by nextcloud.
the class FileDisplayActivity method onRenameFileOperationFinish.
/**
* Updates the view associated to the activity after the finish of an operation trying to rename a file.
*
* @param operation Renaming operation performed.
* @param result Result of the renaming.
*/
private void onRenameFileOperationFinish(RenameFileOperation operation, RemoteOperationResult result) {
Optional<User> optionalUser = getUser();
OCFile renamedFile = operation.getFile();
if (result.isSuccess() && optionalUser.isPresent()) {
final User currentUser = optionalUser.get();
Fragment leftFragment = getLeftFragment();
if (leftFragment instanceof FileFragment) {
final FileFragment fileFragment = (FileFragment) leftFragment;
if (fileFragment instanceof FileDetailFragment && renamedFile.equals(fileFragment.getFile())) {
((FileDetailFragment) fileFragment).updateFileDetails(renamedFile, currentUser);
showDetails(renamedFile);
} else if (fileFragment instanceof PreviewMediaFragment && renamedFile.equals(fileFragment.getFile())) {
((PreviewMediaFragment) fileFragment).updateFile(renamedFile);
if (PreviewMediaFragment.canBePreviewed(renamedFile)) {
long position = ((PreviewMediaFragment) fileFragment).getPosition();
startMediaPreview(renamedFile, position, true, true, true);
} else {
getFileOperationsHelper().openFile(renamedFile);
}
} else if (fileFragment instanceof PreviewTextFragment && renamedFile.equals(fileFragment.getFile())) {
((PreviewTextFileFragment) fileFragment).updateFile(renamedFile);
if (PreviewTextFileFragment.canBePreviewed(renamedFile)) {
startTextPreview(renamedFile, true);
} else {
getFileOperationsHelper().openFile(renamedFile);
}
}
}
OCFile file = getStorageManager().getFileById(renamedFile.getParentId());
if (file != null && file.equals(getCurrentDir())) {
updateListOfFilesFragment(false);
}
} else {
DisplayUtils.showSnackMessage(this, ErrorMessageAdapter.getErrorCauseMessage(result, operation, getResources()));
if (result.isSslRecoverableException()) {
mLastSslUntrustedServerResult = result;
showUntrustedCertDialog(mLastSslUntrustedServerResult);
}
}
}
Aggregations