mirror of
https://github.com/tijder/SmsMatrix.git
synced 2024-10-27 18:24:01 +00:00
Add semi-support for sending MMS messages
Allow Matrix users to send MMS messages. Not entirely sure how to do this properly, so in the meantime just link the recipient to the URL of the file on the Matrix server.
This commit is contained in:
parent
51377834ad
commit
1bff1adac9
@ -1,11 +1,13 @@
|
|||||||
package eu.droogers.smsmatrix;
|
package eu.droogers.smsmatrix;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.provider.ContactsContract;
|
import android.provider.ContactsContract;
|
||||||
import android.telephony.SmsManager;
|
import android.telephony.SmsManager;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
|
||||||
import com.google.gson.JsonElement;
|
import com.google.gson.JsonElement;
|
||||||
@ -250,10 +252,17 @@ public class Matrix {
|
|||||||
public void sendEvent(Event event) {
|
public void sendEvent(Event event) {
|
||||||
if (event.sender.equals(realUserid)) {
|
if (event.sender.equals(realUserid)) {
|
||||||
Room room = store.getRoom(event.roomId);
|
Room room = store.getRoom(event.roomId);
|
||||||
JsonElement json = event.getContent();
|
|
||||||
String body = json.getAsJsonObject().get("body").getAsString();
|
|
||||||
SmsManager smsManager = SmsManager.getDefault();
|
SmsManager smsManager = SmsManager.getDefault();
|
||||||
smsManager.sendTextMessage(room.getTopic(), null, body, null, null);
|
JsonObject json = event.getContent().getAsJsonObject();
|
||||||
|
|
||||||
|
if (json.get("msgtype").getAsString().equals(MESSAGE_TYPE_TEXT)) {
|
||||||
|
String body = json.get("body").getAsString();
|
||||||
|
smsManager.sendTextMessage(room.getTopic(), null, body, null, null);
|
||||||
|
} else {
|
||||||
|
String url = session.getContentManager().getDownloadableUrl(json.get("url").getAsString());
|
||||||
|
smsManager.sendTextMessage(room.getTopic(), null, url, null, null);
|
||||||
|
}
|
||||||
|
|
||||||
room.markAllAsRead(new SimpleApiCallback<Void>());
|
room.markAllAsRead(new SimpleApiCallback<Void>());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user