Panagiotis Triantafyllou

webview fix for sm deals campaign

......@@ -38,7 +38,7 @@ public class SplashActivity extends BaseActivity {
if (!WarplyDBHelper.getInstance(SplashActivity.this).isTableNotEmpty("auth")) {
//6012049321, 6012049322, 6012049323, 7000000831 history, 7000000826, 7000000831 shared coupons
//prod 6006552990, prod 6005892749, live 3000184910,prod 7000070282, live 3000136179
WarplyManager.getCosmoteUser("7000000833", mLoginReceiver);
WarplyManager.getCosmoteUser("7000023687", mLoginReceiver);
// WarplyManager.verifyTicket("", "7000023699", mLoginReceiver);
} else {
startNextActivity();
......
......@@ -2,7 +2,7 @@ apply plugin: 'com.android.library'
ext {
PUBLISH_GROUP_ID = 'ly.warp'
PUBLISH_VERSION = '4.5.5.4r20'
PUBLISH_VERSION = '4.5.5.4r21'
PUBLISH_ARTIFACT_ID = 'warply-android-sdk'
}
......
......@@ -91,6 +91,7 @@ public class WarpViewActivity extends WarpBaseActivity {
private WarpView mWarpView;
private static Handler metersHandler;
private static boolean mWebviewSupermarket = false;
// ===========================================================
// Methods for/from SuperClass/Interfaces
......@@ -100,6 +101,7 @@ public class WarpViewActivity extends WarpBaseActivity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
metersHandler = new Handler();
mWebviewSupermarket = false;
WarplySessionManager.onCreateActivity(this);
initViews();
Warply.getInitializer(this).init();
......@@ -118,6 +120,16 @@ public class WarpViewActivity extends WarpBaseActivity {
super.onStart();
WarplySessionManager.onStartActivity(this);
EventBus.getDefault().register(this);
if (mWarpView != null) {
if (getWebviewSupermarket()) {
String scriptSourceInit = "webviewDidFocusRefresh(" + String.valueOf(getWebviewSupermarket()) + ");";
mWarpView.evaluateJavascript(scriptSourceInit, s -> {
});
setWebviewSupermarket(false);
}
}
}
@Override
......@@ -133,6 +145,7 @@ public class WarpViewActivity extends WarpBaseActivity {
if (metersHandler != null) metersHandler.removeCallbacksAndMessages(null);
sendSteps();
WarpUtils.setWebviewParams(this, new JSONObject());
setWebviewSupermarket(false);
}
@Override
......@@ -326,6 +339,14 @@ public class WarpViewActivity extends WarpBaseActivity {
return metersHandler;
}
public static boolean getWebviewSupermarket() {
return mWebviewSupermarket;
}
public static void setWebviewSupermarket(boolean isLoaded) {
mWebviewSupermarket = isLoaded;
}
private void sendSteps() {
String date = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss", Locale.getDefault()).format(new Date());
WarpUtils.log("SEND_STEPS: " + String.valueOf(WarpUtils.getStepsCounter(this)));
......
......@@ -139,7 +139,7 @@ public class WarpView extends WebView implements DefaultLifecycleObserver {
private Activity WarpActivity;
private String geolocationOrigin = "";
private Callback geolocationCallback;
private static boolean mWebviewLoaded = false, mWebviewSupermarket = false;
private static boolean mWebviewLoaded = false;
// ===========================================================
// Constructors
......@@ -159,7 +159,6 @@ public class WarpView extends WebView implements DefaultLifecycleObserver {
ProcessLifecycleOwner.get().getLifecycle().addObserver(this);
WarpActivity = activity;
mWebviewLoaded = false;
mWebviewSupermarket = false;
init();
}
......@@ -437,13 +436,6 @@ public class WarpView extends WebView implements DefaultLifecycleObserver {
});
}
if (mWebviewSupermarket) {
String scriptSourceInit = "webviewDidFocusRefresh(" + String.valueOf(mWebviewSupermarket) + ");";
WarpView.this.evaluateJavascript(scriptSourceInit, s -> {
});
mWebviewSupermarket = false;
}
}
@Override
......@@ -481,9 +473,9 @@ public class WarpView extends WebView implements DefaultLifecycleObserver {
if (message.contains("event")) {
String[] parts = message.split(":");
if (parts[1].equals("webviewRefresh")) {
mWebviewSupermarket = true;
WarpViewActivity.setWebviewSupermarket(true);
} else if (parts[1].equals("closeArtwork")) {
mWebviewSupermarket = false;
WarpViewActivity.setWebviewSupermarket(false);
QuestionnaireEventModel questionnaireEvent = new QuestionnaireEventModel();
questionnaireEvent.setName(parts[1]);
EventBus.getDefault().post(new WarplyEventBusManager(questionnaireEvent));
......