Rebase to master when repo went private
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
.restore-backup {
|
||||
padding-top: 4px;
|
||||
}
|
||||
.restore-backup i{
|
||||
font-size: 2em;
|
||||
margin-left: 6px;
|
||||
margin-top: -3px;
|
||||
}
|
||||
.show-all {
|
||||
margin-top: 25px;
|
||||
}
|
||||
.small-text{
|
||||
font-size: 0.7rem;
|
||||
line-height: 25px;
|
||||
}
|
||||
#SearchPackage{
|
||||
color: white!important;
|
||||
}
|
||||
@@ -0,0 +1,212 @@
|
||||
<div class="container">
|
||||
|
||||
<div *ngIf="!isConnected()">
|
||||
<h4
|
||||
[ngClass]="{'text-dark-theme':appService.currentTheme === 'dark','text-light-theme':appService.currentTheme === 'light'}">
|
||||
No device connected...</h4>
|
||||
</div>
|
||||
<div *ngIf="isConnected()">
|
||||
<div class="row">
|
||||
<div class="input-field col s9">
|
||||
<input id="SearchPackage" [(ngModel)]="search" type="text" />
|
||||
<label for="SearchPackage">Search package</label>
|
||||
</div>
|
||||
<div class="col s3 right-align show-all">
|
||||
<div class="switch">
|
||||
<label>
|
||||
<input type="checkbox" [(ngModel)]="show_all" (change)="setShowAll()" />
|
||||
<span class="lever"></span>
|
||||
Show All
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="right waves-effect waves-light btn pink-button small-button" (click)="backupEverything.openModal()">
|
||||
Backup/Restore All</div>
|
||||
<div class="right waves-effect waves-light btn pink-button small-button margin-right" mzTooltip
|
||||
[tooltip]="'Current backup location: ' + appService.backupPath" position="bottom"
|
||||
(click)="pickLocation.openModal()">Change Backup Location</div>
|
||||
<br><br>
|
||||
<div class="row">
|
||||
<ng-container *ngFor="let package of myApps;">
|
||||
<app-package-item *ngIf="!search
|
||||
|| (package.name && package.name.indexOf(search)) > -1
|
||||
|| package.packageName.indexOf(search) > -1" [package]="package"
|
||||
(settings)="currentPackage = $event;appSettingsModal.openModal();getCurrentInstalledInfo()">
|
||||
</app-package-item>
|
||||
</ng-container>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<mz-modal #appSettingsModal [fixedFooter]="true">
|
||||
<mz-modal-header>
|
||||
<h4>App Settings</h4>
|
||||
</mz-modal-header>
|
||||
<mz-modal-content>
|
||||
|
||||
|
||||
<br>
|
||||
<div class="row no-margin">
|
||||
<div class="col s7">
|
||||
|
||||
<span class="chip">
|
||||
<img *ngIf="currentPackage.package.icon" [src]="currentPackage.package.icon">
|
||||
{{currentPackage.package.name?currentPackage.package.name:currentPackage.package.packageName}}
|
||||
</span><br>
|
||||
<div *ngIf="currentPackage.package.name" class="small-text">{{currentPackage.package.packageName}}</div>
|
||||
<div *ngIf="currentPackage.versionCode" class="small-text">Version: {{currentPackage.versionCode}}</div><br><br>
|
||||
<h4>APK Backups</h4>
|
||||
Backup your APK file from your device.<br><br>
|
||||
<a class="waves-effect waves-light btn backup-this-package margin-right"
|
||||
(click)="backupApk(currentPackage.package.packageName)">Backup APK File</a>
|
||||
<a class="waves-effect waves-light btn"
|
||||
(click)="appService.openFolder(folder.APP_BACKUP,currentPackage.package.packageName)">Open Backups</a><br><br>
|
||||
<div class="row" *ngFor="let backup of backups">
|
||||
<div class="col s1">
|
||||
<div class="chip cursor restore-backup tooltipped" data-position="right" data-tooltip="Restore this backup"
|
||||
(click)="installBackupApk(backup)">
|
||||
<i class="material-icons">sync</i>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col s11">
|
||||
<div class="chip">
|
||||
<span class="backup-name">{{showBackupFileName(backup)}}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<br><br>
|
||||
<h4>Game Data Backups</h4>
|
||||
Backup data files from your SD Card for this app/game.<br><br>
|
||||
<a class="waves-effect waves-light btn backup-this-package"
|
||||
(click)="backupData(currentPackage.package.packageName)">Backup Game Data</a><br><br>
|
||||
<div class="row" *ngFor="let backup of dataBackups">
|
||||
<div class="col s1">
|
||||
<div class="chip cursor restore-backup tooltipped" data-position="right" data-tooltip="Restore this backup"
|
||||
(click)="restoreBackup(showBackupFileName(backup))">
|
||||
<i class="material-icons">sync</i>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col s11">
|
||||
<div class="chip">
|
||||
<span class="backup-name">{{showBackupFileName(backup)}}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<br><br>
|
||||
</div>
|
||||
<div class="col s5">
|
||||
|
||||
<h4>Manage App</h4>
|
||||
<a class="waves-effect waves-light btn green" (click)="launchApp()">Launch App</a><br><br>
|
||||
<a class="waves-effect waves-light btn orange " (click)="forceClose()">Force Close App</a><br><br>
|
||||
<a class="waves-effect waves-light btn orange " (click)="clearData()">Clear App Data</a><br><br>
|
||||
<a class="waves-effect waves-light btn red " (click)="uninstallApk()">Uninstall App</a><br><br>
|
||||
|
||||
<br><br>
|
||||
|
||||
|
||||
<h4>Permissions</h4>
|
||||
<div>{{perms && !perms.length ? 'No permissions for this app...' : 'Manage permissions for this app.'}}</div>
|
||||
<br>
|
||||
<div class="row no-margin" *ngFor="let perm of perms">
|
||||
<div class="col s8 small-text">
|
||||
{{perm.display_permission}}
|
||||
</div>
|
||||
<div class="col s4">
|
||||
<div class="switch move-up">
|
||||
<label>
|
||||
<input type="checkbox" [(ngModel)]="perm.enabled" (change)="setPerm(perm)" />
|
||||
<span class="lever"></span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</mz-modal-content>
|
||||
<mz-modal-footer>
|
||||
<button mz-button [flat]="true" mz-modal-close>Close</button>
|
||||
</mz-modal-footer>
|
||||
</mz-modal>
|
||||
|
||||
|
||||
|
||||
<mz-modal #backupEverything [fixedFooter]="true">
|
||||
<mz-modal-header>
|
||||
<h4>
|
||||
<div class="right waves-effect waves-light btn pink-button small-button"
|
||||
(click)="isBackingUp = !isBackingUp;getMyBackups()">{{isBackingUp?'Change To Restore':'Change To Backup'}}</div>
|
||||
{{isBackingUp?'Backup':'Restore'}} Everything
|
||||
</h4>
|
||||
</mz-modal-header>
|
||||
<mz-modal-content>
|
||||
{{!isBackingUp?'WARNING: This will copy the latest available backup for each app to your device including the APK and the data files. It may overwrite existing files! This cannot be undone.':''}}
|
||||
<br *ngIf="!isBackingUp"><br *ngIf="!isBackingUp">
|
||||
This process can take a long time to complete, please do not restart SideQuest while the operation is running.
|
||||
Select which apps you want to backup/restore:
|
||||
<div class="clearfix"></div>
|
||||
<div class="waves-effect right waves-light btn pink-button small-button" (click)="selectAll()">Select All</div>
|
||||
<div class="waves-effect right waves-light btn pink-button small-button margin-right" (click)="deSelectAll()">
|
||||
Deselect All</div>
|
||||
<div class="clearfix"></div><br>
|
||||
|
||||
<ng-container *ngIf="!isBackingUp">
|
||||
<div class="row no-margin" *ngFor="let package of myBackups">
|
||||
<div class="col s9">
|
||||
<span class="chip">{{package.name}}</span>
|
||||
</div>
|
||||
<div class="col s3">
|
||||
<div class="switch">
|
||||
<label>
|
||||
<input type="checkbox" [(ngModel)]="package.isRestore" />
|
||||
<span class="lever"></span>
|
||||
Restore
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</ng-container>
|
||||
<ng-container *ngIf="isBackingUp">
|
||||
<div class="row no-margin" *ngFor="let package of myApps">
|
||||
<div class="col s9">
|
||||
<span class="chip"><img *ngIf="package.icon"
|
||||
[src]="package.icon">{{package.name?package.name:package.packageName}}</span>
|
||||
</div>
|
||||
<div class="col s3">
|
||||
<div class="switch">
|
||||
<label>
|
||||
<input type="checkbox" [(ngModel)]="package.backupAll" />
|
||||
<span class="lever"></span>
|
||||
Backup
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</ng-container>
|
||||
</mz-modal-content>
|
||||
<mz-modal-footer>
|
||||
<button mz-button [flat]="true" mz-modal-close>Close</button>
|
||||
<button mz-button class="pink-button"
|
||||
(click)="(isBackingUp?backupAll():restoreAll()); backupEverything.closeModal()">{{isBackingUp?'Run Backup':'Run Restore'}}</button>
|
||||
</mz-modal-footer>
|
||||
</mz-modal>
|
||||
|
||||
|
||||
<mz-modal #pickLocation [fixedFooter]="true">
|
||||
<mz-modal-header>
|
||||
<h4>Set the save location for backup data.</h4>
|
||||
</mz-modal-header>
|
||||
<mz-modal-content>
|
||||
<ng-container>
|
||||
Pick a location on your PC to save backup files:<br><br>
|
||||
<button mz-button class="pink-button" (click)="pickBackupLocation()">Select Location</button><br><br>
|
||||
Current Location: {{appService.backupPath}}
|
||||
</ng-container>
|
||||
</mz-modal-content>
|
||||
<mz-modal-footer>
|
||||
<button mz-button [flat]="true" mz-modal-close>Done</button>
|
||||
</mz-modal-footer>
|
||||
</mz-modal>
|
||||
@@ -0,0 +1,25 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { PackagesComponent } from './packages.component';
|
||||
|
||||
describe('PackagesComponent', () => {
|
||||
let component: PackagesComponent;
|
||||
let fixture: ComponentFixture<PackagesComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ PackagesComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(PackagesComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,272 @@
|
||||
import { Component, OnInit, ViewChild } from '@angular/core';
|
||||
import { AdbClientService, ConnectionStatus } from '../adb-client.service';
|
||||
import { AppService, FolderType } from '../app.service';
|
||||
import { LoadingSpinnerService } from '../loading-spinner.service';
|
||||
import { StatusBarService } from '../status-bar.service';
|
||||
import { ActivatedRoute, NavigationEnd, Router } from '@angular/router';
|
||||
import { Subscription } from 'rxjs/Subscription';
|
||||
import { RepoService } from '../repo.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-packages',
|
||||
templateUrl: './packages.component.html',
|
||||
styleUrls: ['./packages.component.css'],
|
||||
})
|
||||
export class PackagesComponent implements OnInit {
|
||||
@ViewChild('appSettingsModal', { static: false }) appSettingsModal;
|
||||
|
||||
folder = FolderType;
|
||||
currentPackage: any = { package: { packageName: '', name: '', icon: '' }, versionCode: 0 };
|
||||
routerPackage: string;
|
||||
backups: string[];
|
||||
dataBackups: string[];
|
||||
myApps: any[];
|
||||
myBackups: any[];
|
||||
isBackingUp = true;
|
||||
isOpen: boolean;
|
||||
sub: Subscription;
|
||||
show_all: boolean;
|
||||
search: string;
|
||||
savePath: string;
|
||||
perms: any;
|
||||
constructor(
|
||||
public adbService: AdbClientService,
|
||||
public appService: AppService,
|
||||
public spinnerService: LoadingSpinnerService,
|
||||
public statusService: StatusBarService,
|
||||
private repoService: RepoService,
|
||||
router: Router,
|
||||
route: ActivatedRoute
|
||||
) {
|
||||
appService.webService.isWebviewOpen = false;
|
||||
appService.resetTop();
|
||||
appService.isPackagesOpen = true;
|
||||
this.appService.setTitle('Installed Apps');
|
||||
this.sub = router.events.subscribe(val => {
|
||||
if (val instanceof NavigationEnd) {
|
||||
this.routerPackage = route.snapshot.paramMap.get('packageName');
|
||||
}
|
||||
});
|
||||
this.show_all = !!localStorage.getItem('packages_show_all');
|
||||
}
|
||||
|
||||
setShowAll() {
|
||||
if (this.show_all) {
|
||||
localStorage.setItem('packages_show_all', 'true');
|
||||
} else {
|
||||
localStorage.removeItem('packages_show_all');
|
||||
}
|
||||
this.isOpen = false;
|
||||
}
|
||||
|
||||
deSelectAll() {
|
||||
if (this.isBackingUp) {
|
||||
this.myApps.forEach(a => (a.backupAll = false));
|
||||
} else {
|
||||
this.myBackups.forEach(a => (a.isRestore = false));
|
||||
}
|
||||
}
|
||||
|
||||
selectAll() {
|
||||
if (this.isBackingUp) {
|
||||
this.myApps.forEach(a => (a.backupAll = true));
|
||||
} else {
|
||||
this.myBackups.forEach(a => (a.isRestore = true));
|
||||
}
|
||||
}
|
||||
|
||||
setPerm(perm) {
|
||||
this.adbService.setPermission(this.currentPackage.package.packageName, perm.permission, !perm.enabled);
|
||||
}
|
||||
|
||||
pickBackupLocation() {
|
||||
this.appService.electron.remote.dialog.showOpenDialog(
|
||||
{
|
||||
properties: ['openDirectory'],
|
||||
defaultPath: this.appService.backupPath,
|
||||
},
|
||||
files => {
|
||||
if (files !== undefined && files.length === 1) {
|
||||
this.appService.backupPath = files[0];
|
||||
localStorage.setItem('backup-path', this.appService.backupPath);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
backupAll() {
|
||||
this.myApps
|
||||
.filter(d => d.backupAll)
|
||||
.forEach(d => {
|
||||
this.backupApk(d.packageName).then(() => this.backupData(d.packageName));
|
||||
});
|
||||
this.statusService.showStatus('Backing up all the selected apps. Check the Tasks screen for more information.');
|
||||
}
|
||||
|
||||
restoreAll() {
|
||||
this.myBackups
|
||||
.filter(d => d.isRestore)
|
||||
.forEach((d: any) => {
|
||||
if (d.dataBackups.length) {
|
||||
this.adbService.restoreDataBackup(d.name, this.showBackupFileName(d.dataBackups[0]));
|
||||
}
|
||||
if (d.backups.length) {
|
||||
this.adbService.installAPK(d.backups[0], true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
ngOnInit() {}
|
||||
isConnected() {
|
||||
let isConnected = this.adbService.deviceStatus === ConnectionStatus.CONNECTED;
|
||||
if (isConnected && !this.isOpen) {
|
||||
this.isOpen = true;
|
||||
this.adbService
|
||||
.getPackages(this.show_all)
|
||||
.then(() => {
|
||||
this.myApps = this.adbService.devicePackages
|
||||
.map(p => {
|
||||
if (this.repoService.allApps[p]) {
|
||||
return {
|
||||
name: this.repoService.allApps[p].name,
|
||||
icon: this.repoService.allApps[p].icon,
|
||||
packageName: p,
|
||||
};
|
||||
}
|
||||
return {
|
||||
packageName: p,
|
||||
};
|
||||
})
|
||||
.sort((a, b) => {
|
||||
let textA = (a.name || a.packageName).toUpperCase();
|
||||
let textB = (b.name || b.packageName).toUpperCase();
|
||||
return textA < textB ? -1 : textA > textB ? 1 : 0;
|
||||
});
|
||||
this.myApps.forEach(p => {
|
||||
if (this.routerPackage && p.packageName === this.routerPackage) {
|
||||
this.currentPackage.package = p;
|
||||
}
|
||||
});
|
||||
|
||||
if (
|
||||
this.currentPackage.package.packageName &&
|
||||
~this.adbService.devicePackages.indexOf(this.currentPackage.package.packageName)
|
||||
) {
|
||||
this.appSettingsModal.openModal();
|
||||
} else if (this.currentPackage.package.packageName) {
|
||||
this.statusService.showStatus(
|
||||
'App not installed...' + (this.currentPackage.package ? this.currentPackage.package.packageName : ''),
|
||||
true
|
||||
);
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
this.statusService.showStatus(
|
||||
'Warning: Cannot retrieve information from the headset, try another USB cable or port. Try a USB2 port.',
|
||||
true
|
||||
);
|
||||
});
|
||||
}
|
||||
return isConnected;
|
||||
}
|
||||
ngAfterViewInit() {}
|
||||
|
||||
async getBackupFiles(file) {
|
||||
file.isDirectory = this.appService.fs.lstatSync(file.path).isDirectory();
|
||||
if (file.isDirectory) {
|
||||
file.backups = await this.adbService.getBackups(file.name);
|
||||
file.dataBackups = await this.adbService.getDataBackups(file.name);
|
||||
}
|
||||
return file;
|
||||
}
|
||||
|
||||
getMyBackups() {
|
||||
if (this.isBackingUp) return;
|
||||
let backupPath = this.appService.path.join(this.appService.backupPath);
|
||||
let backups = this.appService.fs
|
||||
.readdirSync(backupPath)
|
||||
.map(file => ({ name: file, path: this.appService.path.join(backupPath, file), isRestore: false }));
|
||||
Promise.all(backups.map((file: any) => this.getBackupFiles(file))).then(files => {
|
||||
this.myBackups = files.filter((file: any) => {
|
||||
return file.isDirectory && (file.backups.length || file.dataBackups.length);
|
||||
});
|
||||
});
|
||||
}
|
||||
getCurrentInstalledInfo() {
|
||||
this.adbService
|
||||
.getBackups(this.currentPackage.package.packageName)
|
||||
.then(backups => (this.backups = backups))
|
||||
.then(() => this.adbService.getAppVersionCode(this.currentPackage.package.packageName))
|
||||
.then(version => (this.currentPackage.versionCode = version))
|
||||
.then(() => this.adbService.getPackagePermissions(this.currentPackage.package.packageName))
|
||||
.then(perms => {
|
||||
perms.forEach((p: any) => {
|
||||
const perm_split = p.permission.split('.');
|
||||
p.display_permission = perm_split[perm_split.length - 1];
|
||||
});
|
||||
this.perms = perms;
|
||||
})
|
||||
.then(() => this.adbService.getDataBackups(this.currentPackage.package.packageName))
|
||||
.then(dataBackups => (this.dataBackups = dataBackups));
|
||||
}
|
||||
async backupApk(packageName: string) {
|
||||
this.appSettingsModal.closeModal();
|
||||
let location = await this.adbService.getPackageLocation(packageName);
|
||||
this.adbService.backupPackage(location, packageName).then(savePath => {
|
||||
// if (
|
||||
// packageName === this.bsaberService.beatSaberPackage &&
|
||||
// !this.bsaberService.backupExists()
|
||||
// ) {
|
||||
// this.appService.fs.copyFileSync(savePath, this.appService.path.join(this.appService.appData, 'bsaber-base.apk'));
|
||||
// this.appService.fs.copyFileSync(
|
||||
// savePath,
|
||||
// this.appService.path.join(this.appService.appData, 'bsaber-base_patched.apk')
|
||||
// );
|
||||
// }
|
||||
});
|
||||
}
|
||||
backupData(packageName) {
|
||||
this.appSettingsModal.closeModal();
|
||||
this.adbService.makeDataBackup(packageName);
|
||||
}
|
||||
showBackupFileName(file) {
|
||||
return this.appService.path.basename(file);
|
||||
}
|
||||
restoreBackup(backup: string) {
|
||||
this.appSettingsModal.closeModal();
|
||||
this.adbService
|
||||
.restoreDataBackup(this.currentPackage.package.packageName, backup)
|
||||
.then(() => this.statusService.showStatus('Backup restored ok!!'));
|
||||
}
|
||||
installBackupApk(filePath) {
|
||||
this.appSettingsModal.closeModal();
|
||||
this.adbService.installAPK(filePath, true);
|
||||
}
|
||||
uninstallApk() {
|
||||
this.appSettingsModal.closeModal();
|
||||
this.adbService.uninstallAPK(this.currentPackage.package.packageName);
|
||||
}
|
||||
launchApp() {
|
||||
this.adbService.launchApp(this.currentPackage.package.packageName);
|
||||
}
|
||||
forceClose() {
|
||||
this.adbService
|
||||
.adbCommand('shell', {
|
||||
serial: this.adbService.deviceSerial,
|
||||
command: 'am force-stop ' + this.currentPackage.package.packageName,
|
||||
})
|
||||
.then(r => {
|
||||
this.statusService.showStatus('Force Close Sent!!');
|
||||
});
|
||||
}
|
||||
clearData() {
|
||||
this.adbService
|
||||
.adbCommand('clear', {
|
||||
serial: this.adbService.deviceSerial,
|
||||
packageName: this.currentPackage.package.packageName,
|
||||
})
|
||||
.then(r => {
|
||||
this.statusService.showStatus('Clear Data Sent!!');
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user