Search in sources :

Example 1 with Recovery

use of com.moro.mtweaks.utils.tools.Recovery in project MTweaks-KernelAdiutorMOD by morogoku.

the class RecoveryFragment method flashNow.

private void flashNow(final int recoveryOption) {
    mFlashDialog = ViewUtils.dialogBuilder(getString(R.string.flash_now_confirm), new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialogInterface, int i) {
        }
    }, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialogInterface, int i) {
            String file = "/cache/recovery/" + mCommands.get(0).getFile(recoveryOption == 1 ? Recovery.RECOVERY.TWRP : Recovery.RECOVERY.CWM);
            RootFile recoveryFile = new RootFile(file);
            recoveryFile.delete();
            for (Recovery commands : mCommands) {
                for (String command : commands.getCommands(recoveryOption == 1 ? Recovery.RECOVERY.TWRP : Recovery.RECOVERY.CWM)) recoveryFile.write(command, true);
            }
            RootUtils.runCommand("reboot recovery");
        }
    }, new DialogInterface.OnDismissListener() {

        @Override
        public void onDismiss(DialogInterface dialogInterface) {
            mFlashDialog = null;
        }
    }, getActivity());
    mFlashDialog.show();
}
Also used : DialogInterface(android.content.DialogInterface) RootFile(com.moro.mtweaks.utils.root.RootFile) Recovery(com.moro.mtweaks.utils.tools.Recovery)

Example 2 with Recovery

use of com.moro.mtweaks.utils.tools.Recovery in project MTweaks-KernelAdiutorMOD by morogoku.

the class DownloadKernelView method postMD5Check.

private void postMD5Check(boolean match, final String path, final String installMethod) {
    if (match) {
        mInstallButton.setVisibility(View.VISIBLE);
        mInstallButton.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(final View view) {
                if (!Utils.existFile(path)) {
                    Utils.toast(view.getContext().getString(R.string.went_wrong), view.getContext());
                    return;
                }
                if (installMethod != null) {
                    ViewUtils.dialogBuilder(view.getContext().getString(R.string.sure_question), new DialogInterface.OnClickListener() {

                        @Override
                        public void onClick(DialogInterface dialogInterface, int i) {
                        }
                    }, new DialogInterface.OnClickListener() {

                        @Override
                        public void onClick(DialogInterface dialogInterface, int i) {
                            RootUtils.runCommand(installMethod.replace("$FILE", path));
                            RootUtils.runCommand("rm -f " + path);
                            RootUtils.runCommand("reboot");
                        }
                    }, new DialogInterface.OnDismissListener() {

                        @Override
                        public void onDismiss(DialogInterface dialogInterface) {
                        }
                    }, view.getContext()).setTitle(view.getContext().getString(R.string.install)).show();
                } else {
                    mRecoverySelection = 0;
                    String[] items = view.getResources().getStringArray(R.array.downloads_recovery);
                    new Dialog(view.getContext()).setSingleChoiceItems(items, 0, new DialogInterface.OnClickListener() {

                        @Override
                        public void onClick(DialogInterface dialogInterface, int i) {
                            mRecoverySelection = i;
                        }
                    }).setPositiveButton(view.getContext().getString(R.string.ok), new DialogInterface.OnClickListener() {

                        @Override
                        public void onClick(DialogInterface dialogInterface, int i) {
                            if (mRecoverySelection == 2) {
                                Utils.toast(view.getContext().getString(R.string.file_location, path), view.getContext());
                                return;
                            }
                            Recovery recovery = new Recovery(Recovery.RECOVERY_COMMAND.FLASH_ZIP, new File(path));
                            Recovery.RECOVERY type = mRecoverySelection == 1 ? Recovery.RECOVERY.TWRP : Recovery.RECOVERY.CWM;
                            RootFile recoveryFile = new RootFile("/cache/recovery/" + recovery.getFile(type));
                            for (String command : recovery.getCommands(type)) {
                                recoveryFile.write(command, true);
                            }
                            RootUtils.runCommand("reboot recovery");
                        }
                    }).show();
                }
            }
        });
    } else {
        mMismatchMD5.setVisibility(View.VISIBLE);
    }
    mCheckMD5.setVisibility(View.GONE);
    mDownloadSection.setVisibility(View.VISIBLE);
    mCheckMD5Task = null;
}
Also used : DialogInterface(android.content.DialogInterface) TextView(android.widget.TextView) View(android.view.View) Recovery(com.moro.mtweaks.utils.tools.Recovery) Dialog(com.moro.mtweaks.views.dialog.Dialog) RootFile(com.moro.mtweaks.utils.root.RootFile) File(java.io.File) RootFile(com.moro.mtweaks.utils.root.RootFile)

Example 3 with Recovery

use of com.moro.mtweaks.utils.tools.Recovery in project MTweaks-KernelAdiutorMOD by morogoku.

the class RecoveryFragment method addAction.

private void addAction(Recovery.RECOVERY_COMMAND recovery_command, String path) {
    String summary = null;
    switch(recovery_command) {
        case WIPE_DATA:
            summary = getString(R.string.wipe_data);
            break;
        case WIPE_CACHE:
            summary = getString(R.string.wipe_cache);
            break;
        case FLASH_ZIP:
            summary = new File(path).getName();
            break;
    }
    final Recovery recovery = new Recovery(recovery_command, path == null ? null : new File(path));
    mCommands.add(recovery);
    CardView cardView = new CardView(getActivity());
    cardView.setOnMenuListener(new CardView.OnMenuListener() {

        @Override
        public void onMenuReady(final CardView cardView, PopupMenu popupMenu) {
            popupMenu.getMenu().add(Menu.NONE, 0, Menu.NONE, getString(R.string.delete));
            popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {

                @Override
                public boolean onMenuItemClick(MenuItem item) {
                    if (item.getItemId() == 0) {
                        mCommands.remove(recovery);
                        removeItem(cardView);
                    }
                    return false;
                }
            });
        }
    });
    DescriptionView descriptionView = new DescriptionView();
    if (path != null) {
        descriptionView.setTitle(getString(R.string.flash_zip));
    }
    descriptionView.setSummary(summary);
    cardView.addItem(descriptionView);
    addItem(cardView);
}
Also used : DescriptionView(com.moro.mtweaks.views.recyclerview.DescriptionView) CardView(com.moro.mtweaks.views.recyclerview.CardView) MenuItem(android.view.MenuItem) RootFile(com.moro.mtweaks.utils.root.RootFile) File(java.io.File) Recovery(com.moro.mtweaks.utils.tools.Recovery) PopupMenu(android.support.v7.widget.PopupMenu)

Aggregations

RootFile (com.moro.mtweaks.utils.root.RootFile)3 Recovery (com.moro.mtweaks.utils.tools.Recovery)3 DialogInterface (android.content.DialogInterface)2 File (java.io.File)2 PopupMenu (android.support.v7.widget.PopupMenu)1 MenuItem (android.view.MenuItem)1 View (android.view.View)1 TextView (android.widget.TextView)1 Dialog (com.moro.mtweaks.views.dialog.Dialog)1 CardView (com.moro.mtweaks.views.recyclerview.CardView)1 DescriptionView (com.moro.mtweaks.views.recyclerview.DescriptionView)1