diff --git a/android/app/src/main/java/me/teafry/voipmessages/ChatActivity.java b/android/app/src/main/java/me/teafry/voipmessages/ChatActivity.java index 262d90b..e3cae5d 100644 --- a/android/app/src/main/java/me/teafry/voipmessages/ChatActivity.java +++ b/android/app/src/main/java/me/teafry/voipmessages/ChatActivity.java @@ -754,6 +754,14 @@ public final class ChatActivity extends BaseActivity { ImageView iv = new ImageView(c); iv.setScaleType(ImageView.ScaleType.CENTER_CROP); iv.setBackgroundColor(0x22FFFFFF); + // The picture's corners match the bubble's (30 dp). + float corner = Ui.dp(c, 30); + iv.setOutlineProvider(new android.view.ViewOutlineProvider() { + @Override public void getOutline(View v, android.graphics.Outline o) { + o.setRoundRect(0, 0, v.getWidth(), v.getHeight(), corner); + } + }); + iv.setClipToOutline(true); FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(bw, bh); iv.setLayoutParams(new LinearLayout.LayoutParams(bw, bh)); String tag = id + "/" + index; diff --git a/android/app/src/main/java/me/teafry/voipmessages/Store.java b/android/app/src/main/java/me/teafry/voipmessages/Store.java index cc986db..5888692 100644 --- a/android/app/src/main/java/me/teafry/voipmessages/Store.java +++ b/android/app/src/main/java/me/teafry/voipmessages/Store.java @@ -96,6 +96,11 @@ final class Store { db.execSQL("UPDATE messages SET body = '' WHERE media_json IS NOT NULL AND lower(trim(body)) = 'mms received'"); set("mms_received_stripped", "1"); } + // ...and one we sent with no words "MMS Sent". + if (get("mms_sent_stripped") == null) { + db.execSQL("UPDATE messages SET body = '' WHERE media_json IS NOT NULL AND lower(trim(body)) = 'mms sent'"); + set("mms_sent_stripped", "1"); + } if (get("unread_floor") == null) set("unread_floor", String.valueOf(System.currentTimeMillis())); } diff --git a/android/app/src/main/java/me/teafry/voipmessages/VoipMs.java b/android/app/src/main/java/me/teafry/voipmessages/VoipMs.java index a30ca0c..af40a82 100644 --- a/android/app/src/main/java/me/teafry/voipmessages/VoipMs.java +++ b/android/app/src/main/java/me/teafry/voipmessages/VoipMs.java @@ -127,7 +127,7 @@ final class VoipMs { for (String u : urls) refs.put(new JSONObject().put("url", u)); m.mediaJson = refs.toString(); // voip.ms's own stand-in text for a picture with no words, not the sender's. - if (m.body.trim().equalsIgnoreCase("MMS Received")) m.body = ""; + if (m.body.trim().equalsIgnoreCase("MMS Received") || m.body.trim().equalsIgnoreCase("MMS Sent")) m.body = ""; } else if (Phone.charCount(m.body) > Phone.SMS_TEXT_LIMIT) { m.kind = "mms"; } diff --git a/android/build.py b/android/build.py index 099ca8f..714c6ea 100644 --- a/android/build.py +++ b/android/build.py @@ -26,8 +26,8 @@ import sys import zipfile from pathlib import Path -VERSION_NAME = "0.7.5" -VERSION_CODE = 13 +VERSION_NAME = "0.7.6" +VERSION_CODE = 14 PACKAGE = "me.teafry.voipmessages" DEV_PACKAGE = PACKAGE + ".dev" diff --git a/android/tools/push_sandbox.py b/android/tools/push_sandbox.py index bdc17f6..b5eb097 100644 --- a/android/tools/push_sandbox.py +++ b/android/tools/push_sandbox.py @@ -17,7 +17,9 @@ import json import os import sqlite3 import subprocess +import struct import tempfile +import zlib import time from pathlib import Path @@ -26,6 +28,12 @@ VOIP, GV = "5415550100", "5415550177" GROUP = "5415550101,5415550102,5415550103" +def gradient_png(w: int, h: int) -> bytes: + raw = b"".join(b"\0" + bytes(c for x in range(w) for c in (x * 255 // w, y * 255 // h, 160)) for y in range(h)) + chunk = lambda t, b: struct.pack(">I", len(b)) + t + b + struct.pack(">I", zlib.crc32(t + b)) + return b"\x89PNG\r\n\x1a\n" + chunk(b"IHDR", struct.pack(">IIBBBBB", w, h, 8, 2, 0, 0, 0)) + chunk(b"IDAT", zlib.compress(raw)) + chunk(b"IEND", b"") + + def push(local: Path, name: str): with open(local, "rb") as f: subprocess.run(["adb", "shell", f"run-as {PKG} sh -c 'cat > files/{name}'"], stdin=f, check=True) @@ -84,6 +92,12 @@ def main(): rows.append((SIM_BASE + 1, "sim", "5415550150", "in", "Texting your SIM number now", now - 20 * m, None)) rows.append((SIM_BASE + 2, "sim", "5415550150", "out", "Got it, this is the SIM", now - 19 * m, None)) con.executemany("INSERT INTO messages (id, did, contact, direction, body, ts, sender) VALUES (?,?,?,?,?,?,?)", rows) + # Pictures both ways (a made-up gradient), to see their corners. + pic = Path(d) / "sandbox-pic.png" + pic.write_bytes(gradient_png(400, 300)) + ref = json.dumps([{"file": "sandbox-pic.png", "mime": "image/png", "width": 400, "height": 300}]) + con.execute("INSERT INTO messages (id, did, contact, direction, body, ts, kind, media_json) VALUES (1007, ?, '5415550110', 'in', 'Look at this', ?, 'mms', ?)", (VOIP, now - 280 * m, ref)) + con.execute("INSERT INTO messages (id, did, contact, direction, body, ts, kind, media_json) VALUES (1008, ?, '5415550110', 'out', '', ?, 'mms', ?)", (VOIP, now - 279 * m, ref)) con.execute("INSERT INTO kv VALUES ('unread_floor', '0')") con.execute("INSERT INTO gv_threads VALUES (?, ?, 'g.demo')", (GV, GROUP)) con.commit() @@ -99,6 +113,8 @@ def main(): })) push(db, "messages.db") push(cfg, "config.json") + subprocess.run(["adb", "shell", f"run-as {PKG} mkdir -p files/media"], check=True) + push(pic, "media/sandbox-pic.png") subprocess.run(["adb", "shell", "am", "start", "-n", f"{PKG}/me.teafry.voipmessages.MainActivity"], check=True) print("sandbox data pushed to", PKG) diff --git a/package.json b/package.json index 20cac4d..82b6906 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "voipms-desktop", "productName": "bubble", - "version": "0.9.0", + "version": "0.9.1", "description": "Signal-style desktop SMS client for voip.ms", "author": "trav ", "private": true, diff --git a/resources/android/VoipMessages.apk b/resources/android/VoipMessages.apk index 6dd51bc..8402a67 100644 Binary files a/resources/android/VoipMessages.apk and b/resources/android/VoipMessages.apk differ diff --git a/resources/android/VoipMessages.json b/resources/android/VoipMessages.json index 2263dd0..fa15c4c 100644 --- a/resources/android/VoipMessages.json +++ b/resources/android/VoipMessages.json @@ -1 +1 @@ -{"version_name": "0.7.5", "version_code": 13, "package": "me.teafry.voipmessages"} +{"version_name": "0.7.6", "version_code": 14, "package": "me.teafry.voipmessages"} diff --git a/src/main/db.ts b/src/main/db.ts index 4e7ad83..84ecb8a 100644 --- a/src/main/db.ts +++ b/src/main/db.ts @@ -6,7 +6,7 @@ import type { Conversation, Direction, MediaRef, Message, MessageKind, MessageSt import { SNIPPET_END, SNIPPET_START } from '@shared/types' import { fixVoipDst } from './voipms' -const SCHEMA_VERSION = 11 +const SCHEMA_VERSION = 12 export interface ReadState { did: string @@ -170,6 +170,9 @@ export class MessageDb { // Received"; nobody wrote it, so it goes. if (version >= 1 && version < 11) this.db.exec(`UPDATE messages SET body = '' WHERE media_json IS NOT NULL AND lower(trim(body)) = 'mms received'`) + // v12: and one we sent with no words "MMS Sent". + if (version >= 1 && version < 12) + this.db.exec(`UPDATE messages SET body = '' WHERE media_json IS NOT NULL AND lower(trim(body)) = 'mms sent'`) this.db.pragma(`user_version = ${SCHEMA_VERSION}`) } diff --git a/src/main/sync.ts b/src/main/sync.ts index 0d5a148..068407e 100644 --- a/src/main/sync.ts +++ b/src/main/sync.ts @@ -18,7 +18,7 @@ function parseYmd(s: string): number { return Date.parse(s + 'T00:00:00Z') } -export const isMmsPlaceholder = (body: string): boolean => body.trim().toLowerCase() === 'mms received' +export const isMmsPlaceholder = (body: string): boolean => /^mms (received|sent)$/.test(body.trim().toLowerCase()) export function toNewMessage(r: RawSms): NewMessage { const m: NewMessage = { diff --git a/test/sync.test.ts b/test/sync.test.ts index 754e99c..8367c2b 100644 --- a/test/sync.test.ts +++ b/test/sync.test.ts @@ -53,6 +53,7 @@ describe('toNewMessage (MMS)', () => { expect(toNewMessage({ ...mms, message: 'MMS Received', col_media1: url }).body).toBe('') expect(toNewMessage({ ...mms, message: ' mms received\n', col_media1: url }).body).toBe('') expect(toNewMessage({ ...mms, message: 'MMS Received, thanks', col_media1: url }).body).toBe('MMS Received, thanks') + expect(toNewMessage({ ...mms, message: 'MMS Sent', col_media1: url }).body).toBe('') // Typed by a person, with no picture: kept. expect(toNewMessage({ ...mms, message: 'MMS received', col_media1: '' }).body).toBe('MMS received') })