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());
}
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());
}
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;
}
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);
}
}
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;
}
Aggregations