Merge pull request #1913 from dpalou/desktop-rebased

Desktop rebased
main
Juan Leyva 2019-05-16 10:11:10 +02:00 committed by GitHub
commit b8859c1642
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 73 additions and 43 deletions

View File

@ -6,6 +6,7 @@ const url = require('url');
const fs = require('fs');
const os = require('os');
const userAgent = 'MoodleMobile';
const isMac = os.platform().indexOf('darwin') != -1;
// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected.
@ -68,6 +69,14 @@ function createWindow() {
// Append some text to the user agent.
mainWindow.webContents.setUserAgent(mainWindow.webContents.getUserAgent() + ' ' + userAgent);
// Add shortcut to open dev tools: Cmd + Option + I in MacOS, Ctrl + Shift + I in Windows/Linux.
mainWindow.webContents.on('before-input-event', function(e, input) {
if (input.type == 'keyDown' && !input.isAutoRepeat && input.code == 'KeyI' &&
((isMac && input.alt && input.meta) || (!isMac && input.shift && input.control))) {
mainWindow.webContents.toggleDevTools();
}
}, true)
}
// Make sure that only a single instance of the app is running.
@ -75,7 +84,7 @@ function createWindow() {
// See https://github.com/electron/electron/issues/15958
var gotTheLock = app.requestSingleInstanceLock();
if (!gotTheLock && os.platform().indexOf('darwin') == -1) {
if (!gotTheLock && !isMac) {
// It's not the main instance of the app, kill it.
app.exit();
return;
@ -221,22 +230,18 @@ function setAppMenu() {
submenu: [
{
label: 'Cut',
accelerator: 'CmdOrCtrl+X',
role: 'cut'
},
{
label: 'Copy',
accelerator: 'CmdOrCtrl+C',
role: 'copy'
},
{
label: 'Paste',
accelerator: 'CmdOrCtrl+V',
role: 'paste'
},
{
label: 'Select All',
accelerator: 'CmdOrCtrl+A',
role: 'selectall'
}
]

46
package-lock.json generated
View File

@ -1387,7 +1387,6 @@
"version": "1.0.10",
"resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz",
"integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==",
"dev": true,
"requires": {
"sprintf-js": "~1.0.2"
}
@ -4081,10 +4080,9 @@
}
},
"esprima": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.0.tgz",
"integrity": "sha512-oftTcaMu/EGrEIu904mWteKIv8vMuOgGYo7EhVJJN00R/EED9DCua/xxHRdYnKtcECzVg7xOWhflvJMnqcFZjw==",
"dev": true
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz",
"integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A=="
},
"esrecurse": {
"version": "4.2.1",
@ -5252,9 +5250,9 @@
}
},
"fstream": {
"version": "1.0.11",
"resolved": "https://registry.npmjs.org/fstream/-/fstream-1.0.11.tgz",
"integrity": "sha1-XB+x8RdHcRTwYyoOtLcbPLD9MXE=",
"version": "1.0.12",
"resolved": "https://registry.npmjs.org/fstream/-/fstream-1.0.12.tgz",
"integrity": "sha512-WvJ193OHa0GHPEL+AycEJgxvBEwyfRkN1vhjca23OaPVMCaLCXTd5qAu82AjTcgP1UJmytkOKb63Ypde7raDIg==",
"dev": true,
"requires": {
"graceful-fs": "^4.1.2",
@ -6671,10 +6669,9 @@
"dev": true
},
"js-yaml": {
"version": "3.12.0",
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.12.0.tgz",
"integrity": "sha512-PIt2cnwmPfL4hKNwqeiuz4bKfnzHTBv6HyVgjahA6mPLwPDzjDWrplJBMjHUFxku/N3FlmrbyPclad+I+4mJ3A==",
"dev": true,
"version": "3.13.1",
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.1.tgz",
"integrity": "sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==",
"requires": {
"argparse": "^1.0.7",
"esprima": "^4.0.0"
@ -9960,8 +9957,7 @@
"sprintf-js": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz",
"integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=",
"dev": true
"integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw="
},
"sshpk": {
"version": "1.14.2",
@ -10178,14 +10174,28 @@
"dev": true
},
"tar": {
"version": "2.2.1",
"resolved": "https://registry.npmjs.org/tar/-/tar-2.2.1.tgz",
"integrity": "sha1-jk0qJWwOIYXGsYrWlK7JaLg8sdE=",
"version": "2.2.2",
"resolved": "https://registry.npmjs.org/tar/-/tar-2.2.2.tgz",
"integrity": "sha512-FCEhQ/4rE1zYv9rYXJw/msRqsnmlje5jHP6huWeBZ704jUTy02c5AZyWujpMR1ax6mVw9NyJMfuK2CMDWVIfgA==",
"dev": true,
"requires": {
"block-stream": "*",
"fstream": "^1.0.2",
"fstream": "^1.0.12",
"inherits": "2"
},
"dependencies": {
"fstream": {
"version": "1.0.12",
"resolved": "https://registry.npmjs.org/fstream/-/fstream-1.0.12.tgz",
"integrity": "sha512-WvJ193OHa0GHPEL+AycEJgxvBEwyfRkN1vhjca23OaPVMCaLCXTd5qAu82AjTcgP1UJmytkOKb63Ypde7raDIg==",
"dev": true,
"requires": {
"graceful-fs": "^4.1.2",
"inherits": "~2.0.0",
"mkdirp": ">=0.5 0",
"rimraf": "2"
}
}
}
},
"temp-file": {

View File

@ -227,6 +227,9 @@
},
"snap": {
"confinement": "classic"
},
"nsis": {
"deleteAppDataOnUninstall": true
}
}
}

View File

@ -28,6 +28,10 @@ if [ ! -z $GIT_ORG_PRIVATE ] && [ ! -z $GIT_TOKEN ] ; then
mv Moodle*.AppImage linux-x64.AppImage
ls
tar -czvf MoodleDesktop32.tar.gz linux-ia32.AppImage
tar -czvf MoodleDesktop64.tar.gz linux-x64.AppImage
rm *.AppImage
git add .
git commit -m "Linux desktop versions from Travis build $TRAVIS_BUILD_NUMBER"
git push

View File

@ -224,6 +224,7 @@ export class InAppBrowserObjectMock {
}
};
if (!this.window.isDestroyed() && !this.window.webContents.isDestroyed()) {
switch (name) {
case 'loadstart':
this.window.webContents.on('did-start-loading', received);
@ -246,9 +247,15 @@ export class InAppBrowserObjectMock {
break;
default:
}
}
return (): void => {
// Unsubscribing. We need to remove the listeners.
if (this.window.isDestroyed() || this.window.webContents.isDestroyed()) {
// Page has been destroyed already, no need to remove listeners.
return;
}
switch (name) {
case 'loadstart':
this.window.webContents.removeListener('did-start-loading', received);

View File

@ -211,7 +211,8 @@ export const IONIC_NATIVE_PROVIDERS = [
]
})
export class CoreEmulatorModule {
constructor(appProvider: CoreAppProvider, initDelegate: CoreInitDelegate, helper: CoreEmulatorHelperProvider) {
constructor(appProvider: CoreAppProvider, initDelegate: CoreInitDelegate, helper: CoreEmulatorHelperProvider,
platform: Platform) {
const win = <any> window; // Convert the "window" to "any" type to be able to use non-standard properties.
// Emulate Custom URL Scheme plugin in desktop apps.
@ -224,7 +225,7 @@ export class CoreEmulatorModule {
// Listen for 'resume' events.
require('electron').ipcRenderer.on('coreAppFocused', () => {
document.dispatchEvent(new Event('resume'));
platform.resume.emit();
});
}