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
+ }
0 commit comments