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