@Override
  public void onDialogClosed(boolean positiveResult) {

    if (positiveResult) {
      if (boolProtect && strPass1 != null && strPass1.equals(strPass2)) {
        String hash = Utils.md5(strPass1);
        MyApplication.PrefKey.SET_PASSWORD.putString(hash);
      }
      ((PasswordPreference) getPreference()).setValue(boolProtect);
    }
  }
 @Override
 public void onClick(View v) {
   final SharedPreferences settings = MyApplication.getInstance().getSettings();
   final String securityQuestion = MyApplication.PrefKey.SECURITY_QUESTION.getString("");
   EditText input = (EditText) dialog.findViewById(R.id.password);
   TextView error = (TextView) dialog.findViewById(R.id.passwordInvalid);
   if (v == dialog.getButton(AlertDialog.BUTTON_NEGATIVE)) {
     if ((Boolean) input.getTag()) {
       input.setTag(Boolean.valueOf(false));
       ((Button) v).setText(R.string.password_lost);
       dialog.setTitle(R.string.password_prompt);
     } else {
       input.setTag(Boolean.valueOf(true));
       dialog.setTitle(securityQuestion);
       ((Button) v).setText(android.R.string.cancel);
     }
   } else {
     String value = input.getText().toString();
     boolean isInSecurityQuestion = (Boolean) input.getTag();
     if (Utils.md5(value)
         .equals(
             (isInSecurityQuestion
                     ? MyApplication.PrefKey.SECURITY_ANSWER
                     : MyApplication.PrefKey.SET_PASSWORD)
                 .getString(""))) {
       input.setText("");
       error.setText("");
       MyApplication.getInstance().setLocked(false);
       ctx.findViewById(android.R.id.content).setVisibility(View.VISIBLE);
       if (ctx instanceof ActionBarActivity) {
         ((ActionBarActivity) ctx).getSupportActionBar().show();
       }
       if (isInSecurityQuestion) {
         MyApplication.PrefKey.PERFORM_PROTECTION.putBoolean(false);
         Toast.makeText(
                 ctx.getBaseContext(), R.string.password_disabled_reenable, Toast.LENGTH_LONG)
             .show();
         dialog.getButton(AlertDialog.BUTTON_NEGATIVE).setText(R.string.password_lost);
         dialog.setTitle(R.string.password_prompt);
         input.setTag(Boolean.valueOf(false));
       }
       dialog.dismiss();
     } else {
       input.setText("");
       error.setText(
           isInSecurityQuestion
               ? R.string.password_security_answer_not_valid
               : R.string.password_not_valid);
     }
   }
 }