diff --git a/src/main/java/com/owncloud/android/ui/activity/DrawerActivity.java b/src/main/java/com/owncloud/android/ui/activity/DrawerActivity.java index 3d81508694..7ff2970f0f 100644 --- a/src/main/java/com/owncloud/android/ui/activity/DrawerActivity.java +++ b/src/main/java/com/owncloud/android/ui/activity/DrawerActivity.java @@ -374,8 +374,8 @@ public abstract class DrawerActivity extends ToolbarActivity getContentResolver()); OCCapability capability = storageManager.getCapability(user.getAccountName()); - DrawerMenuUtil.filterSearchMenuItems(menu, user.toPlatformAccount(), getResources(), true); - DrawerMenuUtil.filterTrashbinMenuItem(menu, user.toPlatformAccount(), capability, accountManager); + DrawerMenuUtil.filterSearchMenuItems(menu, user, getResources(), true); + DrawerMenuUtil.filterTrashbinMenuItem(menu, user, capability); DrawerMenuUtil.filterActivityMenuItem(menu, capability); DrawerMenuUtil.setupHomeMenuItem(menu, getResources()); diff --git a/src/main/java/com/owncloud/android/utils/DrawerMenuUtil.java b/src/main/java/com/owncloud/android/utils/DrawerMenuUtil.java index 45252f9073..1a3831e8f3 100644 --- a/src/main/java/com/owncloud/android/utils/DrawerMenuUtil.java +++ b/src/main/java/com/owncloud/android/utils/DrawerMenuUtil.java @@ -20,11 +20,10 @@ package com.owncloud.android.utils; -import android.accounts.Account; import android.content.res.Resources; import android.view.Menu; -import com.nextcloud.client.account.UserAccountManager; +import com.nextcloud.client.account.User; import com.owncloud.android.R; import com.owncloud.android.lib.resources.status.OCCapability; import com.owncloud.android.lib.resources.status.OwnCloudVersion; @@ -39,10 +38,10 @@ public final class DrawerMenuUtil { } public static void filterSearchMenuItems(Menu menu, - Account account, + User user, Resources resources, boolean hasSearchSupport) { - if (account != null && !hasSearchSupport) { + if (!user.isAnonymous() && !hasSearchSupport) { filterMenuItems(menu, R.id.nav_photos, R.id.nav_favorites, R.id.nav_videos); } @@ -58,18 +57,16 @@ public final class DrawerMenuUtil { if (!resources.getBoolean(R.bool.videos_enabled)) { menu.removeItem(R.id.nav_videos); } - } else if (account != null) { + } else if (!user.isAnonymous()) { filterMenuItems(menu, R.id.nav_recently_added, R.id.nav_recently_modified, R.id.nav_videos); } } - public static void filterTrashbinMenuItem(Menu menu, - @Nullable Account account, - @Nullable OCCapability capability, - UserAccountManager accountManager) { - if (account != null && capability != null && - (accountManager.getServerVersion(account).compareTo(OwnCloudVersion.nextcloud_14) < 0 || - capability.getFilesUndelete().isFalse() || capability.getFilesUndelete().isUnknown())) { + public static void filterTrashbinMenuItem(Menu menu, User user, @Nullable OCCapability capability) { + if (!user.isAnonymous() && + user.getServer().getVersion().compareTo(OwnCloudVersion.nextcloud_14) < 0 || + capability != null && capability.getFilesUndelete().isFalse() || + capability != null && capability.getFilesUndelete().isUnknown()) { filterMenuItems(menu, R.id.nav_trashbin); } }