private void options(final boolean flashing, final File 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();
  }
  private void restoreDialog(
      final File 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 ProgressDialog progressDialog;

              @Override
              protected void onPreExecute() {
                super.onPreExecute();
                progressDialog = new ProgressDialog(getActivity());
                progressDialog.setMessage(
                    getString(restoring ? R.string.restoring : R.string.flashing));
                progressDialog.setCancelable(false);
                progressDialog.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());
  }