Search in sources :

Example 1 with FileDetailFragment

use of com.owncloud.android.ui.fragment.FileDetailFragment in project android by nextcloud.

the class FileDisplayActivity method refreshDetailsFragmentIfVisible.

protected void refreshDetailsFragmentIfVisible(String downloadEvent, String downloadedRemotePath, boolean success) {
    Fragment leftFragment = getLeftFragment();
    if (leftFragment instanceof FileDetailFragment) {
        boolean waitedPreview = mWaitingToPreview != null && mWaitingToPreview.getRemotePath().equals(downloadedRemotePath);
        FileDetailFragment detailsFragment = (FileDetailFragment) leftFragment;
        OCFile fileInFragment = detailsFragment.getFile();
        if (fileInFragment != null && !downloadedRemotePath.equals(fileInFragment.getRemotePath())) {
            // the user browsed to other file ; forget the automatic preview
            mWaitingToPreview = null;
        } else if (downloadEvent.equals(FileDownloader.getDownloadAddedMessage())) {
            // grant that the right panel updates the progress bar
            detailsFragment.listenForTransferProgress();
            detailsFragment.updateFileDetails(true, false);
        } else if (downloadEvent.equals(FileDownloader.getDownloadFinishMessage())) {
            // update the right panel
            boolean detailsFragmentChanged = false;
            if (waitedPreview) {
                if (success) {
                    // update the file from database, for the local storage path
                    mWaitingToPreview = getStorageManager().getFileById(mWaitingToPreview.getFileId());
                    if (PreviewMediaFragment.canBePreviewed(mWaitingToPreview)) {
                        startMediaPreview(mWaitingToPreview, 0, true, true, true);
                        detailsFragmentChanged = true;
                    } else if (MimeTypeUtil.isVCard(mWaitingToPreview.getMimeType())) {
                        startContactListFragment(mWaitingToPreview);
                        detailsFragmentChanged = true;
                    } else if (PreviewTextFileFragment.canBePreviewed(mWaitingToPreview)) {
                        startTextPreview(mWaitingToPreview, true);
                        detailsFragmentChanged = true;
                    } else if (MimeTypeUtil.isPDF(mWaitingToPreview)) {
                        startPdfPreview(mWaitingToPreview);
                        detailsFragmentChanged = true;
                    } else {
                        getFileOperationsHelper().openFile(mWaitingToPreview);
                    }
                }
                mWaitingToPreview = null;
            }
            if (!detailsFragmentChanged) {
                detailsFragment.updateFileDetails(false, success);
            }
        }
    }
}
Also used : OCFile(com.owncloud.android.datamodel.OCFile) FileDetailFragment(com.owncloud.android.ui.fragment.FileDetailFragment) 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 2 with FileDetailFragment

use of com.owncloud.android.ui.fragment.FileDetailFragment in project android by nextcloud.

the class FileDisplayActivity method onTransferStateChanged.

/**
 * {@inheritDoc}
 */
@Override
public void onTransferStateChanged(OCFile file, boolean downloading, boolean uploading) {
    updateListOfFilesFragment(false);
    Fragment leftFragment = getLeftFragment();
    Optional<User> optionalUser = getUser();
    if (leftFragment instanceof FileDetailFragment && file.equals(((FileDetailFragment) leftFragment).getFile()) && optionalUser.isPresent()) {
        final User currentUser = optionalUser.get();
        if (downloading || uploading) {
            ((FileDetailFragment) leftFragment).updateFileDetails(file, currentUser);
        } else {
            if (!file.fileExists()) {
                cleanSecondFragment();
            } else {
                ((FileDetailFragment) leftFragment).updateFileDetails(false, true);
            }
        }
    }
}
Also used : User(com.nextcloud.client.account.User) FileDetailFragment(com.owncloud.android.ui.fragment.FileDetailFragment) 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 FileDetailFragment

use of com.owncloud.android.ui.fragment.FileDetailFragment in project android by owncloud.

the class FileDisplayActivity method startSyncThenOpen.

/**
     * Requests the synchronization of the received {@link OCFile},
     * updates the UI to monitor the progress and prepares the activity
     * to preview or open the file when the download finishes.
     *
     * @param file {@link OCFile} to sync and open.
     */
public void startSyncThenOpen(OCFile file) {
    FileDetailFragment detailFragment = FileDetailFragment.newInstance(file, getAccount());
    setSecondFragment(detailFragment);
    mWaitingToPreview = file;
    getFileOperationsHelper().syncFile(file);
    updateFragmentsVisibility(true);
    updateActionBarTitleAndHomeButton(file);
    setFile(file);
}
Also used : FileDetailFragment(com.owncloud.android.ui.fragment.FileDetailFragment)

Example 4 with FileDetailFragment

use of com.owncloud.android.ui.fragment.FileDetailFragment in project android by nextcloud.

the class FileDisplayActivity method refreshSecondFragment.

protected void refreshSecondFragment(String downloadEvent, String downloadedRemotePath, boolean success) {
    FileFragment secondFragment = getSecondFragment();
    boolean waitedPreview = (mWaitingToPreview != null && mWaitingToPreview.getRemotePath().equals(downloadedRemotePath));
    if (secondFragment instanceof FileDetailFragment) {
        FileDetailFragment detailsFragment = (FileDetailFragment) secondFragment;
        OCFile fileInFragment = detailsFragment.getFile();
        if (fileInFragment != null && !downloadedRemotePath.equals(fileInFragment.getRemotePath())) {
            // the user browsed to other file ; forget the automatic preview
            mWaitingToPreview = null;
        } else if (downloadEvent.equals(FileDownloader.getDownloadAddedMessage())) {
            // grant that the right panel updates the progress bar
            detailsFragment.listenForTransferProgress();
            detailsFragment.updateFileDetails(true, false);
        } else if (downloadEvent.equals(FileDownloader.getDownloadFinishMessage())) {
            // update the right panel
            boolean detailsFragmentChanged = false;
            if (waitedPreview) {
                if (success) {
                    mWaitingToPreview = getStorageManager().getFileById(// update the file from database,
                    mWaitingToPreview.getFileId());
                    // for the local storage path
                    if (PreviewMediaFragment.canBePreviewed(mWaitingToPreview)) {
                        startMediaPreview(mWaitingToPreview, 0, true, true);
                        detailsFragmentChanged = true;
                    } else if (MimeTypeUtil.isVCard(mWaitingToPreview.getMimetype())) {
                        startContactListFragment(mWaitingToPreview);
                        detailsFragmentChanged = true;
                    } else if (PreviewTextFragment.canBePreviewed(mWaitingToPreview)) {
                        startTextPreview(mWaitingToPreview, true);
                        detailsFragmentChanged = true;
                    } else {
                        getFileOperationsHelper().openFile(mWaitingToPreview);
                    }
                }
                mWaitingToPreview = null;
            }
            if (!detailsFragmentChanged) {
                detailsFragment.updateFileDetails(false, (success));
            }
        }
    }
}
Also used : OCFile(com.owncloud.android.datamodel.OCFile) FileFragment(com.owncloud.android.ui.fragment.FileFragment) FileDetailFragment(com.owncloud.android.ui.fragment.FileDetailFragment)

Example 5 with FileDetailFragment

use of com.owncloud.android.ui.fragment.FileDetailFragment 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

FileDetailFragment (com.owncloud.android.ui.fragment.FileDetailFragment)7 FileFragment (com.owncloud.android.ui.fragment.FileFragment)6 OCFile (com.owncloud.android.datamodel.OCFile)5 OCFileListFragment (com.owncloud.android.ui.fragment.OCFileListFragment)5 UnifiedSearchFragment (com.owncloud.android.ui.fragment.UnifiedSearchFragment)5 PreviewMediaFragment (com.owncloud.android.ui.preview.PreviewMediaFragment)5 PreviewTextFileFragment (com.owncloud.android.ui.preview.PreviewTextFileFragment)5 PreviewPdfFragment (com.owncloud.android.ui.preview.pdf.PreviewPdfFragment)5 Fragment (androidx.fragment.app.Fragment)4 SortingOrderDialogFragment (com.owncloud.android.ui.dialog.SortingOrderDialogFragment)4 GalleryFragment (com.owncloud.android.ui.fragment.GalleryFragment)4 TaskRetainerFragment (com.owncloud.android.ui.fragment.TaskRetainerFragment)4 PreviewImageFragment (com.owncloud.android.ui.preview.PreviewImageFragment)4 PreviewTextFragment (com.owncloud.android.ui.preview.PreviewTextFragment)4 PreviewTextStringFragment (com.owncloud.android.ui.preview.PreviewTextStringFragment)4 User (com.nextcloud.client.account.User)2 SuppressLint (android.annotation.SuppressLint)1 ArrayList (java.util.ArrayList)1