Search in sources :

Example 1 with ChangeMenuEvent

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

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

Intent (android.content.Intent)2 ChangeMenuEvent (com.owncloud.android.ui.events.ChangeMenuEvent)2 SearchEvent (com.owncloud.android.ui.events.SearchEvent)2 User (com.nextcloud.client.account.User)1 GalleryFragment (com.owncloud.android.ui.fragment.GalleryFragment)1 PreviewTextStringFragment (com.owncloud.android.ui.preview.PreviewTextStringFragment)1 TrashbinActivity (com.owncloud.android.ui.trashbin.TrashbinActivity)1