Search in sources :

Example 1 with GalleryFragment

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

Example 2 with GalleryFragment

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

the class FileDisplayActivity method onNewIntent.

// Is called with the flag FLAG_ACTIVITY_SINGLE_TOP and set the new file and intent
@Override
protected void onNewIntent(Intent intent) {
    super.onNewIntent(intent);
    setIntent(intent);
    if (ACTION_DETAILS.equalsIgnoreCase(intent.getAction())) {
        OCFile file = intent.getParcelableExtra(EXTRA_FILE);
        setFile(file);
        setIntent(intent);
        setFile(intent.getParcelableExtra(EXTRA_FILE));
        showDetails(file);
    } else if (Intent.ACTION_VIEW.equals(intent.getAction())) {
        handleOpenFileViaIntent(intent);
    } else if (RESTART.equals(intent.getAction())) {
        finish();
        startActivity(intent);
    } else // Verify the action and get the query
    if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
        setIntent(intent);
        SearchEvent searchEvent = intent.getParcelableExtra(OCFileListFragment.SEARCH_EVENT);
        if (searchEvent != null) {
            if (SearchRemoteOperation.SearchType.PHOTO_SEARCH.equals(searchEvent.getSearchType())) {
                Log_OC.d(this, "Switch to photo search fragment");
                GalleryFragment photoFragment = new GalleryFragment();
                Bundle bundle = new Bundle();
                bundle.putParcelable(OCFileListFragment.SEARCH_EVENT, searchEvent);
                photoFragment.setArguments(bundle);
                setLeftFragment(photoFragment);
            } else {
                Log_OC.d(this, "Switch to oc file search fragment");
                OCFileListFragment photoFragment = new OCFileListFragment();
                Bundle bundle = new Bundle();
                bundle.putParcelable(OCFileListFragment.SEARCH_EVENT, searchEvent);
                photoFragment.setArguments(bundle);
                setLeftFragment(photoFragment);
            }
        }
    } else if (ALL_FILES.equals(intent.getAction())) {
        Log_OC.d(this, "Switch to oc file fragment");
        setLeftFragment(new OCFileListFragment());
    }
}
Also used : OCFile(com.owncloud.android.datamodel.OCFile) GalleryFragment(com.owncloud.android.ui.fragment.GalleryFragment) Bundle(android.os.Bundle) SearchEvent(com.owncloud.android.ui.events.SearchEvent) OCFileListFragment(com.owncloud.android.ui.fragment.OCFileListFragment)

Example 3 with GalleryFragment

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

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

the class FileDisplayActivity method onMessageEvent.

@Subscribe(threadMode = ThreadMode.BACKGROUND)
public void onMessageEvent(final SearchEvent event) {
    if (SearchRemoteOperation.SearchType.PHOTO_SEARCH == event.getSearchType()) {
        Log_OC.d(this, "Switch to photo search fragment");
        setLeftFragment(new GalleryFragment());
    }
}
Also used : GalleryFragment(com.owncloud.android.ui.fragment.GalleryFragment) Subscribe(org.greenrobot.eventbus.Subscribe)

Example 5 with GalleryFragment

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

the class GallerySearchTask method onPostExecute.

@Override
protected void onPostExecute(GallerySearchTask.Result result) {
    if (photoFragmentWeakReference.get() != null) {
        GalleryFragment photoFragment = photoFragmentWeakReference.get();
        photoFragment.setLoading(false);
        photoFragment.searchCompleted(result.emptySearch, result.lastTimestamp);
        if (!result.success) {
            photoFragment.setEmptyListMessage(SearchType.GALLERY_SEARCH);
        }
    }
}
Also used : GalleryFragment(com.owncloud.android.ui.fragment.GalleryFragment)

Aggregations

GalleryFragment (com.owncloud.android.ui.fragment.GalleryFragment)7 OCFile (com.owncloud.android.datamodel.OCFile)3 OCFileListFragment (com.owncloud.android.ui.fragment.OCFileListFragment)3 PreviewTextStringFragment (com.owncloud.android.ui.preview.PreviewTextStringFragment)3 Fragment (androidx.fragment.app.Fragment)2 SortingOrderDialogFragment (com.owncloud.android.ui.dialog.SortingOrderDialogFragment)2 SearchEvent (com.owncloud.android.ui.events.SearchEvent)2 FileDetailFragment (com.owncloud.android.ui.fragment.FileDetailFragment)2 FileFragment (com.owncloud.android.ui.fragment.FileFragment)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 PreviewTextFileFragment (com.owncloud.android.ui.preview.PreviewTextFileFragment)2 PreviewTextFragment (com.owncloud.android.ui.preview.PreviewTextFragment)2 PreviewPdfFragment (com.owncloud.android.ui.preview.pdf.PreviewPdfFragment)2 Intent (android.content.Intent)1 IntentFilter (android.content.IntentFilter)1 Bundle (android.os.Bundle)1 User (com.nextcloud.client.account.User)1