Search in sources :

Example 1 with ModuleVersion

use of de.robv.android.xposed.installer.repo.ModuleVersion in project XposedInstaller by rovo89.

the class DownloadDetailsVersionsFragment method onActivityCreated.

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    module = mActivity.getModule();
    if (module == null)
        return;
    if (module.versions.isEmpty()) {
        setEmptyText(getString(R.string.download_no_versions));
        setListShown(true);
    } else {
        RepoLoader repoLoader = RepoLoader.getInstance();
        if (!repoLoader.isVersionShown(module.versions.get(0))) {
            TextView txtHeader = new TextView(getActivity());
            txtHeader.setText(R.string.download_test_version_not_shown);
            txtHeader.setTextColor(getResources().getColor(R.color.warning));
            txtHeader.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    mActivity.gotoPage(DownloadDetailsActivity.DOWNLOAD_SETTINGS);
                }
            });
            getListView().addHeaderView(txtHeader);
        }
        sAdapter = new VersionsAdapter(mActivity, mActivity.getInstalledModule());
        for (ModuleVersion version : module.versions) {
            if (repoLoader.isVersionShown(version))
                sAdapter.add(version);
        }
        setListAdapter(sAdapter);
    }
    DisplayMetrics metrics = getResources().getDisplayMetrics();
    int sixDp = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 6, metrics);
    int eightDp = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8, metrics);
    getListView().setDivider(null);
    getListView().setDividerHeight(sixDp);
    getListView().setPadding(eightDp, eightDp, eightDp, eightDp);
    getListView().setClipToPadding(false);
}
Also used : RepoLoader(de.robv.android.xposed.installer.util.RepoLoader) ModuleVersion(de.robv.android.xposed.installer.repo.ModuleVersion) TextView(android.widget.TextView) View(android.view.View) DownloadView(de.robv.android.xposed.installer.widget.DownloadView) TextView(android.widget.TextView) DisplayMetrics(android.util.DisplayMetrics)

Example 2 with ModuleVersion

use of de.robv.android.xposed.installer.repo.ModuleVersion in project XposedInstaller by rovo89.

the class ModulesFragment method importModules.

private boolean importModules(File path) {
    if (!Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
        Toast.makeText(getActivity(), R.string.sdcard_not_writable, Toast.LENGTH_LONG).show();
        return false;
    }
    InputStream ips = null;
    RepoLoader repoLoader = RepoLoader.getInstance();
    List<Module> list = new ArrayList<>();
    if (!path.exists()) {
        Toast.makeText(getActivity(), getString(R.string.no_backup_found), Toast.LENGTH_LONG).show();
        return false;
    }
    try {
        ips = new FileInputStream(path);
    } catch (FileNotFoundException e) {
        Log.e(XposedApp.TAG, "Could not open " + path, e);
    }
    if (path.length() == 0) {
        Toast.makeText(getActivity(), R.string.file_is_empty, Toast.LENGTH_LONG).show();
        return false;
    }
    try {
        assert ips != null;
        InputStreamReader ipsr = new InputStreamReader(ips);
        BufferedReader br = new BufferedReader(ipsr);
        String line;
        while ((line = br.readLine()) != null) {
            Module m = repoLoader.getModule(line);
            if (m == null) {
                Toast.makeText(getActivity(), getString(R.string.download_details_not_found, line), Toast.LENGTH_SHORT).show();
            } else {
                list.add(m);
            }
        }
        br.close();
    } catch (ActivityNotFoundException | IOException e) {
        Toast.makeText(getActivity(), e.toString(), Toast.LENGTH_SHORT).show();
    }
    for (Module m : list) {
        ModuleVersion mv = null;
        for (int i = 0; i < m.versions.size(); i++) {
            ModuleVersion mvTemp = m.versions.get(i);
            if (mvTemp.relType == ReleaseType.STABLE) {
                mv = mvTemp;
                break;
            }
        }
        if (mv != null) {
            DownloadsUtil.add(getActivity(), m.name, mv.downloadLink, new DownloadsUtil.DownloadFinishedCallback() {

                @Override
                public void onDownloadFinished(Context context, DownloadsUtil.DownloadInfo info) {
                    XposedApp.installApk(context, info);
                }
            }, DownloadsUtil.MIME_TYPES.APK);
        }
    }
    return true;
}
Also used : Context(android.content.Context) InputStreamReader(java.io.InputStreamReader) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) ArrayList(java.util.ArrayList) FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException) FileInputStream(java.io.FileInputStream) RepoLoader(de.robv.android.xposed.installer.util.RepoLoader) ActivityNotFoundException(android.content.ActivityNotFoundException) ModuleVersion(de.robv.android.xposed.installer.repo.ModuleVersion) BufferedReader(java.io.BufferedReader) InstalledModule(de.robv.android.xposed.installer.util.ModuleUtil.InstalledModule) Module(de.robv.android.xposed.installer.repo.Module) DownloadsUtil(de.robv.android.xposed.installer.util.DownloadsUtil)

Aggregations

ModuleVersion (de.robv.android.xposed.installer.repo.ModuleVersion)2 RepoLoader (de.robv.android.xposed.installer.util.RepoLoader)2 ActivityNotFoundException (android.content.ActivityNotFoundException)1 Context (android.content.Context)1 DisplayMetrics (android.util.DisplayMetrics)1 View (android.view.View)1 TextView (android.widget.TextView)1 Module (de.robv.android.xposed.installer.repo.Module)1 DownloadsUtil (de.robv.android.xposed.installer.util.DownloadsUtil)1 InstalledModule (de.robv.android.xposed.installer.util.ModuleUtil.InstalledModule)1 DownloadView (de.robv.android.xposed.installer.widget.DownloadView)1 BufferedReader (java.io.BufferedReader)1 FileInputStream (java.io.FileInputStream)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 InputStreamReader (java.io.InputStreamReader)1 ArrayList (java.util.ArrayList)1