use of com.owncloud.android.ui.fragment.FileDetailSharingFragment in project android by nextcloud.
the class ShareActivity method refreshSharesFromStorageManager.
/**
* Updates the view, reading data from {@link com.owncloud.android.datamodel.FileDataStorageManager}.
*/
private void refreshSharesFromStorageManager() {
FileDetailSharingFragment shareFileFragment = getShareFileFragment();
if (shareFileFragment != null && shareFileFragment.isAdded()) {
// only if added to the view hierarchy!!
shareFileFragment.refreshCapabilitiesFromDB();
shareFileFragment.refreshSharesFromDB();
}
}
use of com.owncloud.android.ui.fragment.FileDetailSharingFragment in project android by nextcloud.
the class FileActivity method onUpdateShareInformation.
private void onUpdateShareInformation(RemoteOperationResult result, @StringRes int defaultError) {
Snackbar snackbar;
FileDetailSharingFragment sharingFragment = getShareFileFragment();
if (result.isSuccess()) {
updateFileFromDB();
if (sharingFragment != null) {
sharingFragment.onUpdateShareInformation(result, getFile());
}
} else if (sharingFragment != null && sharingFragment.getView() != null) {
if (TextUtils.isEmpty(result.getMessage())) {
snackbar = Snackbar.make(sharingFragment.getView(), defaultError, Snackbar.LENGTH_LONG);
} else {
snackbar = Snackbar.make(sharingFragment.getView(), result.getMessage(), Snackbar.LENGTH_LONG);
}
ThemeSnackbarUtils.colorSnackbar(this, snackbar);
snackbar.show();
}
}
use of com.owncloud.android.ui.fragment.FileDetailSharingFragment in project android by nextcloud.
the class FileActivity method onCreateShareViaLinkOperationFinish.
private void onCreateShareViaLinkOperationFinish(CreateShareViaLinkOperation operation, RemoteOperationResult result) {
FileDetailSharingFragment sharingFragment = getShareFileFragment();
if (result.isSuccess()) {
updateFileFromDB();
// if share to user and share via link multiple ocshares are returned,
// therefore filtering for public_link
String link = "";
OCFile file = null;
for (Object object : result.getData()) {
OCShare shareLink = (OCShare) object;
if (TAG_PUBLIC_LINK.equalsIgnoreCase(shareLink.getShareType().name())) {
link = shareLink.getShareLink();
file = getStorageManager().getFileByPath(shareLink.getPath());
break;
}
}
copyAndShareFileLink(this, file, link);
if (sharingFragment != null) {
sharingFragment.onUpdateShareInformation(result, file);
}
} else {
// Detect Failure (403) --> maybe needs password
String password = operation.getPassword();
if (result.getCode() == RemoteOperationResult.ResultCode.SHARE_FORBIDDEN && TextUtils.isEmpty(password) && getCapabilities().getFilesSharingPublicEnabled().isUnknown()) {
// Try with password before giving up; see also ShareFileFragment#OnShareViaLinkListener
if (sharingFragment != null && sharingFragment.isAdded()) {
// only if added to the view hierarchy
sharingFragment.requestPasswordForShareViaLink(true, getCapabilities().getFilesSharingPublicAskForOptionalPassword().isTrue());
}
} else {
if (sharingFragment != null) {
sharingFragment.refreshSharesFromDB();
}
Snackbar snackbar = Snackbar.make(findViewById(android.R.id.content), ErrorMessageAdapter.getErrorCauseMessage(result, operation, getResources()), Snackbar.LENGTH_LONG);
ThemeSnackbarUtils.colorSnackbar(this, snackbar);
snackbar.show();
}
}
}
Aggregations