Browse Source

Update

hbw_build
Wong Joon Hui 3 years ago
parent
commit
d47c595e4c
  1. 3
      app/src/main/java/com/cst/im30/activity/ICCActivity.java
  2. 31
      app/src/main/java/com/cst/im30/activity/MainActivity.java
  3. 2
      app/src/main/java/com/cst/im30/common/Constants.java
  4. 19
      app/src/main/java/com/cst/im30/utility/Logger.java

3
app/src/main/java/com/cst/im30/activity/ICCActivity.java

@ -29,10 +29,11 @@ import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Date; import java.util.Date;
import java.util.Locale;
public class ICCActivity extends AppCompatActivity { public class ICCActivity extends AppCompatActivity {
private static final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); private static final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.ENGLISH);
private static final int RETURN_REQUEST = 0; private static final int RETURN_REQUEST = 0;
public static IccDetectedThread iccDetectedThread; public static IccDetectedThread iccDetectedThread;
public static CardDetectedThread cardDetectedThread; public static CardDetectedThread cardDetectedThread;

31
app/src/main/java/com/cst/im30/activity/MainActivity.java

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

2
app/src/main/java/com/cst/im30/common/Constants.java

@ -2,6 +2,8 @@ package com.cst.im30.common;
public class Constants { public class Constants {
//change to gradle properties
public static final String SERVER_URL = "http://hello-booking-api-build.testpigeon.net"; public static final String SERVER_URL = "http://hello-booking-api-build.testpigeon.net";
public static final String CLIENT_ID = "3"; public static final String CLIENT_ID = "3";
public static final String CLIENT_SECRET = "w5RJ7bMF6NH39aDVyJJV0M1gOg0nZQcO2atVcXyF"; public static final String CLIENT_SECRET = "w5RJ7bMF6NH39aDVyJJV0M1gOg0nZQcO2atVcXyF";

19
app/src/main/java/com/cst/im30/utility/Logger.java

@ -0,0 +1,19 @@
package com.cst.im30.utility;
import android.util.Log;
public class Logger {
public static final String TAG = "CST";
public static void logD(String title, String message) {
Log.d(TAG, title + " - " + message);
}
public static void logI(String title, String message) {
Log.i(TAG, title + " - " + message);
}
public static void logV(String title, String message) {
Log.v(TAG, title + " - " + message);
}
}
Loading…
Cancel
Save