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();
}
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;
}
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);
}
Aggregations