Skip to content

Commit 759079b

Browse files
authored
Merge pull request #216 from chrisknepper/november_2019_rollup
November 2019 rollup
2 parents 74b4851 + 023a701 commit 759079b

File tree

10 files changed

+1039
-1447
lines changed

10 files changed

+1039
-1447
lines changed

CHANGELOG.md

+9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
# Changelog
22

3+
## [3.1.0] - 2019-11-26
4+
### Added
5+
- Setting to follow (sync) system dark mode setting, changing from dark to light and vice versa as the operating system does -- This overrides the Google-provided setting within the 3-dot menu
6+
- Setting and keyboard shortcut (Command or Control +/-) to zoom the application in or out a la a web browser allows a page
7+
8+
### Changed
9+
- Under the hood: Notarize the macOS build of the app per Apple requirements
10+
- Under the hood: Update electron from 6.0.7 to 7.0.1
11+
312
## [3.0.0] - 2019-09-04
413
### Changed
514
- No longer prompt Linux users for sudo
+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>com.apple.security.cs.allow-unsigned-executable-memory</key>
6+
<true/>
7+
</dict>
8+
</plist>

config/packaging/notarize.js

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
const { notarize } = require('electron-notarize');
2+
3+
exports.default = async function notarizing(context) {
4+
const { electronPlatformName, appOutDir } = context;
5+
if (electronPlatformName !== 'darwin') {
6+
return;
7+
}
8+
9+
const appName = context.packager.appInfo.productFilename;
10+
11+
return await notarize({
12+
appBundleId: 'com.knepper.android-messages-desktop',
13+
appPath: `${appOutDir}/${appName}.app`,
14+
appleId: process.env.ANDROID_MESSAGES_APPLE_ID_EMAIL,
15+
appleIdPassword: process.env.ANDROID_MESSAGES_APPLE_ID_APP_PASSWORD,
16+
});
17+
};

package-lock.json

+918-1,403
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+8-4
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,15 @@
2828
"extraResources": [
2929
"resources/dictionaries"
3030
],
31+
"afterSign": "config/packaging/notarize.js",
3132
"mac": {
3233
"category": "public.app-category.social-networking",
3334
"target": [
3435
"zip",
3536
"dmg"
36-
]
37+
],
38+
"entitlements": "config/packaging/macosEntitlements.plist",
39+
"entitlementsInherit": "config/packaging/macosEntitlements.plist"
3740
},
3841
"win": {
3942
"target": [
@@ -74,7 +77,7 @@
7477
"e2e": "mocha temp/e2e.js --require source-map-support/register",
7578
"test": "npm run unit && npm run e2e",
7679
"start": "node build/start.js",
77-
"release": "npm test && webpack --config=build/webpack.app.config.js --env=production && electron-builder -mwl",
80+
"release": "webpack --config=build/webpack.app.config.js --env=production && electron-builder -mwl",
7881
"build": "webpack --config=build/webpack.app.config.js --env=production && electron-builder --publish never",
7982
"build-all": "webpack --config=build/webpack.app.config.js --env=production && electron-builder -mwl --publish never",
8083
"generate-icons": "png2icons assets/android_messages_desktop_icon.png resources/icon -all -i"
@@ -83,7 +86,7 @@
8386
"about-window": "1.13.0",
8487
"electron-hunspell": "1.0.0-beta.12",
8588
"electron-settings": "3.2.0",
86-
"electron-updater": "4.1.2",
89+
"electron-updater": "4.2.0",
8790
"fs-jetpack": "^1.0.0"
8891
},
8992
"devDependencies": {
@@ -93,9 +96,10 @@
9396
"babel-plugin-transform-object-rest-spread": "^7.0.0-beta.3",
9497
"chai": "^4.1.0",
9598
"css-loader": "^0.28.7",
96-
"electron": "6.0.7",
99+
"electron": "7.0.1",
97100
"electron-builder": "21.2.0",
98101
"electron-mocha": "^6.0.4",
102+
"electron-notarize": "^0.2.0",
99103
"file-loader": "^1.1.11",
100104
"friendly-errors-webpack-plugin": "^1.6.1",
101105
"mocha": "^5.2.0",

src/app.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,6 @@ androidMessagesWebview.addEventListener('dom-ready', () => {
106106
});
107107

108108
// Forward event from main process to webview bridge
109-
ipcRenderer.on(EVENT_UPDATE_USER_SETTING, (event, { enterToSend }) => {
110-
androidMessagesWebview.getWebContents().send(EVENT_UPDATE_USER_SETTING, {
111-
enterToSend
112-
});
109+
ipcRenderer.on(EVENT_UPDATE_USER_SETTING, (event, settingsList) => {
110+
androidMessagesWebview.getWebContents().send(EVENT_UPDATE_USER_SETTING, settingsList);
113111
});

src/background.js

+20-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import path from 'path';
77
import url from 'url';
8-
import { app, Menu, ipcMain, Notification, shell } from 'electron';
8+
import { app, Menu, ipcMain, Notification, shell, nativeTheme } from 'electron';
99
import { autoUpdater } from 'electron-updater';
1010
import { baseMenuTemplate } from './menu/base_menu_template';
1111
import { devMenuTemplate } from './menu/dev_menu_template';
@@ -25,7 +25,8 @@ const state = {
2525
unreadNotificationCount: 0,
2626
notificationSoundEnabled: true,
2727
notificationContentHidden: false,
28-
bridgeInitDone: false
28+
bridgeInitDone: false,
29+
useSystemDarkMode: true
2930
};
3031

3132
let mainWindow = null;
@@ -81,6 +82,7 @@ if (!isFirstInstance) {
8182
const notificationSoundEnabled = settings.get('notificationSoundEnabledPref', true);
8283
const pressEnterToSendEnabled = settings.get('pressEnterToSendPref', true);
8384
const hideNotificationContent = settings.get('hideNotificationContentPref', false);
85+
const useSystemDarkMode = settings.get('useSystemDarkModePref', true);
8486
settings.watch(SETTING_TRAY_ENABLED, trayManager.handleTrayEnabledToggle);
8587
settings.watch(SETTING_TRAY_CLICK_SHORTCUT, trayManager.handleTrayClickShortcutToggle);
8688
settings.watch('notificationSoundEnabledPref', (newValue) => {
@@ -94,6 +96,9 @@ if (!isFirstInstance) {
9496
settings.watch('hideNotificationContentPref', (newValue) => {
9597
state.notificationContentHidden = newValue;
9698
});
99+
settings.watch('useSystemDarkModePref', (newValue) => {
100+
state.useSystemDarkMode = newValue;
101+
});
97102

98103
setApplicationMenu();
99104
const menuInstance = Menu.getApplicationMenu();
@@ -104,11 +109,20 @@ if (!isFirstInstance) {
104109
});
105110
}
106111

112+
nativeTheme.on('updated', () => {
113+
if (state.useSystemDarkMode) {
114+
mainWindow.webContents.send(EVENT_UPDATE_USER_SETTING, {
115+
useDarkMode: nativeTheme.shouldUseDarkColors
116+
});
117+
}
118+
});
119+
107120
const trayMenuItem = menuInstance.getMenuItemById('startInTrayMenuItem');
108121
const enableTrayIconMenuItem = menuInstance.getMenuItemById('enableTrayIconMenuItem');
109122
const notificationSoundEnabledMenuItem = menuInstance.getMenuItemById('notificationSoundEnabledMenuItem');
110123
const pressEnterToSendMenuItem = menuInstance.getMenuItemById('pressEnterToSendMenuItem');
111124
const hideNotificationContentMenuItem = menuInstance.getMenuItemById('hideNotificationContentMenuItem');
125+
const useSystemDarkModeMenuItem = menuInstance.getMenuItemById('useSystemDarkModeMenuItem');
112126

113127
if (!IS_MAC) {
114128
// Sets checked status based on user prefs
@@ -131,9 +145,11 @@ if (!isFirstInstance) {
131145
notificationSoundEnabledMenuItem.checked = notificationSoundEnabled;
132146
pressEnterToSendMenuItem.checked = pressEnterToSendEnabled;
133147
hideNotificationContentMenuItem.checked = hideNotificationContent;
148+
useSystemDarkModeMenuItem.checked = useSystemDarkMode;
134149

135150
state.notificationSoundEnabled = notificationSoundEnabled;
136151
state.notificationContentHidden = hideNotificationContent;
152+
state.useSystemDarkMode = useSystemDarkMode;
137153

138154
autoUpdater.checkForUpdatesAndNotify();
139155

@@ -237,7 +253,8 @@ if (!isFirstInstance) {
237253
// via the renderer process. I'm not sure of a way to get a reference to the androidMessagesWebview inside the renderer from
238254
// here. There may be a legit way to do it, or we can do it a dirty way like how we pass this process to the renderer.
239255
mainWindow.webContents.send(EVENT_UPDATE_USER_SETTING, {
240-
enterToSend: pressEnterToSendEnabled
256+
enterToSend: pressEnterToSendEnabled,
257+
useDarkMode: useSystemDarkMode ? nativeTheme.shouldUseDarkColors : null
241258
});
242259

243260
let spellCheckFiles = null;

src/helpers/webview/bridge.js

+16-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import { popupContextMenu } from './context_menu';
44
import { EVENT_WEBVIEW_NOTIFICATION, EVENT_NOTIFICATION_REFLECT_READY, EVENT_BRIDGE_INIT, EVENT_SPELLING_REFLECT_READY, EVENT_UPDATE_USER_SETTING } from '../../constants';
5+
import { isObject } from '../../helpers/utilities';
56
import { ipcRenderer, remote } from 'electron';
67
import InputManager from './input_manager';
78
import fs from 'fs';
@@ -57,8 +58,21 @@ ipcRenderer.once(EVENT_SPELLING_REFLECT_READY, async (event, { dictionaryLocaleK
5758
}
5859
});
5960

60-
ipcRenderer.on(EVENT_UPDATE_USER_SETTING, (event, { enterToSend }) => {
61-
InputManager.handleEnterPrefToggle(enterToSend);
61+
ipcRenderer.on(EVENT_UPDATE_USER_SETTING, (event, settingsList) => {
62+
if (isObject(settingsList)) {
63+
if ('useDarkMode' in settingsList && settingsList.useDarkMode !== null) {
64+
if (settingsList.useDarkMode) {
65+
// Props to Google for making the web app use dark mode entirely based on this class
66+
// and for making the class name semantic!
67+
document.body.classList.add('dark-mode');
68+
} else {
69+
document.body.classList.remove('dark-mode');
70+
}
71+
}
72+
if ('enterToSend' in settingsList) {
73+
InputManager.handleEnterPrefToggle(settingsList.enterToSend);
74+
}
75+
}
6276
});
6377

6478
const OriginalBrowserNotification = Notification;

src/menu/settings_menu_template.js

+9-2
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,14 @@ settingsMenu.submenu.push(
115115
click: (item) => {
116116
settings.set('hideNotificationContentPref', item.checked);
117117
}
118+
},
119+
separator,
120+
{
121+
id: 'useSystemDarkModeMenuItem',
122+
label: 'Use System Dark Mode Setting',
123+
type: 'checkbox',
124+
click: (item) => {
125+
settings.set('useSystemDarkModePref', item.checked);
126+
}
118127
}
119128
);
120-
121-

src/menu/view_menu_template.js

+32-29
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,32 @@
1-
export const viewMenuTemplate = {
2-
label: "View",
3-
submenu: [
4-
{
5-
role: "toggleFullScreen",
6-
},
7-
{
8-
role: "reload"
9-
},
10-
{
11-
type: 'separator'
12-
},
13-
{
14-
role: "resetZoom"
15-
},
16-
{
17-
role: "zoomIn"
18-
},
19-
{
20-
role: 'zoomin',
21-
accelerator: 'CommandOrControl+=',
22-
visible: false,
23-
enabled: true,
24-
},
25-
{
26-
role: "zoomOut"
27-
},
28-
]
29-
};
1+
export const viewMenuTemplate = {
2+
label: "View",
3+
submenu: [
4+
{
5+
role: "toggleFullScreen",
6+
},
7+
{
8+
role: "reload"
9+
},
10+
{
11+
type: 'separator'
12+
},
13+
{
14+
role: "resetZoom"
15+
},
16+
// Having two items to get the zoom-in functionality is necessary due to a bug in Electron
17+
// Without doing this, either the keyboard shortcut is displayed wrong, or zooming in doesn't work
18+
// See: https://github.com/electron/electron/issues/15496
19+
{
20+
role: "zoomIn"
21+
},
22+
{
23+
role: 'zoomin',
24+
accelerator: 'CommandOrControl+=',
25+
visible: false,
26+
enabled: true,
27+
},
28+
{
29+
role: "zoomOut"
30+
},
31+
]
32+
};

0 commit comments

Comments
 (0)