mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-06-05 23:05:38 +01:00
fix handling of sms:, smsto:, mms:, mmsto: URIs
1) add VIEW action and BROWSABLE category to SmsSendtoActivity intent filter 2) created class Rfc5724Uri for processing RFC5724 SMS URIs 3) added a set of tests for new Rfc5724Uri class 4) updated SmsSendtoActivity to use Rfc5742Uri for processing VIEW intents Fixes #2578 Closes #3030 // FREEBIE
This commit is contained in:
committed by
Moxie Marlinspike
parent
3fe676a3dd
commit
8f002bd68d
@@ -3,13 +3,20 @@ package org.thoughtcrime.securesms;
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
|
||||
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
||||
import org.thoughtcrime.securesms.recipients.RecipientFactory;
|
||||
import org.thoughtcrime.securesms.recipients.Recipients;
|
||||
import org.thoughtcrime.securesms.util.Rfc5724Uri;
|
||||
|
||||
import java.net.URISyntaxException;
|
||||
|
||||
public class SmsSendtoActivity extends Activity {
|
||||
|
||||
private static final String TAG = SmsSendtoActivity.class.getSimpleName();
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
startActivity(getNextIntent(getIntent()));
|
||||
@@ -18,8 +25,22 @@ public class SmsSendtoActivity extends Activity {
|
||||
}
|
||||
|
||||
private Intent getNextIntent(Intent original) {
|
||||
String body = original.getStringExtra("sms_body");
|
||||
String data = original.getData().getSchemeSpecificPart();
|
||||
String body = "";
|
||||
String data = "";
|
||||
|
||||
if (original.getAction().equals(Intent.ACTION_SENDTO)) {
|
||||
body = original.getStringExtra("sms_body");
|
||||
data = original.getData().getSchemeSpecificPart();
|
||||
} else {
|
||||
try {
|
||||
Rfc5724Uri smsUri = new Rfc5724Uri(original.getData().toString());
|
||||
body = smsUri.getQueryParams().get("body");
|
||||
data = smsUri.getPath();
|
||||
} catch (URISyntaxException e) {
|
||||
Log.w(TAG, "unable to parse RFC5724 URI from intent", e);
|
||||
}
|
||||
}
|
||||
|
||||
Recipients recipients = RecipientFactory.getRecipientsFromString(this, data, false);
|
||||
long threadId = DatabaseFactory.getThreadDatabase(this).getThreadIdIfExistsFor(recipients);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user