Skip to content

Commit 0f5482c

Browse files
committed
fix#1250 passcode verification implemented
1 parent 5c96db2 commit 0f5482c

File tree

5 files changed

+205
-6
lines changed

5 files changed

+205
-6
lines changed

app/src/main/AndroidManifest.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,8 @@
146146
android:exported="false"
147147
android:name="org.mifos.mobile.utils.fcm.RegistrationIntentService">
148148
</service>
149-
150149
<activity android:name="org.mifos.mobile.ui.activities.SettingsActivity"/>
150+
<activity android:name="com.mifos.mobile.passcode.TransferVerificationActivity"/>
151151
</application>
152152

153153
</manifest>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,178 @@
1+
package com.mifos.mobile.passcode;
2+
3+
import android.app.Activity;
4+
import android.content.Intent;
5+
import android.os.Bundle;
6+
import android.view.View;
7+
8+
import android.widget.ImageView;
9+
import android.widget.TextView;
10+
11+
import com.mifos.mobile.passcode.utils.PasscodePreferencesHelper;
12+
import com.mifos.mobile.passcode.utils.EncryptionUtil;
13+
14+
import org.mifos.mobile.utils.Toaster;
15+
16+
import androidx.appcompat.app.AppCompatActivity;
17+
import androidx.appcompat.widget.AppCompatButton;
18+
import androidx.core.content.ContextCompat;
19+
import androidx.core.widget.NestedScrollView;
20+
21+
22+
public class TransferVerificationActivity extends
23+
AppCompatActivity implements
24+
MifosPassCodeView.
25+
PassCodeListener {
26+
27+
NestedScrollView clRootview;
28+
AppCompatButton btnForgotPasscode;
29+
MifosPassCodeView mifosPassCodeView;
30+
AppCompatButton btnSkip;
31+
AppCompatButton btnSave;
32+
TextView tvPasscodeIntro;
33+
ImageView ivVisibility;
34+
ImageView ivLogo;
35+
36+
private PasscodePreferencesHelper passcodePreferencesHelper;
37+
38+
@Override
39+
protected void onCreate(Bundle savedInstanceState) {
40+
super.onCreate(savedInstanceState);
41+
setContentView(R.layout.activity_pass_code);
42+
43+
clRootview = findViewById(R.id.cl_rootview);
44+
btnForgotPasscode = findViewById(R.id.btn_forgot_passcode);
45+
mifosPassCodeView = findViewById(R.id.pv_passcode);
46+
btnSkip = findViewById(R.id.btn_skip);
47+
btnSkip.setText(getString(org.mifos.mobile.R.string.cancel_transaction));
48+
btnSave = findViewById(R.id.btn_save);
49+
btnSave.setText(getString(org.mifos.mobile.R.string.transfer));
50+
tvPasscodeIntro = findViewById(R.id.tv_passcode);
51+
tvPasscodeIntro.setText(getString(org.mifos.mobile.R.string.transfer_verify_passcode));
52+
ivVisibility = findViewById(R.id.iv_visibility);
53+
ivLogo = findViewById(R.id.iv_logo);
54+
ivLogo.setImageResource(org.mifos.mobile.R.drawable.mifos_logo);
55+
56+
passcodePreferencesHelper = new PasscodePreferencesHelper(this);
57+
58+
}
59+
60+
private String encryptPassCode(String passCode) {
61+
String encryptedPassCode = EncryptionUtil.getMobileBankingHash(passCode);
62+
return encryptedPassCode;
63+
}
64+
65+
66+
public void savePassCode(View view) {
67+
if (isPassCodeLengthCorrect()) {
68+
if (encryptPassCode(mifosPassCodeView.getPasscode())
69+
.equals(passcodePreferencesHelper
70+
.getPassCode())
71+
) {
72+
Intent resultIntent = new Intent();
73+
setResult(Activity.RESULT_OK, resultIntent);
74+
finish();
75+
} else {
76+
Toaster.show(view, org.mifos.mobile.R.string.incorrect_passcode);
77+
78+
}
79+
} else {
80+
Toaster.show(view, org.mifos.mobile.R.string.incorrect_passcode);
81+
}
82+
}
83+
84+
@Override
85+
public void passCodeEntered(String passcode) {
86+
87+
}
88+
89+
public void clickedOne(View v) {
90+
mifosPassCodeView.enterCode(getString(R.string.one));
91+
}
92+
93+
public void clickedTwo(View v) {
94+
mifosPassCodeView.enterCode(getString(R.string.two));
95+
}
96+
97+
public void clickedThree(View v) {
98+
mifosPassCodeView.enterCode(getString(R.string.three));
99+
}
100+
101+
public void clickedFour(View v) {
102+
mifosPassCodeView.enterCode(getString(R.string.four));
103+
}
104+
105+
public void clickedFive(View v) {
106+
mifosPassCodeView.enterCode(getString(R.string.five));
107+
}
108+
109+
public void clickedSix(View v) {
110+
mifosPassCodeView.enterCode(getString(R.string.six));
111+
}
112+
113+
public void clickedSeven(View v) {
114+
mifosPassCodeView.enterCode(getString(R.string.seven));
115+
}
116+
117+
public void clickedEight(View v) {
118+
mifosPassCodeView.enterCode(getString(R.string.eight));
119+
}
120+
121+
public void clickedNine(View v) {
122+
mifosPassCodeView.enterCode(getString(R.string.nine));
123+
}
124+
125+
public void clickedZero(View v) {
126+
mifosPassCodeView.enterCode(getString(R.string.zero));
127+
}
128+
129+
public void clickedBackSpace(View v) {
130+
mifosPassCodeView.backSpace();
131+
}
132+
133+
public void skip(View v) {
134+
finish();
135+
}
136+
137+
/**
138+
* @param view PasscodeView that changes to text if it was hidden and vice a versa
139+
*/
140+
public void visibilityChange(View view) {
141+
mifosPassCodeView.revertPassCodeVisibility();
142+
if (!mifosPassCodeView.passcodeVisible()) {
143+
ivVisibility.setColorFilter(
144+
ContextCompat.getColor(
145+
TransferVerificationActivity.this,
146+
R.color.light_grey));
147+
} else {
148+
ivVisibility.setColorFilter(
149+
ContextCompat.getColor(
150+
TransferVerificationActivity.this,
151+
R.color.gray_dark));
152+
}
153+
}
154+
155+
/**
156+
* Checks whether passcode entered is of correct length
157+
*
158+
* @return Returns true if passcode lenght is 4 else shows message
159+
*/
160+
private boolean isPassCodeLengthCorrect() {
161+
if (mifosPassCodeView.getPasscode().length() == 4) {
162+
return true;
163+
}
164+
return false;
165+
}
166+
167+
@Override
168+
public void onBackPressed() {
169+
170+
}
171+
172+
@Override
173+
protected void onResume() {
174+
super.onResume();
175+
176+
}
177+
178+
}

app/src/main/java/org/mifos/mobile/ui/fragments/TransferProcessFragment.java

+21-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.mifos.mobile.ui.fragments;
22

3+
import android.content.Intent;
34
import android.graphics.drawable.Animatable;
45
import android.os.Bundle;
56
import android.view.LayoutInflater;
@@ -10,6 +11,7 @@
1011
import android.widget.TextView;
1112

1213
import com.google.android.material.snackbar.Snackbar;
14+
import com.mifos.mobile.passcode.TransferVerificationActivity;
1315

1416
import org.mifos.mobile.R;
1517
import org.mifos.mobile.models.payload.TransferPayload;
@@ -124,11 +126,8 @@ public void startTransfer() {
124126
Toaster.show(rootView, getString(R.string.internet_not_connected));
125127
return;
126128
}
127-
if (transferType == TransferType.SELF) {
128-
presenter.makeSavingsTransfer(payload);
129-
} else if (transferType == TransferType.TPT) {
130-
presenter.makeTPTTransfer(payload);
131-
}
129+
Intent i = new Intent(getActivity(), TransferVerificationActivity.class);
130+
startActivityForResult(i, Constants.VERIFICATION_REQUEST);
132131
}
133132

134133
/**
@@ -193,4 +192,21 @@ public void onDestroyView() {
193192
super.onDestroyView();
194193
presenter.detachView();
195194
}
195+
196+
@Override
197+
public void onActivityResult(int requestCode, int resultCode, Intent data) {
198+
super.onActivityResult(requestCode, resultCode, data);
199+
switch (requestCode) {
200+
case (Constants.VERIFICATION_REQUEST) : {
201+
if (resultCode == getActivity().RESULT_OK) {
202+
if (transferType == TransferType.SELF) {
203+
presenter.makeSavingsTransfer(payload);
204+
} else if (transferType == TransferType.TPT) {
205+
presenter.makeTPTTransfer(payload);
206+
}
207+
}
208+
break;
209+
}
210+
}
211+
}
196212
}

app/src/main/java/org/mifos/mobile/utils/Constants.java

+2
Original file line numberDiff line numberDiff line change
@@ -126,4 +126,6 @@ public class Constants {
126126
public static final String OUTSTANDING_BALANCE = "outstanding_balance";
127127

128128
public static final String LOAN_REPAYMENT = "loan_repayment";
129+
130+
public static final int VERIFICATION_REQUEST = 299;
129131
}

app/src/main/res/values/strings.xml

+3
Original file line numberDiff line numberDiff line change
@@ -567,6 +567,9 @@
567567
<string name="savings_account_transaction">Savings Account Transaction</string>
568568
<string name="transaction_period">Transaction Period</string>
569569
<string name="transaction_type">Transaction Type</string>
570+
<string name="transfer_verify_passcode">Enter your passcode</string>
571+
<string name="cancel_transaction">Cancel</string>
572+
<string name="transfer_type">TransferType</string>
570573

571574
<string-array name="languages" translatable="false">
572575
<item>English</item>

0 commit comments

Comments
 (0)