delegate uri permission to service when processing files
This commit is contained in:
parent
0dbad2eea5
commit
676ac32a97
|
@ -670,6 +670,12 @@ public class XmppConnectionService extends Service {
|
||||||
Log.d(Config.LOGTAG, "gcm push message arrived in service. extras=" + intent.getExtras());
|
Log.d(Config.LOGTAG, "gcm push message arrived in service. extras=" + intent.getExtras());
|
||||||
pushedAccountHash = intent.getStringExtra("account");
|
pushedAccountHash = intent.getStringExtra("account");
|
||||||
break;
|
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) {
|
synchronized (this) {
|
||||||
|
|
|
@ -1601,6 +1601,7 @@ public class ConversationActivity extends XmppActivity
|
||||||
}
|
}
|
||||||
final Toast prepareFileToast = Toast.makeText(getApplicationContext(),getText(R.string.preparing_file), Toast.LENGTH_LONG);
|
final Toast prepareFileToast = Toast.makeText(getApplicationContext(),getText(R.string.preparing_file), Toast.LENGTH_LONG);
|
||||||
prepareFileToast.show();
|
prepareFileToast.show();
|
||||||
|
delegateUriPermissionsToService(uri);
|
||||||
xmppConnectionService.attachFileToConversation(conversation, uri, new UiInformableCallback<Message>() {
|
xmppConnectionService.attachFileToConversation(conversation, uri, new UiInformableCallback<Message>() {
|
||||||
@Override
|
@Override
|
||||||
public void inform(final String text) {
|
public void inform(final String text) {
|
||||||
|
@ -1654,6 +1655,7 @@ public class ConversationActivity extends XmppActivity
|
||||||
}
|
}
|
||||||
final Toast prepareFileToast = Toast.makeText(getApplicationContext(),getText(R.string.preparing_image), Toast.LENGTH_LONG);
|
final Toast prepareFileToast = Toast.makeText(getApplicationContext(),getText(R.string.preparing_image), Toast.LENGTH_LONG);
|
||||||
prepareFileToast.show();
|
prepareFileToast.show();
|
||||||
|
delegateUriPermissionsToService(uri);
|
||||||
xmppConnectionService.attachImageToConversation(conversation, uri,
|
xmppConnectionService.attachImageToConversation(conversation, uri,
|
||||||
new UiCallback<Message>() {
|
new UiCallback<Message>() {
|
||||||
|
|
||||||
|
|
|
@ -816,7 +816,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();
|
Toast.makeText(activity, activity.getString(R.string.no_permission_to_access_x, file.getAbsolutePath()), Toast.LENGTH_SHORT).show();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
shareIntent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
||||||
String mime = message.getMimeType();
|
String mime = message.getMimeType();
|
||||||
if (mime == null) {
|
if (mime == null) {
|
||||||
mime = "*/*";
|
mime = "*/*";
|
||||||
|
|
|
@ -318,11 +318,15 @@ public class ShareWithActivity extends XmppActivity implements XmppConnectionSer
|
||||||
share.multiple = share.uris.size() > 1;
|
share.multiple = share.uris.size() > 1;
|
||||||
replaceToast(getString(share.multiple ? R.string.preparing_images : R.string.preparing_image));
|
replaceToast(getString(share.multiple ? R.string.preparing_images : R.string.preparing_image));
|
||||||
for (Iterator<Uri> i = share.uris.iterator(); i.hasNext(); i.remove()) {
|
for (Iterator<Uri> i = share.uris.iterator(); i.hasNext(); i.remove()) {
|
||||||
|
final Uri uri = i.next();
|
||||||
|
delegateUriPermissionsToService(uri);
|
||||||
xmppConnectionService.attachImageToConversation(conversation, i.next(), attachFileCallback);
|
xmppConnectionService.attachImageToConversation(conversation, i.next(), attachFileCallback);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
replaceToast(getString(R.string.preparing_file));
|
replaceToast(getString(R.string.preparing_file));
|
||||||
xmppConnectionService.attachFileToConversation(conversation, share.uris.get(0), attachFileCallback);
|
final Uri uri = share.uris.get(0);
|
||||||
|
delegateUriPermissionsToService(uri);
|
||||||
|
xmppConnectionService.attachFileToConversation(conversation, uri, attachFileCallback);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
if (account.httpUploadAvailable()
|
if (account.httpUploadAvailable()
|
||||||
|
|
|
@ -525,6 +525,14 @@ public abstract class XmppActivity extends Activity {
|
||||||
startActivity(intent);
|
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) {
|
protected void inviteToConversation(Conversation conversation) {
|
||||||
Intent intent = new Intent(getApplicationContext(),
|
Intent intent = new Intent(getApplicationContext(),
|
||||||
ChooseContactActivity.class);
|
ChooseContactActivity.class);
|
||||||
|
|
Loading…
Reference in a new issue