Skip to content

Commit

Permalink
Merge pull request #8 from nikfaris88/_/bugfix/release_3.33.3_grabpay…
Browse files Browse the repository at this point in the history
…_infiniteloop

release_3.33.4
  • Loading branch information
apis17 authored Dec 18, 2023
2 parents 0a614b8 + d93a7a1 commit 1c5e525
Show file tree
Hide file tree
Showing 6 changed files with 720 additions and 721 deletions.
2 changes: 1 addition & 1 deletion molpayxdk/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ afterEvaluate {
from components.release
groupId ='com.rms.mobile'
artifactId = 'mobile_xdk'
version = '3.33.2'
version = '3.33.4'
}
}
}
Expand Down
1,308 changes: 654 additions & 654 deletions molpayxdk/src/main/assets/molpay-mobile-xdk-www/fonts/fontawesome-webfont.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion molpayxdk/src/main/assets/molpay-mobile-xdk-www/index.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<!doctype html> <html> <head> <meta charset="utf-8"> <title></title> <meta name="description" content=""> <!-- <meta name="viewport" content="width=device-width"> --> <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no"> <meta name="format-detection" content="telephone=no"> <!-- Place favicon.ico and apple-touch-icon.png in the root directory --> <link rel="stylesheet" href="styles/vendor.2f041884.css"> <link rel="stylesheet" href="styles/main.08e504b6.css"> </head> <body ng-app="molpayXsdkApp"> <div class="header"> </div> <div id="debugger"></div> <div id="app-body" class="app-body container-fluid"> <div class="row"> <div class="hidden-xs col-sm-2 col-md-3 col-lg-4"></div> <div class="col-xs-12 col-sm-8 col-md-6 col-lg-4" ng-view=""></div> <div class="hidden-xs col-sm-2 col-md-3 col-lg-4"></div> </div> </div> <div ng-cloak ng-show="isStarting || isLoading" class="text-center"> <br> <p>{{label_preparing}}</p> <p>{{label_pleasewait}}</p> </div> <div class="footer"> </div> <div ng-cloak ng-show="isLoading || D7ARequeryActiveNow" class="loading text-center vertical-center"> <div class="loadingbackground"></div> <i class="fa fa-spinner fa-spin fa-3x"></i> <div class="loading-text">{{label_loading}}</div> </div> <div class="iframe-container slide-in" id="mastercardc2pModal" style="display: none;"> <div class="loadingbackground"></div> <iframe class="iframe-checkout" id="mastercardc2pIframe" name="checkout-iframe" title="mastercardc2pIframe" src=""></iframe> </div> <div id="extra"> <script type="module" src="https://src.mastercard.com/srci/integration/components/src-ui-kit/src-ui-kit.esm.js"></script> </div> <script src="scripts/vendor.6fadcbba.js"></script> <script src="scripts/scripts.8ff1a206.js"></script> </body> </html>
<!doctype html> <html> <head> <meta charset="utf-8"> <title></title> <meta name="description" content=""> <!-- <meta name="viewport" content="width=device-width"> --> <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no"> <meta name="format-detection" content="telephone=no"> <!-- Place favicon.ico and apple-touch-icon.png in the root directory --> <link rel="stylesheet" href="styles/vendor.2f041884.css"> <link rel="stylesheet" href="styles/main.08e504b6.css"> </head> <body ng-app="molpayXsdkApp"> <div class="header"> </div> <div id="debugger"></div> <div id="app-body" class="app-body container-fluid"> <div class="row"> <div class="hidden-xs col-sm-2 col-md-3 col-lg-4"></div> <div class="col-xs-12 col-sm-8 col-md-6 col-lg-4" ng-view=""></div> <div class="hidden-xs col-sm-2 col-md-3 col-lg-4"></div> </div> </div> <div ng-cloak ng-show="isStarting || isLoading" class="text-center"> <br> <p>{{label_preparing}}</p> <p>{{label_pleasewait}}</p> </div> <div class="footer"> </div> <div ng-cloak ng-show="isLoading || D7ARequeryActiveNow" class="loading text-center vertical-center"> <div class="loadingbackground"></div> <i class="fa fa-spinner fa-spin fa-3x"></i> <div class="loading-text">{{label_loading}}</div> </div> <div class="iframe-container slide-in" id="mastercardc2pModal" style="display: none;"> <div class="loadingbackground"></div> <iframe class="iframe-checkout" id="mastercardc2pIframe" name="checkout-iframe" title="mastercardc2pIframe" src=""></iframe> </div> <div id="extra"> <script type="module" src="https://src.mastercard.com/srci/integration/components/src-ui-kit/src-ui-kit.esm.js"></script> </div> <script src="scripts/vendor.6fadcbba.js"></script> <script src="scripts/scripts.f4a719f4.js"></script> </body> </html>

Large diffs are not rendered by default.

Large diffs are not rendered by default.

114 changes: 56 additions & 58 deletions molpayxdk/src/main/java/com/molpay/molpayxdk/MOLPayActivity.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.molpay.molpayxdk;

import android.Manifest;
import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.content.ActivityNotFoundException;
import android.content.Intent;
Expand All @@ -13,6 +14,8 @@
import android.os.Bundle;
import android.os.Environment;
import android.os.Message;

import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
import androidx.core.app.ActivityCompat;
import androidx.appcompat.app.AppCompatActivity;
Expand All @@ -38,6 +41,7 @@
import java.io.File;
import java.io.FileOutputStream;
import java.util.HashMap;
import java.util.Objects;

public class MOLPayActivity extends AppCompatActivity {

Expand Down Expand Up @@ -142,6 +146,7 @@ public boolean onOptionsItemSelected(MenuItem item) {
return super.onOptionsItemSelected(item);
}

@SuppressLint("SetJavaScriptEnabled")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Expand All @@ -151,18 +156,19 @@ protected void onCreate(Bundle savedInstanceState) {

// For submodule wrappers
boolean is_submodule = false;
assert paymentDetails != null;
if (paymentDetails.containsKey("is_submodule")) {
is_submodule = Boolean.valueOf(paymentDetails.get("is_submodule").toString());
is_submodule = Boolean.parseBoolean(Objects.requireNonNull(paymentDetails.get("is_submodule")).toString());
}
String submodule_module_id = null;
if (paymentDetails.containsKey("module_id")) {
submodule_module_id = paymentDetails.get("module_id").toString();
submodule_module_id = Objects.requireNonNull(paymentDetails.get("module_id")).toString();
}
String submodule_wrapper_version = null;
if (paymentDetails.containsKey("wrapper_version")) {
submodule_wrapper_version = paymentDetails.get("wrapper_version").toString();
submodule_wrapper_version = Objects.requireNonNull(paymentDetails.get("wrapper_version")).toString();
}
if (is_submodule && submodule_module_id != "" && submodule_wrapper_version != "") {
if (is_submodule && !Objects.equals(submodule_module_id, "") && !Objects.equals(submodule_wrapper_version, "")) {
paymentDetails.put(module_id, submodule_module_id);
paymentDetails.put(wrapper_version, wrapperVersion+"."+submodule_wrapper_version);
} else {
Expand Down Expand Up @@ -194,7 +200,7 @@ protected void onCreate(Bundle savedInstanceState) {
mpMainUI.loadUrl("file:///android_asset/molpay-mobile-xdk-www/index.html");

// Configure MOLPay ui
mpMOLPayUI.getSettings().setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
mpMOLPayUI.getSettings().setCacheMode(WebSettings.LOAD_DEFAULT);
mpMOLPayUI.getSettings().setAllowUniversalAccessFromFileURLs(true);
mpMOLPayUI.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
mpMOLPayUI.getSettings().setSupportMultipleWindows(true);
Expand All @@ -207,29 +213,26 @@ protected void onCreate(Bundle savedInstanceState) {
CookieManager.getInstance().setAcceptCookie(true);

mpMOLPayUI.setLongClickable(true);
mpMOLPayUI.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View view) {
Log.d(MOLPAY, "Long press fired!");
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
mpMOLPayUI.evaluateJavascript("document.getElementById(\"qrcode_img\").src", new ValueCallback<String>() {
@Override
public void onReceiveValue(String qrdata) {
Log.d(MOLPAY, "QR data = " + qrdata);
if(qrdata != null && !qrdata.equals("null")) {
String imageQrCode = qrdata.replaceAll("data:image/png;base64,", "");
Log.d(MOLPAY, "imageQrCode = " + imageQrCode);
byte[] decodedBytes = Base64.decode(imageQrCode, 0);
imgBitmap = BitmapFactory.decodeByteArray(decodedBytes, 0, decodedBytes.length);
filename = paymentDetails.get("mp_order_ID").toString() + ".png";

isStoragePermissionGranted();
}
mpMOLPayUI.setOnLongClickListener(view -> {
Log.d(MOLPAY, "Long press fired!");
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
mpMOLPayUI.evaluateJavascript("document.getElementById(\"qrcode_img\").src", new ValueCallback<String>() {
@Override
public void onReceiveValue(String qrdata) {
Log.d(MOLPAY, "QR data = " + qrdata);
if(qrdata != null && !qrdata.equals("null")) {
String imageQrCode = qrdata.replaceAll("data:image/png;base64,", "");
Log.d(MOLPAY, "imageQrCode = " + imageQrCode);
byte[] decodedBytes = Base64.decode(imageQrCode, 0);
imgBitmap = BitmapFactory.decodeByteArray(decodedBytes, 0, decodedBytes.length);
filename = Objects.requireNonNull(paymentDetails.get("mp_order_ID")) + ".png";

isStoragePermissionGranted();
}
});
}
return false;
}
});
}
return false;
});

}
Expand Down Expand Up @@ -343,32 +346,29 @@ public void onPageFinished (final WebView view, String url) {

Log.d(MOLPAY, "contains url");

view.evaluateJavascript("document.getElementById(\"systembrowserurl\").innerHTML", new ValueCallback<String>() {
@Override
public void onReceiveValue(String s) {
String base64String = s;
Log.d(MOLPAY, "MPMOLPayUIWebClient base64String = " + base64String);

// // Decode base64
byte[] data = Base64.decode(base64String, Base64.DEFAULT);
String dataString = new String(data);
Log.d(MOLPAY, "MPBankUIWebClient dataString = " + dataString);

if (base64String.length() > 0) {
Log.d(MOLPAY, "MPMOLPayUIWebClient success");
Intent intent= new Intent(Intent.ACTION_VIEW, Uri.parse(dataString));
startActivity(intent);
} else {
Log.d(MOLPAY, "MPMOLPayUIWebClient empty dataString");
}
}
});
view.evaluateJavascript("document.getElementById(\"systembrowserurl\").innerHTML", s -> {
Log.d(MOLPAY, "MPMOLPayUIWebClient base64String = " + s);

// // Decode base64
byte[] data = Base64.decode(s, Base64.DEFAULT);
String dataString = new String(data);
Log.d(MOLPAY, "MPBankUIWebClient dataString = " + dataString);

if (s.length() > 0) {
Log.d(MOLPAY, "MPMOLPayUIWebClient success");
Intent intent= new Intent(Intent.ACTION_VIEW, Uri.parse(dataString));
startActivity(intent);
} else {
Log.d(MOLPAY, "MPMOLPayUIWebClient empty dataString");
}
});

}
}
}

private class MPMOLPayUIWebChromeClient extends WebChromeClient {
@SuppressLint("SetJavaScriptEnabled")
@Override
public boolean onCreateWindow(WebView view, boolean dialog, boolean userGesture, Message resultMsg) {

Expand All @@ -379,7 +379,7 @@ public boolean onCreateWindow(WebView view, boolean dialog, boolean userGesture,
mpBankUI = new WebView(MOLPayActivity.this);

mpBankUI.getSettings().setJavaScriptEnabled(true);
mpBankUI.getSettings().setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
mpBankUI.getSettings().setCacheMode(WebSettings.LOAD_DEFAULT);
mpBankUI.getSettings().setAllowUniversalAccessFromFileURLs(true);
mpBankUI.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
mpBankUI.getSettings().setSupportMultipleWindows(true);
Expand Down Expand Up @@ -589,21 +589,19 @@ public boolean isStoragePermissionGranted() {

@TargetApi(23)
@Override
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);

switch (requestCode) {
case REQUEST_EXTERNAL_STORAGE: {
if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
Log.d(MOLPAY, "onRequestPermissionsResult Permission: " + permissions[0] + "was " + grantResults[0]);
//resume tasks needing this permission
if (requestCode == REQUEST_EXTERNAL_STORAGE) {
if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
Log.d(MOLPAY, "onRequestPermissionsResult Permission: " + permissions[0] + "was " + grantResults[0]);
//resume tasks needing this permission

storeImage(imgBitmap);
storeImage(imgBitmap);

} else {
Log.d(MOLPAY, "onRequestPermissionsResult EXTERNAL_STORAGE permission was NOT granted.");
Toast.makeText(this, "Image not saved", Toast.LENGTH_LONG).show();
}
} else {
Log.d(MOLPAY, "onRequestPermissionsResult EXTERNAL_STORAGE permission was NOT granted.");
Toast.makeText(this, "Image not saved", Toast.LENGTH_LONG).show();
}
}
}
Expand Down

0 comments on commit 1c5e525

Please sign in to comment.