|
|
@ -10,7 +10,6 @@ import android.graphics.drawable.AnimationDrawable; |
|
|
|
import android.graphics.drawable.ColorDrawable; |
|
|
|
import android.graphics.drawable.ColorDrawable; |
|
|
|
import android.os.Bundle; |
|
|
|
import android.os.Bundle; |
|
|
|
import android.os.Handler; |
|
|
|
import android.os.Handler; |
|
|
|
import android.os.Looper; |
|
|
|
|
|
|
|
import android.view.LayoutInflater; |
|
|
|
import android.view.LayoutInflater; |
|
|
|
import android.view.View; |
|
|
|
import android.view.View; |
|
|
|
import android.widget.ImageView; |
|
|
|
import android.widget.ImageView; |
|
|
@ -54,10 +53,6 @@ public class MainActivity extends AppCompatActivity implements CallableInterface |
|
|
|
|
|
|
|
|
|
|
|
ImageView load; |
|
|
|
ImageView load; |
|
|
|
AnimationDrawable animationDrawable; |
|
|
|
AnimationDrawable animationDrawable; |
|
|
|
private EchoClient paymentClient; |
|
|
|
|
|
|
|
private EchoClient icClient; |
|
|
|
|
|
|
|
private boolean paymentIsConnected = false; |
|
|
|
|
|
|
|
private boolean icIsConnected = false; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private String status; |
|
|
|
private String status; |
|
|
|
|
|
|
|
|
|
|
@ -68,6 +63,7 @@ public class MainActivity extends AppCompatActivity implements CallableInterface |
|
|
|
ActivityResultLauncher<Intent> icVerificationLauncher = registerForActivityResult( |
|
|
|
ActivityResultLauncher<Intent> icVerificationLauncher = registerForActivityResult( |
|
|
|
new ActivityResultContracts.StartActivityForResult(), |
|
|
|
new ActivityResultContracts.StartActivityForResult(), |
|
|
|
result -> { |
|
|
|
result -> { |
|
|
|
|
|
|
|
Logger.logV("Back from ICCActivity: " + result.getResultCode()); |
|
|
|
IDVerificationService service = new IDVerificationService(MainActivity.this); |
|
|
|
IDVerificationService service = new IDVerificationService(MainActivity.this); |
|
|
|
if (result.getResultCode() == Activity.RESULT_OK) { |
|
|
|
if (result.getResultCode() == Activity.RESULT_OK) { |
|
|
|
Intent incomingData = result.getData(); |
|
|
|
Intent incomingData = result.getData(); |
|
|
@ -105,15 +101,23 @@ public class MainActivity extends AppCompatActivity implements CallableInterface |
|
|
|
|
|
|
|
|
|
|
|
load = findViewById(R.id.loading_image_mt); |
|
|
|
load = findViewById(R.id.loading_image_mt); |
|
|
|
//setupTextSlider();
|
|
|
|
//setupTextSlider();
|
|
|
|
|
|
|
|
|
|
|
|
initEchoClient(); |
|
|
|
|
|
|
|
connectEchoClient(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
protected void onResume() { |
|
|
|
protected void onResume() { |
|
|
|
super.onResume(); |
|
|
|
super.onResume(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!MainApplication.icIsConnected) { |
|
|
|
|
|
|
|
initEchoClientIC(); |
|
|
|
|
|
|
|
connectEchoClientIC(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!MainApplication.paymentIsConnected) { |
|
|
|
|
|
|
|
initEchoClientPayment(); |
|
|
|
|
|
|
|
connectEchoClientPayment(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
MainApplication.currentActivity = this; |
|
|
|
MainApplication.currentActivity = this; |
|
|
|
|
|
|
|
|
|
|
|
Intent incomingIntent = getIntent(); |
|
|
|
Intent incomingIntent = getIntent(); |
|
|
@ -240,7 +244,7 @@ public class MainActivity extends AppCompatActivity implements CallableInterface |
|
|
|
} else if (Constants.PAY_FUNCTION_INQUIRY.equalsIgnoreCase(payFunction)) { |
|
|
|
} else if (Constants.PAY_FUNCTION_INQUIRY.equalsIgnoreCase(payFunction)) { |
|
|
|
//handlePayFunctionPreAuth(eventLogDetailed);
|
|
|
|
//handlePayFunctionPreAuth(eventLogDetailed);
|
|
|
|
} else if (Constants.PAY_FUNCTION_CANCEL.equalsIgnoreCase(payFunction)) { |
|
|
|
} else if (Constants.PAY_FUNCTION_CANCEL.equalsIgnoreCase(payFunction)) { |
|
|
|
handlePayFunctionCancel(eventLogDetailed); |
|
|
|
handlePayFunctionCancel(); |
|
|
|
} else if (Constants.PAY_FUNCTION_SETTLEMENT.equalsIgnoreCase(payFunction)) { |
|
|
|
} else if (Constants.PAY_FUNCTION_SETTLEMENT.equalsIgnoreCase(payFunction)) { |
|
|
|
//handlePayFunctionPreAuth(eventLogDetailed);
|
|
|
|
//handlePayFunctionPreAuth(eventLogDetailed);
|
|
|
|
} else if (Constants.PAY_FUNCTION_SET_DATE_TIME.equalsIgnoreCase(payFunction)) { |
|
|
|
} else if (Constants.PAY_FUNCTION_SET_DATE_TIME.equalsIgnoreCase(payFunction)) { |
|
|
@ -277,7 +281,7 @@ public class MainActivity extends AppCompatActivity implements CallableInterface |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void handlePayFunctionCancel(EventLogDetailed eventLogDetailed) { |
|
|
|
private void handlePayFunctionCancel() { |
|
|
|
CancelRequest request = new CancelRequest(); |
|
|
|
CancelRequest request = new CancelRequest(); |
|
|
|
initCancel(request); |
|
|
|
initCancel(request); |
|
|
|
} |
|
|
|
} |
|
|
@ -352,6 +356,8 @@ public class MainActivity extends AppCompatActivity implements CallableInterface |
|
|
|
if (cancelAction) { |
|
|
|
if (cancelAction) { |
|
|
|
if (MainApplication.working && MainApplication.currentActivity instanceof ICCActivity) { |
|
|
|
if (MainApplication.working && MainApplication.currentActivity instanceof ICCActivity) { |
|
|
|
((ICCActivity) MainApplication.currentActivity).cancel(); |
|
|
|
((ICCActivity) MainApplication.currentActivity).cancel(); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
resetView(); |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
if (MainApplication.working) { |
|
|
|
if (MainApplication.working) { |
|
|
@ -575,35 +581,47 @@ public class MainActivity extends AppCompatActivity implements CallableInterface |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void onDestroy() { |
|
|
|
public void onDestroy() { |
|
|
|
super.onDestroy(); |
|
|
|
super.onDestroy(); |
|
|
|
disconnectEchoClient(); |
|
|
|
disconnectEchoClientIC(); |
|
|
|
|
|
|
|
disconnectEchoClientPayment(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void initEchoClientIC() { |
|
|
|
|
|
|
|
Logger.logD("echoClient IC: " + BuildConfig.ECHO_SERVER_URL + ":" + BuildConfig.ECHO_SERVER_PORT); |
|
|
|
|
|
|
|
MainApplication.icClient = new EchoClient(this, BuildConfig.ECHO_SERVER_URL + ":" + BuildConfig.ECHO_SERVER_PORT); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void initEchoClientPayment() { |
|
|
|
|
|
|
|
Logger.logD("echoClient Payment: " + BuildConfig.ECHO_SERVER_URL + ":" + BuildConfig.ECHO_SERVER_PORT); |
|
|
|
|
|
|
|
MainApplication.paymentClient = new EchoClient(this, BuildConfig.ECHO_SERVER_URL + ":" + BuildConfig.ECHO_SERVER_PORT); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void connectEchoClientIC() { |
|
|
|
|
|
|
|
MainApplication.icClient.connect(this::onConnectSuccessIC, this::onConnectFailureIC); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void initEchoClient() { |
|
|
|
private void connectEchoClientPayment() { |
|
|
|
Logger.logD("echoClient: " + BuildConfig.ECHO_SERVER_URL + ":" + BuildConfig.ECHO_SERVER_PORT); |
|
|
|
MainApplication.paymentClient.connect(this::onConnectSuccessPayment, this::onConnectFailurePayment); |
|
|
|
paymentClient = new EchoClient(this, BuildConfig.ECHO_SERVER_URL + ":" + BuildConfig.ECHO_SERVER_PORT); |
|
|
|
|
|
|
|
icClient = new EchoClient(this, BuildConfig.ECHO_SERVER_URL + ":" + BuildConfig.ECHO_SERVER_PORT); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void connectEchoClient() { |
|
|
|
private void disconnectEchoClientIC() { |
|
|
|
paymentClient.connect(this::onConnectSuccessPayment, this::onConnectFailurePayment); |
|
|
|
MainApplication.icClient.disconnect(); |
|
|
|
icClient.connect(this::onConnectSuccessIC, this::onConnectFailureIC); |
|
|
|
MainApplication.icIsConnected = false; |
|
|
|
|
|
|
|
Logger.logD("Disconnect EchoClient IC"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void disconnectEchoClient() { |
|
|
|
private void disconnectEchoClientPayment() { |
|
|
|
paymentClient.disconnect(); |
|
|
|
MainApplication.paymentClient.disconnect(); |
|
|
|
paymentIsConnected = false; |
|
|
|
MainApplication.paymentIsConnected = false; |
|
|
|
icClient.disconnect(); |
|
|
|
Logger.logD("Disconnect EchoClient Payment"); |
|
|
|
icIsConnected = false; |
|
|
|
|
|
|
|
Logger.logD("Disconnect EchoClient"); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void onConnectSuccessPayment(Object[] args) { |
|
|
|
private void onConnectSuccessPayment(Object[] args) { |
|
|
|
paymentIsConnected = true; |
|
|
|
MainApplication.paymentIsConnected = true; |
|
|
|
try { |
|
|
|
try { |
|
|
|
String channelID = BuildConfig.SOCKET_PREFIX + BuildConfig.PAYMENT_CHANNEL_ID + BuildConfig.KIOSK_CODE; |
|
|
|
String channelID = BuildConfig.SOCKET_PREFIX + BuildConfig.PAYMENT_CHANNEL_ID + BuildConfig.KIOSK_CODE; |
|
|
|
String eventType = BuildConfig.PAYMENT_EVENT_TYPE; |
|
|
|
String eventType = BuildConfig.PAYMENT_EVENT_TYPE; |
|
|
|
EchoCallback echoCallback = this::receiveMessagePayment; |
|
|
|
EchoCallback echoCallback = this::receiveMessagePayment; |
|
|
|
paymentClient.channel(channelID).listen(eventType, echoCallback); |
|
|
|
MainApplication.paymentClient.channel(channelID).listen(eventType, echoCallback); |
|
|
|
Logger.logD("Listening to: " + eventType + " on " + channelID); |
|
|
|
Logger.logD("Listening to: " + eventType + " on " + channelID); |
|
|
|
} catch (Exception ex) { |
|
|
|
} catch (Exception ex) { |
|
|
|
Logger.logE("Error on contact: " + ex.getMessage()); |
|
|
|
Logger.logE("Error on contact: " + ex.getMessage()); |
|
|
@ -611,16 +629,17 @@ public class MainActivity extends AppCompatActivity implements CallableInterface |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void onConnectFailurePayment(Object[] args) { |
|
|
|
private void onConnectFailurePayment(Object[] args) { |
|
|
|
paymentIsConnected = false; |
|
|
|
MainApplication.paymentIsConnected = false; |
|
|
|
|
|
|
|
Logger.logW("Failed To Connect Payment"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void onConnectSuccessIC(Object[] args) { |
|
|
|
private void onConnectSuccessIC(Object[] args) { |
|
|
|
icIsConnected = true; |
|
|
|
MainApplication.icIsConnected = true; |
|
|
|
try { |
|
|
|
try { |
|
|
|
String channelID = BuildConfig.SOCKET_PREFIX + BuildConfig.IC_CHANNEL_ID + BuildConfig.KIOSK_CODE; |
|
|
|
String channelID = BuildConfig.SOCKET_PREFIX + BuildConfig.IC_CHANNEL_ID + BuildConfig.KIOSK_CODE; |
|
|
|
String eventType = BuildConfig.IC_EVENT_TYPE; |
|
|
|
String eventType = BuildConfig.IC_EVENT_TYPE; |
|
|
|
EchoCallback echoCallback = this::receiveMessageIC; |
|
|
|
EchoCallback echoCallback = this::receiveMessageIC; |
|
|
|
icClient.channel(channelID).listen(eventType, echoCallback); |
|
|
|
MainApplication.icClient.channel(channelID).listen(eventType, echoCallback); |
|
|
|
Logger.logD("Listening to: " + eventType + " on " + channelID); |
|
|
|
Logger.logD("Listening to: " + eventType + " on " + channelID); |
|
|
|
} catch (Exception ex) { |
|
|
|
} catch (Exception ex) { |
|
|
|
Logger.logE("Error on contact: " + ex.getMessage()); |
|
|
|
Logger.logE("Error on contact: " + ex.getMessage()); |
|
|
@ -628,7 +647,8 @@ public class MainActivity extends AppCompatActivity implements CallableInterface |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void onConnectFailureIC(Object[] args) { |
|
|
|
private void onConnectFailureIC(Object[] args) { |
|
|
|
icIsConnected = false; |
|
|
|
MainApplication.icIsConnected = false; |
|
|
|
|
|
|
|
Logger.logW("Failed To Connect IC"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void startWork() { |
|
|
|
public void startWork() { |
|
|
|