mirror of
https://github.com/nextcloud/android.git
synced 2024-11-27 17:46:37 +03:00
use correct file for message while sharing via link
Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>
This commit is contained in:
parent
d78900e07c
commit
0e26340a19
4 changed files with 14 additions and 20 deletions
|
@ -656,16 +656,16 @@ public abstract class FileActivity extends DrawerActivity
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void copyAndShareFileLink(FileActivity activity, String link) {
|
public static void copyAndShareFileLink(FileActivity activity, OCFile file, String link) {
|
||||||
ClipboardUtil.copyToClipboard(activity, link, false);
|
ClipboardUtil.copyToClipboard(activity, link, false);
|
||||||
Snackbar snackbar = Snackbar.make(activity.findViewById(android.R.id.content), R.string.clipboard_text_copied,
|
Snackbar snackbar = Snackbar.make(activity.findViewById(android.R.id.content), R.string.clipboard_text_copied,
|
||||||
Snackbar.LENGTH_LONG)
|
Snackbar.LENGTH_LONG)
|
||||||
.setAction(R.string.share, v -> showShareLinkDialog(activity, link));
|
.setAction(R.string.share, v -> showShareLinkDialog(activity, file, link));
|
||||||
ThemeUtils.colorSnackbar(activity, snackbar);
|
ThemeUtils.colorSnackbar(activity, snackbar);
|
||||||
snackbar.show();
|
snackbar.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void showShareLinkDialog(FileActivity activity, String link) {
|
public static void showShareLinkDialog(FileActivity activity, OCFile file, String link) {
|
||||||
// Create dialog to allow the user choose an app to send the link
|
// Create dialog to allow the user choose an app to send the link
|
||||||
Intent intentToShareLink = new Intent(Intent.ACTION_SEND);
|
Intent intentToShareLink = new Intent(Intent.ACTION_SEND);
|
||||||
|
|
||||||
|
@ -689,11 +689,11 @@ public abstract class FileActivity extends DrawerActivity
|
||||||
if (username != null) {
|
if (username != null) {
|
||||||
intentToShareLink.putExtra(Intent.EXTRA_SUBJECT,
|
intentToShareLink.putExtra(Intent.EXTRA_SUBJECT,
|
||||||
activity.getString(R.string.subject_user_shared_with_you, username,
|
activity.getString(R.string.subject_user_shared_with_you, username,
|
||||||
activity.getFile().getFileName()));
|
file.getFileName()));
|
||||||
} else {
|
} else {
|
||||||
intentToShareLink.putExtra(Intent.EXTRA_SUBJECT,
|
intentToShareLink.putExtra(Intent.EXTRA_SUBJECT,
|
||||||
activity.getString(R.string.subject_shared_with_you,
|
activity.getString(R.string.subject_shared_with_you,
|
||||||
activity.getFile().getFileName()));
|
file.getFileName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
String[] packagesToExclude = new String[]{activity.getPackageName()};
|
String[] packagesToExclude = new String[]{activity.getPackageName()};
|
||||||
|
|
|
@ -1987,15 +1987,17 @@ public class FileDisplayActivity extends FileActivity
|
||||||
// if share to user and share via link multiple ocshares are returned,
|
// if share to user and share via link multiple ocshares are returned,
|
||||||
// therefore filtering for public_link
|
// therefore filtering for public_link
|
||||||
String link = "";
|
String link = "";
|
||||||
|
OCFile file = null;
|
||||||
for (Object object : result.getData()) {
|
for (Object object : result.getData()) {
|
||||||
OCShare shareLink = (OCShare) object;
|
OCShare shareLink = (OCShare) object;
|
||||||
if (TAG_PUBLIC_LINK.equalsIgnoreCase(shareLink.getShareType().name())) {
|
if (TAG_PUBLIC_LINK.equalsIgnoreCase(shareLink.getShareType().name())) {
|
||||||
link = shareLink.getShareLink();
|
link = shareLink.getShareLink();
|
||||||
|
file = getStorageManager().getFileByPath(shareLink.getPath());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
copyAndShareFileLink(this, link);
|
copyAndShareFileLink(this, file, link);
|
||||||
|
|
||||||
if (fileDetailFragment != null && fileDetailFragment.getFileDetailSharingFragment() != null) {
|
if (fileDetailFragment != null && fileDetailFragment.getFileDetailSharingFragment() != null) {
|
||||||
fileDetailFragment.getFileDetailSharingFragment().refreshPublicShareFromDB();
|
fileDetailFragment.getFileDetailSharingFragment().refreshPublicShareFromDB();
|
||||||
|
|
|
@ -346,7 +346,7 @@ public class FileDetailSharingFragment extends Fragment implements UserListAdapt
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
FileDisplayActivity.showShareLinkDialog(fileDisplayActivity, createInternalLink(account, file));
|
FileDisplayActivity.showShareLinkDialog(fileDisplayActivity, file, createInternalLink(account, file));
|
||||||
}
|
}
|
||||||
|
|
||||||
private String createInternalLink(OwnCloudAccount account, OCFile file) {
|
private String createInternalLink(OwnCloudAccount account, OCFile file) {
|
||||||
|
@ -371,7 +371,7 @@ public class FileDetailSharingFragment extends Fragment implements UserListAdapt
|
||||||
if (TextUtils.isEmpty(file.getPublicLink())) {
|
if (TextUtils.isEmpty(file.getPublicLink())) {
|
||||||
fileOperationsHelper.getFileWithLink(file);
|
fileOperationsHelper.getFileWithLink(file);
|
||||||
} else {
|
} else {
|
||||||
FileDisplayActivity.showShareLinkDialog(fileDisplayActivity, file.getPublicLink());
|
FileDisplayActivity.showShareLinkDialog(fileDisplayActivity, file, file.getPublicLink());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -466,7 +466,7 @@ public class FileDetailSharingFragment extends Fragment implements UserListAdapt
|
||||||
}
|
}
|
||||||
case R.id.action_share_send_link: {
|
case R.id.action_share_send_link: {
|
||||||
if(shareByLink.isChecked() && file.isSharedViaLink() && !TextUtils.isEmpty(file.getPublicLink())) {
|
if(shareByLink.isChecked() && file.isSharedViaLink() && !TextUtils.isEmpty(file.getPublicLink())) {
|
||||||
FileDisplayActivity.showShareLinkDialog(fileDisplayActivity, file.getPublicLink());
|
FileDisplayActivity.showShareLinkDialog(fileDisplayActivity, file, file.getPublicLink());
|
||||||
} else {
|
} else {
|
||||||
showSendLinkTo();
|
showSendLinkTo();
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,7 +59,6 @@ import com.owncloud.android.operations.SynchronizeFileOperation;
|
||||||
import com.owncloud.android.ui.activity.FileActivity;
|
import com.owncloud.android.ui.activity.FileActivity;
|
||||||
import com.owncloud.android.ui.activity.FileDisplayActivity;
|
import com.owncloud.android.ui.activity.FileDisplayActivity;
|
||||||
import com.owncloud.android.ui.fragment.FileFragment;
|
import com.owncloud.android.ui.fragment.FileFragment;
|
||||||
import com.owncloud.android.utils.ClipboardUtil;
|
|
||||||
import com.owncloud.android.utils.ErrorMessageAdapter;
|
import com.owncloud.android.utils.ErrorMessageAdapter;
|
||||||
import com.owncloud.android.utils.MimeTypeUtil;
|
import com.owncloud.android.utils.MimeTypeUtil;
|
||||||
import com.owncloud.android.utils.ThemeUtils;
|
import com.owncloud.android.utils.ThemeUtils;
|
||||||
|
@ -210,15 +209,17 @@ public class PreviewImageActivity extends FileActivity implements
|
||||||
// if share to user and share via link multiple ocshares are returned,
|
// if share to user and share via link multiple ocshares are returned,
|
||||||
// therefore filtering for public_link
|
// therefore filtering for public_link
|
||||||
String link = "";
|
String link = "";
|
||||||
|
OCFile file = null;
|
||||||
for (Object object : result.getData()) {
|
for (Object object : result.getData()) {
|
||||||
OCShare shareLink = (OCShare) object;
|
OCShare shareLink = (OCShare) object;
|
||||||
if (FileDisplayActivity.TAG_PUBLIC_LINK.equalsIgnoreCase(shareLink.getShareType().name())) {
|
if (FileDisplayActivity.TAG_PUBLIC_LINK.equalsIgnoreCase(shareLink.getShareType().name())) {
|
||||||
link = shareLink.getShareLink();
|
link = shareLink.getShareLink();
|
||||||
|
file = getStorageManager().getFileByPath(shareLink.getPath());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
copyAndShareFileLink(link);
|
copyAndShareFileLink(this, file, link);
|
||||||
} else {
|
} else {
|
||||||
// Detect Failure (403) --> maybe needs password
|
// Detect Failure (403) --> maybe needs password
|
||||||
String password = op.getPassword();
|
String password = op.getPassword();
|
||||||
|
@ -239,15 +240,6 @@ public class PreviewImageActivity extends FileActivity implements
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void copyAndShareFileLink(String link) {
|
|
||||||
ClipboardUtil.copyToClipboard(this, link, false);
|
|
||||||
Snackbar snackbar = Snackbar.make(findViewById(android.R.id.content), R.string.clipboard_text_copied,
|
|
||||||
Snackbar.LENGTH_LONG)
|
|
||||||
.setAction(R.string.share, v -> showShareLinkDialog(this, link));
|
|
||||||
ThemeUtils.colorSnackbar(this, snackbar);
|
|
||||||
snackbar.show();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void onSynchronizeFileOperationFinish(RemoteOperationResult result) {
|
private void onSynchronizeFileOperationFinish(RemoteOperationResult result) {
|
||||||
if (result.isSuccess()) {
|
if (result.isSuccess()) {
|
||||||
supportInvalidateOptionsMenu();
|
supportInvalidateOptionsMenu();
|
||||||
|
|
Loading…
Reference in a new issue