Search in sources :

Example 16 with OCCapability

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;
}
Also used : OCCapability(com.owncloud.android.lib.resources.status.OCCapability) Cursor(android.database.Cursor) NonNull(androidx.annotation.NonNull)

Example 17 with OCCapability

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);
}
Also used : OCCapability(com.owncloud.android.lib.resources.status.OCCapability)

Example 18 with OCCapability

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;
}
Also used : OCCapability(com.owncloud.android.lib.resources.status.OCCapability)

Example 19 with OCCapability

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);
        }
    }
}
Also used : SVGorImage(com.owncloud.android.utils.svg.SVGorImage) FileToStreamDecoder(com.bumptech.glide.load.resource.file.FileToStreamDecoder) OCCapability(com.owncloud.android.lib.resources.status.OCCapability) InputStream(java.io.InputStream) ColorDrawable(android.graphics.drawable.ColorDrawable) Drawable(android.graphics.drawable.Drawable) LayerDrawable(android.graphics.drawable.LayerDrawable) BitmapDrawable(android.graphics.drawable.BitmapDrawable) BitmapDrawable(android.graphics.drawable.BitmapDrawable) GlideAnimation(com.bumptech.glide.request.animation.GlideAnimation) Uri(android.net.Uri) MenuSimpleTarget(com.owncloud.android.utils.svg.MenuSimpleTarget) SimpleTarget(com.bumptech.glide.request.target.SimpleTarget) Bitmap(android.graphics.Bitmap) SvgOrImageDecoder(com.owncloud.android.utils.svg.SvgOrImageDecoder) ColorDrawable(android.graphics.drawable.ColorDrawable) LayerDrawable(android.graphics.drawable.LayerDrawable) SvgOrImageBitmapTranscoder(com.owncloud.android.utils.svg.SvgOrImageBitmapTranscoder) LinearLayout(android.widget.LinearLayout) StreamEncoder(com.bumptech.glide.load.model.StreamEncoder)

Example 20 with OCCapability

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));
}
Also used : OCCapability(com.owncloud.android.lib.resources.status.OCCapability) FileDataStorageManager(com.owncloud.android.datamodel.FileDataStorageManager)

Aggregations

OCCapability (com.owncloud.android.lib.resources.status.OCCapability)26 FileDataStorageManager (com.owncloud.android.datamodel.FileDataStorageManager)9 User (com.nextcloud.client.account.User)6 RemoteOperationResult (com.owncloud.android.lib.common.operations.RemoteOperationResult)6 Account (android.accounts.Account)5 AccountManager (android.accounts.AccountManager)3 Intent (android.content.Intent)3 UserAccountManager (com.nextcloud.client.account.UserAccountManager)3 FileDisplayActivity (com.owncloud.android.ui.activity.FileDisplayActivity)3 Test (org.junit.Test)3 ActivityNotFoundException (android.content.ActivityNotFoundException)2 Cursor (android.database.Cursor)2 ColorDrawable (android.graphics.drawable.ColorDrawable)2 Drawable (android.graphics.drawable.Drawable)2 LayerDrawable (android.graphics.drawable.LayerDrawable)2 GlideAnimation (com.bumptech.glide.request.animation.GlideAnimation)2 SimpleTarget (com.bumptech.glide.request.target.SimpleTarget)2 Gson (com.google.gson.Gson)2 RegisteredUser (com.nextcloud.client.account.RegisteredUser)2 Server (com.nextcloud.client.account.Server)2