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();
}
}
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());
}
}
}
Aggregations