Java Code Examples for com.grarak.kerneladiutor.utils.tools.Backup#PARTITION
The following examples show how to use
com.grarak.kerneladiutor.utils.tools.Backup#PARTITION .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BackupFragment.java From KA27 with Apache License 2.0 | 6 votes |
private void options(final boolean flashing, final RootFile file) { final LinkedHashMap < String, Backup.PARTITION > menu = new LinkedHashMap < > (); if (Backup.getBootPartition() != null) menu.put(getString(R.string.boot), Backup.PARTITION.BOOT); if (Backup.getRecoveryPartition() != null) menu.put(getString(R.string.recovery), Backup.PARTITION.RECOVERY); String[] items = new String[menu.keySet().toArray().length]; for (int i = 0; i < items.length; i++) items[i] = (String) menu.keySet().toArray()[i]; new AlertDialog.Builder(getActivity(), (Utils.DARKTHEME ? R.style.AlertDialogStyleDark : R.style.AlertDialogStyleLight)).setItems(items, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (flashing) restoreDialog(file, (Backup.PARTITION) menu.values().toArray()[which], false); else backupDialog((Backup.PARTITION) menu.values().toArray()[which]); } }).show(); }
Example 2
Source File: BackupFragment.java From kernel_adiutor with Apache License 2.0 | 6 votes |
private void options(final boolean flashing, final RootFile file) { final LinkedHashMap<String, Backup.PARTITION> menu = new LinkedHashMap<>(); if (Backup.getBootPartition() != null) menu.put(getString(R.string.boot), Backup.PARTITION.BOOT); if (Backup.getRecoveryPartition() != null) menu.put(getString(R.string.recovery), Backup.PARTITION.RECOVERY); if (Backup.getFotaPartition() != null) menu.put(getString(R.string.fota), Backup.PARTITION.FOTA); String[] items = new String[menu.keySet().toArray().length]; for (int i = 0; i < items.length; i++) items[i] = (String) menu.keySet().toArray()[i]; new AlertDialog.Builder(getActivity()).setItems(items, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (flashing) restoreDialog(file, (Backup.PARTITION) menu.values().toArray()[which], false); else backupDialog((Backup.PARTITION) menu.values().toArray()[which]); } }).show(); }
Example 3
Source File: BackupFragment.java From KernelAdiutor with GNU General Public License v3.0 | 6 votes |
private void backup(final Backup.PARTITION partition) { mBackupPartition = partition; ViewUtils.dialogEditText(partition == Backup.PARTITION.BOOT ? Device.getKernelVersion(false) : null, (dialogInterface, i) -> { }, text -> { if (text.isEmpty()) { Utils.toast(R.string.name_empty, getActivity()); return; } if (!text.endsWith(".img")) { text += ".img"; } if (Utils.existFile(Backup.getPath(partition) + "/" + text)) { Utils.toast(getString(R.string.already_exists, text), getActivity()); return; } showDialog(new BackupTask(getActivity(), text, partition)); }, getActivity()) .setOnDismissListener(dialogInterface -> mBackupPartition = null).show(); }
Example 4
Source File: BackupFragment.java From KA27 with Apache License 2.0 | 5 votes |
private void restoreDialog(final RootFile file, final Backup.PARTITION partition_type, final boolean restoring) { Utils.confirmDialog(null, getString(R.string.overwrite_question, Backup.getPartition(partition_type)), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { new AsyncTask < Void, Void, Void > () { private MaterialDialog progressDialog; @Override protected void onPreExecute() { super.onPreExecute(); progressDialog = new MaterialDialog.Builder(getActivity()) .content(restoring ? R.string.restoring : R.string.flashing) .progress(true, 0) .canceledOnTouchOutside(false) .show(); } @Override protected Void doInBackground(Void...params) { Backup.restore(file, partition_type); return null; } @Override protected void onPostExecute(Void aVoid) { super.onPostExecute(aVoid); progressDialog.dismiss(); } }.execute(); } }, getActivity()); }
Example 5
Source File: BackupFragment.java From kernel_adiutor with Apache License 2.0 | 5 votes |
private long viewInit(RootFile folder, final Backup.PARTITION partition_type) { folder.mkdir(); long size = 0; String text = null; if (folder.toString().endsWith("boot")) text = getString(R.string.boot); else if (folder.toString().endsWith("recovery")) text = getString(R.string.recovery); else if (folder.toString().endsWith("fota")) text = getString(R.string.fota); if (text == null) return 0; for (final RootFile file : folder.listFiles()) if (file.getName().endsWith(".img")) { CardViewItem.DCardView cardView = new CardViewItem.DCardView(); cardView.setTitle(file.getName().replace(".img", "")); float fileSize = file.length() / 1024; size += fileSize; cardView.setDescription(text + ", " + fileSize + getString(R.string.mb)); cardView.setOnDCardListener(new CardViewItem.DCardView.OnDCardListener() { @Override public void onClick(CardViewItem.DCardView dCardView) { new AlertDialog.Builder(getActivity()).setItems(getResources().getStringArray(R.array.backup_menu), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { switch (which) { case 0: restoreDialog(file, partition_type, true); break; case 1: deleteDialog(file); break; } } }).show(); } }); addView(cardView); } return size; }
Example 6
Source File: BackupFragment.java From KernelAdiutor with GNU General Public License v3.0 | 5 votes |
private void itemInit(List<RecyclerViewItem> items, final Backup.PARTITION partition) { File file = new File(Backup.getPath(partition)); if (file.exists()) { for (final File image : file.listFiles()) { if (image.isFile()) { DescriptionView descriptionView = new DescriptionView(); descriptionView.setTitle(image.getName().replace(".img", "")); descriptionView.setSummary((image.length() / 1024L / 1024L) + getString(R.string.mb)); descriptionView.setOnItemClickListener(item -> { mItemOptionsDialog = new Dialog(getActivity()) .setItems(getResources().getStringArray(R.array.backup_item_options), (dialogInterface, i) -> { switch (i) { case 0: restore(partition, image, false); break; case 1: delete(image); break; } }) .setOnDismissListener(dialogInterface -> mItemOptionsDialog = null); mItemOptionsDialog.show(); }); items.add(descriptionView); } } } }
Example 7
Source File: BackupFragment.java From KernelAdiutor with GNU General Public License v3.0 | 5 votes |
private void showBackupFlashingDialog(final File file) { final LinkedHashMap<String, Backup.PARTITION> menu = getPartitionMenu(); mBackupFlashingDialog = new Dialog(getActivity()).setItems(menu.keySet().toArray( new String[menu.size()]), (dialogInterface, i) -> { Backup.PARTITION partition = menu.values().toArray(new Backup.PARTITION[menu.size()])[i]; if (file != null) { restore(partition, file, true); } else { backup(partition); } }) .setOnDismissListener(dialogInterface -> mBackupFlashingDialog = null); mBackupFlashingDialog.show(); }
Example 8
Source File: BackupFragment.java From KernelAdiutor with GNU General Public License v3.0 | 5 votes |
private void restore(final Backup.PARTITION partition, final File file, final boolean flashing) { mRestoreDialog = ViewUtils.dialogBuilder(getString(R.string.sure_question), (dialogInterface, i) -> { }, (dialogInterface, i) -> showDialog(new RestoreTask(getActivity(), flashing, file, partition)), dialogInterface -> mRestoreDialog = null, getActivity()); mRestoreDialog.show(); }
Example 9
Source File: BackupFragment.java From KernelAdiutor with GNU General Public License v3.0 | 5 votes |
private LinkedHashMap<String, Backup.PARTITION> getPartitionMenu() { LinkedHashMap<String, Backup.PARTITION> partitions = new LinkedHashMap<>(); if (Backup.getBootPartition() != null) { partitions.put(getString(R.string.boot_partition), Backup.PARTITION.BOOT); } if (Backup.getRecoveryPartition() != null) { partitions.put(getString(R.string.recovery_partition), Backup.PARTITION.RECOVERY); } if (Backup.getFotaPartition() != null) { partitions.put(getString(R.string.fota_partition), Backup.PARTITION.FOTA); } return partitions; }
Example 10
Source File: BackupFragment.java From KA27 with Apache License 2.0 | 4 votes |
private long viewInit(RootFile folder, final Backup.PARTITION partition_type) { folder.mkdir(); long size = 0; String text = null; if (folder.toString().endsWith("boot")) text = getString(R.string.boot); else if (folder.toString().endsWith("recovery")) text = getString(R.string.recovery); if (text == null) return 0; for (final RootFile file: folder.listFiles()) if (file.getName().endsWith(".img")) { CardViewItem.DCardView cardView = new CardViewItem.DCardView(); cardView.setTitle(file.getName().replace(".img", "")); float fileSize = file.length() / 1024; size += fileSize; cardView.setDescription(text + ", " + fileSize + getString(R.string.mb)); cardView.setOnDCardListener(new CardViewItem.DCardView.OnDCardListener() { @Override public void onClick(CardViewItem.DCardView dCardView) { new AlertDialog.Builder(getActivity(), (Utils.DARKTHEME ? R.style.AlertDialogStyleDark : R.style.AlertDialogStyleLight)) .setTitle(file.getName().replace(".img", "")) .setItems(getResources().getStringArray(R.array.backup_menu), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { switch (which) { case 0: restoreDialog(file, partition_type, true); break; case 1: deleteDialog(file); break; } } }).show(); } }); addView(cardView); } return size; }
Example 11
Source File: BackupFragment.java From KernelAdiutor with GNU General Public License v3.0 | 4 votes |
private RestoreTask(Context context, boolean flashing, File file, Backup.PARTITION partition) { super(null, context.getString(flashing ? R.string.flashing : R.string.restoring)); mFile = file; mPartition = partition; }
Example 12
Source File: BackupFragment.java From KernelAdiutor with GNU General Public License v3.0 | 4 votes |
private BackupTask(Context context, String name, Backup.PARTITION partition) { super(null, context.getString(R.string.backing_up)); mName = name; mPartition = partition; }