mirror of
https://github.com/KDE/kdeconnect-android
synced 2025-09-05 16:45:08 +00:00
[SMSApp] Support plain-text MMS
## Summary Not having support for MMS caused some minor problems, like in https://bugs.kde.org/show_bug.cgi?id=398889 . This patch adds basic MMS support for plain-text MMS, including multi-target messages. Android companion to https://invent.kde.org/kde/kdeconnect-kde/merge_requests/97 Currently there are several rough areas: - Multi-target messages do not have the full list of recipients (I am planning to work on this in another patch, because this one is already quite large enough) - Parsing MMS is significantly slower than parsing SMS. This makes sense, since we need to make significantly many more content:// calls for MMS. The only solution I can think of here is to add the ability to request a range of messages, which I need to do anyway, but which should not be part of this patch. - The desktop app is totally busted with regard to multi-target MMS, but that will also be fixed in another MR BUG: 398889 ## Test Plan ### Before: Open SMS app on desktop, scroll through conversations, notice: - Any single-target message which had the most-recent message as an MMS does not appear - Any multi-target MMS conversations do not appear ### After: Open SMS app on desktop, notice: - Conversations which have an MMS as their most-recent message appear - MMS which consisted of only text are rendered correctly - Multi-target conversations are shown (though pretty busted, as said before. Do not attempt to reply to one!)
This commit is contained in:
@@ -55,12 +55,12 @@ import org.kde.kdeconnect_tp.R;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.locks.Lock;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
|
||||
import androidx.annotation.RequiresApi;
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
import static org.kde.kdeconnect.Plugins.TelephonyPlugin.TelephonyPlugin.PACKET_TYPE_TELEPHONY;
|
||||
@@ -197,9 +197,9 @@ public class SMSPlugin extends Plugin {
|
||||
long mostRecentTimestamp = mPlugin.mostRecentTimestamp;
|
||||
mostRecentTimestampLock.unlock();
|
||||
|
||||
List<SMSHelper.Message> messages = SMSHelper.getMessagesSinceTimestamp(mPlugin.context, mostRecentTimestamp);
|
||||
SMSHelper.Message message = SMSHelper.getNewestMessage(mPlugin.context);
|
||||
|
||||
if (messages.size() == 0) {
|
||||
if (message.date <= mostRecentTimestamp) {
|
||||
// Our onChange often gets called many times for a single message. Don't make unnecessary
|
||||
// noise
|
||||
return;
|
||||
@@ -207,15 +207,11 @@ public class SMSPlugin extends Plugin {
|
||||
|
||||
// Update the most recent counter
|
||||
mostRecentTimestampLock.lock();
|
||||
for (SMSHelper.Message message : messages) {
|
||||
if (message.date > mostRecentTimestamp) {
|
||||
mPlugin.mostRecentTimestamp = message.date;
|
||||
}
|
||||
}
|
||||
mPlugin.mostRecentTimestamp = message.date;
|
||||
mostRecentTimestampLock.unlock();
|
||||
|
||||
// Send the alert about the update
|
||||
device.sendPacket(constructBulkMessagePacket(messages));
|
||||
device.sendPacket(constructBulkMessagePacket(Collections.singleton(message)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -352,8 +348,6 @@ public class SMSPlugin extends Plugin {
|
||||
try {
|
||||
JSONObject json = message.toJSONObject();
|
||||
|
||||
json.put("event", SMSHelper.Message.TEXT_MESSAGE);
|
||||
|
||||
body.put(json);
|
||||
} catch (JSONException e) {
|
||||
Log.e("Conversations", "Error serializing message");
|
||||
|
Reference in New Issue
Block a user