Skip to content

Commit 4d26084

Browse files
authored
Merge pull request #144 from Genymobile/integration/PLAYER74-66-and-fine-tuning-pre-release4.2
[Integration] [Player-66-74-80] and fine tuning pre release 4.2
2 parents c1c69b9 + de74a82 commit 4d26084

27 files changed

+858
-408
lines changed

README.md

Lines changed: 249 additions & 234 deletions
Large diffs are not rendered by default.

example/geny-window.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,6 @@ const initPlayer = (webrtcAddress, fileUploadUrl = null) => {
130130
'ButtonsEvents_VOLUME_DOWN',
131131
'ButtonsEvents_ROTATE',
132132
'separator',
133-
'GAPPSInstall',
134133
'Screenrecord',
135134
'Screenshot',
136135
'Battery',
@@ -140,12 +139,13 @@ const initPlayer = (webrtcAddress, fileUploadUrl = null) => {
140139
'FingerPrint',
141140
'IOThrottling',
142141
'Network',
143-
'GPS',
144142
'Clipboard',
145143
'separator',
146144
'StreamResolution',
147145
'Camera',
148146
'separator',
147+
'GAPPSInstall',
148+
'GPS',
149149
'ButtonsEvents_RECENT_APP',
150150
'ButtonsEvents_HOMEPAGE',
151151
'ButtonsEvents_BACK',

src/DeviceRenderer.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1034,9 +1034,6 @@ module.exports = class DeviceRenderer {
10341034
const videoBorderWidth = 8;
10351035
const videoOutlineWidth = 7;
10361036

1037-
// Set margin for the video wrapper (using original calculation for safety)
1038-
this.videoWrapper.style.margin = videoBorderWidth * 2 + videoOutlineWidth * 2 + 'px';
1039-
10401037
// Apply styles to the border div (using original calculation for safety)
10411038
borderDiv.style.borderWidth = videoBorderWidth + 'px';
10421039
borderDiv.style.outlineWidth = videoOutlineWidth + 'px';

src/DeviceRendererFactory.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ const defaultsDeep = require('lodash/defaultsDeep');
77
const store = require('./store');
88
const APIManager = require('./APIManager');
99
const ToolbarManager = require('./plugins/util/ToolBarManager');
10+
const TooltipManager = require('./plugins/util/TooltipManager');
1011

1112
const log = require('loglevel');
1213
log.setDefaultLevel('debug');
@@ -168,6 +169,7 @@ module.exports = class DeviceRendererFactory {
168169

169170
instance.apiManager = new APIManager(instance);
170171
instance.toolbarManager = new ToolbarManager(instance);
172+
instance.tooltipManager = new TooltipManager(instance);
171173

172174
this.instances.push(instance);
173175

@@ -187,6 +189,7 @@ module.exports = class DeviceRendererFactory {
187189
loadTemplate(dom, options) {
188190
dom.innerHTML = `
189191
<div class="gm-wrapper waitingForStream ${options.showPhoneBorder ? 'phoneBorder' : ''}
192+
${options.floatingToolbar ? 'floatingBarDisplayed' : ''}
190193
toolbarPosition-${options.toolbarPosition}">
191194
<div class="player-screen-wrapper">
192195
<div class="gm-video-wrapper">

src/plugins/Clipboard.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,7 @@ module.exports = class Clipboard extends OverlayPlugin {
4949
if (this.clipboard !== this.clipboardInput.value) {
5050
this.container.classList.remove('gm-clipboard-saved');
5151
}
52-
if (!this.instance.store.getters.isWidgetOpened(this.overlayID)) {
53-
// if the widget is not opened, we update the clipboard input
54-
this.clipboardInput.value = this.clipboard;
55-
}
52+
this.clipboardInput.value = this.clipboard;
5653
} catch (error) {
5754
log.warn('Malformed clipboard content');
5855
}

src/plugins/FileUpload.js

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,28 @@ module.exports = class FileUpload extends OverlayPlugin {
5050
case 'PROGRESS':
5151
this.fileUploader.updateProgress(msg.value * 100, msg.uploadedSize, msg.fileSize);
5252
break;
53+
case 'SOCKET_FAIL':
54+
this.fileUploader.showUploadError(
55+
this.i18n.FILE_UPLOAD_CONNECTION_FAILED ||
56+
'Something went wrong while connecting to the server.'
57+
);
58+
this.fileUploader.setEnabled(false);
59+
break;
60+
case 'SOCKET_SUCCESS':
61+
this.fileUploader.reset();
62+
break;
5363
default:
5464
break;
5565
}
5666
};
5767
} catch (error) {
5868
log.error(error, this.toolbarBtn);
5969
this.toolbarBtn.disable();
70+
this.instance.tooltipManager.setTooltip(
71+
this.toolbarBtn.htmlElement,
72+
i18n.ERROR_ON_LOAD_FILE_UPLOAD || "Upload worker can't be load, check the fileUploadUrl option",
73+
this.instance.options.toolbarPosition === 'right' ? 'left':'right'
74+
);
6075
}
6176
}
6277

@@ -95,9 +110,9 @@ module.exports = class FileUpload extends OverlayPlugin {
95110
const text = document.createElement('div');
96111
text.className = 'gm-text';
97112
text.innerHTML = this.i18n.FILE_UPLOAD_TEXT ||
98-
`You can upload files to the device from here.
99-
Application APK files and flashable ZIP archives will be installed,
100-
other file types will be copied to <b>/sdcard/download</b> folder on the device.`;
113+
`You can upload files from here.
114+
Application (APK) files and flashable ZIP archives will be installed;
115+
other file types will be copied to the Download folder (/sdcard/Download) on the device.`;
101116
introSection.appendChild(text);
102117

103118
// File Upload Section
@@ -124,7 +139,6 @@ module.exports = class FileUpload extends OverlayPlugin {
124139
},
125140
dragDropText: this.i18n.DRAG_DROP_TEXT || 'DRAG & DROP YOUR FILE',
126141
browseButtonText: this.i18n.BROWSE_BUTTON_TEXT || 'BROWSE',
127-
maxFileSize: 900,
128142
i18n: this.i18n,
129143
});
130144

@@ -159,6 +173,7 @@ module.exports = class FileUpload extends OverlayPlugin {
159173
return container;
160174
}
161175

176+
// Attach the drag and drop events on root to handle the drag of all file except apk (which is handle in gapps plugin)
162177
addListenerOnRoot() {
163178
this.removeListenerDragAndDropOver = this.instance.addListener(this.instance.root, 'dragover', (event) => {
164179
event.preventDefault();
@@ -176,7 +191,9 @@ module.exports = class FileUpload extends OverlayPlugin {
176191
event.preventDefault();
177192
event.stopPropagation();
178193

179-
this.fileUploader.startUpload(event.dataTransfer.files[0]);
194+
if (!event.dataTransfer.files[0].name.toLowerCase().endsWith('.apk')) {
195+
this.fileUploader.startUpload(event.dataTransfer.files[0]);
196+
}
180197
});
181198
}
182199

src/plugins/GAPPSInstall.js

Lines changed: 74 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ class InstallationSuccessView {
161161
closeBtn.className = 'gm-btn';
162162
closeBtn.onclick = () => {
163163
this.plugin.closeWidget();
164-
this.plugin.setView('InitialView');
164+
this.plugin.viewAtNextopening='InitialView';
165165
};
166166

167167
const restartBtn = document.createElement('button');
@@ -174,7 +174,7 @@ class InstallationSuccessView {
174174
};
175175
this.plugin.instance.sendEvent(json);
176176
this.plugin.closeWidget();
177-
this.plugin.setView('InitialView');
177+
this.plugin.viewAtNextopening='InitialView';
178178
};
179179

180180
actionsSection.appendChild(closeBtn);
@@ -243,7 +243,7 @@ class InstallationFailedView {
243243
closeBtn.className = 'gm-btn';
244244
closeBtn.onclick = () => {
245245
this.plugin.closeWidget();
246-
this.plugin.setView('InitialView');
246+
this.plugin.viewAtNextopening='InitialView';
247247
};
248248

249249
actionsSection.appendChild(closeBtn);
@@ -347,6 +347,10 @@ class InitialView {
347347
this.i18n = plugin.i18n;
348348
this.fileUploadWorker = null;
349349

350+
this.removeListenerDragAndDropOver = null;
351+
this.removeListenerDragAndDropLeave = null;
352+
this.removeListenerDragAndDropDrop = null;
353+
350354
try {
351355
this.fileUploadWorker = this.plugin.instance.createFileUploadWorker();
352356
this.fileUploadWorker.onmessage = (event) => {
@@ -374,6 +378,16 @@ class InitialView {
374378
case 'PROGRESS':
375379
this.fileUploaderComponent.updateProgress(msg.value * 100, msg.uploadedSize, msg.fileSize);
376380
break;
381+
case 'SOCKET_FAIL':
382+
this.fileUploaderComponent.showUploadError(
383+
this.i18n.FILE_UPLOAD_CONNECTION_FAILED ||
384+
'Something went wrong while connecting to the server.'
385+
);
386+
this.fileUploaderComponent.setEnabled(false);
387+
break;
388+
case 'SOCKET_SUCCESS':
389+
this.fileUploaderComponent.reset();
390+
break;
377391
default:
378392
break;
379393
}
@@ -483,7 +497,6 @@ class InitialView {
483497
dragDropText: this.i18n.DRAG_DROP_TEXT || 'DRAG & DROP APK FILE TO INSTALL',
484498
browseButtonText: this.i18n.BROWSE_BUTTON_TEXT || 'BROWSE',
485499
accept: '.apk',
486-
maxFileSize: 900,
487500
classes: 'gm-apk-uploader',
488501
i18n: this.plugin.i18n,
489502
});
@@ -496,6 +509,28 @@ class InitialView {
496509
container.appendChild(separator2);
497510
container.appendChild(apkSection);
498511

512+
// Attach the drag and drop events on root to handle the drag of an apk
513+
if (this.instance.store.state.isDragAndDropForUploadFileEnabled) {
514+
this.fileUploaderComponent.setEnabled(true);
515+
this.addListenerOnRoot();
516+
} else {
517+
this.fileUploaderComponent.setEnabled(false);
518+
this.removeListenerOnRoot();
519+
}
520+
521+
this.instance.store.subscribe(
522+
({isDragAndDropForUploadFileEnabled}) => {
523+
if (isDragAndDropForUploadFileEnabled) {
524+
this.fileUploaderComponent.setEnabled(true);
525+
this.addListenerOnRoot();
526+
} else {
527+
this.fileUploaderComponent.setEnabled(false);
528+
this.removeListenerOnRoot();
529+
}
530+
},
531+
['isDragAndDropForUploadFileEnabled'],
532+
);
533+
499534
return container;
500535
}
501536

@@ -511,6 +546,36 @@ class InitialView {
511546
const msg = {type: 'upload', file};
512547
this.fileUploadWorker.postMessage(msg);
513548
}
549+
550+
addListenerOnRoot() {
551+
this.removeListenerDragAndDropOver = this.instance.addListener(this.instance.root, 'dragover', (event) => {
552+
event.preventDefault();
553+
event.stopPropagation();
554+
});
555+
556+
this.removeListenerDragAndDropLeave =
557+
this.instance.addListener(this.instance.root, 'dragleave', (event) => {
558+
event.preventDefault();
559+
event.stopPropagation();
560+
});
561+
562+
this.removeListenerDragAndDropDrop =
563+
this.instance.addListener(this.instance.root, 'drop', (event) => {
564+
event.preventDefault();
565+
event.stopPropagation();
566+
567+
const file = event.dataTransfer.files[0];
568+
if (file && file.name && file.name.toLowerCase().endsWith('.apk')) {
569+
this.fileUploaderComponent.startUpload(file);
570+
}
571+
});
572+
}
573+
574+
removeListenerOnRoot() {
575+
this.removeListenerDragAndDropOver?.();
576+
this.removeListenerDragAndDropDrop?.();
577+
this.removeListenerDragAndDropLeave?.();
578+
}
514579
}
515580

516581
// Plugin main class
@@ -526,6 +591,7 @@ module.exports = class GAPPSInstall extends OverlayPlugin {
526591
this.instance.gappsInstall = this;
527592
this.instanciatedViews = new Map(); // Store rendered elements by view type
528593
this.currentViewType = null;
594+
this.viewAtNextopening = null;
529595
this.GAPPSInstalled = false;
530596

531597
this.registerToolbarButton();
@@ -684,6 +750,10 @@ module.exports = class GAPPSInstall extends OverlayPlugin {
684750
}
685751

686752
toggleWidget() {
753+
// if widget is opening laod the right view is needed
754+
if (this.viewAtNextopening && !this.instance.store.getters.isWidgetOpened(this.overlayID)) {
755+
this.setView(this.viewAtNextopening);
756+
}
687757
super.toggleWidget();
688758
}
689759
};

src/plugins/IOThrottling.js

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,17 @@ module.exports = class IOThrottling extends OverlayPlugin {
125125
value: '50',
126126
classes: 'gm-iothrottling-readbyterate',
127127
regexFilter: /^[0-9]*$/,
128+
messageField: true,
129+
onChange: (value) => {
130+
const num = Number(value);
131+
if (isNaN(num) || num < 0 || num > 4095) {
132+
this.readByteRate.setErrorMessage('0 to 4095');
133+
this.applyBtn.disabled = true;
134+
} else {
135+
this.readByteRate.setErrorMessage('');
136+
this.applyBtn.disabled = false;
137+
}
138+
}
128139
});
129140

130141
const readByteRateSpeedText = document.createElement('div');
@@ -151,13 +162,13 @@ module.exports = class IOThrottling extends OverlayPlugin {
151162

152163
statusDiv.appendChild(appliedTag.element);
153164

154-
const applyBtn = document.createElement('button');
155-
applyBtn.className = 'gm-btn';
156-
applyBtn.innerHTML = this.i18n.IOTHROTTLING_UPDATE || 'Apply';
157-
applyBtn.onclick = this.sendDataToInstance.bind(this);
165+
this.applyBtn = document.createElement('button');
166+
this.applyBtn.className = 'gm-btn';
167+
this.applyBtn.innerHTML = this.i18n.IOTHROTTLING_UPDATE || 'Apply';
168+
this.applyBtn.onclick = this.sendDataToInstance.bind(this);
158169

159170
applyBtnDiv.appendChild(statusDiv);
160-
applyBtnDiv.appendChild(applyBtn);
171+
applyBtnDiv.appendChild(this.applyBtn);
161172

162173
// Add clear cache button
163174
const clearCacheDiv = document.createElement('div');

0 commit comments

Comments
 (0)