Răsfoiți Sursa

remove any app

karl.hudgell 4 ani în urmă
părinte
comite
63cd59c6a1
5 a modificat fișierele cu 55 adăugiri și 21 ștergeri
  1. 7 4
      lang/en.json
  2. 7 4
      lang/es.json
  3. 12 0
      lib/adb.js
  4. 9 0
      lib/inquirer.js
  5. 20 13
      pages/pages.js

+ 7 - 4
lang/en.json

@@ -5,9 +5,10 @@
     "main-menu-item-3": "Restore Xiaomi Apps",
     "main-menu-item-4": "Install Compatible Apps",
     "main-menu-item-5": "Restore ANY app",
-    "main-menu-item-6": "Batch Install Apps",
-    "main-menu-item-7": "Batch Remove Installed Apps",
-    "main-menu-item-8": "Quit",
+    "main-menu-item-6": "Remove ANY app",
+    "main-menu-item-7": "Batch Install Apps",
+    "main-menu-item-8": "Batch Remove Installed Apps",
+    "main-menu-item-9": "Quit",
     "connection-type-message": "How do you want to connect?",
     "connect-wifi-message":"What is your MiWatch IpAdress?",
     "restore-app-message": "What apps do you want to restore?",
@@ -49,5 +50,7 @@
     "try-again": "Try Again",
     "connect-wifi-complete": "Connect Wifi Complete",
     "not-authenticated": "Not Authenticated",
-    "error": "Error"
+    "error": "Error",
+    "remove-any-app-message": "What App do you want to remove?",
+    "removing-apps-complete": "Removing Apps Complete"
 }

+ 7 - 4
lang/es.json

@@ -5,9 +5,10 @@
     "main-menu-item-3": "Restaurar aplicaciones Xiaomi",
     "main-menu-item-4": "Instalar aplicaciones compatibles",
     "main-menu-item-5": "Restaura CUALQUIER aplicación",
-    "main-menu-item-6": "Aplicaciones de instalación por lotes",
-    "main-menu-item-7": "Eliminar por lotes las aplicaciones instaladas",
-    "main-menu-item-8": "Salir",
+    "main-menu-item-6": "Eliminar CUALQUIER aplicación",
+    "main-menu-item-7": "Aplicaciones de instalación por lotes",
+    "main-menu-item-8": "Eliminar por lotes las aplicaciones instaladas",
+    "main-menu-item-9": "Salir",
     "connection-type-message": "¿Cómo desea conectarse?",
     "connect-wifi-message":"¿Cuál es su MiWatch IpAdress?",
     "restore-app-message": "¿Qué aplicaciones quieres restaurar?",
@@ -48,5 +49,7 @@
     "try-again": "Inténtalo de nuevo",
     "connect-wifi-complete": "Conectar Wifi Completo",
     "not-authenticated": "No autenticado",
-    "error": "Error"
+    "error": "Error",
+    "remove-any-app-message": "¿Qué aplicación quieres eliminar?",
+    "removing-apps-complete": "Eliminación de aplicaciones completa"
 }

+ 12 - 0
lib/adb.js

@@ -84,6 +84,18 @@ module.exports = {
       common.dualLog(await Language.get('restoring') + ' ' + package + ' - ' + result.stdout)
     }
   },
+  removeAnyApk: async (package) => {
+    Language.setActiveLang(globalVariables.language)
+    result = await shellExec(adbRun + ' shell pm uninstall -k --user 0 ' + package.removeAnyApp)
+    if (result.stderr != '') {
+      common.dualLog('device-not-authorised' + ' ' + result.stderr, 'red')
+    } else if (result.stdout.includes('doesn\'t exist')) {
+      logger.info(result.stdout);
+      console.log(chalk.redBright(result.stdout));
+    } else {
+      common.dualLog(await Language.get('removing') + ' ' + package + ' - ' + result.stdout)
+    }
+  },
   getInstalledPacakges: async () => {
     Language.setActiveLang(globalVariables.language)
     result = await shellExec(adbRun + ' shell pm list packages -3')

+ 9 - 0
lib/inquirer.js

@@ -112,4 +112,13 @@ module.exports = {
     },];
     return inquirer.prompt(questions);
   },
+  restoreAnyApp: async () => {
+    Language.setActiveLang(globalVariables.language)
+    const questions = [{
+      type: "input",
+      name: "removeAnyApp",
+      message: await Language.get('remove-any-app-message'),
+    },];
+    return inquirer.prompt(questions);
+  },
 };

+ 20 - 13
pages/pages.js

@@ -126,9 +126,19 @@ module.exports = {
         module.exports.mainMenu()
     },
 
-    batchInstallApps: async () => {
+    removeAnyApp: async () => {
         common.header('main-menu-item-6')
         common.log('main-menu-item-6')
+        const value = await inquirer.restoreAnyApp();
+        await adb.restoreAnyApk(value)
+        common.dualLog('removing-apps-complete', 'green')
+        await common.pause(2000)
+        module.exports.mainMenu()
+    },
+
+    batchInstallApps: async () => {
+        common.header('main-menu-item-7')
+        common.log('main-menu-item-7')
 
         let apkList = await files.getListOfAPk('./my-apk/')
         await files.renameLocalApk(apkList)
@@ -145,8 +155,8 @@ module.exports = {
     },
 
     batchRemoveInstalledApps: async () => {
-        common.header('main-menu-item-7')
-        common.log('main-menu-item-7')
+        common.header('main-menu-item-8')
+        common.log('main-menu-item-8')
 
         value = await adb.getInstalledPacakges()
 
@@ -176,14 +186,7 @@ module.exports = {
     selectLanguage: async () => {
         common.header('Select Language')
         common.log('Select Language')
-        // const value = await inquirer.connectionType()
         const v = await inquirer.LanguageSelect()
-        // connected = await adb.watchConnection(value)
-        // if (connected != true) {
-        //     module.exports.connectWatch()
-        // } else {
-        //     module.exports.mainMenu()
-        // }
         return v
     },
 
@@ -199,6 +202,7 @@ module.exports = {
         menu_7 = await Language.get('main-menu-item-7')
         menu_8 = await Language.get('main-menu-item-8')
         menu_9 = await Language.get('main-menu-item-9')
+        menu_10 = await Language.get('main-menu-item-10')
 
         switch (mainMenuSelection.mainMenu) {
             case menu_1.toLowerCase():
@@ -217,15 +221,18 @@ module.exports = {
                 module.exports.restoreAnyApp()
                 break;
             case menu_6.toLowerCase():
-                module.exports.batchInstallApps()
+                module.exports.removeAnyApp()
                 break;
             case menu_7.toLowerCase():
-                module.exports.batchRemoveInstalledApps()
+                module.exports.batchInstallApps()
                 break;
             case menu_8.toLowerCase():
-                module.exports.connectWatch()
+                module.exports.batchRemoveInstalledApps()
                 break;
             case menu_9.toLowerCase():
+                module.exports.connectWatch()
+                break;
+            case menu_10.toLowerCase():
                 break;
             default:
             // code block