This source file includes following definitions.
- onCreateDialog
- onDismiss
package org.chromium.chrome.browser;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.DialogFragment;
import android.content.DialogInterface;
import android.os.Bundle;
import org.chromium.chrome.R;
class KeyStoreSelectionDialog extends DialogFragment {
private static final CharSequence SYSTEM_STORE = "Android";
private final Runnable mSystemCallback;
private final Runnable mSmartCardCallback;
private final Runnable mCancelCallback;
private Runnable mSelectedChoice;
public KeyStoreSelectionDialog(Runnable systemCallback, Runnable smartCardCallback,
Runnable cancelCallback) {
mSystemCallback = systemCallback;
mSmartCardCallback = smartCardCallback;
mCancelCallback = cancelCallback;
mSelectedChoice = mSmartCardCallback;
}
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
final CharSequence[] choices = {
getString(R.string.smartcard_certificate_option),
SYSTEM_STORE
};
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity())
.setTitle(R.string.smartcard_dialog_title)
.setSingleChoiceItems(choices, 0, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {
if (choices[id] == SYSTEM_STORE) {
mSelectedChoice = mSystemCallback;
} else {
mSelectedChoice = mSmartCardCallback;
}
}
})
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {
mSelectedChoice.run();
}
})
.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {
mCancelCallback.run();
}
});
return builder.create();
}
@Override
public void onDismiss(DialogInterface dialog) {
super.onDismiss(dialog);
}
}