use of com.owncloud.android.lib.resources.status.OCCapability in project android by nextcloud.
the class FileOperationsHelper method sendShareFile.
public void sendShareFile(OCFile file, boolean hideNcSharingOptions) {
// Show dialog
FragmentManager fm = fileActivity.getSupportFragmentManager();
FragmentTransaction ft = fm.beginTransaction();
ft.addToBackStack(null);
OCCapability capability = fileActivity.getStorageManager().getCapability(fileActivity.getAccount().name);
SendShareDialog mSendShareDialog = SendShareDialog.newInstance(file, hideNcSharingOptions, capability);
mSendShareDialog.setFileOperationsHelper(this);
mSendShareDialog.show(ft, "TAG_SEND_SHARE_DIALOG");
}
use of com.owncloud.android.lib.resources.status.OCCapability in project android by nextcloud.
the class FileOperationsHelper method openFile.
public void openFile(OCFile file) {
if (file != null) {
final Intent openFileWithIntent = createOpenFileIntent(file);
List<ResolveInfo> launchables = fileActivity.getPackageManager().queryIntentActivities(openFileWithIntent, PackageManager.GET_RESOLVED_FILTER);
if (launchables.isEmpty()) {
Optional<User> optionalUser = fileActivity.getUser();
if (optionalUser.isPresent() && FileMenuFilter.isEditorAvailable(fileActivity.getContentResolver(), optionalUser.get(), file.getMimeType())) {
openFileWithTextEditor(file, fileActivity);
} else {
Account account = fileActivity.getAccount();
OCCapability capability = fileActivity.getStorageManager().getCapability(account.name);
if (capability.getRichDocumentsMimeTypeList().contains(file.getMimeType()) && capability.getRichDocumentsDirectEditing().isTrue()) {
openFileAsRichDocument(file, fileActivity);
return;
} else {
DisplayUtils.showSnackMessage(fileActivity, R.string.file_list_no_app_for_file_type);
return;
}
}
}
fileActivity.showLoadingDialog(fileActivity.getResources().getString(R.string.sync_in_progress));
new Thread(new Runnable() {
@Override
public void run() {
User user = currentAccount.getUser();
FileDataStorageManager storageManager = new FileDataStorageManager(user, fileActivity.getContentResolver());
// a fresh object is needed; many things could have occurred to the file
// since it was registered to observe again, assuming that local files
// are linked to a remote file AT MOST, SOMETHING TO BE DONE;
SynchronizeFileOperation sfo = new SynchronizeFileOperation(file, null, user, true, fileActivity, storageManager);
RemoteOperationResult result = sfo.execute(fileActivity);
fileActivity.dismissLoadingDialog();
if (result.getCode() == RemoteOperationResult.ResultCode.SYNC_CONFLICT) {
// ISSUE 5: if the user is not running the app (this is a service!),
// this can be very intrusive; a notification should be preferred
Intent intent = ConflictsResolveActivity.createIntent(file, user, -1, Intent.FLAG_ACTIVITY_NEW_TASK, fileActivity);
fileActivity.startActivity(intent);
} else {
if (!launchables.isEmpty()) {
try {
if (!result.isSuccess()) {
DisplayUtils.showSnackMessage(fileActivity, R.string.file_not_synced);
try {
Thread.sleep(3000);
} catch (InterruptedException e) {
Log.e(TAG, "Failed to sleep");
}
}
openFileWithIntent.setFlags(openFileWithIntent.getFlags() | Intent.FLAG_ACTIVITY_NEW_TASK);
fileActivity.startActivity(openFileWithIntent);
} catch (ActivityNotFoundException exception) {
DisplayUtils.showSnackMessage(fileActivity, R.string.file_list_no_app_for_file_type);
}
} else {
DisplayUtils.showSnackMessage(fileActivity, R.string.file_list_no_app_for_file_type);
}
}
}
}).start();
} else {
Log_OC.e(TAG, "Trying to open a NULL OCFile");
}
}
use of com.owncloud.android.lib.resources.status.OCCapability in project android by nextcloud.
the class GallerySearchTask method doInBackground.
@Override
protected GallerySearchTask.Result doInBackground(Void... voids) {
if (photoFragmentWeakReference.get() == null) {
return new Result(false, false, -1);
}
GalleryFragment photoFragment = photoFragmentWeakReference.get();
if (isCancelled()) {
return new Result(false, false, -1);
} else {
OCCapability ocCapability = storageManager.getCapability(user.getAccountName());
SearchRemoteOperation searchRemoteOperation = new SearchRemoteOperation("", SearchRemoteOperation.SearchType.GALLERY_SEARCH, false, ocCapability);
searchRemoteOperation.setLimit(limit);
searchRemoteOperation.setStartDate(startDate);
searchRemoteOperation.setEndDate(endDate);
if (photoFragment.getContext() != null) {
Log_OC.d(this, "Start gallery search with " + new Date(startDate * 1000L) + " - " + new Date(endDate * 1000L) + " with limit: " + limit);
RemoteOperationResult result = searchRemoteOperation.execute(user.toPlatformAccount(), photoFragment.getContext());
boolean emptySearch = parseMedia(startDate, endDate, result.getData());
long lastTimeStamp = findLastTimestamp(result.getData());
photoFragment.getAdapter().showAllGalleryItems(storageManager);
return new Result(result.isSuccess(), emptySearch, lastTimeStamp);
} else {
return new Result(false, false, -1);
}
}
}
use of com.owncloud.android.lib.resources.status.OCCapability in project android by nextcloud.
the class FileDetailActivitiesFragment method setupView.
private void setupView() {
FileDataStorageManager storageManager = new FileDataStorageManager(user, contentResolver);
operationsHelper = ((ComponentsGetter) requireActivity()).getFileOperationsHelper();
OCCapability capability = storageManager.getCapability(user.getAccountName());
restoreFileVersionSupported = capability.getFilesVersioning().isTrue();
binding.emptyList.emptyListIcon.setImageDrawable(ResourcesCompat.getDrawable(getResources(), R.drawable.ic_activity, null));
binding.emptyList.emptyListView.setVisibility(View.GONE);
adapter = new ActivityAndVersionListAdapter(getContext(), accountManager, this, this, clientFactory);
binding.list.setAdapter(adapter);
LinearLayoutManager layoutManager = new LinearLayoutManager(getContext());
binding.list.setLayoutManager(layoutManager);
binding.list.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
super.onScrolled(recyclerView, dx, dy);
int visibleItemCount = recyclerView.getChildCount();
int totalItemCount = layoutManager.getItemCount();
int firstVisibleItemIndex = layoutManager.findFirstVisibleItemPosition();
// synchronize loading state when item count changes
if (!isLoadingActivities && (totalItemCount - visibleItemCount) <= (firstVisibleItemIndex + 5) && lastGiven > 0) {
// Almost reached the end, continue to load new activities
fetchAndSetData(lastGiven);
}
}
});
}
use of com.owncloud.android.lib.resources.status.OCCapability in project android by nextcloud.
the class OCFileListBottomSheetDialog method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
binding = FileListActionsBottomSheetFragmentBinding.inflate(getLayoutInflater());
setContentView(binding.getRoot());
if (getWindow() != null) {
getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
}
int primaryColor = ThemeColorUtils.primaryColor(getContext(), true);
ThemeDrawableUtils.tintDrawable(binding.menuIconUploadFiles.getDrawable(), primaryColor);
ThemeDrawableUtils.tintDrawable(binding.menuIconUploadFromApp.getDrawable(), primaryColor);
ThemeDrawableUtils.tintDrawable(binding.menuIconDirectCameraUpload.getDrawable(), primaryColor);
ThemeDrawableUtils.tintDrawable(binding.menuIconMkdir.getDrawable(), primaryColor);
binding.addToCloud.setText(getContext().getResources().getString(R.string.add_to_cloud, ThemeUtils.getDefaultDisplayNameForRootFolder(getContext())));
OCCapability capability = fileActivity.getCapabilities();
if (capability != null && capability.getRichDocuments().isTrue() && capability.getRichDocumentsDirectEditing().isTrue() && capability.getRichDocumentsTemplatesAvailable().isTrue() && !file.isEncrypted()) {
binding.templates.setVisibility(View.VISIBLE);
}
String json = new ArbitraryDataProvider(getContext().getContentResolver()).getValue(user, ArbitraryDataProvider.DIRECT_EDITING);
if (!json.isEmpty() && !file.isEncrypted()) {
DirectEditing directEditing = new Gson().fromJson(json, DirectEditing.class);
if (!directEditing.getCreators().isEmpty()) {
binding.creatorsContainer.setVisibility(View.VISIBLE);
for (Creator creator : directEditing.getCreators().values()) {
FileListActionsBottomSheetCreatorBinding creatorViewBinding = FileListActionsBottomSheetCreatorBinding.inflate(getLayoutInflater());
View creatorView = creatorViewBinding.getRoot();
creatorViewBinding.creatorName.setText(String.format(fileActivity.getString(R.string.editor_placeholder), fileActivity.getString(R.string.create_new), creator.getName()));
creatorViewBinding.creatorThumbnail.setImageDrawable(MimeTypeUtil.getFileTypeIcon(creator.getMimetype(), creator.getExtension(), user, getContext()));
creatorView.setOnClickListener(v -> {
actions.showTemplate(creator, creatorViewBinding.creatorName.getText().toString());
dismiss();
});
binding.creators.addView(creatorView);
}
}
}
if (!deviceInfo.hasCamera(getContext())) {
binding.menuDirectCameraUpload.setVisibility(View.GONE);
}
// create rich workspace
if (FileMenuFilter.isEditorAvailable(getContext().getContentResolver(), user, MimeTypeUtil.MIMETYPE_TEXT_MARKDOWN) && file != null && !file.isEncrypted()) {
// != "": info set -> hide button
if (file.getRichWorkspace() == null || !"".equals(file.getRichWorkspace())) {
binding.menuCreateRichWorkspace.setVisibility(View.GONE);
} else {
binding.menuCreateRichWorkspace.setVisibility(View.VISIBLE);
}
} else {
binding.menuCreateRichWorkspace.setVisibility(View.GONE);
}
setupClickListener();
setOnShowListener(d -> BottomSheetBehavior.from((View) binding.getRoot().getParent()).setPeekHeight(binding.getRoot().getMeasuredHeight()));
}
Aggregations