v0.4.0: bubble for Android 0.4.0 — an inverted (lighter) icon, chosen in Settings on both

The original icon is a little dark: resources/icon-inverted.png and
ic_launcher_inverted.png are its negative (alpha kept).

- Desktop: Settings → Appearance → Icon (Dark / Inverted), saved on click;
  sets the window icon and rewrites the launcher's installed copy
- Android: Settings → Icon; two launcher activity-aliases, one enabled
This commit is contained in:
2026-11-06 17:20:56 -08:00
parent 94188a42c7
commit e1bceb06a3
14 changed files with 127 additions and 12 deletions
+32 -2
View File
@@ -7,7 +7,7 @@ import path from 'node:path'
import os from 'node:os'
import { pathToFileURL } from 'node:url'
import { charCount, groupMembers, isGroup, normalizeNumber, SMS_TEXT_LIMIT } from '@shared/phone'
import type { ChatExport, Credentials, Did, MediaRef, Message, NewContact, OutgoingAttachment, Provider, Settings, SyncStatus, Theme } from '@shared/types'
import type { ChatExport, IconStyle, Credentials, Did, MediaRef, Message, NewContact, OutgoingAttachment, Provider, Settings, SyncStatus, Theme } from '@shared/types'
import type { AppState } from '@shared/api'
import { addToAddressBook, ContactDirectory, listAddressBooks } from './contacts'
import { localDay, MessageDb, type NewMessage } from './db'
@@ -275,6 +275,30 @@ async function readMedia(id: number, index: number): Promise<{ mime: string; dat
return { mime: ref.mime ?? guessMime(ref.file) ?? 'application/octet-stream', data: new Uint8Array(fs.readFileSync(media.filePath(ref.file))) }
}
// ---- icon: the dark original or its negative (Settings → Appearance) ----
const iconFile = (style: IconStyle | undefined): string =>
path.join(__dirname, '../../resources', style === 'inverted' ? 'icon-inverted.png' : 'icon.png')
// The window's icon, and the launcher's (the copy scripts/install-desktop.sh
// put in ~/.local/share/icons), so the dash and Alt+Tab match too.
function applyIcon(): void {
const file = iconFile(settings.icon)
win?.setIcon(file)
if (SANDBOX || !app.isPackaged) return
const installed = path.join(os.homedir(), '.local/share/icons/hicolor/512x512/apps/voipms-desktop.png')
try {
if (!fs.existsSync(installed)) return
const want = fs.readFileSync(file)
if (Buffer.compare(want, fs.readFileSync(installed)) === 0) return
fs.writeFileSync(installed, want)
// GNOME caches icons by name: nudge it to look again.
const now = new Date()
fs.utimesSync(path.join(os.homedir(), '.local/share/icons/hicolor'), now, now)
} catch (e) {
console.warn('[icon] could not update the launcher icon:', (e as Error).message)
}
}
// ---- theme + zoom ----
function applyTheme(): void {
nativeTheme.themeSource = settings.theme
@@ -476,6 +500,11 @@ function registerIpc(): void {
gvSync?.resetBackfill()
}
})
ipcMain.handle('setIcon', (_e, icon: IconStyle) => {
settings = { ...settings, icon }
saveSettings(settings)
applyIcon()
})
// Theme takes effect (and is saved) immediately, without the dialog's Save.
ipcMain.handle('setTheme', (_e, theme: Theme) => {
settings = { ...settings, theme }
@@ -596,7 +625,7 @@ function createWindow(): void {
title: SANDBOX ? 'bubble (sandbox)' : 'bubble',
backgroundColor: windowBackground(),
autoHideMenuBar: true,
icon: path.join(__dirname, '../../resources/icon.png'),
icon: iconFile(settings.icon),
webPreferences: {
preload: path.join(__dirname, '../preload/index.js'),
contextIsolation: true,
@@ -662,6 +691,7 @@ app.whenReady().then(async () => {
protocol.handle('mms-media', serveMedia)
registerIpc()
createWindow()
applyIcon()
// The sandbox stays away from the real address book.
if (!SANDBOX) void contacts.load()