Search in sources :

Example 1 with LocalFrameworkZip

use of de.robv.android.xposed.installer.util.FrameworkZips.LocalFrameworkZip in project XposedInstaller by rovo89.

the class StatusInstallerFragment method showActionDialog.

private void showActionDialog(final Context context, final String title, final FrameworkZips.Type type) {
    final int ACTION_FLASH = 0;
    final int ACTION_FLASH_RECOVERY = 1;
    final int ACTION_SAVE = 2;
    final int ACTION_DELETE = 3;
    boolean isDownloaded = FrameworkZips.hasLocal(title, type);
    int itemCount = isDownloaded ? 3 : 2;
    String[] texts = new String[itemCount];
    int[] ids = new int[itemCount];
    int i = 0;
    texts[i] = context.getString(type.text_flash);
    ids[i++] = ACTION_FLASH;
    texts[i] = context.getString(type.text_flash_recovery);
    ids[i++] = ACTION_FLASH_RECOVERY;
    if (FrameworkZips.hasLocal(title, type)) {
        texts[i] = context.getString(R.string.framework_delete);
        ids[i++] = ACTION_DELETE;
    }
    new MaterialDialog.Builder(context).title(title).items(texts).itemsIds(ids).itemsCallback(new MaterialDialog.ListCallback() {

        @Override
        public void onSelection(MaterialDialog dialog, View itemView, int position, CharSequence text) {
            final int action = itemView.getId();
            // Handle delete simple actions.
            if (action == ACTION_DELETE) {
                FrameworkZips.delete(context, title, type);
                LOCAL_ZIP_LOADER.triggerReload(true);
                return;
            }
            // Handle actions that need a download first.
            RunnableWithParam<File> runAfterDownload = null;
            if (action == ACTION_FLASH) {
                runAfterDownload = new RunnableWithParam<File>() {

                    @Override
                    public void run(File file) {
                        flash(context, new FlashDirectly(file, type, title, false));
                    }
                };
            } else if (action == ACTION_FLASH_RECOVERY) {
                runAfterDownload = new RunnableWithParam<File>() {

                    @Override
                    public void run(File file) {
                        flash(context, new FlashRecoveryAuto(file, type, title));
                    }
                };
            } else if (action == ACTION_SAVE) {
                runAfterDownload = new RunnableWithParam<File>() {

                    @Override
                    public void run(File file) {
                        saveTo(context, file);
                    }
                };
            }
            LocalFrameworkZip local = FrameworkZips.getLocal(title, type);
            if (local != null) {
                runAfterDownload.run(local.path);
            } else {
                download(context, title, type, runAfterDownload);
            }
        }
    }).show();
}
Also used : MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) RunnableWithParam(de.robv.android.xposed.installer.util.RunnableWithParam) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) SuppressLint(android.annotation.SuppressLint) LocalFrameworkZip(de.robv.android.xposed.installer.util.FrameworkZips.LocalFrameworkZip) File(java.io.File)

Example 2 with LocalFrameworkZip

use of de.robv.android.xposed.installer.util.FrameworkZips.LocalFrameworkZip in project XposedInstaller by rovo89.

the class StatusInstallerFragment method addZipViews.

private boolean addZipViews(LayoutInflater inflater, ViewGroup root, FrameworkZips.Type type) {
    ViewGroup container = null;
    Set<String> allTitles = FrameworkZips.getAllTitles(type);
    for (String title : allTitles) {
        OnlineFrameworkZip online = FrameworkZips.getOnline(title, type);
        LocalFrameworkZip local = FrameworkZips.getLocal(title, type);
        boolean hasOnline = (online != null);
        boolean hasLocal = (local != null);
        FrameworkZip zip = hasOnline ? online : local;
        boolean isOutdated = zip.isOutdated();
        if (isOutdated && !mShowOutdated) {
            continue;
        }
        if (container == null) {
            View card = inflater.inflate(R.layout.framework_zip_group, root, false);
            TextView tv = (TextView) card.findViewById(android.R.id.title);
            tv.setText(type.title);
            container = (ViewGroup) card.findViewById(android.R.id.content);
            root.addView(card);
        }
        addZipView(inflater, container, zip, hasOnline, hasLocal, isOutdated);
    }
    return !allTitles.isEmpty();
}
Also used : LocalFrameworkZip(de.robv.android.xposed.installer.util.FrameworkZips.LocalFrameworkZip) FrameworkZip(de.robv.android.xposed.installer.util.FrameworkZips.FrameworkZip) OnlineFrameworkZip(de.robv.android.xposed.installer.util.FrameworkZips.OnlineFrameworkZip) ViewGroup(android.view.ViewGroup) LocalFrameworkZip(de.robv.android.xposed.installer.util.FrameworkZips.LocalFrameworkZip) TextView(android.widget.TextView) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) OnlineFrameworkZip(de.robv.android.xposed.installer.util.FrameworkZips.OnlineFrameworkZip)

Aggregations

View (android.view.View)2 ImageView (android.widget.ImageView)2 TextView (android.widget.TextView)2 LocalFrameworkZip (de.robv.android.xposed.installer.util.FrameworkZips.LocalFrameworkZip)2 SuppressLint (android.annotation.SuppressLint)1 ViewGroup (android.view.ViewGroup)1 MaterialDialog (com.afollestad.materialdialogs.MaterialDialog)1 FrameworkZip (de.robv.android.xposed.installer.util.FrameworkZips.FrameworkZip)1 OnlineFrameworkZip (de.robv.android.xposed.installer.util.FrameworkZips.OnlineFrameworkZip)1 RunnableWithParam (de.robv.android.xposed.installer.util.RunnableWithParam)1 File (java.io.File)1