Search in sources :

Example 1 with PreviewTextFileFragment

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);
    }
}
Also used : PreviewTextFileFragment(com.owncloud.android.ui.preview.PreviewTextFileFragment) FileOperationsHelper(com.owncloud.android.ui.helpers.FileOperationsHelper) User(com.nextcloud.client.account.User) Intent(android.content.Intent)

Example 2 with PreviewTextFileFragment

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();
    }
}
Also used : OCFile(com.owncloud.android.datamodel.OCFile) FileFragment(com.owncloud.android.ui.fragment.FileFragment) PreviewTextFileFragment(com.owncloud.android.ui.preview.PreviewTextFileFragment) PreviewMediaFragment(com.owncloud.android.ui.preview.PreviewMediaFragment) PreviewTextFragment(com.owncloud.android.ui.preview.PreviewTextFragment) OCFileListFragment(com.owncloud.android.ui.fragment.OCFileListFragment) UnifiedSearchFragment(com.owncloud.android.ui.fragment.UnifiedSearchFragment) Fragment(androidx.fragment.app.Fragment) TaskRetainerFragment(com.owncloud.android.ui.fragment.TaskRetainerFragment) FileFragment(com.owncloud.android.ui.fragment.FileFragment) PreviewTextStringFragment(com.owncloud.android.ui.preview.PreviewTextStringFragment) PreviewTextFragment(com.owncloud.android.ui.preview.PreviewTextFragment) PreviewTextFileFragment(com.owncloud.android.ui.preview.PreviewTextFileFragment) GalleryFragment(com.owncloud.android.ui.fragment.GalleryFragment) SortingOrderDialogFragment(com.owncloud.android.ui.dialog.SortingOrderDialogFragment) PreviewImageFragment(com.owncloud.android.ui.preview.PreviewImageFragment) PreviewMediaFragment(com.owncloud.android.ui.preview.PreviewMediaFragment) FileDetailFragment(com.owncloud.android.ui.fragment.FileDetailFragment) PreviewPdfFragment(com.owncloud.android.ui.preview.pdf.PreviewPdfFragment)

Example 3 with PreviewTextFileFragment

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);
        }
    }
}
Also used : OCFile(com.owncloud.android.datamodel.OCFile) PreviewTextFileFragment(com.owncloud.android.ui.preview.PreviewTextFileFragment) User(com.nextcloud.client.account.User) FileFragment(com.owncloud.android.ui.fragment.FileFragment) PreviewTextFileFragment(com.owncloud.android.ui.preview.PreviewTextFileFragment) PreviewMediaFragment(com.owncloud.android.ui.preview.PreviewMediaFragment) FileDetailFragment(com.owncloud.android.ui.fragment.FileDetailFragment) PreviewTextFragment(com.owncloud.android.ui.preview.PreviewTextFragment) OCFileListFragment(com.owncloud.android.ui.fragment.OCFileListFragment) UnifiedSearchFragment(com.owncloud.android.ui.fragment.UnifiedSearchFragment) Fragment(androidx.fragment.app.Fragment) TaskRetainerFragment(com.owncloud.android.ui.fragment.TaskRetainerFragment) FileFragment(com.owncloud.android.ui.fragment.FileFragment) PreviewTextStringFragment(com.owncloud.android.ui.preview.PreviewTextStringFragment) PreviewTextFragment(com.owncloud.android.ui.preview.PreviewTextFragment) PreviewTextFileFragment(com.owncloud.android.ui.preview.PreviewTextFileFragment) GalleryFragment(com.owncloud.android.ui.fragment.GalleryFragment) SortingOrderDialogFragment(com.owncloud.android.ui.dialog.SortingOrderDialogFragment) PreviewImageFragment(com.owncloud.android.ui.preview.PreviewImageFragment) PreviewMediaFragment(com.owncloud.android.ui.preview.PreviewMediaFragment) FileDetailFragment(com.owncloud.android.ui.fragment.FileDetailFragment) PreviewPdfFragment(com.owncloud.android.ui.preview.pdf.PreviewPdfFragment)

Aggregations

PreviewTextFileFragment (com.owncloud.android.ui.preview.PreviewTextFileFragment)3 Fragment (androidx.fragment.app.Fragment)2 User (com.nextcloud.client.account.User)2 OCFile (com.owncloud.android.datamodel.OCFile)2 SortingOrderDialogFragment (com.owncloud.android.ui.dialog.SortingOrderDialogFragment)2 FileDetailFragment (com.owncloud.android.ui.fragment.FileDetailFragment)2 FileFragment (com.owncloud.android.ui.fragment.FileFragment)2 GalleryFragment (com.owncloud.android.ui.fragment.GalleryFragment)2 OCFileListFragment (com.owncloud.android.ui.fragment.OCFileListFragment)2 TaskRetainerFragment (com.owncloud.android.ui.fragment.TaskRetainerFragment)2 UnifiedSearchFragment (com.owncloud.android.ui.fragment.UnifiedSearchFragment)2 PreviewImageFragment (com.owncloud.android.ui.preview.PreviewImageFragment)2 PreviewMediaFragment (com.owncloud.android.ui.preview.PreviewMediaFragment)2 PreviewTextFragment (com.owncloud.android.ui.preview.PreviewTextFragment)2 PreviewTextStringFragment (com.owncloud.android.ui.preview.PreviewTextStringFragment)2 PreviewPdfFragment (com.owncloud.android.ui.preview.pdf.PreviewPdfFragment)2 Intent (android.content.Intent)1 FileOperationsHelper (com.owncloud.android.ui.helpers.FileOperationsHelper)1