|
|
|
@ -1,7 +1,6 @@
|
|
|
|
|
package com.cst.im30.activity; |
|
|
|
|
|
|
|
|
|
import android.app.Activity; |
|
|
|
|
import android.content.Context; |
|
|
|
|
import android.content.Intent; |
|
|
|
|
import android.graphics.drawable.AnimationDrawable; |
|
|
|
|
import android.os.Bundle; |
|
|
|
@ -23,6 +22,7 @@ import com.cst.im30.common.CallableInterface;
|
|
|
|
|
import com.cst.im30.common.Constants; |
|
|
|
|
import com.cst.im30.model.EventLogDetailed; |
|
|
|
|
import com.cst.im30.service.IDVerificationService; |
|
|
|
|
import com.cst.im30.utility.Logger; |
|
|
|
|
import com.daimajia.slider.library.SliderLayout; |
|
|
|
|
import com.daimajia.slider.library.SliderTypes.BaseSliderView; |
|
|
|
|
import com.daimajia.slider.library.SliderTypes.TextSliderView; |
|
|
|
@ -35,7 +35,7 @@ import org.json.JSONObject;
|
|
|
|
|
import java.util.regex.Pattern; |
|
|
|
|
|
|
|
|
|
public class MainActivity extends AppCompatActivity implements CallableInterface { |
|
|
|
|
public static final String TAG = "CST-DBG"; |
|
|
|
|
public static final String TAG = "MainActivity."; |
|
|
|
|
//Set value to get temp value-RefNum
|
|
|
|
|
private static String value; |
|
|
|
|
//Set value to get temp value-Amount
|
|
|
|
@ -266,8 +266,9 @@ public class MainActivity extends AppCompatActivity implements CallableInterface
|
|
|
|
|
runOnUiThread(() -> textViewViewRespTranslateAmount.setText("Amount..."));*/ |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void receiveMessage(Object... args) { |
|
|
|
|
Log.d(TAG, "receiveMessage"); |
|
|
|
|
private void receiveMessagePayment(Object... args) { |
|
|
|
|
Logger.logD(TAG + "receiveMessagePayment()", "Received Payment Message"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//debug error
|
|
|
|
|
try { |
|
|
|
@ -303,7 +304,7 @@ public class MainActivity extends AppCompatActivity implements CallableInterface
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void receiveMessageIC(Object... args) { |
|
|
|
|
Log.d(TAG, "receiveMessage"); |
|
|
|
|
Logger.logD(TAG + "receiveMessageIC()", "Received IC Message"); |
|
|
|
|
|
|
|
|
|
//debug error
|
|
|
|
|
try { |
|
|
|
@ -335,6 +336,7 @@ public class MainActivity extends AppCompatActivity implements CallableInterface
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void initEchoClient() { |
|
|
|
|
Logger.logD(TAG + "initEchoClient()", "echoClient: " + Constants.ECHO_SERVER_URL + ":" + Constants.ECHO_SERVER_PORT); |
|
|
|
|
paymentClient = new EchoClient(this, Constants.ECHO_SERVER_URL + ":" + Constants.ECHO_SERVER_PORT); |
|
|
|
|
icClient = new EchoClient(this, Constants.ECHO_SERVER_URL + ":" + Constants.ECHO_SERVER_PORT); |
|
|
|
|
} |
|
|
|
@ -349,6 +351,7 @@ public class MainActivity extends AppCompatActivity implements CallableInterface
|
|
|
|
|
paymentIsConnected = false; |
|
|
|
|
icClient.disconnect(); |
|
|
|
|
icIsConnected = false; |
|
|
|
|
Logger.logD(TAG + "disconnectEchoClient()", ""); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void onConnectSuccessPayment(Object[] args) { |
|
|
|
@ -356,8 +359,9 @@ public class MainActivity extends AppCompatActivity implements CallableInterface
|
|
|
|
|
try { |
|
|
|
|
String channelID = Constants.SOCKET_PREFIX + Constants.PAYMENT_CHANNEL_ID + Constants.KIOSK_CODE; |
|
|
|
|
String eventType = Constants.PAYMENT_EVENT_TYPE; |
|
|
|
|
EchoCallback echoCallback = this::receiveMessage; |
|
|
|
|
EchoCallback echoCallback = this::receiveMessagePayment; |
|
|
|
|
paymentClient.channel(channelID).listen(eventType, echoCallback); |
|
|
|
|
Logger.logD(TAG + "onConnectSuccessPayment()", "Listening to: " + eventType + " on " + channelID); |
|
|
|
|
} catch (Exception ex) { |
|
|
|
|
Log.e("Error on contact", ex.getMessage()); |
|
|
|
|
} |
|
|
|
@ -374,6 +378,7 @@ public class MainActivity extends AppCompatActivity implements CallableInterface
|
|
|
|
|
String eventType = Constants.IC_EVENT_TYPE; |
|
|
|
|
EchoCallback echoCallback = this::receiveMessageIC; |
|
|
|
|
icClient.channel(channelID).listen(eventType, echoCallback); |
|
|
|
|
Logger.logD(TAG + "onConnectSuccessIC()", "Listening to: " + eventType + " on " + channelID); |
|
|
|
|
} catch (Exception ex) { |
|
|
|
|
Log.e("Error on contact", ex.getMessage()); |
|
|
|
|
} |
|
|
|
@ -387,11 +392,12 @@ public class MainActivity extends AppCompatActivity implements CallableInterface
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void callBack(String source) { |
|
|
|
|
|
|
|
|
|
Logger.logD(TAG + "callBack()", source); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void callBack(String source, Object object) { |
|
|
|
|
Logger.logD(TAG + "callBack()", source); |
|
|
|
|
if (source.equalsIgnoreCase(IDVerificationService.CALLBACK_SUCCESS_GET_EVENT_LOG)) { |
|
|
|
|
this.eventLogDetailed = (EventLogDetailed) object; |
|
|
|
|
Intent i = new Intent(MainActivity.this, ICCActivity.class); |
|
|
|
@ -401,21 +407,26 @@ public class MainActivity extends AppCompatActivity implements CallableInterface
|
|
|
|
|
|
|
|
|
|
private boolean verifyIC(String name, String cardNo) { |
|
|
|
|
boolean match = true; |
|
|
|
|
String savedNo = this.eventLogDetailed.getDocumentNumber().trim(); |
|
|
|
|
String firstName = this.eventLogDetailed.getFirstName().trim().toUpperCase(); |
|
|
|
|
|
|
|
|
|
Logger.logD(TAG + "verifyIC()", "Comparing: " + name + ":" + cardNo + " to " + savedNo + ":" + firstName); |
|
|
|
|
|
|
|
|
|
// Verify Card No.
|
|
|
|
|
String savedNo = this.eventLogDetailed.getDocumentNumber().trim(); |
|
|
|
|
if (!cardNo.contains(savedNo)) { |
|
|
|
|
match = false; |
|
|
|
|
Toast.makeText(MainActivity.this, "Card Number not correct!", Toast.LENGTH_SHORT).show(); |
|
|
|
|
Logger.logD(TAG + "verifyIC()", "Card Number not correct! " + cardNo + " : " + savedNo); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Verify Name...
|
|
|
|
|
String firstName = this.eventLogDetailed.getFirstName().trim().toUpperCase(); |
|
|
|
|
|
|
|
|
|
String[] firstNames = firstName.split(Pattern.quote(" ")); |
|
|
|
|
for (String s : firstNames) { |
|
|
|
|
if (!name.contains(s)) { |
|
|
|
|
match = false; |
|
|
|
|
Toast.makeText(MainActivity.this, "First Name not found", Toast.LENGTH_SHORT).show(); |
|
|
|
|
Logger.logD(TAG + "verifyIC()", "First Name Not Found! " + s + " : " + name); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -426,12 +437,14 @@ public class MainActivity extends AppCompatActivity implements CallableInterface
|
|
|
|
|
if (!name.contains(s)) { |
|
|
|
|
match = false; |
|
|
|
|
Toast.makeText(MainActivity.this, "Last Name not found", Toast.LENGTH_SHORT).show(); |
|
|
|
|
Logger.logD(TAG + "verifyIC()", "Last Name Not Found! " + s + " : " + name); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (match) { |
|
|
|
|
Toast.makeText(MainActivity.this, "NRIC match!", Toast.LENGTH_SHORT).show(); |
|
|
|
|
Logger.logD(TAG + "verifyIC()", "NRIC MATCH!"); |
|
|
|
|
} |
|
|
|
|
return match; |
|
|
|
|
} |
|
|
|
|