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:
+32
-2
@@ -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()
|
||||
|
||||
|
||||
@@ -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),
|
||||
|
||||
@@ -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<string>()
|
||||
// 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) {
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
<div className="field">
|
||||
Icon
|
||||
<div className="segmented" role="radiogroup" aria-label="Icon">
|
||||
{(['dark', 'inverted'] as IconStyle[]).map((t) => (
|
||||
<button
|
||||
key={t}
|
||||
role="radio"
|
||||
aria-checked={(s.icon ?? 'dark') === t}
|
||||
className={(s.icon ?? 'dark') === t ? 'on' : ''}
|
||||
onClick={() => {
|
||||
setS({ ...s, icon: t })
|
||||
void window.api.setIcon(t).then(onChanged)
|
||||
}}
|
||||
>
|
||||
{t === 'dark' ? 'Dark' : 'Inverted'}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
<label className="field">
|
||||
Show new messages in the notification list
|
||||
<input type="checkbox" checked={s.notifications} onChange={(e) => setS({ ...s, notifications: e.target.checked })} />
|
||||
|
||||
+2
-1
@@ -1,5 +1,5 @@
|
||||
// The typed bridge exposed to the renderer as window.api.
|
||||
import type { AddressBook, ChatExport, ContactInfo, NewContact, Conversation, Credentials, Did, Message, OutgoingAttachment, SearchHit, Settings, SyncStatus, Theme } from './types'
|
||||
import type { IconStyle, AddressBook, ChatExport, ContactInfo, NewContact, Conversation, Credentials, Did, Message, OutgoingAttachment, SearchHit, Settings, SyncStatus, Theme } from './types'
|
||||
|
||||
export interface AppState {
|
||||
configured: boolean
|
||||
@@ -23,6 +23,7 @@ export interface Api {
|
||||
saveSetup(creds: Credentials, settings: Settings): Promise<void>
|
||||
updateSettings(settings: Settings): Promise<void>
|
||||
setTheme(theme: Theme): Promise<void>
|
||||
setIcon(icon: IconStyle): Promise<void>
|
||||
signOut(): Promise<void>
|
||||
connectGoogleVoice(): Promise<void>
|
||||
connectGoogleVoiceCookies(text: string): Promise<void>
|
||||
|
||||
@@ -4,6 +4,8 @@ export type Direction = 'in' | 'out'
|
||||
export type MessageStatus = 'delivered' | 'pending' | 'failed'
|
||||
export type MessageKind = 'sms' | 'mms'
|
||||
export type Theme = 'system' | 'light' | 'dark'
|
||||
// The app icon: the original dark photo, or its negative (lighter).
|
||||
export type IconStyle = 'dark' | 'inverted'
|
||||
|
||||
// One MMS attachment. `url` is where voip.ms serves it; `file` is our cached
|
||||
// copy (a name inside <dataDir>/media), filled in once downloaded or sent.
|
||||
@@ -127,6 +129,7 @@ export interface Settings {
|
||||
defaultDid?: string
|
||||
backfillFloor: string // YYYY-MM-DD, stop backfill here
|
||||
theme: Theme
|
||||
icon?: IconStyle // absent = dark
|
||||
notifications: boolean // new messages go to the notification list
|
||||
contactBook?: string // where "Add to contacts" puts them; default: GNOME Contacts' default
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user