Search in sources :

Example 6 with OCCapability

use of com.owncloud.android.lib.resources.status.OCCapability in project android by nextcloud.

the class DialogFragmentIT method testBottomSheet.

@Test
@ScreenshotTest
public void testBottomSheet() {
    if (Looper.myLooper() == null) {
        Looper.prepare();
    }
    OCFileListBottomSheetActions action = new OCFileListBottomSheetActions() {

        @Override
        public void createFolder() {
        }

        @Override
        public void uploadFromApp() {
        }

        @Override
        public void uploadFiles() {
        }

        @Override
        public void newDocument() {
        }

        @Override
        public void newSpreadsheet() {
        }

        @Override
        public void newPresentation() {
        }

        @Override
        public void directCameraUpload() {
        }

        @Override
        public void scanDocUpload() {
        }

        @Override
        public void showTemplate(Creator creator, String headline) {
        }

        @Override
        public void createRichWorkspace() {
        }
    };
    DeviceInfo info = new DeviceInfo();
    OCFile ocFile = new OCFile("/test.md");
    Intent intent = new Intent(targetContext, FileDisplayActivity.class);
    FileDisplayActivity fda = activityRule.launchActivity(intent);
    // add direct editing info
    DirectEditing directEditing = new DirectEditing();
    directEditing.getCreators().put("1", new Creator("1", "text", "text file", ".md", "application/octet-stream", false));
    directEditing.getCreators().put("2", new Creator("2", "md", "markdown file", ".md", "application/octet-stream", false));
    directEditing.getEditors().put("text", new Editor("1", "Text", new ArrayList<>(Collections.singletonList(MimeTypeUtil.MIMETYPE_TEXT_MARKDOWN)), new ArrayList<>(), false));
    String json = new Gson().toJson(directEditing);
    new ArbitraryDataProvider(targetContext.getContentResolver()).storeOrUpdateKeyValue(user.getAccountName(), ArbitraryDataProvider.DIRECT_EDITING, json);
    // activate templates
    OCCapability capability = fda.getCapabilities();
    capability.setRichDocuments(CapabilityBooleanType.TRUE);
    capability.setRichDocumentsDirectEditing(CapabilityBooleanType.TRUE);
    capability.setRichDocumentsTemplatesAvailable(CapabilityBooleanType.TRUE);
    OCFileListBottomSheetDialog sut = new OCFileListBottomSheetDialog(fda, action, info, user, ocFile);
    fda.runOnUiThread(sut::show);
    waitForIdleSync();
    screenshot(sut.getWindow().getDecorView());
}
Also used : DirectEditing(com.owncloud.android.lib.common.DirectEditing) OCCapability(com.owncloud.android.lib.resources.status.OCCapability) OCFileListBottomSheetDialog(com.owncloud.android.ui.fragment.OCFileListBottomSheetDialog) ArrayList(java.util.ArrayList) OCFileListBottomSheetActions(com.owncloud.android.ui.fragment.OCFileListBottomSheetActions) Gson(com.google.gson.Gson) ArbitraryDataProvider(com.owncloud.android.datamodel.ArbitraryDataProvider) Intent(android.content.Intent) Creator(com.owncloud.android.lib.common.Creator) OCFile(com.owncloud.android.datamodel.OCFile) FileDisplayActivity(com.owncloud.android.ui.activity.FileDisplayActivity) DeviceInfo(com.nextcloud.client.device.DeviceInfo) Editor(com.owncloud.android.lib.common.Editor) ScreenshotTest(com.owncloud.android.utils.ScreenshotTest) Test(org.junit.Test) ScreenshotTest(com.owncloud.android.utils.ScreenshotTest)

Example 7 with OCCapability

use of com.owncloud.android.lib.resources.status.OCCapability in project android by nextcloud.

the class FileDataStorageManagerIT method testOCCapability.

@Test
public void testOCCapability() {
    OCCapability capability = new OCCapability();
    capability.setUserStatus(CapabilityBooleanType.TRUE);
    sut.saveCapabilities(capability);
    OCCapability newCapability = sut.getCapability(user);
    assertEquals(capability.getUserStatus(), newCapability.getUserStatus());
}
Also used : OCCapability(com.owncloud.android.lib.resources.status.OCCapability) Test(org.junit.Test)

Example 8 with OCCapability

use of com.owncloud.android.lib.resources.status.OCCapability in project android by nextcloud.

the class GetCapabilitiesOperation method run.

@Override
protected RemoteOperationResult run(OwnCloudClient client) {
    final FileDataStorageManager storageManager = getStorageManager();
    OCCapability currentCapability = null;
    if (!storageManager.getUser().isAnonymous()) {
        currentCapability = storageManager.getCapability(storageManager.getUser().getAccountName());
    }
    RemoteOperationResult result = new GetCapabilitiesRemoteOperation(currentCapability).execute(client);
    if (result.isSuccess() && result.getData() != null && result.getData().size() > 0) {
        // Read data from the result
        OCCapability capability = (OCCapability) result.getData().get(0);
        // Save the capabilities into database
        storageManager.saveCapabilities(capability);
    }
    return result;
}
Also used : OCCapability(com.owncloud.android.lib.resources.status.OCCapability) RemoteOperationResult(com.owncloud.android.lib.common.operations.RemoteOperationResult) FileDataStorageManager(com.owncloud.android.datamodel.FileDataStorageManager) GetCapabilitiesRemoteOperation(com.owncloud.android.lib.resources.status.GetCapabilitiesRemoteOperation)

Example 9 with OCCapability

use of com.owncloud.android.lib.resources.status.OCCapability in project android by owncloud.

the class FileMenuFilter method filter.

/**
     * Performs the real filtering, to be applied in the {@link Menu} by the caller methods.
     *
     * Decides what actions must be shown and hidden.
     *
     * @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.
     */
private void filter(List<Integer> toShow, List<Integer> toHide) {
    boolean synchronizing = anyFileSynchronizing();
    // DOWNLOAD 
    if (mFiles.isEmpty() || containsFolder() || anyFileDown() || synchronizing) {
        toHide.add(R.id.action_download_file);
    } else {
        toShow.add(R.id.action_download_file);
    }
    // RENAME
    if (!isSingleSelection() || synchronizing) {
        toHide.add(R.id.action_rename_file);
    } else {
        toShow.add(R.id.action_rename_file);
    }
    // MOVE & COPY
    if (mFiles.isEmpty() || synchronizing) {
        toHide.add(R.id.action_move);
        toHide.add(R.id.action_copy);
    } else {
        toShow.add(R.id.action_move);
        toShow.add(R.id.action_copy);
    }
    // REMOVE
    if (mFiles.isEmpty() || synchronizing) {
        toHide.add(R.id.action_remove_file);
    } else {
        toShow.add(R.id.action_remove_file);
    }
    // OPEN WITH (different to preview!)
    if (!isSingleFile() || !anyFileDown() || synchronizing) {
        toHide.add(R.id.action_open_file_with);
    } else {
        toShow.add(R.id.action_open_file_with);
    }
    // CANCEL SYNCHRONIZATION
    if (mFiles.isEmpty() || !synchronizing || anyFavorite()) {
        toHide.add(R.id.action_cancel_sync);
    } else {
        toShow.add(R.id.action_cancel_sync);
    }
    // SYNC CONTENTS (BOTH FILE AND FOLDER)
    if (mFiles.isEmpty() || (!anyFileDown() && !containsFolder()) || synchronizing) {
        toHide.add(R.id.action_sync_file);
    } else {
        toShow.add(R.id.action_sync_file);
    }
    // SHARE FILE
    boolean shareViaLinkAllowed = (mContext != null && mContext.getResources().getBoolean(R.bool.share_via_link_feature));
    boolean shareWithUsersAllowed = (mContext != null && mContext.getResources().getBoolean(R.bool.share_with_users_feature));
    OCCapability capability = mComponentsGetter.getStorageManager().getCapability(mAccount.name);
    boolean shareApiEnabled = capability != null && (capability.getFilesSharingApiEnabled().isTrue() || capability.getFilesSharingApiEnabled().isUnknown());
    if ((!shareViaLinkAllowed && !shareWithUsersAllowed) || !isSingleSelection() || !shareApiEnabled) {
        toHide.add(R.id.action_share_file);
    } else {
        toShow.add(R.id.action_share_file);
    }
    // SEE DETAILS
    if (!isSingleFile()) {
        toHide.add(R.id.action_see_details);
    } else {
        toShow.add(R.id.action_see_details);
    }
    // SEND
    boolean sendAllowed = (mContext != null && mContext.getString(R.string.send_files_to_other_apps).equalsIgnoreCase("on"));
    if (!isSingleFile() || !sendAllowed || synchronizing) {
        toHide.add(R.id.action_send_file);
    } else {
        toShow.add(R.id.action_send_file);
    }
    // SET AS AVAILABLE OFFLINE
    if (synchronizing || !anyUnfavorite()) {
        toHide.add(R.id.action_set_available_offline);
    } else {
        toShow.add(R.id.action_set_available_offline);
    }
    // UNSET AS AVAILABLE OFFLINE
    if (!anyFavorite()) {
        toHide.add(R.id.action_unset_available_offline);
    } else {
        toShow.add(R.id.action_unset_available_offline);
    }
}
Also used : OCCapability(com.owncloud.android.lib.resources.status.OCCapability)

Example 10 with OCCapability

use of com.owncloud.android.lib.resources.status.OCCapability in project android by owncloud.

the class FileDataStorageManager method createCapabilityInstance.

private OCCapability createCapabilityInstance(Cursor c) {
    OCCapability capability = null;
    if (c != null) {
        capability = new OCCapability();
        capability.setId(c.getLong(c.getColumnIndex(ProviderTableMeta._ID)));
        capability.setAccountName(c.getString(c.getColumnIndex(ProviderTableMeta.CAPABILITIES_ACCOUNT_NAME)));
        capability.setVersionMayor(c.getInt(c.getColumnIndex(ProviderTableMeta.CAPABILITIES_VERSION_MAYOR)));
        capability.setVersionMinor(c.getInt(c.getColumnIndex(ProviderTableMeta.CAPABILITIES_VERSION_MINOR)));
        capability.setVersionMicro(c.getInt(c.getColumnIndex(ProviderTableMeta.CAPABILITIES_VERSION_MICRO)));
        capability.setVersionString(c.getString(c.getColumnIndex(ProviderTableMeta.CAPABILITIES_VERSION_STRING)));
        capability.setVersionEdition(c.getString(c.getColumnIndex(ProviderTableMeta.CAPABILITIES_VERSION_EDITION)));
        capability.setCorePollinterval(c.getInt(c.getColumnIndex(ProviderTableMeta.CAPABILITIES_CORE_POLLINTERVAL)));
        capability.setFilesSharingApiEnabled(CapabilityBooleanType.fromValue(c.getInt(c.getColumnIndex(ProviderTableMeta.CAPABILITIES_SHARING_API_ENABLED))));
        capability.setFilesSharingPublicEnabled(CapabilityBooleanType.fromValue(c.getInt(c.getColumnIndex(ProviderTableMeta.CAPABILITIES_SHARING_PUBLIC_ENABLED))));
        capability.setFilesSharingPublicPasswordEnforced(CapabilityBooleanType.fromValue(c.getInt(c.getColumnIndex(ProviderTableMeta.CAPABILITIES_SHARING_PUBLIC_PASSWORD_ENFORCED))));
        capability.setFilesSharingPublicExpireDateEnabled(CapabilityBooleanType.fromValue(c.getInt(c.getColumnIndex(ProviderTableMeta.CAPABILITIES_SHARING_PUBLIC_EXPIRE_DATE_ENABLED))));
        capability.setFilesSharingPublicExpireDateDays(c.getInt(c.getColumnIndex(ProviderTableMeta.CAPABILITIES_SHARING_PUBLIC_EXPIRE_DATE_DAYS)));
        capability.setFilesSharingPublicExpireDateEnforced(CapabilityBooleanType.fromValue(c.getInt(c.getColumnIndex(ProviderTableMeta.CAPABILITIES_SHARING_PUBLIC_EXPIRE_DATE_ENFORCED))));
        capability.setFilesSharingPublicSendMail(CapabilityBooleanType.fromValue(c.getInt(c.getColumnIndex(ProviderTableMeta.CAPABILITIES_SHARING_PUBLIC_SEND_MAIL))));
        capability.setFilesSharingPublicUpload(CapabilityBooleanType.fromValue(c.getInt(c.getColumnIndex(ProviderTableMeta.CAPABILITIES_SHARING_PUBLIC_UPLOAD))));
        capability.setFilesSharingUserSendMail(CapabilityBooleanType.fromValue(c.getInt(c.getColumnIndex(ProviderTableMeta.CAPABILITIES_SHARING_USER_SEND_MAIL))));
        capability.setFilesSharingResharing(CapabilityBooleanType.fromValue(c.getInt(c.getColumnIndex(ProviderTableMeta.CAPABILITIES_SHARING_RESHARING))));
        capability.setFilesSharingFederationOutgoing(CapabilityBooleanType.fromValue(c.getInt(c.getColumnIndex(ProviderTableMeta.CAPABILITIES_SHARING_FEDERATION_OUTGOING))));
        capability.setFilesSharingFederationIncoming(CapabilityBooleanType.fromValue(c.getInt(c.getColumnIndex(ProviderTableMeta.CAPABILITIES_SHARING_FEDERATION_INCOMING))));
        capability.setFilesBigFileChuncking(CapabilityBooleanType.fromValue(c.getInt(c.getColumnIndex(ProviderTableMeta.CAPABILITIES_FILES_BIGFILECHUNKING))));
        capability.setFilesUndelete(CapabilityBooleanType.fromValue(c.getInt(c.getColumnIndex(ProviderTableMeta.CAPABILITIES_FILES_UNDELETE))));
        capability.setFilesVersioning(CapabilityBooleanType.fromValue(c.getInt(c.getColumnIndex(ProviderTableMeta.CAPABILITIES_FILES_VERSIONING))));
    }
    return capability;
}
Also used : OCCapability(com.owncloud.android.lib.resources.status.OCCapability)

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