active morelocale

This commit is contained in:
karl.hudgell 2020-04-27 12:24:32 +01:00
parent f531e0641f
commit 7899d50a30

View File

@ -68,7 +68,7 @@ module.exports = {
} }
}); });
} else { } else {
await shellExec('./adb install -r ' + element).then(function (result) { await shellExec('./adb install -r ' + element).then(async function (result) {
console.log(element + ' - ' + result.stdout); console.log(element + ' - ' + result.stdout);
if (element === "data\\apps\\MoreLocale.apk") { if (element === "data\\apps\\MoreLocale.apk") {
await shellExec('./adb shell pm grant jp.co.c_lis.ccl.morelocale android.permission.CHANGE_CONFIGURATION').then(function (result) { await shellExec('./adb shell pm grant jp.co.c_lis.ccl.morelocale android.permission.CHANGE_CONFIGURATION').then(function (result) {
@ -76,14 +76,13 @@ module.exports = {
}); });
} }
}); });
}); }
} }
} console.log(chalk.green('Compatible Apps Installed'))
console.log(chalk.green('Compatible Apps Installed')) await common.pause(2000)
await common.pause(2000) module.exports.mainMenu()
module.exports.mainMenu() },
}, removeApps: async () => {
removeApps: async () => {
common.header('Remove Apps') common.header('Remove Apps')
const value = await inquirer.removeAppsList(); const value = await inquirer.removeAppsList();
for (let element of value.removeAppsList) { for (let element of value.removeAppsList) {
@ -102,114 +101,114 @@ removeApps: async () => {
module.exports.mainMenu() module.exports.mainMenu()
}, },
restoreApps: async () => { restoreApps: async () => {
common.header('Restore Apps') common.header('Restore Apps')
const value = await inquirer.removeAppsList(); const value = await inquirer.removeAppsList();
for (let element of value.removeAppsList) { for (let element of value.removeAppsList) {
if (process.platform === 'win32' || process.platform === 'win64') { if (process.platform === 'win32' || process.platform === 'win64') {
await shellExec('adb shell cmd package install-existing ' + element).then(function (result) { await shellExec('adb shell cmd package install-existing ' + element).then(function (result) {
console.log('Restoring ' + element + ' - ' + result.stdout); console.log('Restoring ' + element + ' - ' + result.stdout);
}); });
} else { } else {
await shellExec('./adb shell cmd package install-existing ' + element).then(function (result) { await shellExec('./adb shell cmd package install-existing ' + element).then(function (result) {
console.log('Restoring ' + element + ' - ' + result.stdout); console.log('Restoring ' + element + ' - ' + result.stdout);
}); });
}
} }
console.log(chalk.green('Restore Complete')) }
await common.pause(2000) console.log(chalk.green('Restore Complete'))
module.exports.mainMenu() await common.pause(2000)
}, module.exports.mainMenu()
connectWifi: async () => { },
const miwatchData = JSON.parse(fs.readFileSync('./data/MiWatch.json', 'utf8')); connectWifi: async () => {
common.header('Connect Wifi') const miwatchData = JSON.parse(fs.readFileSync('./data/MiWatch.json', 'utf8'));
if (miwatchData.ipAddress !== "") { common.header('Connect Wifi')
console.log('Trying to connect with stored ipAddress') if (miwatchData.ipAddress !== "") {
if (process.platform === 'win32' || process.platform === 'win64') { console.log('Trying to connect with stored ipAddress')
shellExec('adb connect ' + miwatchData.ipAddress).then(async function (result) { if (process.platform === 'win32' || process.platform === 'win64') {
if (result.stdout.includes('already connected') || result.stdout.includes('connected to ')) { shellExec('adb connect ' + miwatchData.ipAddress).then(async function (result) {
console.log(chalk.green('MiWatch Connected')) if (result.stdout.includes('already connected') || result.stdout.includes('connected to ')) {
await common.pause(3000) console.log(chalk.green('MiWatch Connected'))
module.exports.mainMenu() await common.pause(3000)
} else { module.exports.mainMenu()
console.log(chalk.red('MiWatch not found'))
await common.pause(2000)
console.log(chalk.white('Try Again'))
await common.pause(1000)
module.exports.connectWifi()
}
}).catch()
} else { } else {
shellExec('./adb connect ' + miwatchData.ipAddress).then(async function (result) { console.log(chalk.red('MiWatch not found'))
if (result.stdout.includes('already connected') || result.stdout.includes('connected to ')) { await common.pause(2000)
console.log(chalk.green('MiWatch Connected')) console.log(chalk.white('Try Again'))
files.writeIpAddress(miWatchIpaddress) await common.pause(1000)
await common.pause(3000)
module.exports.mainMenu()
} else {
console.log(chalk.red('MiWatch not found'))
await common.pause(2000)
console.log(chalk.white('Try Again'))
await common.pause(1000)
module.exports.connectWifi()
}
}).catch()
}
} else {
const value = await inquirer.connectWifi();
const miWatchIpaddress = value.connectWifi
if (process.platform === 'win32' || process.platform === 'win64') {
shellExec('adb connect ' + miWatchIpaddress).then(async function (result) {
if (result.stdout.includes('already connected') || result.stdout.includes('connected to ')) {
console.log(chalk.green('MiWatch Connected'))
files.writeIpAddress(miWatchIpaddress)
await common.pause(3000)
module.exports.mainMenu()
} else {
console.log(chalk.red('MiWatch not found'))
await common.pause(2000)
console.log(chalk.white('Try Again'))
await common.pause(1000)
module.exports.connectWifi()
}
}).catch()
} else {
shellExec('./adb connect ' + miWatchIpaddress).then(async function (result) {
if (result.stdout.includes('already connected') || result.stdout.includes('connected to ')) {
console.log(chalk.green('MiWatch Connected'))
files.writeIpAddress(miWatchIpaddress)
await common.pause(3000)
module.exports.mainMenu()
} else {
console.log(chalk.red('MiWatch not found'))
await common.pause(2000)
console.log(chalk.white('Try Again'))
await common.pause(1000)
module.exports.connectWifi()
}
}).catch()
}
}
},
mainMenu: async () => {
common.header('Main Menu')
const mainMenuSelection = await inquirer.mainMenu();
switch (mainMenuSelection.mainMenu) {
case 'connect to miwatch via wifi':
module.exports.connectWifi() module.exports.connectWifi()
break; }
case 'remove xiaomi apps': }).catch()
module.exports.removeApps() } else {
break; shellExec('./adb connect ' + miwatchData.ipAddress).then(async function (result) {
case 'restore xiaomi apps': if (result.stdout.includes('already connected') || result.stdout.includes('connected to ')) {
module.exports.restoreApps() console.log(chalk.green('MiWatch Connected'))
break; files.writeIpAddress(miWatchIpaddress)
case 'install compatible apps': await common.pause(3000)
module.exports.compatibleApps() module.exports.mainMenu()
break; } else {
case 'quit': console.log(chalk.red('MiWatch not found'))
break; await common.pause(2000)
default: console.log(chalk.white('Try Again'))
// code block await common.pause(1000)
} module.exports.connectWifi()
}
}).catch()
} }
} else {
const value = await inquirer.connectWifi();
const miWatchIpaddress = value.connectWifi
if (process.platform === 'win32' || process.platform === 'win64') {
shellExec('adb connect ' + miWatchIpaddress).then(async function (result) {
if (result.stdout.includes('already connected') || result.stdout.includes('connected to ')) {
console.log(chalk.green('MiWatch Connected'))
files.writeIpAddress(miWatchIpaddress)
await common.pause(3000)
module.exports.mainMenu()
} else {
console.log(chalk.red('MiWatch not found'))
await common.pause(2000)
console.log(chalk.white('Try Again'))
await common.pause(1000)
module.exports.connectWifi()
}
}).catch()
} else {
shellExec('./adb connect ' + miWatchIpaddress).then(async function (result) {
if (result.stdout.includes('already connected') || result.stdout.includes('connected to ')) {
console.log(chalk.green('MiWatch Connected'))
files.writeIpAddress(miWatchIpaddress)
await common.pause(3000)
module.exports.mainMenu()
} else {
console.log(chalk.red('MiWatch not found'))
await common.pause(2000)
console.log(chalk.white('Try Again'))
await common.pause(1000)
module.exports.connectWifi()
}
}).catch()
}
}
},
mainMenu: async () => {
common.header('Main Menu')
const mainMenuSelection = await inquirer.mainMenu();
switch (mainMenuSelection.mainMenu) {
case 'connect to miwatch via wifi':
module.exports.connectWifi()
break;
case 'remove xiaomi apps':
module.exports.removeApps()
break;
case 'restore xiaomi apps':
module.exports.restoreApps()
break;
case 'install compatible apps':
module.exports.compatibleApps()
break;
case 'quit':
break;
default:
// code block
}
}
}; };