diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index bb57e42..03c763f 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -35,12 +35,25 @@ android:name="me.teafry.voipmessages.MainActivity" android:exported="true" android:launchMode="singleTask" - android:windowSoftInputMode="adjustResize|stateHidden"> + android:windowSoftInputMode="adjustResize|stateHidden" /> + + - + + + + + + + Config.prefs(c).edit().putBoolean("notifications", on).apply()); box.addView(notify); + section("Icon"); + boolean inv = Icons.isInverted(c); + row("Launcher icon", inv ? "Inverted (lighter)" : "Dark", v -> { + new AlertDialog.Builder(c).setTitle("Launcher icon") + .setSingleChoiceItems(new String[] {"Dark", "Inverted (lighter)"}, inv ? 1 : 0, (d, i) -> { + if ((i == 1) != inv) Icons.setInverted(c, i == 1); + d.dismiss(); + changed(); + }).show(); + }); + note("The home screen can take a few seconds to show the new one."); + section("Accounts"); Config cfg = Config.get(c); kv("voip.ms", cfg.voipUser == null ? "Not set up" : Sync.voipError != null ? "⚠ " + Sync.voipError : cfg.voipUser); diff --git a/android/app/src/main/res/drawable-nodpi/ic_launcher_inverted.png b/android/app/src/main/res/drawable-nodpi/ic_launcher_inverted.png new file mode 100644 index 0000000..7941121 Binary files /dev/null and b/android/app/src/main/res/drawable-nodpi/ic_launcher_inverted.png differ diff --git a/android/build.py b/android/build.py index 01ab184..ed1732b 100644 --- a/android/build.py +++ b/android/build.py @@ -26,8 +26,8 @@ import sys import zipfile from pathlib import Path -VERSION_NAME = "0.3.0" -VERSION_CODE = 3 +VERSION_NAME = "0.4.0" +VERSION_CODE = 4 PACKAGE = "me.teafry.voipmessages" DEV_PACKAGE = PACKAGE + ".dev" diff --git a/package.json b/package.json index bc6d8dd..f87dbb4 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "voipms-desktop", "productName": "bubble", - "version": "0.3.0", + "version": "0.4.0", "description": "Signal-style desktop SMS client for voip.ms", "author": "trav ", "private": true, @@ -52,6 +52,7 @@ "files": [ "out/**", "resources/icon.png", + "resources/icon-inverted.png", "package.json" ], "extraResources": [ diff --git a/resources/android/VoipMessages.apk b/resources/android/VoipMessages.apk index 0ee290f..72c0d77 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 c30ad4c..b1d53bd 100644 --- a/resources/android/VoipMessages.json +++ b/resources/android/VoipMessages.json @@ -1 +1 @@ -{"version_name": "0.3.0", "version_code": 3, "package": "me.teafry.voipmessages"} +{"version_name": "0.4.0", "version_code": 4, "package": "me.teafry.voipmessages"} diff --git a/resources/icon-inverted.png b/resources/icon-inverted.png new file mode 100644 index 0000000..a507462 Binary files /dev/null and b/resources/icon-inverted.png differ diff --git a/src/main/index.ts b/src/main/index.ts index d101612..8f812e7 100644 --- a/src/main/index.ts +++ b/src/main/index.ts @@ -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() diff --git a/src/preload/index.ts b/src/preload/index.ts index e47accd..9026ab6 100644 --- a/src/preload/index.ts +++ b/src/preload/index.ts @@ -13,6 +13,7 @@ const api: Api = { saveSetup: (creds, settings) => ipcRenderer.invoke('saveSetup', creds, settings), updateSettings: (settings) => ipcRenderer.invoke('updateSettings', settings), setTheme: (theme) => ipcRenderer.invoke('setTheme', theme), + setIcon: (icon) => ipcRenderer.invoke('setIcon', icon), signOut: () => ipcRenderer.invoke('signOut'), connectGoogleVoice: () => ipcRenderer.invoke('connectGoogleVoice'), connectGoogleVoiceCookies: (text) => ipcRenderer.invoke('connectGoogleVoiceCookies', text), diff --git a/src/renderer/src/components/SettingsDialog.tsx b/src/renderer/src/components/SettingsDialog.tsx index 4a891fa..68b2f27 100644 --- a/src/renderer/src/components/SettingsDialog.tsx +++ b/src/renderer/src/components/SettingsDialog.tsx @@ -1,7 +1,7 @@ import { useEffect, useState } from 'react' import type { AppState, RabbitStatus } from '@shared/api' import { formatNumber } from '@shared/phone' -import type { AddressBook, GvStatus, Settings, SyncStatus, Theme } from '@shared/types' +import type { AddressBook, GvStatus, IconStyle, Settings, SyncStatus, Theme } from '@shared/types' import { CloseIcon } from './Icons' interface Props { @@ -16,8 +16,9 @@ export function SettingsDialog({ state, sync, onClose, onChanged }: Props) { const [note, setNote] = useState() // voip.ms numbers; Google Voice has its own section. const smsDids = state.dids.filter((d) => d.smsEnabled && d.provider !== 'gvoice') - // Theme is saved on click, so it never makes the dialog dirty. - const dirty = JSON.stringify({ ...s, theme: undefined }) !== JSON.stringify({ ...state.settings, theme: undefined }) + // Theme and icon are saved on click, so they never make the dialog dirty. + const clicked = { theme: undefined, icon: undefined } + const dirty = JSON.stringify({ ...s, ...clicked }) !== JSON.stringify({ ...state.settings, ...clicked }) useEffect(() => { const onKey = (e: KeyboardEvent): void => { @@ -67,6 +68,25 @@ export function SettingsDialog({ state, sync, onClose, onChanged }: Props) { ))} +
+ Icon +
+ {(['dark', 'inverted'] as IconStyle[]).map((t) => ( + + ))} +
+