diff options
Diffstat (limited to 'src/main/java')
5 files changed, 23 insertions, 2 deletions
diff --git a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java index f3d93cbc0..6378fcb03 100644 --- a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java +++ b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java @@ -674,6 +674,12 @@ public class XmppConnectionService extends Service { Log.d(Config.LOGTAG, "gcm push message arrived in service. extras=" + intent.getExtras()); pushedAccountHash = intent.getStringExtra("account"); break; + case Intent.ACTION_SEND: + Uri uri = intent.getData(); + if (uri != null) { + Log.d(Config.LOGTAG, "received uri permission for " + uri.toString()); + } + return START_STICKY; } } synchronized (this) { diff --git a/src/main/java/de/pixart/messenger/ui/ConversationActivity.java b/src/main/java/de/pixart/messenger/ui/ConversationActivity.java index 005bc2b74..b53c56390 100644 --- a/src/main/java/de/pixart/messenger/ui/ConversationActivity.java +++ b/src/main/java/de/pixart/messenger/ui/ConversationActivity.java @@ -1790,6 +1790,7 @@ public class ConversationActivity extends XmppActivity } final Toast prepareFileToast = Toast.makeText(getApplicationContext(), getText(R.string.preparing_file), Toast.LENGTH_LONG); prepareFileToast.show(); + delegateUriPermissionsToService(uri); xmppConnectionService.attachFileToConversation(conversation, uri, new UiInformableCallback<Message>() { @Override public void inform(final String text) { @@ -1839,6 +1840,7 @@ public class ConversationActivity extends XmppActivity } final Toast prepareFileToast = Toast.makeText(getApplicationContext(), getText(R.string.preparing_image), Toast.LENGTH_LONG); prepareFileToast.show(); + delegateUriPermissionsToService(uri); xmppConnectionService.attachImageToConversation(conversation, uri, new UiCallback<Message>() { @@ -1872,6 +1874,7 @@ public class ConversationActivity extends XmppActivity } final Toast prepareFileToast = Toast.makeText(getApplicationContext(), getText(R.string.preparing_image), Toast.LENGTH_LONG); prepareFileToast.show(); + delegateUriPermissionsToService(uri); xmppConnectionService.attachImageToConversation(conversation, uri, new UiCallback<Message>() { diff --git a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java index 00e2f6b12..56ad55b8a 100644 --- a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java +++ b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java @@ -858,7 +858,7 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa Toast.makeText(activity, activity.getString(R.string.no_permission_to_access_x, file.getAbsolutePath()), Toast.LENGTH_SHORT).show(); return; } - shareIntent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); + shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); String mime = message.getMimeType(); if (mime == null) { mime = "*/*"; diff --git a/src/main/java/de/pixart/messenger/ui/ShareWithActivity.java b/src/main/java/de/pixart/messenger/ui/ShareWithActivity.java index 731639280..18afea15d 100644 --- a/src/main/java/de/pixart/messenger/ui/ShareWithActivity.java +++ b/src/main/java/de/pixart/messenger/ui/ShareWithActivity.java @@ -346,12 +346,16 @@ public class ShareWithActivity extends XmppActivity implements XmppConnectionSer share.multiple = share.uris.size() > 1; replaceToast(getString(share.multiple ? R.string.preparing_images : R.string.preparing_image)); for (Iterator<Uri> i = share.uris.iterator(); i.hasNext(); i.remove()) { + final Uri uri = i.next(); + delegateUriPermissionsToService(uri); ShareWithActivity.this.xmppConnectionService.attachImageToConversation(conversation, i.next(), attachFileCallback); } } else { Log.d(Config.LOGTAG, "ShareWithActivity share() file " + share.uris.size() + " uri(s) " + share.uris.toString()); replaceToast(getString(R.string.preparing_file)); - ShareWithActivity.this.xmppConnectionService.attachFileToConversation(conversation, share.uris.get(0), attachFileCallback); + final Uri uri = share.uris.get(0); + delegateUriPermissionsToService(uri); + xmppConnectionService.attachFileToConversation(conversation, uri, attachFileCallback); finish(); } }; diff --git a/src/main/java/de/pixart/messenger/ui/XmppActivity.java b/src/main/java/de/pixart/messenger/ui/XmppActivity.java index e14efd734..6808a4058 100644 --- a/src/main/java/de/pixart/messenger/ui/XmppActivity.java +++ b/src/main/java/de/pixart/messenger/ui/XmppActivity.java @@ -540,6 +540,14 @@ public abstract class XmppActivity extends Activity { startActivity(intent); } + protected void delegateUriPermissionsToService(Uri uri) { + Intent intent = new Intent(this, XmppConnectionService.class); + intent.setAction(Intent.ACTION_SEND); + intent.setData(uri); + intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); + startService(intent); + } + protected void inviteToConversation(Conversation conversation) { Intent intent = new Intent(getApplicationContext(), ChooseContactActivity.class); |