Search in sources :

Example 1 with PreviewTextStringFragment

use of com.owncloud.android.ui.preview.PreviewTextStringFragment in project android by nextcloud.

the class FileDisplayActivity method onBackPressed.

/*
     * BackPressed priority/hierarchy:
     *    1. close search view if opened
     *    2. close drawer if opened
     *    3. close FAB if open (only if drawer isn't open)
     *    4. navigate up (only if drawer and FAB aren't open)
     */
@SuppressFBWarnings("ITC_INHERITANCE_TYPE_CHECKING")
@Override
public void onBackPressed() {
    final boolean isDrawerOpen = isDrawerOpen();
    final boolean isSearchOpen = isSearchOpen();
    final Fragment leftFragment = getLeftFragment();
    if (leftFragment instanceof OCFileListFragment) {
        OCFileListFragment listOfFiles = (OCFileListFragment) leftFragment;
        if (isSearchOpen && searchView != null) {
            searchView.setQuery("", true);
            searchView.onActionViewCollapsed();
            searchView.clearFocus();
            // Remove the list to the original state
            listOfFiles.performSearch("", true);
            hideSearchView(getCurrentDir());
            setDrawerIndicatorEnabled(isDrawerIndicatorAvailable());
        } else if (isDrawerOpen) {
            // close drawer first
            super.onBackPressed();
        } else {
            // all closed
            if (mDualPane || getSecondFragment() == null) {
                OCFile currentDir = getCurrentDir();
                if (currentDir == null || currentDir.getParentId() == FileDataStorageManager.ROOT_PARENT_ID) {
                    finish();
                    return;
                }
                listOfFiles.onBrowseUp();
            }
            setFile(listOfFiles.getCurrentFile());
            listOfFiles.setFabVisible(true);
            listOfFiles.registerFabListener();
            showSortListGroup(true);
            cleanSecondFragment();
        }
    } else if (leftFragment instanceof PreviewTextStringFragment) {
        createMinFragments(null);
    } else {
        // pop back
        ((CoordinatorLayout.LayoutParams) binding.rootLayout.getLayoutParams()).setBehavior(new AppBarLayout.ScrollingViewBehavior());
        hideSearchView(getCurrentDir());
        showSortListGroup(true);
        super.onBackPressed();
    }
}
Also used : OCFile(com.owncloud.android.datamodel.OCFile) CoordinatorLayout(androidx.coordinatorlayout.widget.CoordinatorLayout) PreviewTextStringFragment(com.owncloud.android.ui.preview.PreviewTextStringFragment) 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) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings)

Example 2 with PreviewTextStringFragment

use of com.owncloud.android.ui.preview.PreviewTextStringFragment in project android by nextcloud.

the class DrawerActivity method onNavigationItemClicked.

private void onNavigationItemClicked(final MenuItem menuItem) {
    setDrawerMenuItemChecked(menuItem.getItemId());
    int itemId = menuItem.getItemId();
    if (itemId == R.id.nav_all_files) {
        if (this instanceof FileDisplayActivity && !(((FileDisplayActivity) this).getLeftFragment() instanceof GalleryFragment) && !(((FileDisplayActivity) this).getLeftFragment() instanceof PreviewTextStringFragment)) {
            showFiles(false);
            ((FileDisplayActivity) this).browseToRoot();
            EventBus.getDefault().post(new ChangeMenuEvent());
        } else {
            Intent intent = new Intent(getApplicationContext(), FileDisplayActivity.class);
            intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
            intent.setAction(FileDisplayActivity.ALL_FILES);
            intent.putExtra(FileDisplayActivity.DRAWER_MENU_ID, menuItem.getItemId());
            startActivity(intent);
        }
    } else if (itemId == R.id.nav_favorites) {
        handleSearchEvents(new SearchEvent("", SearchRemoteOperation.SearchType.FAVORITE_SEARCH), menuItem.getItemId());
    } else if (itemId == R.id.nav_gallery) {
        startPhotoSearch(menuItem);
    } else if (itemId == R.id.nav_on_device) {
        EventBus.getDefault().post(new ChangeMenuEvent());
        showFiles(true);
    } else if (itemId == R.id.nav_uploads) {
        startActivity(UploadListActivity.class, Intent.FLAG_ACTIVITY_CLEAR_TOP);
    } else if (itemId == R.id.nav_trashbin) {
        startActivity(TrashbinActivity.class, Intent.FLAG_ACTIVITY_CLEAR_TOP);
    } else if (itemId == R.id.nav_activity) {
        startActivity(ActivitiesActivity.class, Intent.FLAG_ACTIVITY_CLEAR_TOP);
    } else if (itemId == R.id.nav_notifications) {
        startActivity(NotificationsActivity.class);
    } else if (itemId == R.id.nav_settings) {
        startActivity(SettingsActivity.class);
    } else if (itemId == R.id.nav_community) {
        startActivity(CommunityActivity.class);
    } else if (itemId == R.id.nav_logout) {
        mCheckedMenuItem = -1;
        menuItem.setChecked(false);
        final Optional<User> optionalUser = getUser();
        if (optionalUser.isPresent()) {
            UserInfoActivity.openAccountRemovalConfirmationDialog(optionalUser.get(), getSupportFragmentManager());
        }
    } else if (itemId == R.id.nav_shared) {
        handleSearchEvents(new SearchEvent("", SearchRemoteOperation.SearchType.SHARED_FILTER), menuItem.getItemId());
    } else if (itemId == R.id.nav_recently_modified) {
        handleSearchEvents(new SearchEvent("", SearchRemoteOperation.SearchType.RECENTLY_MODIFIED_SEARCH), menuItem.getItemId());
    } else {
        if (menuItem.getItemId() >= MENU_ITEM_EXTERNAL_LINK && menuItem.getItemId() <= MENU_ITEM_EXTERNAL_LINK + 100) {
            // external link clicked
            externalLinkClicked(menuItem);
        } else {
            Log_OC.w(TAG, "Unknown drawer menu item clicked: " + menuItem.getTitle());
        }
    }
}
Also used : TrashbinActivity(com.owncloud.android.ui.trashbin.TrashbinActivity) GalleryFragment(com.owncloud.android.ui.fragment.GalleryFragment) User(com.nextcloud.client.account.User) ChangeMenuEvent(com.owncloud.android.ui.events.ChangeMenuEvent) PreviewTextStringFragment(com.owncloud.android.ui.preview.PreviewTextStringFragment) Intent(android.content.Intent) SearchEvent(com.owncloud.android.ui.events.SearchEvent)

Aggregations

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