Skip to content

Commit 86ec147

Browse files
committed
Transfer Passcode Verification implemented
1 parent 6fbe4f8 commit 86ec147

File tree

5 files changed

+194
-6
lines changed

5 files changed

+194
-6
lines changed

app/src/main/AndroidManifest.xml

Lines changed: 1 addition & 1 deletion
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>
Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
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+
} else {
79+
Toaster.show(view, org.mifos.mobile.R.string.incorrect_passcode);
80+
}
81+
}
82+
83+
@Override
84+
public void passCodeEntered(String passcode) { }
85+
86+
public void clickedOne(View v) {
87+
mifosPassCodeView.enterCode(getString(R.string.one));
88+
}
89+
90+
public void clickedTwo(View v) {
91+
mifosPassCodeView.enterCode(getString(R.string.two));
92+
}
93+
94+
public void clickedThree(View v) {
95+
mifosPassCodeView.enterCode(getString(R.string.three));
96+
}
97+
98+
public void clickedFour(View v) {
99+
mifosPassCodeView.enterCode(getString(R.string.four));
100+
}
101+
102+
public void clickedFive(View v) {
103+
mifosPassCodeView.enterCode(getString(R.string.five));
104+
}
105+
106+
public void clickedSix(View v) {
107+
mifosPassCodeView.enterCode(getString(R.string.six));
108+
}
109+
110+
public void clickedSeven(View v) {
111+
mifosPassCodeView.enterCode(getString(R.string.seven));
112+
}
113+
114+
public void clickedEight(View v) {
115+
mifosPassCodeView.enterCode(getString(R.string.eight));
116+
}
117+
118+
public void clickedNine(View v) {
119+
mifosPassCodeView.enterCode(getString(R.string.nine));
120+
}
121+
122+
public void clickedZero(View v) {
123+
mifosPassCodeView.enterCode(getString(R.string.zero));
124+
}
125+
126+
public void clickedBackSpace(View v) {
127+
mifosPassCodeView.backSpace();
128+
}
129+
130+
public void skip(View v) {
131+
finish();
132+
}
133+
134+
/**
135+
* @param view PasscodeView that changes to text if it was hidden and vice a versa
136+
*/
137+
public void visibilityChange(View view) {
138+
mifosPassCodeView.revertPassCodeVisibility();
139+
if (!mifosPassCodeView.passcodeVisible()) {
140+
ivVisibility.setColorFilter(
141+
ContextCompat.getColor(
142+
TransferVerificationActivity.this,
143+
R.color.light_grey));
144+
} else {
145+
ivVisibility.setColorFilter(
146+
ContextCompat.getColor(
147+
TransferVerificationActivity.this,
148+
R.color.gray_dark));
149+
}
150+
}
151+
152+
/**
153+
* Checks whether passcode entered is of correct length
154+
*
155+
* @return Returns true if passcode lenght is 4 else shows message
156+
*/
157+
private boolean isPassCodeLengthCorrect() {
158+
if (mifosPassCodeView.getPasscode().length() == 4) {
159+
return true;
160+
}
161+
return false;
162+
}
163+
164+
@Override
165+
public void onBackPressed() { }
166+
167+
@Override
168+
protected void onResume() {
169+
super.onResume();
170+
}
171+
}

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

Lines changed: 17 additions & 5 deletions
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,17 @@ 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+
if (requestCode == Constants.VERIFICATION_REQUEST &&
200+
resultCode == getActivity().RESULT_OK) {
201+
if (transferType == TransferType.SELF) {
202+
presenter.makeSavingsTransfer(payload);
203+
} else if (transferType == TransferType.TPT) {
204+
presenter.makeTPTTransfer(payload);
205+
}
206+
}
207+
}
196208
}

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

Lines changed: 2 additions & 0 deletions
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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -572,6 +572,9 @@
572572
<string name="savings_account_transaction">Savings Account Transaction</string>
573573
<string name="transaction_period">Transaction Period</string>
574574
<string name="transaction_type">Transaction Type</string>
575+
<string name="transfer_verify_passcode">Enter your passcode</string>
576+
<string name="cancel_transaction">Cancel</string>
577+
<string name="transfer_type">TransferType</string>
575578

576579
<string-array name="languages" translatable="false">
577580
<item>English</item>

0 commit comments

Comments
 (0)