use of com.owncloud.android.ui.fragment.ShareFileFragment in project android by owncloud.
the class ShareActivity method onCreateShareViaLinkOperationFinish.
private void onCreateShareViaLinkOperationFinish(CreateShareViaLinkOperation operation, RemoteOperationResult result) {
if (result.isSuccess()) {
updateFileFromDB();
// Create dialog to allow the user choose an app to send the link
Intent intentToShareLink = new Intent(Intent.ACTION_SEND);
String link = ((OCShare) (result.getData().get(0))).getShareLink();
intentToShareLink.putExtra(Intent.EXTRA_TEXT, link);
intentToShareLink.setType("text/plain");
String username = AccountUtils.getUsernameForAccount(getAccount());
if (username != null) {
intentToShareLink.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.subject_user_shared_with_you, username, getFile().getFileName()));
} else {
intentToShareLink.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.subject_shared_with_you, getFile().getFileName()));
}
String[] packagesToExclude = new String[] { getPackageName() };
DialogFragment chooserDialog = ShareLinkToDialog.newInstance(intentToShareLink, packagesToExclude);
chooserDialog.show(getSupportFragmentManager(), FTAG_CHOOSER_DIALOG);
} else {
// Detect Failure (403) --> maybe needs password
String password = operation.getPassword();
if (result.getCode() == RemoteOperationResult.ResultCode.SHARE_FORBIDDEN && (password == null || password.length() == 0) && getCapabilities().getFilesSharingPublicEnabled().isUnknown()) {
// Was tried without password, but not sure that it's optional.
// Try with password before giving up; see also ShareFileFragment#OnShareViaLinkListener
ShareFileFragment shareFileFragment = getShareFileFragment();
if (shareFileFragment != null && shareFileFragment.isAdded()) {
// only if added to the view hierarchy!!
shareFileFragment.requestPasswordForShareViaLink(true);
}
} else {
Snackbar snackbar = Snackbar.make(findViewById(android.R.id.content), ErrorMessageAdapter.getErrorCauseMessage(result, operation, getResources()), Snackbar.LENGTH_LONG);
snackbar.show();
}
}
}
use of com.owncloud.android.ui.fragment.ShareFileFragment in project android by owncloud.
the class ShareActivity method refreshSharesFromStorageManager.
/**
* Updates the view, reading data from {@link com.owncloud.android.datamodel.FileDataStorageManager}
*/
private void refreshSharesFromStorageManager() {
ShareFileFragment shareFileFragment = getShareFileFragment();
if (shareFileFragment != null && shareFileFragment.isAdded()) {
// only if added to the view hierarchy!!
shareFileFragment.refreshCapabilitiesFromDB();
shareFileFragment.refreshUsersOrGroupsListFromDB();
shareFileFragment.refreshPublicShareFromDB();
}
SearchShareesFragment searchShareesFragment = getSearchFragment();
if (searchShareesFragment != null && searchShareesFragment.isAdded()) {
// only if added to the view hierarchy!!
searchShareesFragment.refreshUsersOrGroupsListFromDB();
}
EditShareFragment editShareFragment = getEditShareFragment();
if (editShareFragment != null && editShareFragment.isAdded()) {
editShareFragment.refreshUiFromDB();
}
}
Aggregations