Search in sources :

Example 1 with InstalledModule

use of de.robv.android.xposed.installer.util.ModuleUtil.InstalledModule in project XposedInstaller by rovo89.

the class ModulesFragment method onCreateContextMenu.

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    InstalledModule installedModule = getItemFromContextMenuInfo(menuInfo);
    if (installedModule == null)
        return;
    menu.setHeaderTitle(installedModule.getAppName());
    getActivity().getMenuInflater().inflate(R.menu.context_menu_modules, menu);
    if (getSettingsIntent(installedModule.packageName) == null)
        menu.removeItem(R.id.menu_launch);
    try {
        String support = RepoDb.getModuleSupport(installedModule.packageName);
        if (NavUtil.parseURL(support) == null)
            menu.removeItem(R.id.menu_support);
    } catch (RowNotFoundException e) {
        menu.removeItem(R.id.menu_download_updates);
        menu.removeItem(R.id.menu_support);
    }
    String installer = mPm.getInstallerPackageName(installedModule.packageName);
    if (PLAY_STORE_LABEL != null && PLAY_STORE_PACKAGE.equals(installer))
        menu.findItem(R.id.menu_play_store).setTitle(PLAY_STORE_LABEL);
    else
        menu.removeItem(R.id.menu_play_store);
}
Also used : RowNotFoundException(de.robv.android.xposed.installer.repo.RepoDb.RowNotFoundException) InstalledModule(de.robv.android.xposed.installer.util.ModuleUtil.InstalledModule)

Example 2 with InstalledModule

use of de.robv.android.xposed.installer.util.ModuleUtil.InstalledModule in project XposedInstaller by rovo89.

the class ModulesFragment method onOptionsItemSelected.

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    if (item.getItemId() == R.id.bookmarks) {
        startActivity(new Intent(getActivity(), ModulesBookmark.class));
        return true;
    }
    String backupPath = Environment.getExternalStorageDirectory() + "/XposedInstaller";
    File enabledModulesPath = new File(backupPath, "enabled_modules.list");
    File installedModulesPath = new File(backupPath, "installed_modules.list");
    File targetDir = new File(backupPath);
    File listModules = new File(XposedApp.ENABLED_MODULES_LIST_FILE);
    mClickedMenuItem = item;
    if (checkPermissions())
        return false;
    switch(item.getItemId()) {
        case R.id.export_enabled_modules:
            if (!Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
                return false;
            }
            if (ModuleUtil.getInstance().getEnabledModules().isEmpty()) {
                Toast.makeText(getActivity(), getString(R.string.no_enabled_modules), Toast.LENGTH_SHORT).show();
                return false;
            }
            try {
                if (!targetDir.exists())
                    targetDir.mkdir();
                FileInputStream in = new FileInputStream(listModules);
                FileOutputStream out = new FileOutputStream(enabledModulesPath);
                byte[] buffer = new byte[1024];
                int len;
                while ((len = in.read(buffer)) > 0) {
                    out.write(buffer, 0, len);
                }
                in.close();
                out.close();
            } catch (IOException e) {
                Toast.makeText(getActivity(), getResources().getString(R.string.logs_save_failed) + "\n" + e.getMessage(), Toast.LENGTH_LONG).show();
                return false;
            }
            Toast.makeText(getActivity(), enabledModulesPath.toString(), Toast.LENGTH_LONG).show();
            return true;
        case R.id.export_installed_modules:
            if (!Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
                Toast.makeText(getActivity(), R.string.sdcard_not_writable, Toast.LENGTH_LONG).show();
                return false;
            }
            Map<String, InstalledModule> installedModules = ModuleUtil.getInstance().getModules();
            if (installedModules.isEmpty()) {
                Toast.makeText(getActivity(), getString(R.string.no_installed_modules), Toast.LENGTH_SHORT).show();
                return false;
            }
            try {
                if (!targetDir.exists())
                    targetDir.mkdir();
                FileWriter fw = new FileWriter(installedModulesPath);
                BufferedWriter bw = new BufferedWriter(fw);
                PrintWriter fileOut = new PrintWriter(bw);
                Set keys = installedModules.keySet();
                for (Object key1 : keys) {
                    String packageName = (String) key1;
                    fileOut.println(packageName);
                }
                fileOut.close();
            } catch (IOException e) {
                Toast.makeText(getActivity(), getResources().getString(R.string.logs_save_failed) + "n" + e.getMessage(), Toast.LENGTH_LONG).show();
                return false;
            }
            Toast.makeText(getActivity(), installedModulesPath.toString(), Toast.LENGTH_LONG).show();
            return true;
        case R.id.import_installed_modules:
            return importModules(installedModulesPath);
        case R.id.import_enabled_modules:
            return importModules(enabledModulesPath);
    }
    return super.onOptionsItemSelected(item);
}
Also used : Set(java.util.Set) FileWriter(java.io.FileWriter) Intent(android.content.Intent) IOException(java.io.IOException) FileInputStream(java.io.FileInputStream) BufferedWriter(java.io.BufferedWriter) FileOutputStream(java.io.FileOutputStream) InstalledModule(de.robv.android.xposed.installer.util.ModuleUtil.InstalledModule) File(java.io.File) PrintWriter(java.io.PrintWriter)

Example 3 with InstalledModule

use of de.robv.android.xposed.installer.util.ModuleUtil.InstalledModule in project XposedInstaller by rovo89.

the class ModulesFragment method onContextItemSelected.

@Override
public boolean onContextItemSelected(MenuItem item) {
    InstalledModule module = getItemFromContextMenuInfo(item.getMenuInfo());
    if (module == null)
        return false;
    switch(item.getItemId()) {
        case R.id.menu_launch:
            startActivity(getSettingsIntent(module.packageName));
            return true;
        case R.id.menu_download_updates:
            Intent detailsIntent = new Intent(getActivity(), DownloadDetailsActivity.class);
            detailsIntent.setData(Uri.fromParts("package", module.packageName, null));
            startActivity(detailsIntent);
            return true;
        case R.id.menu_support:
            NavUtil.startURL(getActivity(), Uri.parse(RepoDb.getModuleSupport(module.packageName)));
            return true;
        case R.id.menu_play_store:
            Intent i = new Intent(android.content.Intent.ACTION_VIEW);
            i.setData(Uri.parse(String.format(PLAY_STORE_LINK, module.packageName)));
            i.setPackage(PLAY_STORE_PACKAGE);
            try {
                startActivity(i);
            } catch (ActivityNotFoundException e) {
                i.setPackage(null);
                startActivity(i);
            }
            return true;
        case R.id.menu_app_info:
            startActivity(new Intent(ACTION_APPLICATION_DETAILS_SETTINGS, Uri.fromParts("package", module.packageName, null)));
            return true;
        case R.id.menu_uninstall:
            startActivity(new Intent(Intent.ACTION_UNINSTALL_PACKAGE, Uri.fromParts("package", module.packageName, null)));
            return true;
    }
    return false;
}
Also used : ActivityNotFoundException(android.content.ActivityNotFoundException) InstalledModule(de.robv.android.xposed.installer.util.ModuleUtil.InstalledModule) Intent(android.content.Intent)

Example 4 with InstalledModule

use of de.robv.android.xposed.installer.util.ModuleUtil.InstalledModule in project XposedInstaller by rovo89.

the class PackageChangeReceiver method onReceive.

@Override
public void onReceive(final Context context, final Intent intent) {
    if (intent.getAction().equals(Intent.ACTION_PACKAGE_REMOVED) && intent.getBooleanExtra(Intent.EXTRA_REPLACING, false))
        // Ignore existing packages being removed in order to be updated
        return;
    String packageName = getPackageName(intent);
    if (packageName == null)
        return;
    if (intent.getAction().equals(Intent.ACTION_PACKAGE_CHANGED)) {
        // make sure that the change is for the complete package, not only a
        // component
        String[] components = intent.getStringArrayExtra(Intent.EXTRA_CHANGED_COMPONENT_NAME_LIST);
        if (components != null) {
            boolean isForPackage = false;
            for (String component : components) {
                if (packageName.equals(component)) {
                    isForPackage = true;
                    break;
                }
            }
            if (!isForPackage)
                return;
        }
    }
    InstalledModule module = ModuleUtil.getInstance().reloadSingleModule(packageName);
    if (module == null || intent.getAction().equals(Intent.ACTION_PACKAGE_REMOVED)) {
        // Xposed mod
        if (mModuleUtil.isModuleEnabled(packageName)) {
            mModuleUtil.setModuleEnabled(packageName, false);
            mModuleUtil.updateModulesList(false);
        }
        return;
    }
    if (mModuleUtil.isModuleEnabled(packageName)) {
        mModuleUtil.updateModulesList(false);
        NotificationUtil.showModulesUpdatedNotification();
    } else {
        NotificationUtil.showNotActivatedNotification(packageName, module.getAppName());
    }
}
Also used : InstalledModule(de.robv.android.xposed.installer.util.ModuleUtil.InstalledModule)

Aggregations

InstalledModule (de.robv.android.xposed.installer.util.ModuleUtil.InstalledModule)4 Intent (android.content.Intent)2 ActivityNotFoundException (android.content.ActivityNotFoundException)1 RowNotFoundException (de.robv.android.xposed.installer.repo.RepoDb.RowNotFoundException)1 BufferedWriter (java.io.BufferedWriter)1 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 FileOutputStream (java.io.FileOutputStream)1 FileWriter (java.io.FileWriter)1 IOException (java.io.IOException)1 PrintWriter (java.io.PrintWriter)1 Set (java.util.Set)1