public HookUpGroupPasswordDialog(final Activity activity) { super(activity, R.style.Theme_Transparent); mActivity = activity; setContentView(R.layout.group_password_dialog); mEtGroupPassword = (EditText) findViewById(R.id.etGroupPassword); mEtGroupPassword.setTypeface(SpikaApp.getTfMyriadPro()); mBtnOk = (Button) findViewById(R.id.btnOk); mBtnOk.setTypeface(SpikaApp.getTfMyriadProBold(), Typeface.BOLD); mBtnOk.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { String passwordsResult = checkPasswords(); if (passwordsResult.equals(PASSWORD_SUCCESS)) { if (activity instanceof GroupProfileActivity) { if (mIsSubscribe) { ((GroupProfileActivity) activity).addToFavoritesAsync(mGroupId); } else { ((GroupProfileActivity) activity).redirect(); } HookUpGroupPasswordDialog.this.dismiss(); } } else { Toast.makeText(activity, passwordsResult, Toast.LENGTH_SHORT).show(); } } }); mBtnCancel = (Button) this.findViewById(R.id.btnCancel); mBtnCancel.setTypeface(SpikaApp.getTfMyriadProBold(), Typeface.BOLD); mBtnCancel.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { HookUpGroupPasswordDialog.this.dismiss(); } }); }
private String checkPasswords() { String currentPass = FileManagement.md5(mEtGroupPassword.getText().toString()); if (!currentPass.equals(mCurrentPassword)) { return mActivity.getString(R.string.wrongpassword); } SpikaApp.getPreferences().savePasswordForGroup(mGroupId, mCurrentPassword); return PASSWORD_SUCCESS; }