use of com.owncloud.android.lib.resources.status.OCCapability in project android by nextcloud.
the class FileDataStorageManager method getCapability.
@NonNull
public OCCapability getCapability(String accountName) {
OCCapability capability;
Cursor cursor = getCapabilityCursorForAccount(accountName);
if (cursor.moveToFirst()) {
capability = createCapabilityInstance(cursor);
} else {
// return default with all UNKNOWN
capability = new OCCapability();
}
cursor.close();
return capability;
}
use of com.owncloud.android.lib.resources.status.OCCapability in project android by nextcloud.
the class FileMenuFilter method filter.
/**
* Decides what actions must be shown and hidden implementing the different rule sets.
* @param toShow List to save the options that must be shown in the menu.
* @param toHide List to save the options that must be shown in the menu.
* @param inSingleFileFragment True if this is not listing, but single file fragment, like preview or details.
*/
private void filter(List<Integer> toShow, List<Integer> toHide, boolean inSingleFileFragment) {
boolean synchronizing = anyFileSynchronizing();
OCCapability capability = componentsGetter.getStorageManager().getCapability(user.getAccountName());
boolean endToEndEncryptionEnabled = capability.getEndToEndEncryption().isTrue();
filterEdit(toShow, toHide, capability);
filterDownload(toShow, toHide, synchronizing);
filterRename(toShow, toHide, synchronizing);
filterMoveCopy(toShow, toHide, synchronizing);
filterRemove(toShow, toHide, synchronizing);
filterSelectAll(toShow, toHide, inSingleFileFragment);
filterDeselectAll(toShow, toHide, inSingleFileFragment);
filterOpenWith(toShow, toHide, synchronizing);
filterCancelSync(toShow, toHide, synchronizing);
filterSync(toShow, toHide, synchronizing);
filterShareFile(toShow, toHide, capability);
filterSendFiles(toShow, toHide, inSingleFileFragment);
filterDetails(toShow, toHide);
filterFavorite(toShow, toHide, synchronizing);
filterUnfavorite(toShow, toHide, synchronizing);
filterEncrypt(toShow, toHide, endToEndEncryptionEnabled);
filterUnsetEncrypted(toShow, toHide, endToEndEncryptionEnabled);
filterSetPictureAs(toShow, toHide);
filterStream(toShow, toHide);
}
use of com.owncloud.android.lib.resources.status.OCCapability in project android by nextcloud.
the class FileDataStorageManager method createCapabilityInstance.
private OCCapability createCapabilityInstance(Cursor cursor) {
OCCapability capability = null;
if (cursor != null) {
capability = new OCCapability();
capability.setId(getLong(cursor, ProviderTableMeta._ID));
capability.setAccountName(getString(cursor, ProviderTableMeta.CAPABILITIES_ACCOUNT_NAME));
capability.setVersionMayor(getInt(cursor, ProviderTableMeta.CAPABILITIES_VERSION_MAYOR));
capability.setVersionMinor(getInt(cursor, ProviderTableMeta.CAPABILITIES_VERSION_MINOR));
capability.setVersionMicro(getInt(cursor, ProviderTableMeta.CAPABILITIES_VERSION_MICRO));
capability.setVersionString(getString(cursor, ProviderTableMeta.CAPABILITIES_VERSION_STRING));
capability.setVersionEdition(getString(cursor, ProviderTableMeta.CAPABILITIES_VERSION_EDITION));
capability.setExtendedSupport(getBoolean(cursor, ProviderTableMeta.CAPABILITIES_EXTENDED_SUPPORT));
capability.setCorePollInterval(getInt(cursor, ProviderTableMeta.CAPABILITIES_CORE_POLLINTERVAL));
capability.setFilesSharingApiEnabled(getBoolean(cursor, ProviderTableMeta.CAPABILITIES_SHARING_API_ENABLED));
capability.setFilesSharingPublicEnabled(getBoolean(cursor, ProviderTableMeta.CAPABILITIES_SHARING_PUBLIC_ENABLED));
capability.setFilesSharingPublicPasswordEnforced(getBoolean(cursor, ProviderTableMeta.CAPABILITIES_SHARING_PUBLIC_PASSWORD_ENFORCED));
capability.setFilesSharingPublicAskForOptionalPassword(getBoolean(cursor, ProviderTableMeta.CAPABILITIES_SHARING_PUBLIC_ASK_FOR_OPTIONAL_PASSWORD));
capability.setFilesSharingPublicExpireDateEnabled(getBoolean(cursor, ProviderTableMeta.CAPABILITIES_SHARING_PUBLIC_EXPIRE_DATE_ENABLED));
capability.setFilesSharingPublicExpireDateDays(getInt(cursor, ProviderTableMeta.CAPABILITIES_SHARING_PUBLIC_EXPIRE_DATE_DAYS));
capability.setFilesSharingPublicExpireDateEnforced(getBoolean(cursor, ProviderTableMeta.CAPABILITIES_SHARING_PUBLIC_EXPIRE_DATE_ENFORCED));
capability.setFilesSharingPublicSendMail(getBoolean(cursor, ProviderTableMeta.CAPABILITIES_SHARING_PUBLIC_SEND_MAIL));
capability.setFilesSharingPublicUpload(getBoolean(cursor, ProviderTableMeta.CAPABILITIES_SHARING_PUBLIC_UPLOAD));
capability.setFilesSharingUserSendMail(getBoolean(cursor, ProviderTableMeta.CAPABILITIES_SHARING_USER_SEND_MAIL));
capability.setFilesSharingResharing(getBoolean(cursor, ProviderTableMeta.CAPABILITIES_SHARING_RESHARING));
capability.setFilesSharingFederationOutgoing(getBoolean(cursor, ProviderTableMeta.CAPABILITIES_SHARING_FEDERATION_OUTGOING));
capability.setFilesSharingFederationIncoming(getBoolean(cursor, ProviderTableMeta.CAPABILITIES_SHARING_FEDERATION_INCOMING));
capability.setFilesBigFileChunking(getBoolean(cursor, ProviderTableMeta.CAPABILITIES_FILES_BIGFILECHUNKING));
capability.setFilesUndelete(getBoolean(cursor, ProviderTableMeta.CAPABILITIES_FILES_UNDELETE));
capability.setFilesVersioning(getBoolean(cursor, ProviderTableMeta.CAPABILITIES_FILES_VERSIONING));
capability.setExternalLinks(getBoolean(cursor, ProviderTableMeta.CAPABILITIES_EXTERNAL_LINKS));
capability.setServerName(getString(cursor, ProviderTableMeta.CAPABILITIES_SERVER_NAME));
capability.setServerColor(getString(cursor, ProviderTableMeta.CAPABILITIES_SERVER_COLOR));
capability.setServerTextColor(getString(cursor, ProviderTableMeta.CAPABILITIES_SERVER_TEXT_COLOR));
capability.setServerElementColor(getString(cursor, ProviderTableMeta.CAPABILITIES_SERVER_ELEMENT_COLOR));
capability.setServerBackground(getString(cursor, ProviderTableMeta.CAPABILITIES_SERVER_BACKGROUND_URL));
capability.setServerSlogan(getString(cursor, ProviderTableMeta.CAPABILITIES_SERVER_SLOGAN));
capability.setServerLogo(getString(cursor, ProviderTableMeta.CAPABILITIES_SERVER_LOGO));
capability.setEndToEndEncryption(getBoolean(cursor, ProviderTableMeta.CAPABILITIES_END_TO_END_ENCRYPTION));
capability.setServerBackgroundDefault(getBoolean(cursor, ProviderTableMeta.CAPABILITIES_SERVER_BACKGROUND_DEFAULT));
capability.setServerBackgroundPlain(getBoolean(cursor, ProviderTableMeta.CAPABILITIES_SERVER_BACKGROUND_PLAIN));
capability.setActivity(getBoolean(cursor, ProviderTableMeta.CAPABILITIES_ACTIVITY));
capability.setRichDocuments(getBoolean(cursor, ProviderTableMeta.CAPABILITIES_RICHDOCUMENT));
capability.setRichDocumentsDirectEditing(getBoolean(cursor, ProviderTableMeta.CAPABILITIES_RICHDOCUMENT_DIRECT_EDITING));
capability.setRichDocumentsTemplatesAvailable(getBoolean(cursor, ProviderTableMeta.CAPABILITIES_RICHDOCUMENT_TEMPLATES));
String mimetypes = getString(cursor, ProviderTableMeta.CAPABILITIES_RICHDOCUMENT_MIMETYPE_LIST);
if (mimetypes == null) {
mimetypes = "";
}
capability.setRichDocumentsMimeTypeList(Arrays.asList(mimetypes.split(",")));
String optionalMimetypes = getString(cursor, ProviderTableMeta.CAPABILITIES_RICHDOCUMENT_OPTIONAL_MIMETYPE_LIST);
if (optionalMimetypes == null) {
optionalMimetypes = "";
}
capability.setRichDocumentsOptionalMimeTypeList(Arrays.asList(optionalMimetypes.split(",")));
capability.setRichDocumentsProductName(getString(cursor, ProviderTableMeta.CAPABILITIES_RICHDOCUMENT_PRODUCT_NAME));
capability.setDirectEditingEtag(getString(cursor, ProviderTableMeta.CAPABILITIES_DIRECT_EDITING_ETAG));
capability.setEtag(getString(cursor, ProviderTableMeta.CAPABILITIES_ETAG));
capability.setUserStatus(getBoolean(cursor, ProviderTableMeta.CAPABILITIES_USER_STATUS));
capability.setUserStatusSupportsEmoji(getBoolean(cursor, ProviderTableMeta.CAPABILITIES_USER_STATUS_SUPPORTS_EMOJI));
}
return capability;
}
use of com.owncloud.android.lib.resources.status.OCCapability in project android by nextcloud.
the class DrawerActivity method updateHeader.
public void updateHeader() {
if (getAccount() != null && getStorageManager().getCapability(getAccount().name).getServerBackground() != null) {
OCCapability capability = getStorageManager().getCapability(getAccount().name);
String logo = capability.getServerLogo();
int primaryColor = ThemeColorUtils.primaryColor(getAccount(), false, this);
// set background to primary color
LinearLayout drawerHeader = mNavigationViewHeader.findViewById(R.id.drawer_header_view);
drawerHeader.setBackgroundColor(ThemeColorUtils.unchangedPrimaryColor(getAccount(), this));
if (!TextUtils.isEmpty(logo) && URLUtil.isValidUrl(logo)) {
// background image
GenericRequestBuilder<Uri, InputStream, SVGorImage, Bitmap> requestBuilder = Glide.with(this).using(Glide.buildStreamModelLoader(Uri.class, this), InputStream.class).from(Uri.class).as(SVGorImage.class).transcode(new SvgOrImageBitmapTranscoder(128, 128), Bitmap.class).sourceEncoder(new StreamEncoder()).cacheDecoder(new FileToStreamDecoder<>(new SvgOrImageDecoder())).decoder(new SvgOrImageDecoder());
// background image
SimpleTarget target = new SimpleTarget<Bitmap>() {
@Override
public void onResourceReady(Bitmap resource, GlideAnimation glideAnimation) {
Bitmap logo = resource;
int width = resource.getWidth();
int height = resource.getHeight();
int max = Math.max(width, height);
if (max > MAX_LOGO_SIZE_PX) {
logo = BitmapUtils.scaleBitmap(resource, MAX_LOGO_SIZE_PX, width, height, max);
}
Drawable[] drawables = { new ColorDrawable(primaryColor), new BitmapDrawable(logo) };
LayerDrawable layerDrawable = new LayerDrawable(drawables);
String name = capability.getServerName();
setDrawerHeaderLogo(layerDrawable, name);
}
};
requestBuilder.diskCacheStrategy(DiskCacheStrategy.SOURCE).load(Uri.parse(logo)).into(target);
}
}
}
use of com.owncloud.android.lib.resources.status.OCCapability in project android by nextcloud.
the class DrawerActivity method filterDrawerMenu.
private void filterDrawerMenu(final Menu menu, @NonNull final User user) {
FileDataStorageManager storageManager = new FileDataStorageManager(user, getContentResolver());
OCCapability capability = storageManager.getCapability(user.getAccountName());
DrawerMenuUtil.filterSearchMenuItems(menu, user, getResources());
DrawerMenuUtil.filterTrashbinMenuItem(menu, capability);
DrawerMenuUtil.filterActivityMenuItem(menu, capability);
DrawerMenuUtil.setupHomeMenuItem(menu, getResources());
DrawerMenuUtil.removeMenuItem(menu, R.id.nav_community, !getResources().getBoolean(R.bool.participate_enabled));
DrawerMenuUtil.removeMenuItem(menu, R.id.nav_shared, !getResources().getBoolean(R.bool.shared_enabled));
DrawerMenuUtil.removeMenuItem(menu, R.id.nav_logout, !getResources().getBoolean(R.bool.show_drawer_logout));
}
Aggregations