Example usage for android.app Activity getLayoutInflater

List of usage examples for android.app Activity getLayoutInflater

Introduction

In this page you can find the example usage for android.app Activity getLayoutInflater.

Prototype

@NonNull
public LayoutInflater getLayoutInflater() 

Source Link

Document

Convenience for calling android.view.Window#getLayoutInflater .

Usage

From source file:com.docd.purefm.adapters.BrowserBaseAdapter.java

protected BrowserBaseAdapter(@NonNull final Activity context) {
    if (sDrawableLruCache == null) {
        sDrawableLruCache = new DrawableLruCache<>();
    }/*from w w w . j av  a 2 s  . co m*/
    if (sMimeTypeIconCache == null) {
        sMimeTypeIconCache = new DrawableLruCache<>();
    }
    mSettings = Settings.getInstance(context);
    mPreviewHolder = PreviewHolder.getInstance(context);
    mTheme = context.getTheme();
    mResources = context.getResources();
    mHandler = new FileObserverEventHandler(this);
    mLayoutInflater = context.getLayoutInflater();
}

From source file:org.thbz.hanguldrill.HelpDialogFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    Activity activity = getActivity();

    AlertDialog.Builder builder = new AlertDialog.Builder(activity);

    // Initialiser le texte de l'aide  partir d'un fichier inclu dans l'APK
    StringBuilder htmlHelpText = new StringBuilder();
    try {/*w  w  w  . j a  v  a2 s  .  c  o m*/
        BufferedReader in = new BufferedReader(
                new InputStreamReader(activity.getAssets().open("help_contents.html")));
        String line;
        int state = 0;
        while ((line = in.readLine()) != null) {
            if (line.contains("<!-- START APP CONTENTS -->"))
                state = 1;
            else if (state == 1) {
                if (line.contains("<!-- END APP CONTENTS -->"))
                    state = 2;
                else
                    htmlHelpText.append(line);
            }
        }
    } catch (IOException exc) {
        htmlHelpText.setLength(0);
        htmlHelpText.append("Help is not available (").append(exc.getMessage()).append(")");
    }

    LayoutInflater inflater = activity.getLayoutInflater();
    View dialogView = inflater.inflate(R.layout.dialog_help, null);
    TextView helpTextView = (TextView) dialogView.findViewById(R.id.dialog_help_text);
    helpTextView.setText(Html.fromHtml(htmlHelpText.toString()));

    // Allow for external hyperlinks in the HTML text
    helpTextView.setMovementMethod(LinkMovementMethod.getInstance());

    // Inflate and set the layout for the dialog
    // Pass null as the parent view because its going in the dialog layout
    builder.setView(dialogView)
            // Add action buttons
            .setPositiveButton("Ok", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int id) {
                }
            });

    return builder.create();
}

From source file:org.uguess.android.sysinfo.NetStateManager.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = super.onCreateView(inflater, container, savedInstanceState);

    ListView listView = (ListView) view.findViewById(android.R.id.list);

    registerForContextMenu(listView);/*from  ww w  .  j ava2  s  .com*/

    ArrayAdapter<ConnectionItem> adapter = new ArrayAdapter<ConnectionItem>(getActivity(), R.layout.net_item) {

        public android.view.View getView(int position, android.view.View convertView,
                android.view.ViewGroup parent) {
            View view;
            TextView txt_proto, txt_ip, txt_state;

            Activity ctx = getActivity();

            if (convertView == null) {
                view = ctx.getLayoutInflater().inflate(R.layout.net_item, parent, false);
            } else {
                view = convertView;
            }

            if (position >= getCount()) {
                return view;
            }

            ConnectionItem itm = getItem(position);

            txt_proto = (TextView) view.findViewById(R.id.txt_proto);
            txt_ip = (TextView) view.findViewById(R.id.txt_ip);
            txt_state = (TextView) view.findViewById(R.id.txt_state);

            txt_proto.setText(itm.proto);
            txt_state.setText(itm.state);

            boolean showLocal = Util.getBooleanOption(ctx, PSTORE_NETMANAGER, PREF_KEY_SHOW_LOCAL_ADDRESS);

            if (itm == dummyInfo) {
                if (showLocal) {
                    txt_ip.setText(R.string.local_remote_addr);
                } else {
                    txt_ip.setText(R.string.remote_address);
                }

                txt_proto.setTextColor(Color.WHITE);
                txt_ip.setTextColor(Color.WHITE);
                txt_state.setTextColor(Color.WHITE);
            } else {
                if (showLocal) {
                    txt_ip.setText(itm.local + '\n' + (itm.remoteName == null ? itm.remote : itm.remoteName));
                } else {
                    txt_ip.setText(itm.remoteName == null ? itm.remote : itm.remoteName);
                }

                txt_proto.setTextAppearance(ctx, android.R.style.TextAppearance_Small);
                txt_ip.setTextAppearance(ctx, android.R.style.TextAppearance_Small);
                txt_state.setTextAppearance(ctx, android.R.style.TextAppearance_Small);
            }

            return view;
        }
    };

    setListAdapter(adapter);

    return view;
}

From source file:com.hackensack.umc.activity.ProfileSelfieActivity.java

public void showAlert(Activity activity, String title, String message) {
    if (!activity.isFinishing()) {

        android.support.v7.app.AlertDialog.Builder builder = new android.support.v7.app.AlertDialog.Builder(
                activity);//from  ww  w  . jav a  2 s.  co  m

        LayoutInflater inflater = activity.getLayoutInflater();
        View dialogView = inflater.inflate(R.layout.dialog_network_offline, null);
        builder.setView(dialogView);

        if (title.length() > 0)
            ((TextView) dialogView.findViewById(R.id.dialog_title)).setText(title);
        else
            ((TextView) dialogView.findViewById(R.id.dialog_title)).setVisibility(View.GONE);

        ((TextView) dialogView.findViewById(R.id.text_message)).setText(message);

        Button btnDismiss = (Button) dialogView.findViewById(R.id.button_dialog_ok);
        btnDismiss.setOnClickListener(new Button.OnClickListener() {

            @Override
            public void onClick(View v) {
                alert.dismiss();
                isMessageShown = true;
                selectedImageView = Constant.SELFIE;
                imageUri = CameraFunctionality.dispatchTakePictureIntent(ProfileSelfieActivity.this, 1,
                        Constant.SELFIE);
            }
        });

        alert = builder.show();
    }

}

From source file:com.social.solution.fragment.MyFragment.java

@Override
public void onAttach(Activity activity) {
    super.onAttach(activity);

    ViewBinder viewBinder = new ViewBinder.Builder(R.layout.mynativead).mainImageId(R.id.tw__full_ad_image)
            .iconImageId(R.id.tw__tweet_author_avatar_pran).titleId(R.id.tw__tweet_author_full_name_pran)
            .textId(R.id.tw__tweet_text_pran)
            //.addExtra("sponsoredText", R.id.sponsored_text)
            //.addExtra("sponsoredImage", R.id.sponsored_image)
            .build();//from   w w w. jav  a2  s. c om

    MoPubNativeAdPositioning.MoPubServerPositioning adPositioning = MoPubNativeAdPositioning
            .serverPositioning();
    MoPubNativeAdRenderer adRenderer = new MoPubNativeAdRenderer(viewBinder);

    footer = (View) activity.getLayoutInflater().inflate(R.layout.listview_footer_row, null);

    tweetadapter = new MyAdapter(activity);
    mAdAdapter = new MoPubAdAdapter(activity, tweetadapter, adPositioning);
    mAdAdapter.registerAdRenderer(adRenderer);

    storedActivity = activity;

    LoadFirst();
}

From source file:org.sufficientlysecure.keychain.ui.dialog.EditSubkeyExpiryDialogFragment.java

/**
 * Creates dialog/* ww w  . j a  v  a 2  s.com*/
 */
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    Activity activity = getActivity();

    mMessenger = getArguments().getParcelable(ARG_MESSENGER);
    long creation = getArguments().getLong(ARG_CREATION);
    long expiry = getArguments().getLong(ARG_EXPIRY);

    final Calendar creationCal = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
    creationCal.setTimeInMillis(creation * 1000);
    Calendar expiryCal = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
    expiryCal.setTimeInMillis(expiry * 1000);

    // date picker works with default time zone, we need to convert from UTC to default timezone
    creationCal.setTimeZone(TimeZone.getDefault());
    expiryCal.setTimeZone(TimeZone.getDefault());

    // Explicitly not using DatePickerDialog here!
    // DatePickerDialog is difficult to customize and has many problems (see old git versions)
    CustomAlertDialogBuilder alert = new CustomAlertDialogBuilder(activity);

    alert.setTitle(R.string.expiry_date_dialog_title);

    LayoutInflater inflater = activity.getLayoutInflater();
    View view = inflater.inflate(R.layout.edit_subkey_expiry_dialog, null);
    alert.setView(view);

    final CheckBox noExpiry = (CheckBox) view.findViewById(R.id.edit_subkey_expiry_no_expiry);
    final DatePicker datePicker = (DatePicker) view.findViewById(R.id.edit_subkey_expiry_date_picker);
    final TextView currentExpiry = (TextView) view.findViewById(R.id.edit_subkey_expiry_current_expiry);
    final LinearLayout expiryLayout = (LinearLayout) view.findViewById(R.id.edit_subkey_expiry_layout);

    noExpiry.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            if (isChecked) {
                expiryLayout.setVisibility(View.GONE);
            } else {
                expiryLayout.setVisibility(View.VISIBLE);
            }
        }
    });

    if (expiry == 0L) {
        noExpiry.setChecked(true);
        expiryLayout.setVisibility(View.GONE);

        currentExpiry.setText(R.string.btn_no_date);
    } else {
        noExpiry.setChecked(false);
        expiryLayout.setVisibility(View.VISIBLE);

        currentExpiry.setText(DateFormat.getDateFormat(getActivity()).format(expiryCal.getTime()));
    }

    // date picker works based on default time zone
    Calendar todayCal = Calendar.getInstance(TimeZone.getDefault());
    if (creationCal.after(todayCal)) {
        // NOTE: This is just for the rare cases where creation is _after_ today
        // Min Date: Creation date + 1 day

        Calendar creationCalPlusOne = (Calendar) creationCal.clone();
        creationCalPlusOne.add(Calendar.DAY_OF_YEAR, 1);
        datePicker.setMinDate(creationCalPlusOne.getTime().getTime());
        datePicker.init(creationCalPlusOne.get(Calendar.YEAR), creationCalPlusOne.get(Calendar.MONTH),
                creationCalPlusOne.get(Calendar.DAY_OF_MONTH), null);
    } else {
        // Min Date: today + 1 day

        // at least one day after creation (today)
        todayCal.add(Calendar.DAY_OF_YEAR, 1);
        datePicker.setMinDate(todayCal.getTime().getTime());
        datePicker.init(todayCal.get(Calendar.YEAR), todayCal.get(Calendar.MONTH),
                todayCal.get(Calendar.DAY_OF_MONTH), null);
    }

    alert.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int id) {
            dismiss();

            long expiry;
            if (noExpiry.isChecked()) {
                expiry = 0L;
            } else {
                Calendar selectedCal = Calendar.getInstance(TimeZone.getDefault());
                //noinspection ResourceType
                selectedCal.set(datePicker.getYear(), datePicker.getMonth(), datePicker.getDayOfMonth());
                // date picker uses default time zone, we need to convert to UTC
                selectedCal.setTimeZone(TimeZone.getTimeZone("UTC"));

                long numDays = (selectedCal.getTimeInMillis() / 86400000)
                        - (creationCal.getTimeInMillis() / 86400000);
                if (numDays <= 0) {
                    Activity activity = getActivity();
                    if (activity != null) {
                        Notify.create(activity, R.string.error_expiry_past, Style.ERROR).show();
                    }
                    return;
                }
                expiry = selectedCal.getTime().getTime() / 1000;
            }

            Bundle data = new Bundle();
            data.putSerializable(MESSAGE_DATA_EXPIRY, expiry);
            sendMessageToHandler(MESSAGE_NEW_EXPIRY, data);
        }
    });

    alert.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int id) {
            dismiss();
        }
    });

    return alert.show();
}

From source file:im.neon.activity.CommonActivityUtils.java

/**
 * Display the device verification warning
 *
 * @param deviceInfo the device info/*from  ww w. j a  va 2  s  .  c om*/
 */
static public <T> void displayDeviceVerificationDialog(final MXDeviceInfo deviceInfo, final String sender,
        final MXSession session, Activity activiy, final ApiCallback<Void> callback) {

    // sanity check
    if ((null == deviceInfo) || (null == sender) || (null == session)) {
        Log.e(LOG_TAG, "## displayDeviceVerificationDialog(): invalid imput parameters");
        return;
    }

    android.support.v7.app.AlertDialog.Builder builder = new android.support.v7.app.AlertDialog.Builder(
            activiy);
    LayoutInflater inflater = activiy.getLayoutInflater();

    View layout = inflater.inflate(R.layout.encrypted_verify_device, null);

    TextView textView;

    textView = (TextView) layout.findViewById(R.id.encrypted_device_info_device_name);
    textView.setText(deviceInfo.displayName());

    textView = (TextView) layout.findViewById(R.id.encrypted_device_info_device_id);
    textView.setText(deviceInfo.deviceId);

    textView = (TextView) layout.findViewById(R.id.encrypted_device_info_device_key);
    textView.setText(deviceInfo.fingerprint());

    builder.setView(layout);
    builder.setTitle(R.string.encryption_information_verify_device);

    builder.setPositiveButton(R.string.encryption_information_verify_key_match,
            new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    session.getCrypto().setDeviceVerification(MXDeviceInfo.DEVICE_VERIFICATION_VERIFIED,
                            deviceInfo.deviceId, sender, callback);
                }
            });

    builder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
        }
    });

    builder.create().show();
}

From source file:com.docd.purefm.ui.dialogs.FilePropertiesDialog.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    final Activity activity = getActivity();
    if (activity == null || activity.isFinishing()) {
        return null;
    }/*from  w  w w .j av a  2s. c o m*/
    final AlertDialog.Builder builder = new AlertDialog.Builder(activity);
    mAdapter = new PropertiesAdapter(activity, file);
    builder.setIcon(ThemeUtils.getDrawableNonNull(activity, R.attr.ic_menu_info));
    builder.setTitle(file.getName());
    builder.setNeutralButton(R.string.close, null);
    builder.setPositiveButton(R.string.apply, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            final FilePermissionsPagerItem fragment = (FilePermissionsPagerItem) mAdapter.getItem(1);
            fragment.applyPermissions(getActivity());
        }
    });

    //noinspection InflateParams
    final View content = activity.getLayoutInflater().inflate(R.layout.dialog_properties_container, null);
    if (content == null) {
        throw new RuntimeException("Inflated view is null");
    }
    this.initView(content);
    builder.setView(content);
    final AlertDialog dialog = builder.create();
    dialog.setOnShowListener(new DialogInterface.OnShowListener() {
        @Override
        public void onShow(final DialogInterface dialog) {
            final Button button = ((AlertDialog) dialog).getButton(DialogInterface.BUTTON_POSITIVE);
            if (button == null) {
                throw new RuntimeException("Can't get positive button");
            }
            button.setVisibility(View.GONE);
        }
    });
    return dialog;
}

From source file:org.sufficientlysecure.keychain.ui.dialog.PassphraseDialogFragment.java

/**
 * Creates dialog/*from  w w  w.j  a  v  a2  s  . c om*/
 */
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    final Activity activity = getActivity();
    final long secretKeyId = getArguments().getLong(ARG_SECRET_KEY_ID);
    mMessenger = getArguments().getParcelable(ARG_MESSENGER);

    AlertDialog.Builder alert = new AlertDialog.Builder(activity);

    alert.setTitle(R.string.title_authentication);

    final PGPSecretKey secretKey;

    if (secretKeyId == Id.key.symmetric || secretKeyId == Id.key.none) {
        secretKey = null;
        alert.setMessage(R.string.passPhraseForSymmetricEncryption);
    } else {
        // TODO: by master key id???
        secretKey = PgpHelper.getMasterKey(ProviderHelper.getPGPSecretKeyRingByKeyId(activity, secretKeyId));
        // secretKey = PGPHelper.getMasterKey(PGPMain.getSecretKeyRing(secretKeyId));

        if (secretKey == null) {
            alert.setTitle(R.string.title_keyNotFound);
            alert.setMessage(getString(R.string.keyNotFound, secretKeyId));
            alert.setPositiveButton(android.R.string.ok, new OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    dismiss();
                }
            });
            alert.setCancelable(false);
            canKB = false;
            return alert.create();
        }
        String userId = PgpHelper.getMainUserIdSafe(activity, secretKey);

        Log.d(Constants.TAG, "User id: '" + userId + "'");
        alert.setMessage(getString(R.string.passPhraseFor, userId));
    }

    LayoutInflater inflater = activity.getLayoutInflater();
    View view = inflater.inflate(R.layout.passphrase, null);
    alert.setView(view);

    mPassphraseEditText = (EditText) view.findViewById(R.id.passphrase_passphrase);

    alert.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int id) {
            dismiss();
            long curKeyIndex = 1;
            boolean keyOK = true;
            String passPhrase = mPassphraseEditText.getText().toString();
            long keyId;
            PGPSecretKey clickSecretKey = secretKey;

            if (clickSecretKey != null) {
                while (keyOK == true) {
                    if (clickSecretKey != null) { //check again for loop
                        try {
                            PBESecretKeyDecryptor keyDecryptor = new JcePBESecretKeyDecryptorBuilder()
                                    .setProvider(PgpMain.BOUNCY_CASTLE_PROVIDER_NAME)
                                    .build(passPhrase.toCharArray());
                            PGPPrivateKey testKey = clickSecretKey.extractPrivateKey(keyDecryptor);
                            if (testKey == null) {
                                if (!clickSecretKey.isMasterKey()) {
                                    Toast.makeText(activity, R.string.error_couldNotExtractPrivateKey,
                                            Toast.LENGTH_SHORT).show();
                                    return;
                                } else {
                                    clickSecretKey = PgpHelper.getKeyNum(
                                            ProviderHelper.getPGPSecretKeyRingByKeyId(activity, secretKeyId),
                                            curKeyIndex);
                                    curKeyIndex++; //does post-increment work like C?
                                    continue;
                                }
                            } else {
                                keyOK = false;
                            }
                        } catch (PGPException e) {
                            Toast.makeText(activity, R.string.wrongPassPhrase, Toast.LENGTH_SHORT).show();
                            return;
                        }
                    } else {
                        Toast.makeText(activity, R.string.error_couldNotExtractPrivateKey, Toast.LENGTH_SHORT)
                                .show();
                        return; //ran out of keys to try
                    }
                }
                keyId = secretKey.getKeyID();
            } else {
                keyId = Id.key.symmetric;
            }

            // cache the new passphrase
            Log.d(Constants.TAG, "Everything okay! Caching entered passphrase");
            PassphraseCacheService.addCachedPassphrase(activity, keyId, passPhrase);
            if (keyOK == false && clickSecretKey.getKeyID() != keyId) {
                PassphraseCacheService.addCachedPassphrase(activity, clickSecretKey.getKeyID(), passPhrase);
            }

            sendMessageToHandler(MESSAGE_OKAY);
        }
    });

    alert.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int id) {
            dismiss();
        }
    });

    canKB = true;
    return alert.create();
}

From source file:org.thialfihar.android.apg.ui.dialog.PassphraseDialogFragment.java

/**
 * Creates dialog/*from   w w w  .  j a v  a  2  s .  c  o  m*/
 */
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    final Activity activity = getActivity();
    final long secretKeyId = getArguments().getLong(ARG_SECRET_KEY_ID);
    mMessenger = getArguments().getParcelable(ARG_MESSENGER);

    AlertDialog.Builder alert = new AlertDialog.Builder(activity);

    alert.setTitle(R.string.title_authentication);

    final PGPSecretKey secretKey;

    if (secretKeyId == Id.key.symmetric || secretKeyId == Id.key.none) {
        secretKey = null;
        alert.setMessage(R.string.passphrase_for_symmetric_encryption);
    } else {
        // TODO: by master key id???
        secretKey = PgpKeyHelper.getMasterKey(ProviderHelper.getPGPSecretKeyRingByKeyId(activity, secretKeyId));
        // secretKey = PGPHelper.getMasterKey(PGPMain.getSecretKeyRing(secretKeyId));

        if (secretKey == null) {
            alert.setTitle(R.string.title_key_not_found);
            alert.setMessage(getString(R.string.key_not_found, secretKeyId));
            alert.setPositiveButton(android.R.string.ok, new OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    dismiss();
                }
            });
            alert.setCancelable(false);
            mCanRequestFocus = false;
            return alert.create();
        }
        String userId = PgpKeyHelper.getMainUserIdSafe(activity, secretKey);

        Log.d(Constants.TAG, "User id: '" + userId + "'");
        alert.setMessage(getString(R.string.passphrase_for, userId));
    }

    LayoutInflater inflater = activity.getLayoutInflater();
    View view = inflater.inflate(R.layout.passphrase_dialog, null);
    alert.setView(view);

    mPassphraseEditText = (EditText) view.findViewById(R.id.passphrase_passphrase);

    alert.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int id) {
            dismiss();
            long curKeyIndex = 1;
            boolean keyOK = true;
            String passphrase = mPassphraseEditText.getText().toString();
            long keyId;
            PGPSecretKey clickSecretKey = secretKey;

            if (clickSecretKey != null) {
                while (keyOK) {
                    if (clickSecretKey != null) { // check again for loop
                        try {
                            PBESecretKeyDecryptor keyDecryptor = new JcePBESecretKeyDecryptorBuilder()
                                    .setProvider(Constants.BOUNCY_CASTLE_PROVIDER_NAME)
                                    .build(passphrase.toCharArray());
                            PGPPrivateKey testKey = clickSecretKey.extractPrivateKey(keyDecryptor);
                            if (testKey == null) {
                                if (!clickSecretKey.isMasterKey()) {
                                    Toast.makeText(activity, R.string.error_could_not_extract_private_key,
                                            Toast.LENGTH_SHORT).show();

                                    sendMessageToHandler(MESSAGE_CANCEL);
                                    return;
                                } else {
                                    clickSecretKey = PgpKeyHelper.getKeyNum(
                                            ProviderHelper.getPGPSecretKeyRingByKeyId(activity, secretKeyId),
                                            curKeyIndex);
                                    curKeyIndex++; // does post-increment work like C?
                                    continue;
                                }
                            } else {
                                keyOK = false;
                            }
                        } catch (PGPException e) {
                            Toast.makeText(activity, R.string.wrong_passphrase, Toast.LENGTH_SHORT).show();

                            sendMessageToHandler(MESSAGE_CANCEL);
                            return;
                        }
                    } else {
                        Toast.makeText(activity, R.string.error_could_not_extract_private_key,
                                Toast.LENGTH_SHORT).show();

                        sendMessageToHandler(MESSAGE_CANCEL);
                        return; // ran out of keys to try
                    }
                }
                keyId = secretKey.getKeyID();
            } else {
                keyId = Id.key.symmetric;
            }

            // cache the new passphrase
            Log.d(Constants.TAG, "Everything okay! Caching entered passphrase");
            PassphraseCacheService.addCachedPassphrase(activity, keyId, passphrase);
            if (!keyOK && clickSecretKey.getKeyID() != keyId) {
                PassphraseCacheService.addCachedPassphrase(activity, clickSecretKey.getKeyID(), passphrase);
            }

            sendMessageToHandler(MESSAGE_OKAY);
        }
    });

    alert.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int id) {
            dialog.cancel();
        }
    });

    mCanRequestFocus = true;
    return alert.create();
}