v0.8.8: bubble for Android 0.7.5 — the composer is always the small size; smoother scrolling past photos

Android: the composer used to shrink only with the keyboard up; now it is always that size (small text, tight padding, 60 dp buttons), and the keyboard only takes a line off the text box and the subtitle. Checked on the Rabbit with the dev app, at rest and typing.

Desktop: the chat and Get info show a smaller copy of each still picture (720 px long edge, made once into <dataDir>/thumbs) instead of decoding a phone's 4000 px photo every time a row scrolls in. Full size, Save and Copy still use the original; GIFs and pictures already that small are served as they are. Pictures decode off the main thread.
This commit is contained in:
2026-11-13 12:01:56 -08:00
parent a3017bdd50
commit dd994c5bc3
9 changed files with 62 additions and 25 deletions
@@ -123,23 +123,16 @@ public final class ChatActivity extends BaseActivity {
/**
* The R1 has 640 px of height and the keyboard takes about half: with a
* photo attached, the full-size composer would push the text box under
* it. So while it's up, the photos, text and padding all shrink and the
* subtitle goes, leaving the text box and a few messages in view.
* photo attached, the composer would push the text box under it. So
* while it's up, the photos shrink, the text box gives up a line and the
* subtitle goes, leaving the text box and a few messages in view. (The
* composer itself is always the small size: see composer().)
*/
private void setCompact(boolean on) {
compact = on;
header.setPadding(Ui.dp(this, 24), Ui.dp(this, on ? 4 : 10), Ui.dp(this, 24), Ui.dp(this, on ? 4 : 10));
subView.setVisibility(on || subView.getText().length() == 0 ? View.GONE : View.VISIBLE);
composerBox.setPadding(Ui.dp(this, 12), Ui.dp(this, on ? 4 : 10), Ui.dp(this, 12), Ui.dp(this, on ? 4 : 10));
input.setTextSize(TypedValue.COMPLEX_UNIT_SP, on ? Ui.T_SMALL : Ui.T_BODY);
input.setPadding(Ui.dp(this, on ? 18 : 24), Ui.dp(this, on ? 8 : 14), Ui.dp(this, on ? 18 : 24), Ui.dp(this, on ? 8 : 14));
input.setMaxLines(on ? 3 : 4);
for (TextView b : new TextView[] {attach, send}) {
b.setMinWidth(Ui.dp(this, on ? 60 : 80));
b.setMinHeight(Ui.dp(this, on ? 56 : 80));
b.setTextSize(TypedValue.COMPLEX_UNIT_SP, on ? 28 : 34);
}
for (int i = 0; i < tray.getChildCount(); i++) tray.getChildAt(i).setLayoutParams(thumbParams());
if (on) list.post(this::showLatest);
}
@@ -165,7 +158,9 @@ public final class ChatActivity extends BaseActivity {
LinearLayout box = composerBox = new LinearLayout(this);
box.setOrientation(LinearLayout.VERTICAL);
box.setBackgroundColor(Ui.PANEL);
box.setPadding(Ui.dp(this, 12), Ui.dp(this, 10), Ui.dp(this, 12), Ui.dp(this, 10));
// Always the compact size (it used to shrink only with the keyboard
// up): the big one's padding was wasted on a 640 px screen.
box.setPadding(Ui.dp(this, 12), Ui.dp(this, 4), Ui.dp(this, 12), Ui.dp(this, 4));
// From-number picker, only for a conversation with nothing in it yet.
fromRow = new LinearLayout(this);
@@ -189,15 +184,17 @@ public final class ChatActivity extends BaseActivity {
row.setBaselineAligned(false);
attach = Ui.headerButton(this, Glyph.Kind.ATTACH);
attach.setOnTouchListener((v, e) -> attachTouch(e));
compactButton(attach);
input = new EditText(this);
input.setHint("Message");
input.setHintTextColor(Ui.MUTED);
input.setTextColor(Ui.TEXT);
input.setTextSize(TypedValue.COMPLEX_UNIT_SP, Ui.T_BODY);
input.setTextSize(TypedValue.COMPLEX_UNIT_SP, Ui.T_SMALL);
input.setMaxLines(4);
input.setBackground(Ui.input(this, 36));
input.setPadding(Ui.dp(this, 24), Ui.dp(this, 14), Ui.dp(this, 24), Ui.dp(this, 14));
input.setPadding(Ui.dp(this, 18), Ui.dp(this, 8), Ui.dp(this, 18), Ui.dp(this, 8));
send = Ui.headerButton(this, Glyph.Kind.SEND, Ui.ACCENT);
compactButton(send);
send.setOnClickListener(v -> submit());
row.addView(attach);
row.addView(input, new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.WRAP_CONTENT, 1));
@@ -226,6 +223,12 @@ public final class ChatActivity extends BaseActivity {
return box;
}
private void compactButton(TextView b) {
b.setMinWidth(Ui.dp(this, 60));
b.setMinHeight(Ui.dp(this, 56));
b.setTextSize(TypedValue.COMPLEX_UNIT_SP, 28);
}
private android.content.SharedPreferences drafts() {
return getSharedPreferences("drafts", MODE_PRIVATE);
}
+2 -2
View File
@@ -26,8 +26,8 @@ import sys
import zipfile
from pathlib import Path
VERSION_NAME = "0.7.4"
VERSION_CODE = 12
VERSION_NAME = "0.7.5"
VERSION_CODE = 13
PACKAGE = "me.teafry.voipmessages"
DEV_PACKAGE = PACKAGE + ".dev"
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "voipms-desktop",
"productName": "bubble",
"version": "0.8.7",
"version": "0.8.8",
"description": "Signal-style desktop SMS client for voip.ms",
"author": "trav <trav@teafry.me>",
"private": true,
Binary file not shown.
+1 -1
View File
@@ -1 +1 @@
{"version_name": "0.7.4", "version_code": 12, "package": "me.teafry.voipmessages"}
{"version_name": "0.7.5", "version_code": 13, "package": "me.teafry.voipmessages"}
+8 -4
View File
@@ -239,13 +239,17 @@ async function servePhoto(req: Request): Promise<Response> {
}
}
// ---- MMS attachments: mms-media://m/<messageId>/<index> ----
// ---- MMS attachments: mms-media://m/<messageId>/<index>[?thumb] ----
// ?thumb: a smaller copy of a still picture, for the chat and Get info.
async function serveMedia(req: Request): Promise<Response> {
const [id, index] = new URL(req.url).pathname.slice(1).split('/').map(Number)
const url = new URL(req.url)
const [id, index] = url.pathname.slice(1).split('/').map(Number)
const ref = await media.resolve(id, index)
if (!ref?.file) return new Response(null, { status: 404 })
const headers = { 'content-type': ref.mime ?? guessMime(ref.file) ?? 'application/octet-stream' }
return new Response(fs.readFileSync(media.filePath(ref.file)), { headers })
const thumb = url.searchParams.has('thumb') ? await media.thumb(ref).catch(() => undefined) : undefined
const file = thumb ?? media.filePath(ref.file)
const mime = thumb ? (thumb.endsWith('.png') ? 'image/png' : 'image/jpeg') : (ref.mime ?? guessMime(ref.file) ?? 'application/octet-stream')
return new Response(await fs.promises.readFile(file), { headers: { 'content-type': mime } })
}
async function saveMediaAs(id: number, index: number): Promise<void> {
+27
View File
@@ -9,6 +9,9 @@ import { extFor, guessMime } from '@shared/mime'
import type { MediaRef } from '@shared/types'
import type { MessageDb, NewMessage } from './db'
// Long edge of a thumbnail: twice the chat's largest picture box, for HiDPI.
const THUMB_EDGE = 720
export class MediaStore {
private inflight = new Map<string, Promise<MediaRef | undefined>>()
@@ -23,6 +26,30 @@ export class MediaStore {
return path.join(this.dir, path.basename(file))
}
// A smaller copy of a still picture for the chat and Get info, made once
// and kept in <dataDir>/thumbs (outside media/, so it never goes to the
// Rabbit or into backups as if it were an attachment). The chat shows
// pictures at most 300x360, so a phone's 4000 px photo was being decoded
// whole, again and again as rows scrolled in and out. Undefined = use the
// original: already small, animated (GIF), or a format nativeImage can't read.
async thumb(ref: MediaRef): Promise<string | undefined> {
if (!ref.file) return undefined
const mime = ref.mime ?? guessMime(ref.file) ?? ''
if (!mime.startsWith('image/') || mime === 'image/gif') return undefined
const png = mime === 'image/png' || mime === 'image/webp' // may be see-through
const out = path.join(this.dir, '..', 'thumbs', `${path.basename(ref.file)}.${THUMB_EDGE}.${png ? 'png' : 'jpg'}`)
if (fs.existsSync(out)) return out
const img = nativeImage.createFromPath(this.filePath(ref.file))
if (img.isEmpty()) return undefined
const { width, height } = img.getSize()
if (Math.max(width, height) <= THUMB_EDGE) return undefined
const scale = THUMB_EDGE / Math.max(width, height)
const small = img.resize({ width: Math.round(width * scale), height: Math.round(height * scale), quality: 'good' })
await fs.promises.mkdir(path.dirname(out), { recursive: true })
await fs.promises.writeFile(out, png ? small.toPNG() : small.toJPEG(85))
return out
}
save(data: Uint8Array, mime: string): string {
const file = `${crypto.createHash('sha1').update(data).digest('hex')}.${extFor(mime)}`
fs.mkdirSync(this.dir, { recursive: true })
@@ -8,7 +8,7 @@ import { CloseIcon } from './Icons'
import { Via } from './Via'
import { useAddContact } from './AddContact'
import { conversationMedia, Lightbox, type MediaItem } from './Lightbox'
import { mediaSrc } from './MessageBubble'
import { mediaSrc, thumbSrc } from './MessageBubble'
interface Props {
conv: ConvKey
@@ -67,7 +67,7 @@ function MediaGrid({ conv }: { conv: ConvKey }) {
</span>
</>
) : (
<img src={mediaSrc(it.id, it.index)} alt="" loading="lazy" draggable={false} onError={() => setBroken((b) => new Set(b).add(key(it)))} />
<img src={thumbSrc(it.id, it.index)} alt="" loading="lazy" decoding="async" draggable={false} onError={() => setBroken((b) => new Set(b).add(key(it)))} />
)}
</div>
))}
@@ -30,6 +30,8 @@ function renderText(text: string, highlight: string): ReactNode[] {
}
export const mediaSrc = (id: number, index: number): string => `mms-media://m/${id}/${index}`
// The smaller copy the chat and Get info show (the original if it's small already).
export const thumbSrc = (id: number, index: number): string => `${mediaSrc(id, index)}?thumb`
// Display box for an image: fit within 300×360, keeping the aspect ratio when
// we know it (so the list doesn't jump when the image arrives).
@@ -41,8 +43,8 @@ function imageBox(ref: MediaRef): { width: number; height: number } | undefined
function Attachment({ id, index, media, onOpen, onMenu, onLoad }: { id: number; index: number; media: MediaRef; onOpen: () => void; onMenu: (e: React.MouseEvent) => void; onLoad: () => void }) {
const [broken, setBroken] = useState(false)
const src = mediaSrc(id, index)
const kind = mediaKind(media)
const src = kind === 'image' ? thumbSrc(id, index) : mediaSrc(id, index)
// Still on the Rabbit (relayed history): asked for, it arrives after the Rabbit's next check.
if (broken && media.url?.startsWith('mmspart:') && !media.file) return <div className="media-missing">On the Rabbit — it'll appear after its next check</div>
if (broken) return <div className="media-missing">Media unavailable</div>
@@ -53,6 +55,7 @@ function Attachment({ id, index, media, onOpen, onMenu, onLoad }: { id: number;
src={src}
alt=""
draggable={false}
decoding="async"
style={imageBox(media) ?? { minHeight: 120, minWidth: 120 }}
onClick={onOpen}
onContextMenu={onMenu}