This commit is contained in:
Your Name
2020-08-17 13:31:48 +01:00
parent ac30232f80
commit 8afc8214da
8 changed files with 39 additions and 40 deletions
Binary file not shown.
+19 -22
View File
@@ -57,8 +57,7 @@ export class AdbClientService {
private statusService: StatusBarService, private statusService: StatusBarService,
private beatonService: BeatOnService, private beatonService: BeatOnService,
private webService: WebviewService, private webService: WebviewService,
public processService: ProcessBucketService, public processService: ProcessBucketService
public safeSideService: SafeSideService
) { ) {
this.lastConnectionCheck = performance.now() - 4000; this.lastConnectionCheck = performance.now() - 4000;
this.adbPath = appService.path.join(appService.appData, 'platform-tools'); this.adbPath = appService.path.join(appService.appData, 'platform-tools');
@@ -122,11 +121,10 @@ export class AdbClientService {
case '.apk': case '.apk':
return this.installAPK(filepath, true); return this.installAPK(filepath, true);
case '.obb': case '.obb':
if (this.appService.path.basename(filepath).match(/main.[0-9]{1,}.[a-z]{1,}.[A-z]{1,}.[A-z]{1,}.obb/)) { return this.processService.addItem('file_install', async task => {
return this.installLocalObb(filepath).then(() => this.spinnerService.hideLoader()); task.status = 'Transferring OBB file...';
} else { return this.installLocalObb(filepath, false, null, 0, 0, task);
return Promise.reject('Invalid OBB'); });
}
case '.zip': case '.zip':
return this.processService.addItem('file_install', async task => { return this.processService.addItem('file_install', async task => {
return this.installLocalZip(filepath, false, () => this.spinnerService.hideLoader(), task, true); return this.installLocalZip(filepath, false, () => this.spinnerService.hideLoader(), task, true);
@@ -518,22 +516,19 @@ export class AdbClientService {
task => { task => {
name = name ? name + ': ' : ''; name = name ? name + ': ' : '';
if (this.deviceStatus !== ConnectionStatus.CONNECTED) { if (this.deviceStatus !== ConnectionStatus.CONNECTED) {
return Promise.reject(name + 'Apk install failed - No device connected! ' + filePath); return Promise.reject(name + 'Apk install failed - No device connected!');
} }
const showTotal = number && total ? '(' + number + '/' + total + ') ' : ''; const showTotal = number && total ? '(' + number + '/' + total + ') ' : '';
task.app_name = name; task.app_name = name;
task.status = name + showTotal + 'Installing Apk... '; task.status = name + showTotal + 'Installing Apk... ';
return this.adbCommand('install', { serial: this.deviceSerial, path: filePath, isLocal: !!isLocal }, status => { return this.adbCommand('install', { serial: this.deviceSerial, path: filePath, isLocal: !!isLocal }, status => {
task.status = task.status =
(status.percent === 1 status.percent === 1
? name + showTotal + 'Installing Apk... ' ? name + showTotal + 'Installing Apk...'
: name + showTotal + 'Downloading APK... ' + Math.round(status.percent * 100) + '% ') + : name + showTotal + 'Downloading APK... ' + Math.round(status.percent * 100) + '% ';
' <span style="font-style:italic">' +
filePath +
'</span>';
}) })
.then(r => { .then(r => {
task.status = name + 'APK file installed ok!! ' + filePath; task.status = name + 'APK file installed ok!!';
if (deleteAfter) { if (deleteAfter) {
this.appService.fs.unlink(filePath, err => {}); this.appService.fs.unlink(filePath, err => {});
} }
@@ -559,7 +554,11 @@ export class AdbClientService {
if (deleteAfter) { if (deleteAfter) {
this.appService.fs.unlink(filePath, err => {}); this.appService.fs.unlink(filePath, err => {});
} }
return Promise.reject(e.message ? e.message : e.code ? e.code : e.toString() + ' ' + filePath); let er = e.message ? e.message : e.code ? e.code : e.toString();
if (er === 'SAFESIDE') {
this.appService.headerComponent.safeModal.openModal();
}
return Promise.reject(er);
}); });
}, },
name name
@@ -905,7 +904,7 @@ export class AdbClientService {
installLocalObb(filepath: string, dontCatchError = false, cb = null, number?: number, total?: number, task?, name?: string) { installLocalObb(filepath: string, dontCatchError = false, cb = null, number?: number, total?: number, task?, name?: string) {
let filename = this.appService.path.basename(filepath); let filename = this.appService.path.basename(filepath);
let packageId = filename.match(/main.[0-9]{1,}.([A-z0-9.]{1,}).obb/)[1]; let packageId = filename.match(/main.[0-9]{1,}.([A-z0-9.]{1,}).obb/)[1];
console.log(packageId); name = name || packageId;
const showTotal = number && total ? '(' + number + '/' + total + ') ' : ''; const showTotal = number && total ? '(' + number + '/' + total + ') ' : '';
if (!task) this.spinnerService.showLoader(); if (!task) this.spinnerService.showLoader();
let p = this.runAdbCommand('adb push "' + filepath + '" /sdcard/Android/obb/' + packageId + '/' + filename); let p = this.runAdbCommand('adb push "' + filepath + '" /sdcard/Android/obb/' + packageId + '/' + filename);
@@ -914,7 +913,7 @@ export class AdbClientService {
} }
p = p.then(() => { p = p.then(() => {
if (task) { if (task) {
task.status = name + 'File transferred successfully! ' + filepath; task.status = name + ' File transferred successfully! ';
} else { } else {
this.statusService.showStatus('File transferred successfully!'); this.statusService.showStatus('File transferred successfully!');
} }
@@ -923,7 +922,7 @@ export class AdbClientService {
p = p.catch(e => { p = p.catch(e => {
if (task) { if (task) {
task.failed = true; task.failed = true;
task.status = name + 'Failed to transfer file!! - ' + filepath; task.status = name + ' Failed to transfer file!!';
} else { } else {
this.spinnerService.hideLoader(); this.spinnerService.hideLoader();
this.statusService.showStatus(e.toString(), true); this.statusService.showStatus(e.toString(), true);
@@ -940,7 +939,7 @@ export class AdbClientService {
'.obb': filepath => { '.obb': filepath => {
if (this.appService.path.basename(filepath).match(/main.[0-9]{1,}.[a-z]{1,}.[A-z]{1,}.[A-z]{1,}.obb/)) { if (this.appService.path.basename(filepath).match(/main.[0-9]{1,}.[a-z]{1,}.[A-z]{1,}.[A-z]{1,}.obb/)) {
this.processService.addItem('file_install', async task => { this.processService.addItem('file_install', async task => {
return this.installLocalObb(filepath, false, null, 1, 1, task).then(() => { return this.installLocalObb(filepath, false, null, 1, 1, task, '').then(() => {
if (deleteAfter) { if (deleteAfter) {
this.appService.fs.unlink(filepath, err => {}); this.appService.fs.unlink(filepath, err => {});
} }
@@ -951,8 +950,6 @@ export class AdbClientService {
} }
}, },
}; };
//this.cleanUpFolder();
return new Promise(resolve => { return new Promise(resolve => {
if (task) { if (task) {
task.status = 'Extracting zip file download...'; task.status = 'Extracting zip file download...';
@@ -353,7 +353,7 @@
<mz-modal #logcatModal [fixedFooter]="true" [options]="{dismissible: false}"> <mz-modal #logcatModal [fixedFooter]="true" [options]="{dismissible: false}">
<mz-modal-header> <mz-modal-header>
<button mz-button class="right" [flat]="true" mz-modal-close (click)="stopLogcat(); currentLogCat.length = 0; isStarted = false;">Stop & Close</button> <button mz-button class="right" [flat]="true" mz-modal-close (click)="stopLogcat(); currentLogCat.length = 0; isStarted = false;">Stop & Close</button>
<button mz-button class="right" [flat]="true" (click)="stopLogcat(); currentLogCat.length = 0; isStarted = false;">Stop Only</button> <button mz-button class="right" [flat]="true" (click)="stopLogcat(); isStarted = false;">Stop Only</button>
<h4>ADB Logcat</h4> <h4>ADB Logcat</h4>
</mz-modal-header> </mz-modal-header>
<mz-modal-content> <mz-modal-content>
@@ -425,8 +425,7 @@
Thank you and have a great day! Thank you and have a great day!
</mz-modal-content> </mz-modal-content>
<mz-modal-footer> <mz-modal-footer>
<button mz-button mz-modal-close [flat]="true" (click)="safeResolve('DoInstall')">Continue ( Not Recommended )</button> <button mz-button class="pink-button" mz-modal-close>Back to Safety</button>
<button mz-button class="pink-button" mz-modal-close (click)="safeResolve('DontInstall')">Back to Safety</button>
</mz-modal-footer> </mz-modal-footer>
</mz-modal> </mz-modal>
@@ -586,7 +585,6 @@
</mz-modal-footer> </mz-modal-footer>
</mz-modal> </mz-modal>
<mz-modal #manageFavs [fixedFooter]="true"> <mz-modal #manageFavs [fixedFooter]="true">
<mz-modal-header> <mz-modal-header>
<button mz-button class="right pink-button" (click)="showAddFavourite = !showAddFavourite">{{showAddFavourite? 'Hide' : 'Add New'}}</button> <button mz-button class="right pink-button" (click)="showAddFavourite = !showAddFavourite">{{showAddFavourite? 'Hide' : 'Add New'}}</button>
@@ -39,11 +39,8 @@ export class HeaderComponent implements OnInit {
@ViewChild('beatOnModal', { static: false }) beatOnModal; @ViewChild('beatOnModal', { static: false }) beatOnModal;
@ViewChild('mainLogo', { static: false }) mainLogo; @ViewChild('mainLogo', { static: false }) mainLogo;
@ViewChild('safeModal', { static: false }) safeModal; @ViewChild('safeModal', { static: false }) safeModal;
safeResolve: any = val => val;
folder = FolderType; folder = FolderType;
addrepoUrl: string = ''; isAlive = true;
isAlive: boolean = true;
isAliveChecking: boolean = false;
replaceText: ReplaceText[] = []; replaceText: ReplaceText[] = [];
adbCommandToRun: string; adbCommandToRun: string;
osPlatform: string; osPlatform: string;
@@ -97,11 +94,8 @@ export class HeaderComponent implements OnInit {
public webService: WebviewService, public webService: WebviewService,
public spinnerService: LoadingSpinnerService, public spinnerService: LoadingSpinnerService,
public statusService: StatusBarService, public statusService: StatusBarService,
public repoService: RepoService,
public beatonService: BeatOnService, public beatonService: BeatOnService,
public dragAndDropService: DragAndDropService, public dragAndDropService: DragAndDropService,
// private dragulaService: DragulaService,
public router: Router,
public processService: ProcessBucketService public processService: ProcessBucketService
) { ) {
this.osPlatform = this.appService.os.platform(); this.osPlatform = this.appService.os.platform();
@@ -16,3 +16,6 @@
#SearchPackage{ #SearchPackage{
color: white!important; color: white!important;
} }
.backup-name{
line-height: 30px;
}
@@ -63,14 +63,14 @@
<a class="waves-effect waves-light btn backup-this-package" <a class="waves-effect waves-light btn backup-this-package"
(click)="backupData(currentPackage.package.packageName)">Backup Game Data</a><br><br> (click)="backupData(currentPackage.package.packageName)">Backup Game Data</a><br><br>
<div class="row" *ngFor="let backup of dataBackups"> <div class="row" *ngFor="let backup of dataBackups">
<div class="col s3 m2 l1"> <div class="col s3">
<div class="chip cursor restore-backup tooltipped" data-position="right" data-tooltip="Restore this backup" <div class="chip cursor restore-backup tooltipped" data-position="right" data-tooltip="Restore this backup"
(click)="restoreBackup(showBackupFileName(backup))"> (click)="restoreBackup(showBackupFileName(backup))">
<i class="material-icons">sync</i> <i class="material-icons">sync</i>
</div> </div>
</div> </div>
<div class="col s6 s10 l11"> <div class="col s9">
<div class="chip"> <div class="">
<span class="backup-name">{{showBackupFileName(backup)}}</span> <span class="backup-name">{{showBackupFileName(backup)}}</span>
</div> </div>
</div> </div>
@@ -83,14 +83,14 @@
<a class="waves-effect waves-light btn" <a class="waves-effect waves-light btn"
(click)="appService.openFolder(folder.APP_BACKUP,currentPackage.package.packageName)">Open Backups</a><br><br> (click)="appService.openFolder(folder.APP_BACKUP,currentPackage.package.packageName)">Open Backups</a><br><br>
<div class="row" *ngFor="let backup of backups"> <div class="row" *ngFor="let backup of backups">
<div class="col s1"> <div class="col s3">
<div class="chip cursor restore-backup tooltipped" data-position="right" data-tooltip="Restore this backup" <div class="chip cursor restore-backup tooltipped" data-position="right" data-tooltip="Restore this backup"
(click)="installBackupApk(backup)"> (click)="installBackupApk(backup)">
<i class="material-icons">sync</i> <i class="material-icons">sync</i>
</div> </div>
</div> </div>
<div class="col s11"> <div class="col s9">
<div class="chip"> <div class="">
<span class="backup-name">{{showBackupFileName(backup)}}</span> <span class="backup-name">{{showBackupFileName(backup)}}</span>
</div> </div>
</div> </div>
@@ -20,6 +20,7 @@ export interface ProcessTask {
}) })
export class ProcessBucketService { export class ProcessBucketService {
tasks: ProcessTask[]; tasks: ProcessTask[];
currentTask: ProcessTask;
is_running: boolean; is_running: boolean;
left_length: number; left_length: number;
failed_length: number; failed_length: number;
@@ -84,12 +85,14 @@ export class ProcessBucketService {
if (objects.length) { if (objects.length) {
this.is_running = true; this.is_running = true;
let task = objects[0]; let task = objects[0];
this.currentTask = task;
task.running = true; task.running = true;
await task await task
.resolve(task) .resolve(task)
.then(() => { .then(() => {
task.running = false; task.running = false;
task.succeeded = true; task.succeeded = true;
this.currentTask = null;
if (!task.cancelled) { if (!task.cancelled) {
return timeout.then(() => this.processBucket()); return timeout.then(() => this.processBucket());
} }
@@ -99,6 +102,7 @@ export class ProcessBucketService {
task.status = task.status =
(task.app_name ? task.app_name + ': ' : '') + (e.message ? e.message : e.code ? e.code : e.toString()); (task.app_name ? task.app_name + ': ' : '') + (e.message ? e.message : e.code ? e.code : e.toString());
task.failed = true; task.failed = true;
this.currentTask = null;
this.statusService.showStatus(task.status, true); this.statusService.showStatus(task.status, true);
if (!task.cancelled) { if (!task.cancelled) {
return timeout.then(() => this.processBucket()); return timeout.then(() => this.processBucket());
@@ -151,6 +155,9 @@ export class ProcessBucketService {
this.tasks = this.tasks.filter(t => !t.failed); this.tasks = this.tasks.filter(t => !t.failed);
} }
clearAll() { clearAll() {
if (this.currentTask) {
this.skipCurrent(this.currentTask);
}
this.tasks = []; this.tasks = [];
} }
} }
+1 -1
View File
@@ -8,7 +8,7 @@
"main": "build-electron/boot.js", "main": "build-electron/boot.js",
"scripts": { "scripts": {
"concurrently": "concurrently", "concurrently": "concurrently",
"start": "concurrently \"yarn electron-build && wait-on http-get://localhost:4205/ && cross-env NODE_ENV=dev electron .\" \"cd desktop-app && ng serve --port 4205\"", "start": "concurrently \"yarn electron-build && yarn platform-tools && wait-on http-get://localhost:4205/ && cross-env NODE_ENV=dev electron .\" \"cd desktop-app && ng serve --port 4205\"",
"postinstall": "electron-builder install-app-deps && cd desktop-app && yarn install", "postinstall": "electron-builder install-app-deps && cd desktop-app && yarn install",
"dist": "yarn electron-build && yarn platform-tools && yarn app-build && electron-builder", "dist": "yarn electron-build && yarn platform-tools && yarn app-build && electron-builder",
"angular": "cd desktop-app && ng serve --port 4205", "angular": "cd desktop-app && ng serve --port 4205",