Search in sources :

Example 1 with SearchEvent

use of com.owncloud.android.ui.events.SearchEvent 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 2 with SearchEvent

use of com.owncloud.android.ui.events.SearchEvent 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 3 with SearchEvent

use of com.owncloud.android.ui.events.SearchEvent in project android by nextcloud.

the class ExtendedListFragment method performSearch.

public void performSearch(final String query, boolean isBackPressed) {
    handler.removeCallbacksAndMessages(null);
    RecyclerView.Adapter adapter = getRecyclerView().getAdapter();
    Activity activity = getActivity();
    if (activity != null) {
        if (activity instanceof FileDisplayActivity) {
            if (isBackPressed && TextUtils.isEmpty(query)) {
                FileDisplayActivity fileDisplayActivity = (FileDisplayActivity) activity;
                fileDisplayActivity.resetSearchView();
                fileDisplayActivity.updateListOfFilesFragment(true);
            } else {
                handler.post(() -> {
                    if (adapter instanceof OCFileListAdapter) {
                        if (accountManager.getUser().getServer().getVersion().isNewerOrEqual(OwnCloudVersion.nextcloud_20)) {
                            ((FileDisplayActivity) activity).performUnifiedSearch(query);
                        } else {
                            EventBus.getDefault().post(new SearchEvent(query, SearchRemoteOperation.SearchType.FILE_SEARCH));
                        }
                    } else if (adapter instanceof LocalFileListAdapter) {
                        LocalFileListAdapter localFileListAdapter = (LocalFileListAdapter) adapter;
                        localFileListAdapter.filter(query);
                    }
                });
                if (searchView != null) {
                    searchView.clearFocus();
                }
            }
        } else if (activity instanceof UploadFilesActivity) {
            LocalFileListAdapter localFileListAdapter = (LocalFileListAdapter) adapter;
            localFileListAdapter.filter(query);
            ((UploadFilesActivity) activity).showToolbarSpinner();
        } else if (activity instanceof FolderPickerActivity) {
            ((FolderPickerActivity) activity).refreshListOfFilesFragment(true);
        }
    }
}
Also used : FileDisplayActivity(com.owncloud.android.ui.activity.FileDisplayActivity) FolderPickerActivity(com.owncloud.android.ui.activity.FolderPickerActivity) UploadFilesActivity(com.owncloud.android.ui.activity.UploadFilesActivity) FolderPickerActivity(com.owncloud.android.ui.activity.FolderPickerActivity) FileDisplayActivity(com.owncloud.android.ui.activity.FileDisplayActivity) Activity(android.app.Activity) RecyclerView(androidx.recyclerview.widget.RecyclerView) EmptyRecyclerView(com.owncloud.android.ui.EmptyRecyclerView) SearchEvent(com.owncloud.android.ui.events.SearchEvent) LocalFileListAdapter(com.owncloud.android.ui.adapter.LocalFileListAdapter) UploadFilesActivity(com.owncloud.android.ui.activity.UploadFilesActivity) OCFileListAdapter(com.owncloud.android.ui.adapter.OCFileListAdapter)

Example 4 with SearchEvent

use of com.owncloud.android.ui.events.SearchEvent in project android by nextcloud.

the class FileDisplayActivityIT method showShares.

@Test
public // @ScreenshotTest // todo run without real server
void showShares() {
    assertTrue(new ExistenceCheckRemoteOperation("/shareToAdmin/", true).execute(client).isSuccess());
    assertTrue(new CreateFolderRemoteOperation("/shareToAdmin/", true).execute(client).isSuccess());
    assertTrue(new CreateFolderRemoteOperation("/shareToGroup/", true).execute(client).isSuccess());
    assertTrue(new CreateFolderRemoteOperation("/shareViaLink/", true).execute(client).isSuccess());
    assertTrue(new CreateFolderRemoteOperation("/noShare/", true).execute(client).isSuccess());
    // assertTrue(new CreateFolderRemoteOperation("/shareToCircle/", true).execute(client).isSuccess());
    // share folder to user "admin"
    assertTrue(new CreateShareRemoteOperation("/shareToAdmin/", ShareType.USER, "admin", false, "", OCShare.MAXIMUM_PERMISSIONS_FOR_FOLDER).execute(client).isSuccess());
    // share folder via public link
    assertTrue(new CreateShareRemoteOperation("/shareViaLink/", ShareType.PUBLIC_LINK, "", true, "", OCShare.READ_PERMISSION_FLAG).execute(client).isSuccess());
    // share folder to group
    Assert.assertTrue(new CreateShareRemoteOperation("/shareToGroup/", ShareType.GROUP, "users", false, "", OCShare.NO_PERMISSION).execute(client).isSuccess());
    // share folder to circle
    // get share
    // RemoteOperationResult searchResult = new GetShareesRemoteOperation("publicCircle", 1, 50).execute(client);
    // assertTrue(searchResult.getLogMessage(), searchResult.isSuccess());
    // 
    // JSONObject resultJson = (JSONObject) searchResult.getData().get(0);
    // String circleId = resultJson.getJSONObject("value").getString("shareWith");
    // 
    // assertTrue(new CreateShareRemoteOperation("/shareToCircle/",
    // ShareType.CIRCLE,
    // circleId,
    // false,
    // "",
    // OCShare.DEFAULT_PERMISSION)
    // .execute(client).isSuccess());
    Activity sut = activityRule.launchActivity(null);
    getInstrumentation().waitForIdleSync();
    EventBus.getDefault().post(new SearchEvent("", SearchRemoteOperation.SearchType.SHARED_FILTER));
    shortSleep();
    shortSleep();
    screenshot(sut);
}
Also used : CreateFolderRemoteOperation(com.owncloud.android.lib.resources.files.CreateFolderRemoteOperation) ExistenceCheckRemoteOperation(com.owncloud.android.lib.resources.files.ExistenceCheckRemoteOperation) FileDisplayActivity(com.owncloud.android.ui.activity.FileDisplayActivity) Activity(android.app.Activity) SearchEvent(com.owncloud.android.ui.events.SearchEvent) CreateShareRemoteOperation(com.owncloud.android.lib.resources.shares.CreateShareRemoteOperation) Test(org.junit.Test)

Example 5 with SearchEvent

use of com.owncloud.android.ui.events.SearchEvent in project android by nextcloud.

the class DrawerActivity method selectNavigationItem.

private void selectNavigationItem(final MenuItem menuItem) {
    setDrawerMenuItemChecked(menuItem.getItemId());
    switch(menuItem.getItemId()) {
        case R.id.nav_all_files:
            showFiles(false);
            EventBus.getDefault().post(new ChangeMenuEvent());
            break;
        case R.id.nav_favorites:
            switchToSearchFragment(new SearchEvent("", SearchOperation.SearchType.FAVORITE_SEARCH, SearchEvent.UnsetType.NO_UNSET), menuItem);
            break;
        case R.id.nav_photos:
            switchToSearchFragment(new SearchEvent("image/%", SearchOperation.SearchType.CONTENT_TYPE_SEARCH, SearchEvent.UnsetType.NO_UNSET), menuItem);
            break;
        case R.id.nav_on_device:
            EventBus.getDefault().post(new ChangeMenuEvent());
            showFiles(true);
            break;
        case R.id.nav_uploads:
            Intent uploadListIntent = new Intent(getApplicationContext(), UploadListActivity.class);
            uploadListIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
            startActivity(uploadListIntent);
            break;
        case R.id.nav_activity:
            Intent activityIntent = new Intent(getApplicationContext(), ActivitiesListActivity.class);
            activityIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
            startActivity(activityIntent);
            break;
        case R.id.nav_notifications:
            Intent notificationsIntent = new Intent(getApplicationContext(), NotificationsActivity.class);
            startActivity(notificationsIntent);
            break;
        case R.id.nav_synced_folders:
            Intent syncedFoldersIntent = new Intent(getApplicationContext(), SyncedFoldersActivity.class);
            startActivity(syncedFoldersIntent);
            break;
        case R.id.nav_contacts:
            Intent contactsIntent = new Intent(getApplicationContext(), ContactsPreferenceActivity.class);
            startActivity(contactsIntent);
            break;
        case R.id.nav_settings:
            Intent settingsIntent = new Intent(getApplicationContext(), Preferences.class);
            startActivity(settingsIntent);
            break;
        case R.id.nav_participate:
            Intent participateIntent = new Intent(getApplicationContext(), ParticipateActivity.class);
            startActivity(participateIntent);
            break;
        case R.id.nav_logout:
            mCheckedMenuItem = -1;
            menuItem.setChecked(false);
            UserInfoActivity.openAccountRemovalConfirmationDialog(getAccount(), getFragmentManager(), true);
            break;
        case R.id.drawer_menu_account_add:
            createAccount(false);
            break;
        case R.id.drawer_menu_account_manage:
            Intent manageAccountsIntent = new Intent(getApplicationContext(), ManageAccountsActivity.class);
            startActivityForResult(manageAccountsIntent, ACTION_MANAGE_ACCOUNTS);
            break;
        case R.id.nav_recently_added:
            switchToSearchFragment(new SearchEvent("%", SearchOperation.SearchType.CONTENT_TYPE_SEARCH, SearchEvent.UnsetType.UNSET_BOTTOM_NAV_BAR), menuItem);
            break;
        case R.id.nav_recently_modified:
            switchToSearchFragment(new SearchEvent("", SearchOperation.SearchType.RECENTLY_MODIFIED_SEARCH, SearchEvent.UnsetType.UNSET_BOTTOM_NAV_BAR), menuItem);
            break;
        case R.id.nav_shared:
            switchToSearchFragment(new SearchEvent("", SearchOperation.SearchType.SHARED_SEARCH, SearchEvent.UnsetType.UNSET_BOTTOM_NAV_BAR), menuItem);
            break;
        case R.id.nav_videos:
            switchToSearchFragment(new SearchEvent("video/%", SearchOperation.SearchType.CONTENT_TYPE_SEARCH, SearchEvent.UnsetType.UNSET_BOTTOM_NAV_BAR), menuItem);
            break;
        case Menu.NONE:
            // account clicked
            accountClicked(menuItem.getTitle().toString());
            break;
        default:
            break;
    }
    if (menuItem.getItemId() >= MENU_ITEM_EXTERNAL_LINK && menuItem.getItemId() <= MENU_ITEM_EXTERNAL_LINK + 100) {
        // external link clicked
        externalLinkClicked(menuItem);
    } else {
        Log_OC.i(TAG, "Unknown drawer menu item clicked: " + menuItem.getTitle());
    }
}
Also used : ChangeMenuEvent(com.owncloud.android.ui.events.ChangeMenuEvent) SearchEvent(com.owncloud.android.ui.events.SearchEvent) Intent(android.content.Intent)

Aggregations

SearchEvent (com.owncloud.android.ui.events.SearchEvent)7 Activity (android.app.Activity)2 Intent (android.content.Intent)2 FileDisplayActivity (com.owncloud.android.ui.activity.FileDisplayActivity)2 ChangeMenuEvent (com.owncloud.android.ui.events.ChangeMenuEvent)2 GalleryFragment (com.owncloud.android.ui.fragment.GalleryFragment)2 Account (android.accounts.Account)1 Bundle (android.os.Bundle)1 BottomNavigationView (android.support.design.widget.BottomNavigationView)1 Menu (android.view.Menu)1 MenuItem (android.view.MenuItem)1 RecyclerView (androidx.recyclerview.widget.RecyclerView)1 User (com.nextcloud.client.account.User)1 OCFile (com.owncloud.android.datamodel.OCFile)1 OwnCloudAccount (com.owncloud.android.lib.common.OwnCloudAccount)1 CreateFolderRemoteOperation (com.owncloud.android.lib.resources.files.CreateFolderRemoteOperation)1 ExistenceCheckRemoteOperation (com.owncloud.android.lib.resources.files.ExistenceCheckRemoteOperation)1 CreateShareRemoteOperation (com.owncloud.android.lib.resources.shares.CreateShareRemoteOperation)1 EmptyRecyclerView (com.owncloud.android.ui.EmptyRecyclerView)1 FolderPickerActivity (com.owncloud.android.ui.activity.FolderPickerActivity)1