mirror of
https://github.com/nextcloud/talk-android
synced 2025-03-10 08:00:57 +00:00
Merge pull request #1451 from nextcloud/bugfix/1415/share_from_browser
Share from a browser should share the page URL
This commit is contained in:
commit
725c7a1f20
@ -842,13 +842,21 @@ public class ConversationsListController extends BaseController implements Searc
|
|||||||
if (Intent.ACTION_SEND.equals(intent.getAction())
|
if (Intent.ACTION_SEND.equals(intent.getAction())
|
||||||
|| Intent.ACTION_SEND_MULTIPLE.equals(intent.getAction())) {
|
|| Intent.ACTION_SEND_MULTIPLE.equals(intent.getAction())) {
|
||||||
try {
|
try {
|
||||||
|
String mimeType = intent.getType();
|
||||||
|
if ("text/plain".equals(mimeType) && (intent.getStringExtra(Intent.EXTRA_TEXT) != null)) {
|
||||||
|
// Share from Google Chrome sets text/plain MIME type, but also provides a content:// URI
|
||||||
|
// with a *screenshot* of the current page in getClipData().
|
||||||
|
// Here we assume that when sharing a web page the user would prefer to send the URL
|
||||||
|
// of the current page rather than a screenshot.
|
||||||
|
textToPaste = intent.getStringExtra(Intent.EXTRA_TEXT);
|
||||||
|
} else {
|
||||||
if (intent.getClipData() != null) {
|
if (intent.getClipData() != null) {
|
||||||
for (int i = 0; i < intent.getClipData().getItemCount(); i++) {
|
for (int i = 0; i < intent.getClipData().getItemCount(); i++) {
|
||||||
ClipData.Item item = intent.getClipData().getItemAt(i);
|
ClipData.Item item = intent.getClipData().getItemAt(i);
|
||||||
if (item.getUri() != null) {
|
if (item.getUri() != null) {
|
||||||
filesToShare.add(intent.getClipData().getItemAt(i).getUri().toString());
|
filesToShare.add(item.getUri().toString());
|
||||||
} else if (item.getText() != null) {
|
} else if (item.getText() != null) {
|
||||||
textToPaste = intent.getClipData().getItemAt(i).getText().toString();
|
textToPaste = item.getText().toString();
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
Log.w(TAG, "datatype not yet implemented for share-to");
|
Log.w(TAG, "datatype not yet implemented for share-to");
|
||||||
@ -857,6 +865,7 @@ public class ConversationsListController extends BaseController implements Searc
|
|||||||
} else {
|
} else {
|
||||||
filesToShare.add(intent.getData().toString());
|
filesToShare.add(intent.getData().toString());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (filesToShare.isEmpty() && textToPaste.isEmpty()) {
|
if (filesToShare.isEmpty() && textToPaste.isEmpty()) {
|
||||||
Toast.makeText(context, context.getResources().getString(R.string.nc_common_error_sorry),
|
Toast.makeText(context, context.getResources().getString(R.string.nc_common_error_sorry),
|
||||||
Toast.LENGTH_LONG).show();
|
Toast.LENGTH_LONG).show();
|
||||||
|
Loading…
Reference in New Issue
Block a user