add filter helper method for drawer menu

This commit is contained in:
AndyScherzinger 2018-06-24 11:28:23 +02:00
parent 1908d80a10
commit e2b338ea20
No known key found for this signature in database
GPG key ID: 6CADC7E3523C308B

View file

@ -345,16 +345,11 @@ public abstract class DrawerActivity extends ToolbarActivity implements DisplayU
boolean searchSupported = AccountUtils.hasSearchSupport(account); boolean searchSupported = AccountUtils.hasSearchSupport(account);
if (getResources().getBoolean(R.bool.bottom_toolbar_enabled) && account != null) { if (getResources().getBoolean(R.bool.bottom_toolbar_enabled) && account != null) {
menu.removeItem(R.id.nav_all_files); filterMenuItems(menu, R.id.nav_all_files, R.id.nav_settings, R.id.nav_favorites, R.id.nav_photos);
menu.removeItem(R.id.nav_settings);
menu.removeItem(R.id.nav_favorites);
menu.removeItem(R.id.nav_photos);
} }
if (!searchSupported && account != null) { if (!searchSupported && account != null) {
menu.removeItem(R.id.nav_photos); filterMenuItems(menu, R.id.nav_photos, R.id.nav_favorites, R.id.nav_videos);
menu.removeItem(R.id.nav_favorites);
menu.removeItem(R.id.nav_videos);
} }
if (account != null) { if (account != null) {
@ -363,7 +358,7 @@ public abstract class DrawerActivity extends ToolbarActivity implements DisplayU
if (AccountUtils.getServerVersion(getAccount()).compareTo(OwnCloudVersion.nextcloud_14) < 0 || if (AccountUtils.getServerVersion(getAccount()).compareTo(OwnCloudVersion.nextcloud_14) < 0 ||
capability.getFilesUndelete().isFalse() || capability.getFilesUndelete().isUnknown()) { capability.getFilesUndelete().isFalse() || capability.getFilesUndelete().isUnknown()) {
menu.removeItem(R.id.nav_trashbin); filterMenuItems(menu, R.id.nav_trashbin);
} }
} }
@ -406,9 +401,15 @@ public abstract class DrawerActivity extends ToolbarActivity implements DisplayU
menu.removeItem(R.id.nav_videos); menu.removeItem(R.id.nav_videos);
} }
} else if (account != null) { } else if (account != null) {
menu.removeItem(R.id.nav_recently_added); filterMenuItems(menu, R.id.nav_recently_added, R.id.nav_recently_modified, R.id.nav_videos);
menu.removeItem(R.id.nav_recently_modified); }
menu.removeItem(R.id.nav_videos); }
private static void filterMenuItems(Menu menu, int... menuIds) {
if (menuIds != null) {
for (int menuId : menuIds) {
menu.removeItem(menuId);
}
} }
} }