- if (operation instanceof UnshareOperation) {
- if (mShareFileFragment != null){
- mShareFileFragment.refreshUsersOrGroupsListFromDB();
- }
- } else if (operation instanceof GetSharesForFileOperation) {
- onGetSharesForFileOperationFinish((GetSharesForFileOperation) operation, result);
+
+ if (result.isSuccess() ||
+ (operation instanceof GetSharesForFileOperation &&
+ result.getCode() == RemoteOperationResult.ResultCode.SHARE_NOT_FOUND
+ )
+ ) {
+ Log_OC.d(TAG, "Refreshing view on successful operation or finished refresh");
+ refreshSharesFromStorageManager();
+ }
+
+ if (operation instanceof CreateShareViaLinkOperation && result.isSuccess()) {
+ // Send link to the app
+ String link = ((OCShare) (result.getData().get(0))).getShareLink();
+ Log_OC.d(TAG, "Share link = " + link);
+
+ Intent intentToShareLink = new Intent(Intent.ACTION_SEND);
+ intentToShareLink.putExtra(Intent.EXTRA_TEXT, link);
+ intentToShareLink.setType(HTTP.PLAIN_TEXT_TYPE);
+ String[] packagesToExclude = new String[]{getPackageName()};
+ DialogFragment chooserDialog = ShareLinkToDialog.newInstance(intentToShareLink, packagesToExclude);
+ chooserDialog.show(getSupportFragmentManager(), FTAG_CHOOSER_DIALOG);