Search in sources :

Example 81 with Fragment

use of androidx.fragment.app.Fragment 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 82 with Fragment

use of androidx.fragment.app.Fragment 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 83 with Fragment

use of androidx.fragment.app.Fragment in project android by nextcloud.

the class FileDisplayActivity method chooseInitialSecondFragment.

@Deprecated
private Fragment chooseInitialSecondFragment(OCFile file, User user) {
    Fragment secondFragment = null;
    if (file != null && !file.isFolder()) {
        if (file.isDown() && PreviewMediaFragment.canBePreviewed(file)) {
            long startPlaybackPosition = getIntent().getLongExtra(PreviewVideoActivity.EXTRA_START_POSITION, 0);
            boolean autoplay = getIntent().getBooleanExtra(PreviewVideoActivity.EXTRA_AUTOPLAY, true);
            secondFragment = PreviewMediaFragment.newInstance(file, user, startPlaybackPosition, autoplay);
        } else if (file.isDown() && PreviewTextFileFragment.canBePreviewed(file)) {
            secondFragment = null;
        } else {
            secondFragment = FileDetailFragment.newInstance(file, user);
        }
    }
    return secondFragment;
}
Also used : 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 84 with Fragment

use of androidx.fragment.app.Fragment in project android by nextcloud.

the class FileDisplayActivity method onResume.

@Override
protected void onResume() {
    Log_OC.v(TAG, "onResume() start");
    super.onResume();
    // Instead of onPostCreate, starting the loading in onResume for children fragments
    Fragment leftFragment = getLeftFragment();
    // Listen for sync messages
    if (!(leftFragment instanceof OCFileListFragment) || !((OCFileListFragment) leftFragment).isSearchFragment()) {
        IntentFilter syncIntentFilter = new IntentFilter(FileSyncAdapter.EVENT_FULL_SYNC_START);
        syncIntentFilter.addAction(FileSyncAdapter.EVENT_FULL_SYNC_END);
        syncIntentFilter.addAction(FileSyncAdapter.EVENT_FULL_SYNC_FOLDER_CONTENTS_SYNCED);
        syncIntentFilter.addAction(RefreshFolderOperation.EVENT_SINGLE_FOLDER_CONTENTS_SYNCED);
        syncIntentFilter.addAction(RefreshFolderOperation.EVENT_SINGLE_FOLDER_SHARES_SYNCED);
        mSyncBroadcastReceiver = new SyncBroadcastReceiver();
        localBroadcastManager.registerReceiver(mSyncBroadcastReceiver, syncIntentFilter);
    }
    if (!(leftFragment instanceof OCFileListFragment)) {
        if (leftFragment instanceof FileFragment) {
            super.updateActionBarTitleAndHomeButton(((FileFragment) leftFragment).getFile());
        }
        return;
    }
    OCFileListFragment ocFileListFragment = (OCFileListFragment) leftFragment;
    ocFileListFragment.setLoading(mSyncInProgress);
    syncAndUpdateFolder(false);
    OCFile startFile = null;
    if (getIntent() != null && getIntent().getParcelableExtra(EXTRA_FILE) != null) {
        startFile = getIntent().getParcelableExtra(EXTRA_FILE);
        setFile(startFile);
    }
    // refresh list of files
    if (searchView != null && !TextUtils.isEmpty(searchQuery)) {
        searchView.setQuery(searchQuery, false);
    } else if (!ocFileListFragment.isSearchFragment() && startFile == null) {
        updateListOfFilesFragment(false);
        ocFileListFragment.registerFabListener();
    } else {
        ocFileListFragment.listDirectory(startFile, false, false);
        updateActionBarTitleAndHomeButton(startFile);
    }
    // Listen for upload messages
    IntentFilter uploadIntentFilter = new IntentFilter(FileUploader.getUploadFinishMessage());
    mUploadFinishReceiver = new UploadFinishReceiver();
    localBroadcastManager.registerReceiver(mUploadFinishReceiver, uploadIntentFilter);
    // Listen for download messages
    IntentFilter downloadIntentFilter = new IntentFilter(FileDownloader.getDownloadAddedMessage());
    downloadIntentFilter.addAction(FileDownloader.getDownloadFinishMessage());
    mDownloadFinishReceiver = new DownloadFinishReceiver();
    localBroadcastManager.registerReceiver(mDownloadFinishReceiver, downloadIntentFilter);
    // setup drawer
    menuItemId = getIntent().getIntExtra(FileDisplayActivity.DRAWER_MENU_ID, menuItemId);
    if (menuItemId == -1) {
        if (MainApp.isOnlyOnDevice()) {
            setDrawerMenuItemChecked(R.id.nav_on_device);
            setupToolbar();
        } else {
            setDrawerMenuItemChecked(R.id.nav_all_files);
            setupHomeSearchToolbarWithSortAndListButtons();
        }
    } else {
        if (menuItemId == R.id.nav_all_files) {
            setupHomeSearchToolbarWithSortAndListButtons();
        } else {
            setupToolbar();
        }
        setDrawerMenuItemChecked(menuItemId);
    }
    if (ocFileListFragment instanceof GalleryFragment) {
        updateActionBarTitleAndHomeButtonByString(getString(R.string.drawer_item_gallery));
    }
    Log_OC.v(TAG, "onResume() end");
}
Also used : OCFile(com.owncloud.android.datamodel.OCFile) IntentFilter(android.content.IntentFilter) GalleryFragment(com.owncloud.android.ui.fragment.GalleryFragment) FileFragment(com.owncloud.android.ui.fragment.FileFragment) PreviewTextFileFragment(com.owncloud.android.ui.preview.PreviewTextFileFragment) OCFileListFragment(com.owncloud.android.ui.fragment.OCFileListFragment) 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 85 with Fragment

use of androidx.fragment.app.Fragment in project android by nextcloud.

the class FileDisplayActivity method startRichWorkspacePreview.

/**
 * Starts rich workspace preview for a folder.
 *
 * @param folder {@link OCFile} to preview its rich workspace.
 */
public void startRichWorkspacePreview(OCFile folder) {
    showSortListGroup(false);
    Bundle args = new Bundle();
    args.putParcelable(EXTRA_FILE, folder);
    Fragment textPreviewFragment = Fragment.instantiate(getApplicationContext(), PreviewTextStringFragment.class.getName(), args);
    setLeftFragment(textPreviewFragment);
    binding.rightFragmentContainer.setVisibility(View.GONE);
    super.updateActionBarTitleAndHomeButton(folder);
}
Also used : Bundle(android.os.Bundle) PreviewTextStringFragment(com.owncloud.android.ui.preview.PreviewTextStringFragment) 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

Fragment (androidx.fragment.app.Fragment)239 FragmentTransaction (androidx.fragment.app.FragmentTransaction)54 Bundle (android.os.Bundle)46 FragmentManager (androidx.fragment.app.FragmentManager)38 FileFragment (com.owncloud.android.ui.fragment.FileFragment)23 DialogFragment (androidx.fragment.app.DialogFragment)22 View (android.view.View)21 FileDetailFragment (com.owncloud.android.ui.fragment.FileDetailFragment)20 OCFileListFragment (com.owncloud.android.ui.fragment.OCFileListFragment)20 Intent (android.content.Intent)19 SortingOrderDialogFragment (com.owncloud.android.ui.dialog.SortingOrderDialogFragment)19 GalleryFragment (com.owncloud.android.ui.fragment.GalleryFragment)18 TaskRetainerFragment (com.owncloud.android.ui.fragment.TaskRetainerFragment)18 UnifiedSearchFragment (com.owncloud.android.ui.fragment.UnifiedSearchFragment)18 PreviewImageFragment (com.owncloud.android.ui.preview.PreviewImageFragment)18 PreviewMediaFragment (com.owncloud.android.ui.preview.PreviewMediaFragment)18 PreviewTextFileFragment (com.owncloud.android.ui.preview.PreviewTextFileFragment)18 PreviewTextFragment (com.owncloud.android.ui.preview.PreviewTextFragment)18 PreviewTextStringFragment (com.owncloud.android.ui.preview.PreviewTextStringFragment)18 PreviewPdfFragment (com.owncloud.android.ui.preview.pdf.PreviewPdfFragment)18