diff --git a/mifospay/src/main/AndroidManifest.xml b/mifospay/src/main/AndroidManifest.xml
index 0fb3591b0..7429f41da 100644
--- a/mifospay/src/main/AndroidManifest.xml
+++ b/mifospay/src/main/AndroidManifest.xml
@@ -148,6 +148,7 @@
+
\ No newline at end of file
diff --git a/mifospay/src/main/java/org/mifos/mobilewallet/mifospay/editprofile/ui/EditProfileActivity.java b/mifospay/src/main/java/org/mifos/mobilewallet/mifospay/editprofile/ui/EditProfileActivity.java
index 82f6f8a35..7e0559304 100644
--- a/mifospay/src/main/java/org/mifos/mobilewallet/mifospay/editprofile/ui/EditProfileActivity.java
+++ b/mifospay/src/main/java/org/mifos/mobilewallet/mifospay/editprofile/ui/EditProfileActivity.java
@@ -30,6 +30,7 @@
import org.mifos.mobilewallet.mifospay.editprofile.EditProfileContract;
import org.mifos.mobilewallet.mifospay.editprofile.presenter.EditProfilePresenter;
import org.mifos.mobilewallet.mifospay.passcode.ui.PassCodeActivity;
+import org.mifos.mobilewallet.mifospay.passcode.ui.EditPasscodeActivity;
import org.mifos.mobilewallet.mifospay.password.ui.EditPasswordActivity;
import org.mifos.mobilewallet.mifospay.utils.Constants;
import org.mifos.mobilewallet.mifospay.utils.DialogBox;
@@ -166,13 +167,8 @@ public void onChangePasswordClicked() {
@OnClick(R.id.btn_change_passcode)
public void onChangePasscodeClicked() {
- String currentPasscode = passcodePreferencesHelper.getPassCode();
- // for re-initiating passcode generation process
- passcodePreferencesHelper.savePassCode("");
- Intent intent = new Intent(this, PassCodeActivity.class );
- intent.putExtra(Constants.CURRENT_PASSCODE, currentPasscode);
- intent.putExtra(Constants.UPDATE_PASSCODE, true);
- startActivity(intent);
+ Intent i = new Intent(EditProfileActivity.this, EditPasscodeActivity.class);
+ startActivityForResult(i , Constants.PASSCODE_VERIFICATION);
}
@OnTextChanged({R.id.et_edit_profile_username, R.id.et_edit_profile_email,
@@ -312,7 +308,6 @@ public void onRequestPermissionsResult(int requestCode, @NonNull String[] permis
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
-
if (resultCode == RESULT_OK) {
if (requestCode == REQUEST_READ_IMAGE && data != null) {
Uri selectedImageUri = data.getData();
@@ -325,6 +320,14 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
Bundle extras = data.getExtras();
Bitmap profileBitmapImage = (Bitmap) extras.get("data");
ivUserImage.setImageBitmap(profileBitmapImage);
+ } else if ( requestCode == Constants.PASSCODE_VERIFICATION) {
+ String currentPasscode = passcodePreferencesHelper.getPassCode();
+ // for re-initiating passcode generation process
+ passcodePreferencesHelper.savePassCode("");
+ Intent intent = new Intent(this, PassCodeActivity.class );
+ intent.putExtra(Constants.CURRENT_PASSCODE, currentPasscode);
+ intent.putExtra(Constants.UPDATE_PASSCODE, true);
+ startActivity(intent);
}
}
}
diff --git a/mifospay/src/main/java/org/mifos/mobilewallet/mifospay/passcode/ui/EditPasscodeActivity.java b/mifospay/src/main/java/org/mifos/mobilewallet/mifospay/passcode/ui/EditPasscodeActivity.java
new file mode 100644
index 000000000..97d6da6de
--- /dev/null
+++ b/mifospay/src/main/java/org/mifos/mobilewallet/mifospay/passcode/ui/EditPasscodeActivity.java
@@ -0,0 +1,163 @@
+package org.mifos.mobilewallet.mifospay.passcode.ui;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.os.Bundle;
+import android.support.v4.content.ContextCompat;
+import android.support.v4.widget.NestedScrollView;
+import android.support.v7.app.AppCompatActivity;
+import android.support.v7.widget.AppCompatButton;
+import android.view.View;
+import android.widget.Button;
+import android.widget.ImageView;
+import android.widget.TextView;
+import android.widget.Toast;
+
+import com.mifos.mobile.passcode.MifosPassCodeView;
+import com.mifos.mobile.passcode.utils.EncryptionUtil;
+import com.mifos.mobile.passcode.utils.PasscodePreferencesHelper;
+
+import org.mifos.mobilewallet.mifospay.R;
+
+
+public class EditPasscodeActivity extends AppCompatActivity implements MifosPassCodeView.
+ PassCodeListener {
+
+ NestedScrollView clRootview;
+ AppCompatButton btnForgotPasscode;
+ MifosPassCodeView mifosPassCodeView;
+ AppCompatButton btnSkip;
+ Button btnSave;
+ TextView tvPasscodeIntro;
+ ImageView ivVisibility;
+ private PasscodePreferencesHelper passcodePreferencesHelper;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_pass_code);
+
+ clRootview = findViewById(R.id.cl_rootview);
+ btnForgotPasscode = findViewById(R.id.btn_forgot_passcode);
+ mifosPassCodeView = findViewById(R.id.pv_passcode);
+ btnSkip = findViewById(R.id.btn_skip);
+ btnSkip.setText(getString(R.string.cancel));
+ btnSave = findViewById(R.id.btn_save);
+ btnSave.setText(getString(R.string.ok));
+ tvPasscodeIntro = findViewById(R.id.tv_passcode);
+ tvPasscodeIntro.setText(getString(R.string.enter_passcode));
+ ivVisibility = findViewById(R.id.iv_visibility);
+ passcodePreferencesHelper = new PasscodePreferencesHelper(this);
+ }
+
+ private String encryptPassCode(String passCode) {
+ String encryptedPassCode = EncryptionUtil.getMobileBankingHash(passCode);
+ return encryptedPassCode;
+ }
+
+
+ public void savePassCode(View view) {
+ if (isPassCodeLengthCorrect()) {
+ if (encryptPassCode(mifosPassCodeView.getPasscode()).equals(passcodePreferencesHelper
+ .getPassCode())
+ ) {
+ Intent resultIntent = new Intent();
+ setResult(Activity.RESULT_OK, resultIntent);
+ finish();
+ } else {
+ Toast.makeText(this, getString(R.string.incorrect_passcode),
+ Toast.LENGTH_SHORT).show();
+ }
+ } else {
+ Toast.makeText(this, getString(R.string.invalid_passcode),
+ Toast.LENGTH_SHORT).show();
+ }
+ }
+
+ @Override
+ public void passCodeEntered(String passcode) { }
+
+ public void clickedOne(View v) {
+ mifosPassCodeView.enterCode(getString(R.string.one));
+ }
+
+ public void clickedTwo(View v) {
+ mifosPassCodeView.enterCode(getString(R.string.two));
+ }
+
+ public void clickedThree(View v) {
+ mifosPassCodeView.enterCode(getString(R.string.three));
+ }
+
+ public void clickedFour(View v) {
+ mifosPassCodeView.enterCode(getString(R.string.four));
+ }
+
+ public void clickedFive(View v) {
+ mifosPassCodeView.enterCode(getString(R.string.five));
+ }
+
+ public void clickedSix(View v) {
+ mifosPassCodeView.enterCode(getString(R.string.six));
+ }
+
+ public void clickedSeven(View v) {
+ mifosPassCodeView.enterCode(getString(R.string.seven));
+ }
+
+ public void clickedEight(View v) {
+ mifosPassCodeView.enterCode(getString(R.string.eight));
+ }
+
+ public void clickedNine(View v) {
+ mifosPassCodeView.enterCode(getString(R.string.nine));
+ }
+
+ public void clickedZero(View v) {
+ mifosPassCodeView.enterCode(getString(R.string.zero));
+ }
+
+ public void clickedBackSpace(View v) {
+ mifosPassCodeView.backSpace();
+ }
+
+ public void skip(View v) {
+ finish();
+ }
+
+ /**
+ * @param view PasscodeView that changes to text if it was hidden and vice a versa
+ */
+ public void visibilityChange(View view) {
+ mifosPassCodeView.revertPassCodeVisibility();
+ if (!mifosPassCodeView.passcodeVisible()) {
+ ivVisibility.setColorFilter(
+ ContextCompat.getColor(EditPasscodeActivity.this,
+ R.color.light_grey));
+ } else {
+ ivVisibility.setColorFilter(ContextCompat.getColor(
+ EditPasscodeActivity.this,
+ R.color.gray_dark));
+ }
+ }
+
+ /**
+ * Checks whether passcode entered is of correct length
+ *
+ * @return Returns true if passcode lenght is 4 else shows message
+ */
+ private boolean isPassCodeLengthCorrect() {
+ if (mifosPassCodeView.getPasscode().length() == 4) {
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ public void onBackPressed() { }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+ }
+}
diff --git a/mifospay/src/main/java/org/mifos/mobilewallet/mifospay/utils/Constants.java b/mifospay/src/main/java/org/mifos/mobilewallet/mifospay/utils/Constants.java
index 4bd74b77e..4fcd6369c 100644
--- a/mifospay/src/main/java/org/mifos/mobilewallet/mifospay/utils/Constants.java
+++ b/mifospay/src/main/java/org/mifos/mobilewallet/mifospay/utils/Constants.java
@@ -59,6 +59,7 @@ public class Constants {
public static final String KYC_REGISTRATION_LEVEL_3 = "KYC Registration Level 3";
public static final String OK = "OK";
public static final String SCAN_CODE = "Scan code";
+ public static final int PASSCODE_VERIFICATION = 299;
public static final String QR_CODE = "QR code";
public static final String FAILED_TO_WRITE_DATA_TO_QR = "Failed to write data to qr";
public static final String ERROR_OCCURRED = "Error occurred";
diff --git a/mifospay/src/main/res/values/strings.xml b/mifospay/src/main/res/values/strings.xml
index 897c38189..2ca4bfe04 100644
--- a/mifospay/src/main/res/values/strings.xml
+++ b/mifospay/src/main/res/values/strings.xml
@@ -1,6 +1,8 @@
Mifos Pay
-
+ Invalid Passcode
+ Incorrect Passcode
+ Enter your passcode
Open Drawer
Close Drawer
Cancel
@@ -262,7 +264,7 @@
Amount
The transaction history with this merchant will be shown here
Do you want to logout?
- Ok
+ OK
Are you sure you want to disable account?
This will delete all the information about your account
Transfer money to this merchant