2 * Copyright (C) 2014 Tobias Brunner
3 * HSR Hochschule fuer Technik Rapperswil
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 package org.strongswan.android.ui;
18 import android.app.Dialog;
19 import android.content.Context;
20 import android.content.DialogInterface;
21 import android.os.Bundle;
22 import android.support.v7.app.AlertDialog;
23 import android.support.v7.app.AppCompatDialogFragment;
25 import org.strongswan.android.R;
28 * Class that displays a confirmation dialog to delete a selected local
31 public class CertificateDeleteConfirmationDialog extends AppCompatDialogFragment
33 public static final String ALIAS = "alias";
34 OnCertificateDeleteListener mListener;
37 * Interface that can be implemented by parent activities to get the
38 * alias of the certificate to delete, if the user confirms the deletion.
40 public interface OnCertificateDeleteListener
42 public void onDelete(String alias);
46 public void onAttach(Context context)
48 super.onAttach(context);
49 if (context instanceof OnCertificateDeleteListener)
51 mListener = (OnCertificateDeleteListener)context;
56 public Dialog onCreateDialog(Bundle savedInstanceState)
58 return new AlertDialog.Builder(getActivity())
59 .setIcon(android.R.drawable.ic_dialog_alert)
60 .setTitle(R.string.delete_certificate_question)
61 .setMessage(R.string.delete_certificate)
62 .setPositiveButton(R.string.delete_profile, new DialogInterface.OnClickListener() {
64 public void onClick(DialogInterface dialog, int whichButton)
66 if (mListener != null)
68 mListener.onDelete(getArguments().getString(ALIAS));
72 .setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
74 public void onClick(DialogInterface dialog, int which)