mirror of
https://github.com/nextcloud/android.git
synced 2024-11-26 15:15:51 +03:00
Migrate drawer menu utilities to new user model
Signed-off-by: Chris Narkiewicz <hello@ezaquarii.com>
This commit is contained in:
parent
f415cd966f
commit
b5fb9c1374
2 changed files with 11 additions and 14 deletions
|
@ -374,8 +374,8 @@ public abstract class DrawerActivity extends ToolbarActivity
|
||||||
getContentResolver());
|
getContentResolver());
|
||||||
OCCapability capability = storageManager.getCapability(user.getAccountName());
|
OCCapability capability = storageManager.getCapability(user.getAccountName());
|
||||||
|
|
||||||
DrawerMenuUtil.filterSearchMenuItems(menu, user.toPlatformAccount(), getResources(), true);
|
DrawerMenuUtil.filterSearchMenuItems(menu, user, getResources(), true);
|
||||||
DrawerMenuUtil.filterTrashbinMenuItem(menu, user.toPlatformAccount(), capability, accountManager);
|
DrawerMenuUtil.filterTrashbinMenuItem(menu, user, capability);
|
||||||
DrawerMenuUtil.filterActivityMenuItem(menu, capability);
|
DrawerMenuUtil.filterActivityMenuItem(menu, capability);
|
||||||
|
|
||||||
DrawerMenuUtil.setupHomeMenuItem(menu, getResources());
|
DrawerMenuUtil.setupHomeMenuItem(menu, getResources());
|
||||||
|
|
|
@ -20,11 +20,10 @@
|
||||||
|
|
||||||
package com.owncloud.android.utils;
|
package com.owncloud.android.utils;
|
||||||
|
|
||||||
import android.accounts.Account;
|
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.view.Menu;
|
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.R;
|
||||||
import com.owncloud.android.lib.resources.status.OCCapability;
|
import com.owncloud.android.lib.resources.status.OCCapability;
|
||||||
import com.owncloud.android.lib.resources.status.OwnCloudVersion;
|
import com.owncloud.android.lib.resources.status.OwnCloudVersion;
|
||||||
|
@ -39,10 +38,10 @@ public final class DrawerMenuUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void filterSearchMenuItems(Menu menu,
|
public static void filterSearchMenuItems(Menu menu,
|
||||||
Account account,
|
User user,
|
||||||
Resources resources,
|
Resources resources,
|
||||||
boolean hasSearchSupport) {
|
boolean hasSearchSupport) {
|
||||||
if (account != null && !hasSearchSupport) {
|
if (!user.isAnonymous() && !hasSearchSupport) {
|
||||||
filterMenuItems(menu, R.id.nav_photos, R.id.nav_favorites, R.id.nav_videos);
|
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)) {
|
if (!resources.getBoolean(R.bool.videos_enabled)) {
|
||||||
menu.removeItem(R.id.nav_videos);
|
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);
|
filterMenuItems(menu, R.id.nav_recently_added, R.id.nav_recently_modified, R.id.nav_videos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void filterTrashbinMenuItem(Menu menu,
|
public static void filterTrashbinMenuItem(Menu menu, User user, @Nullable OCCapability capability) {
|
||||||
@Nullable Account account,
|
if (!user.isAnonymous() &&
|
||||||
@Nullable OCCapability capability,
|
user.getServer().getVersion().compareTo(OwnCloudVersion.nextcloud_14) < 0 ||
|
||||||
UserAccountManager accountManager) {
|
capability != null && capability.getFilesUndelete().isFalse() ||
|
||||||
if (account != null && capability != null &&
|
capability != null && capability.getFilesUndelete().isUnknown()) {
|
||||||
(accountManager.getServerVersion(account).compareTo(OwnCloudVersion.nextcloud_14) < 0 ||
|
|
||||||
capability.getFilesUndelete().isFalse() || capability.getFilesUndelete().isUnknown())) {
|
|
||||||
filterMenuItems(menu, R.id.nav_trashbin);
|
filterMenuItems(menu, R.id.nav_trashbin);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue