Toggle navigation
Toggle navigation
This project
Loading...
Sign in
open-source
/
warply_android_sdk_maven_plugin
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
Panagiotis Triantafyllou
2025-02-13 14:19:33 +0200
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
395834caf62ed45789073115b36f568cdc9ae6a4
395834ca
1 parent
a8c1f71f
magenta fixes and additions
Show whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
411 additions
and
929 deletions
.idea/deploymentTargetSelector.xml
warply_android_sdk/build.gradle
warply_android_sdk/src/main/java/ly/warp/sdk/Warply.java
warply_android_sdk/src/main/java/ly/warp/sdk/activities/BaseFragmentActivity.java
warply_android_sdk/src/main/java/ly/warp/sdk/activities/WarpViewActivity.java
warply_android_sdk/src/main/java/ly/warp/sdk/fragments/HomeFragment.java
warply_android_sdk/src/main/java/ly/warp/sdk/io/callbacks/InboxStatsHook.java
warply_android_sdk/src/main/java/ly/warp/sdk/io/models/InboxStats.java
warply_android_sdk/src/main/java/ly/warp/sdk/io/models/QuestionnaireEventModel.java
warply_android_sdk/src/main/java/ly/warp/sdk/utils/WarplyManagerHelper.java
warply_android_sdk/src/main/java/ly/warp/sdk/utils/managers/WarplyAnalyticsManager.java
warply_android_sdk/src/main/java/ly/warp/sdk/utils/managers/WarplyEventBusManager.java
warply_android_sdk/src/main/java/ly/warp/sdk/utils/managers/WarplyManager.java
warply_android_sdk/src/main/java/ly/warp/sdk/views/WarpView.java
warply_android_sdk/src/main/res/layout/fragment_home.xml
warply_android_sdk/src/main/res/values/strings.xml
.idea/deploymentTargetSelector.xml
View file @
395834c
...
...
@@ -4,6 +4,14 @@
<selectionStates>
<SelectionState
runConfigName=
"app"
>
<option
name=
"selectionMode"
value=
"DROPDOWN"
/>
<DropdownSelection
timestamp=
"2025-02-13T08:44:19.612560Z"
>
<Target
type=
"DEFAULT_BOOT"
>
<handle>
<DeviceId
pluginId=
"PhysicalDevice"
identifier=
"serial=R58M42EM7YT"
/>
</handle>
</Target>
</DropdownSelection>
<DialogSelection
/>
</SelectionState>
</selectionStates>
</component>
...
...
warply_android_sdk/build.gradle
View file @
395834c
...
...
@@ -55,6 +55,7 @@ dependencies {
api
"androidx.security:security-crypto:1.1.0-alpha03"
// For minSDK 23 use 1.0.0, for minSDK 21 use 1.1.0 that is currently in alpha
api
'org.altbeacon:android-beacon-library:2.19.3'
api
'org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2'
api
'io.reactivex.rxjava3:rxjava:3.1.8'
api
'io.reactivex.rxjava3:rxandroid:3.0.2'
implementation
'com.google.android.material:material:1.5.0'
...
...
warply_android_sdk/src/main/java/ly/warp/sdk/Warply.java
View file @
395834c
...
...
@@ -25,8 +25,6 @@
package
ly
.
warp
.
sdk
;
import
static
ly
.
warp
.
sdk
.
utils
.
constants
.
WarpConstants
.
IN_APP_FILTER_ALL
;
import
android.content.ActivityNotFoundException
;
import
android.content.Context
;
import
android.content.DialogInterface
;
...
...
@@ -36,7 +34,6 @@ import android.content.pm.PackageManager.NameNotFoundException;
import
android.database.Cursor
;
import
android.net.Uri
;
import
android.text.TextUtils
;
import
android.util.Log
;
import
androidx.appcompat.app.AlertDialog
;
...
...
@@ -44,34 +41,23 @@ import org.json.JSONArray;
import
org.json.JSONException
;
import
org.json.JSONObject
;
import
java.io.File
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.Comparator
;
import
java.util.Iterator
;
import
java.util.Map
;
import
java.util.concurrent.atomic.AtomicBoolean
;
import
ly.warp.sdk.db.WarplyDBHelper
;
import
ly.warp.sdk.io.callbacks.CallbackReceiver
;
import
ly.warp.sdk.io.callbacks.CampaignsHook
;
import
ly.warp.sdk.io.callbacks.InboxStatsHook
;
import
ly.warp.sdk.io.callbacks.PostHook
;
import
ly.warp.sdk.io.callbacks.SimpleCallbackReceiver
;
import
ly.warp.sdk.io.callbacks.VolleyTransformer
;
import
ly.warp.sdk.io.callbacks.WarplyReadyCallback
;
import
ly.warp.sdk.io.models.Campaign
;
import
ly.warp.sdk.io.models.CampaignList
;
import
ly.warp.sdk.io.models.InboxStats
;
import
ly.warp.sdk.io.request.WarplyInboxRequest
;
import
ly.warp.sdk.io.request.WarplyJsonArrayRequest
;
import
ly.warp.sdk.io.request.WarplyJsonObjectRequest
;
import
ly.warp.sdk.io.volley.Request.Method
;
import
ly.warp.sdk.io.volley.RequestQueue
;
import
ly.warp.sdk.io.volley.toolbox.Volley
;
import
ly.warp.sdk.receivers.WarplyBeaconsApplication
;
import
ly.warp.sdk.utils.ObjectSerializer
;
import
ly.warp.sdk.utils.WarpJSONParser
;
import
ly.warp.sdk.utils.WarpUtils
;
import
ly.warp.sdk.utils.WarplyDeviceInfoCollector
;
import
ly.warp.sdk.utils.WarplyInitializer
;
...
...
@@ -140,7 +126,7 @@ public enum Warply {
if
(
context
!=
null
)
{
INSTANCE
.
mContext
=
context
.
getApplicationContext
();
}
initInternal
(
context
);
initInternal
(
context
,
true
);
}
});
}
...
...
@@ -162,6 +148,22 @@ public enum Warply {
WarplyServerPreferencesManager
.
initiateMicroAppStatusesMap
(
context
);
}
private
static
void
initInternal
(
Context
context
,
boolean
isNew
)
{
if
(
context
!=
null
)
{
INSTANCE
.
check
(
context
);
if
(
INSTANCE
.
mRequestQueue
==
null
)
INSTANCE
.
mRequestQueue
=
Volley
.
newRequestQueue
(
context
);
INSTANCE
.
mContext
=
context
.
getApplicationContext
();
WarpConstants
.
DEBUG
=
WarplyProperty
.
isDebugMode
(
INSTANCE
.
mContext
);
INSTANCE
.
isInitializedOrThrow
();
WarpConstants
.
GCM_SENDER_ID
=
WarpUtils
.
getLastGCMSenderId
(
INSTANCE
.
mContext
);
if
(!
WarpUtils
.
getLastApplicationUUID
(
context
).
equals
(
WarplyProperty
.
getAppUuid
(
context
)))
{
resetWarplyWebId
();
}
WarplyServerPreferencesManager
.
initiateMicroAppStatusesMap
(
context
);
}
}
/**
* Method used to check if the Warply.INSTANCE is correctly initialized. If
* not, it throws a runtime exception with a message describing the reason
...
...
@@ -328,12 +330,6 @@ public enum Warply {
INSTANCE
.
postReceiveMicroappDataInternal
(
hasAuthHeaders
,
path
,
jObj
,
receiver
);
}
public
static
void
postReceiveMicroappData
(
String
microappName
,
boolean
hasAuthHeaders
,
String
path
,
JSONObject
jObj
,
CallbackReceiver
<
JSONObject
>
receiver
)
{
INSTANCE
.
isInitializedOrThrow
();
INSTANCE
.
postReceiveMicroappDataInternal
(
microappName
,
hasAuthHeaders
,
path
,
jObj
,
receiver
);
}
private
void
postReceiveMicroappDataInternal
(
String
microappName
,
JSONObject
jObj
,
CallbackReceiver
<
JSONObject
>
receiver
)
{
if
(!
WarpUtils
.
isRegisteredWarply
(
mContext
))
{
...
...
@@ -368,25 +364,6 @@ public enum Warply {
postToServerInternal
(
hasAuthHeaders
,
path
,
jObj
,
receiver
,
tag
);
}
private
void
postReceiveMicroappDataInternal
(
String
microappName
,
boolean
hasAuthHeaders
,
String
path
,
JSONObject
jObj
,
CallbackReceiver
<
JSONObject
>
receiver
)
{
if
(!
WarpUtils
.
isRegisteredWarply
(
mContext
))
{
if
(
receiver
!=
null
)
receiver
.
onFailure
(
WarpConstants
.
RESULT_CODE_NOT_REGISTERED
);
return
;
}
JSONObject
jObject
=
new
JSONObject
();
try
{
jObject
.
putOpt
(
microappName
,
jObj
);
}
catch
(
JSONException
e
)
{
if
(
WarpConstants
.
DEBUG
)
{
e
.
printStackTrace
();
}
}
postToServerInternal
(
hasAuthHeaders
,
path
,
jObject
,
receiver
,
null
);
}
/**
* Default method used to post data to context. Same as
* postMicroappData(String,JSONObject,false)
...
...
@@ -418,11 +395,6 @@ public enum Warply {
INSTANCE
.
postMicroappDataInternal
(
microappName
,
jObj
,
force
);
}
public
static
void
postMicroappData
(
Context
context
,
String
microappName
,
JSONObject
jObj
,
boolean
force
)
{
INSTANCE
.
isInitializedOrThrow
();
INSTANCE
.
postMicroappDataInternal
(
context
,
microappName
,
jObj
,
force
);
}
private
void
postMicroappDataInternal
(
String
microappName
,
JSONObject
jObj
,
boolean
force
)
{
isInitializedOrThrow
();
long
requestsInQueueCount
=
0
;
...
...
@@ -433,16 +405,6 @@ public enum Warply {
tryWakingSendingTaskInternal
(
requestsInQueueCount
);
}
private
void
postMicroappDataInternal
(
Context
context
,
String
microappName
,
JSONObject
jObj
,
boolean
force
)
{
isInitializedOrThrow
();
long
requestsInQueueCount
=
0
;
if
(
jObj
!=
null
&&
context
!=
null
)
{
requestsInQueueCount
=
WarplyDBHelper
.
getInstance
(
context
).
addRequest
(
microappName
,
jObj
.
toString
(),
force
);
}
tryWakingSendingTaskInternal
(
context
,
requestsInQueueCount
);
}
public
static
void
postMicroappPush
(
String
microappName
,
JSONObject
jObj
,
boolean
force
)
{
INSTANCE
.
isInitializedOrThrow
();
INSTANCE
.
postMicroappPushInternal
(
microappName
,
jObj
,
force
);
...
...
@@ -473,217 +435,10 @@ public enum Warply {
tryWakingSendingPushAckTaskInternal
(
requestsInQueueCount
,
false
);
}
/* Campaigns specific methods */
/**
* Method used to get the campaigns associated with this device
*
* @param receiver The receiver to get the Campaigns when the task returns
*/
public
static
void
getInbox
(
CallbackReceiver
<
CampaignList
>
receiver
)
{
getInbox
(
null
,
receiver
);
}
public
static
void
getInbox
(
WarplyInboxRequest
request
,
final
CallbackReceiver
<
CampaignList
>
receiver
)
{
if
(
request
==
null
)
{
request
=
new
WarplyInboxRequest
();
}
final
String
requestSignature
=
request
.
getSignature
();
final
WarplyPreferences
warplyPreferences
=
new
WarplyPreferences
(
INSTANCE
.
mContext
);
long
elapsedTimeAfterLastUpdate
=
System
.
currentTimeMillis
()
-
warplyPreferences
.
getInboxLastCachedTimeStamp
(
requestSignature
);
long
updateInterval
=
request
.
getCacheUpdateInterval
();
boolean
isNeedUpdateCampaignsByTimeStamp
=
elapsedTimeAfterLastUpdate
>
updateInterval
;
if
(
isNeedUpdateCampaignsByTimeStamp
||
INSTANCE
.
mLastReceivedCampaigns
==
null
||
INSTANCE
.
mLastReceivedCampaigns
.
size
()
==
0
||
!
INSTANCE
.
mLastReceivedCampaigns
.
getRequestSignature
().
equals
(
requestSignature
))
{
final
ObjectSerializer
objectSerializer
=
new
ObjectSerializer
(
INSTANCE
.
mContext
);
CampaignList
campaignsCache
=
(
CampaignList
)
objectSerializer
.
deserialize
(
File
.
separator
+
requestSignature
);
if
(
isNeedUpdateCampaignsByTimeStamp
||
campaignsCache
==
null
||
campaignsCache
.
size
()
==
0
||
!
campaignsCache
.
getRequestSignature
().
equals
(
requestSignature
))
{
INSTANCE
.
isInitializedOrThrow
();
INSTANCE
.
getInboxInternal
(
new
CallbackReceiver
<
CampaignList
>()
{
@Override
public
void
onSuccess
(
CampaignList
result
)
{
// WarplyManagerHelper.setCampaignList(result);
if
(
result
.
size
()
>=
0
)
{
objectSerializer
.
serialize
(
result
,
File
.
separator
+
requestSignature
);
warplyPreferences
.
saveInboxLastCachedTimeStamp
(
requestSignature
,
System
.
currentTimeMillis
());
CampaignList
campaignLoyaltyList
=
new
CampaignList
();
campaignLoyaltyList
.
clear
();
for
(
Campaign
camp
:
result
)
{
try
{
JSONObject
extraFields
=
WarpJSONParser
.
getJSONFromString
(
camp
.
getExtraFields
());
if
(
extraFields
!=
null
)
{
if
(
extraFields
.
length
()
==
0
||
!(
extraFields
.
has
(
"ccms_offer"
)
||
extraFields
.
has
(
"type"
)))
{
campaignLoyaltyList
.
add
(
camp
);
}
}
}
catch
(
Exception
exception
)
{
campaignLoyaltyList
.
add
(
camp
);
}
}
INSTANCE
.
mLastReceivedCampaigns
=
result
;
if
(
receiver
!=
null
)
{
receiver
.
onSuccess
(
result
/*campaignLoyaltyList*/
);
}
}
}
@Override
public
void
onFailure
(
int
errorCode
)
{
if
(
receiver
!=
null
)
{
receiver
.
onFailure
(
errorCode
);
}
}
},
request
);
}
else
{
INSTANCE
.
mLastReceivedCampaigns
=
campaignsCache
;
if
(
receiver
!=
null
)
{
receiver
.
onSuccess
(
INSTANCE
.
mLastReceivedCampaigns
);
}
}
}
else
{
if
(
receiver
!=
null
)
{
receiver
.
onSuccess
(
INSTANCE
.
mLastReceivedCampaigns
);
}
}
}
public
static
void
getInboxInApp
(
WarplyInboxRequest
request
,
final
CallbackReceiver
<
CampaignList
>
receiver
)
{
INSTANCE
.
isInitializedOrThrow
();
INSTANCE
.
getInboxInAppInternal
(
new
CallbackReceiver
<
CampaignList
>()
{
@Override
public
void
onSuccess
(
CampaignList
result
)
{
receiver
.
onSuccess
(
result
);
}
@Override
public
void
onFailure
(
int
errorCode
)
{
receiver
.
onFailure
(
errorCode
);
}
},
request
);
}
public
CampaignList
getLastReceivedCampaigns
()
{
return
mLastReceivedCampaigns
;
}
public
CampaignList
getInAppCampaigns
()
{
return
mInAppCampaigns
;
}
public
void
getInboxUnreadCount
(
final
CallbackReceiver
<
Integer
>
receiver
,
WarplyInboxRequest
request
)
{
getInbox
(
request
,
new
CallbackReceiver
<
CampaignList
>()
{
@Override
public
void
onSuccess
(
CampaignList
result
)
{
receiver
.
onSuccess
(
result
!=
null
?
result
.
getUnreadCampaignsCount
()
:
0
);
}
@Override
public
void
onFailure
(
int
errorCode
)
{
receiver
.
onSuccess
(
0
);
}
});
}
/**
* @deprecated Use {@link #getInbox(CallbackReceiver) getInbox} method
* instead
*/
@Deprecated
public
static
void
getCampaigns
(
CallbackReceiver
<
CampaignList
>
receiver
)
{
getInbox
(
receiver
);
}
/**
* Method used to get the campaign stats associated with this device
*
* @param receiver The receiver to get the InboxStats when the task returns
*/
public
static
void
getInboxStats
(
CallbackReceiver
<
InboxStats
>
receiver
)
{
INSTANCE
.
isInitializedOrThrow
();
INSTANCE
.
getInboxStatsInternal
(
receiver
);
}
private
void
getInboxInternal
(
CallbackReceiver
<
CampaignList
>
receiver
,
WarplyInboxRequest
request
)
{
WarpUtils
.
log
(
"************* WARPLY Microapp ********************"
);
if
(!
WarplyServerPreferencesManager
.
isMicroAppActive
(
WarpConstants
.
MicroApp
.
OFFERS
))
{
WarpUtils
.
log
(
"[WARP Trace] Offers Microapp is not active"
);
WarpUtils
.
log
(
"**************************************************"
);
receiver
.
onFailure
(
2
);
return
;
}
WarpUtils
.
log
(
"[WARP Trace] Offers Microapp is active"
);
WarpUtils
.
log
(
"**************************************************"
);
request
=
request
!=
null
?
request
:
new
WarplyInboxRequest
();
postReceiveMicroappDataInternal
(
WarpConstants
.
MICROAPP_CAMPAIGNS
,
request
.
toJson
(),
new
CampaignsHook
(
receiver
,
request
.
getSignature
()));
}
private
void
getInboxInAppInternal
(
CallbackReceiver
<
CampaignList
>
receiver
,
WarplyInboxRequest
request
)
{
WarpUtils
.
log
(
"************* WARPLY Microapp ********************"
);
if
(!
WarplyServerPreferencesManager
.
isMicroAppActive
(
WarpConstants
.
MicroApp
.
OFFERS
))
{
WarpUtils
.
log
(
"[WARP Trace] Offers Microapp is not active"
);
WarpUtils
.
log
(
"**************************************************"
);
receiver
.
onFailure
(
2
);
return
;
}
WarpUtils
.
log
(
"[WARP Trace] Offers Microapp is active"
);
WarpUtils
.
log
(
"**************************************************"
);
request
=
request
!=
null
?
request
:
new
WarplyInboxRequest
();
postReceiveMicroappDataInternal
(
WarpConstants
.
MICROAPP_CAMPAIGNS
,
request
.
toJsonInApp
(),
new
CampaignsHook
(
receiver
,
request
.
getSignature
()));
}
private
void
getInboxStatsInternal
(
CallbackReceiver
<
InboxStats
>
receiver
)
{
WarpUtils
.
log
(
"************* WARPLY Microapp ********************"
);
if
(!
WarplyServerPreferencesManager
.
isMicroAppActive
(
WarpConstants
.
MicroApp
.
OFFERS
))
{
WarpUtils
.
log
(
"[WARP Trace] Offers Microapp is not active"
);
WarpUtils
.
log
(
"**************************************************"
);
receiver
.
onFailure
(
2
);
return
;
}
WarpUtils
.
log
(
"[WARP Trace] Offers Microapp is active"
);
WarpUtils
.
log
(
"**************************************************"
);
JSONObject
jObj
=
new
JSONObject
();
try
{
jObj
.
put
(
"action"
,
"offer_status"
);
}
catch
(
JSONException
e
)
{
if
(
WarpConstants
.
DEBUG
)
{
e
.
printStackTrace
();
}
}
postReceiveMicroappDataInternal
(
WarpConstants
.
MICROAPP_CAMPAIGNS
,
jObj
,
new
InboxStatsHook
(
receiver
));
}
/**
* Method used to check if an update of app is available and show alert dialog
*
...
...
@@ -738,35 +493,6 @@ public enum Warply {
}
}
/**
* Add a listener to listen to registration updates
*
* @param receiver
*/
public
static
void
setRegistrationListener
(
CallbackReceiver
<
ServiceRegistrationCallback
>
receiver
)
{
INSTANCE
.
isInitializedOrThrow
();
INSTANCE
.
listenGCMInternal
(
receiver
);
}
private
void
listenGCMInternal
(
CallbackReceiver
<
ServiceRegistrationCallback
>
receiver
)
{
mRegistrationListener
=
receiver
;
}
/**
* Stop listening to registration updates
*/
public
static
void
stopRegistrationListening
()
{
INSTANCE
.
isInitializedOrThrow
();
INSTANCE
.
stopGCMListeningInternal
();
}
private
void
stopGCMListeningInternal
()
{
mRegistrationListener
=
null
;
}
/**
* Method used to register with the Warply service. In order to receive push
* notifications, you also need to register with GCM using registerGCm or
...
...
@@ -804,19 +530,6 @@ public enum Warply {
}
/**
* Method used to enable or disable GCM push notifications. By default, this
* is enabled
*/
public
void
setGCMEnabled
(
boolean
enabled
)
{
INSTANCE
.
isInitializedOrThrow
();
INSTANCE
.
setGCMEnabledInternal
(
enabled
);
}
private
void
setGCMEnabledInternal
(
boolean
enabled
)
{
WarpUtils
.
setGCMEnabled
(
mContext
,
enabled
);
}
/**
* Returns the Warply INSTANCE - identical to using Warply.INSTANCE
*/
public
static
Warply
getWarplyInstance
()
{
...
...
@@ -840,7 +553,6 @@ public enum Warply {
* changed, nothing happens
*/
public
void
postDeviceInfoData
()
{
isInitializedOrThrow
();
WarpUtils
.
log
(
"************* WARPLY Microapp ********************"
);
...
...
@@ -903,7 +615,6 @@ public enum Warply {
* changed, nothing happens
*/
private
void
postApplicationData
(
boolean
force
)
{
isInitializedOrThrow
();
WarpUtils
.
log
(
"************* WARPLY Microapp ********************"
);
if
(!
WarplyServerPreferencesManager
...
...
@@ -1000,24 +711,6 @@ public enum Warply {
return
;
}
public
void
onGCMRegistrationSuccess
()
{
if
(
mRegistrationListener
!=
null
)
mRegistrationListener
.
onSuccess
(
ServiceRegistrationCallback
.
REGISTERED_GCM
);
resetDeviceInfoInternal
();
}
public
void
onGCMUnregistrationSuccess
()
{
if
(
mRegistrationListener
!=
null
)
mRegistrationListener
.
onSuccess
(
ServiceRegistrationCallback
.
UNREGISTERED_GCM
);
}
public
void
onGCMRegistrationFail
(
int
errorCode
)
{
if
(
mRegistrationListener
!=
null
)
mRegistrationListener
.
onFailure
(
errorCode
);
}
private
void
check
()
{
if
(
mContext
==
null
)
{
return
;
...
...
@@ -1030,12 +723,27 @@ public enum Warply {
postDeviceInfoData
();
if
(
WarpUtils
.
getIsAPPDATAENABLED
(
mContext
))
postApplicationData
(
true
);
tryWakingSendingTaskInternal
(
WarplyDBHelper
.
getInstance
(
mContext
)
.
getRequestsInQueueCount
());
tryWakingSendingTaskInternal
(
WarplyDBHelper
.
getInstance
(
mContext
)
.
getRequestsInQueueCount
());
}
private
void
wakeSendingTask
()
{
private
void
check
(
Context
context
)
{
if
(
context
==
null
)
{
return
;
}
if
(!
WarpUtils
.
isRegisteredWarply
(
context
))
{
registerWarply
();
return
;
}
if
(
WarpUtils
.
getIsDEVICEINFOENABLED
(
context
))
postDeviceInfoData
();
if
(
WarpUtils
.
getIsAPPDATAENABLED
(
context
))
postApplicationData
(
true
);
tryWakingSendingTaskInternal
(
WarplyDBHelper
.
getInstance
(
context
).
getRequestsInQueueCount
());
}
private
void
wakeSendingTask
()
{
if
(!
acquirePostLockInternal
())
return
;
...
...
@@ -1070,7 +778,6 @@ public enum Warply {
}
private
void
wakeSendingPushTask
()
{
if
(!
acquirePostLockInternal
())
return
;
...
...
@@ -1101,7 +808,6 @@ public enum Warply {
}
private
void
wakeSendingPushAckTask
()
{
if
(!
acquirePostLockInternal
())
return
;
...
...
@@ -1152,9 +858,6 @@ public enum Warply {
return
;
}
// if (WarplyDBHelper.getInstance(mContext.get()).isForceRequestsExist()
// || (requestsInQueue >= MINIMUM_REQUESTS_FOR_SENDING)) {
if
(
WarplyDBHelper
.
getInstance
(
mContext
).
isForceRequestsExist
()
||
(
requestsInQueue
>
0
))
{
...
...
@@ -1165,109 +868,6 @@ public enum Warply {
}
}
private
void
tryWakingSendingTaskInternal
(
Context
context
,
long
requestsInQueue
)
{
if
(!
WarpUtils
.
isRegisteredWarply
(
mContext
))
{
WarpUtils
.
log
(
"************* WARPLY Registration ********************"
);
WarpUtils
.
log
(
"[WARP TRace] Not registered yet, not waking post task!"
);
WarpUtils
.
log
(
"******************************************************"
);
return
;
}
// if (WarplyDBHelper.getInstance(mContext.get()).isForceRequestsExist()
// || (requestsInQueue >= MINIMUM_REQUESTS_FOR_SENDING)) {
if
(
WarplyDBHelper
.
getInstance
(
mContext
).
isForceRequestsExist
()
||
(
requestsInQueue
>
0
))
{
WarpUtils
.
log
(
"Waking post task!"
);
wakeSendingTask
(
context
);
}
else
{
WarpUtils
.
log
(
"Criteria not matched, not waking post task!"
);
}
}
private
void
wakeSendingTask
(
Context
context
)
{
if
(!
acquirePostLockInternal
())
return
;
ArrayList
<
Long
>
ids
=
new
ArrayList
<>();
JSONArray
jArray
=
new
JSONArray
();
Cursor
c
=
WarplyDBHelper
.
getInstance
(
mContext
).
getAllRequests
();
while
(
c
.
moveToNext
())
{
JSONObject
jObj
=
new
JSONObject
();
try
{
jObj
.
putOpt
(
c
.
getString
(
c
.
getColumnIndex
(
WarplyDBHelper
.
KEY_REQUESTS_MICROAPP
)),
new
JSONObject
(
c
.
getString
(
c
.
getColumnIndex
(
WarplyDBHelper
.
KEY_REQUESTS_ENTITY
))));
jArray
.
put
(
jObj
);
}
catch
(
JSONException
e
)
{
if
(
WarpConstants
.
DEBUG
)
{
WarpUtils
.
warn
(
"[WARP Trace] Exception thrown when creating the JSON from DB with id: "
+
c
.
getLong
(
c
.
getColumnIndex
(
WarplyDBHelper
.
KEY_REQUESTS_ID
)),
e
);
}
}
finally
{
ids
.
add
(
c
.
getLong
(
c
.
getColumnIndex
(
WarplyDBHelper
.
KEY_REQUESTS_ID
)));
}
}
c
.
close
();
PostHook
ph
=
new
PostHook
(
getWarplyContext
(),
ids
);
postToServerInternal
(
context
,
null
,
jArray
,
ph
,
null
);
getFromServerInternal
(
null
,
null
,
null
,
null
);
/** get context **/
}
private
void
postToServerInternal
(
Context
context
,
String
warplyPath
,
JSONArray
data
,
CallbackReceiver
<
JSONObject
>
listener
,
Object
tag
)
{
String
url
=
buildWarplyRequestUrl
(
context
,
warplyPath
);
JSONArray
tempAnalytics
=
new
JSONArray
();
JSONArray
tempDeviceInfo
=
new
JSONArray
();
JSONArray
tempOther
=
new
JSONArray
();
if
(
data
.
length
()
>
0
)
{
for
(
int
i
=
0
;
i
<
data
.
length
();
i
++)
{
JSONObject
microappItem
=
data
.
optJSONObject
(
i
);
if
(
microappItem
!=
null
)
{
if
(
microappItem
.
has
(
"inapp_analytics"
))
{
tempAnalytics
.
put
(
microappItem
);
}
else
if
(
microappItem
.
has
(
"device_info"
)
||
microappItem
.
has
(
"application_data"
))
{
tempDeviceInfo
.
put
(
microappItem
);
}
else
{
tempOther
.
put
(
microappItem
);
}
}
}
}
if
(
tempAnalytics
!=
null
&&
tempAnalytics
.
length
()
>
0
)
{
url
=
WarplyProperty
.
getBaseUrl
(
mContext
)
+
WarpConstants
.
WARPLY_ASYNC
+
WarpConstants
.
WARPLY_ANALYTICS
+
WarplyProperty
.
getAppUuid
(
mContext
)
+
"/"
;
}
if
(
tempDeviceInfo
!=
null
&&
tempDeviceInfo
.
length
()
>
0
)
{
url
=
WarplyProperty
.
getBaseUrl
(
mContext
)
+
WarpConstants
.
WARPLY_ASYNC
+
WarpConstants
.
WARPLY_DEVICE_INFO
+
WarplyProperty
.
getAppUuid
(
mContext
)
+
"/"
;
}
if
(
tempOther
!=
null
&&
tempOther
.
length
()
>
0
)
{
url
=
buildWarplyRequestUrl
(
warplyPath
);
}
requestToServerInternal
(
context
,
Method
.
POST
,
url
,
data
,
listener
,
tag
);
}
private
String
buildWarplyRequestUrl
(
Context
context
,
String
warplyPath
)
{
StringBuilder
sb
=
new
StringBuilder
(
WarplyProperty
.
getBaseUrl
(
context
)
+
WarpConstants
.
BASE_URL_MOBILE
);
sb
.
append
(
WarplyProperty
.
getAppUuid
(
mContext
)).
append
(
"/"
)
.
append
(
WarpConstants
.
PATH_CONTEXT
).
append
(
"/"
);
if
(
warplyPath
!=
null
)
sb
.
append
(
"?path="
).
append
(
warplyPath
);
return
sb
.
toString
();
}
public
static
void
tryWakingSendingPushTask
(
boolean
force
)
{
INSTANCE
.
isInitializedOrThrow
();
INSTANCE
.
tryWakingSendingPushTaskInternal
(
WarplyDBHelper
.
getInstance
(
...
...
@@ -1387,26 +987,6 @@ public enum Warply {
}
}
public
static
void
initBeaconsApplicationIfNeed
()
{
try
{
WarplyBeaconsApplication
beaconsApplication
=
WarplyBeaconsApplication
.
getInstance
();
if
(
beaconsApplication
!=
null
)
{
if
(
WarplyBeaconsApplication
.
isMicroAppEnabled
())
{
beaconsApplication
.
enable
();
beaconsApplication
.
addBeaconLayouts
(
WarplyBeaconsApplication
.
getBeaconLayouts
());
}
else
{
beaconsApplication
.
disable
();
}
}
}
catch
(
NoClassDefFoundError
e
)
{
if
(
WarpConstants
.
DEBUG
)
{
e
.
printStackTrace
();
}
}
}
/**
* Fundamental method, for doing requests to server, using JSON Object. This
* should be kept private and used by every other method in the SDK.
...
...
@@ -1419,7 +999,6 @@ public enum Warply {
*/
private
void
requestToServerInternal
(
int
method
,
String
url
,
JSONObject
data
,
CallbackReceiver
<
JSONObject
>
listener
,
Object
tag
)
{
VolleyTransformer
vt
=
new
VolleyTransformer
(
listener
);
String
methodName
=
null
;
switch
(
method
)
{
...
...
@@ -1457,7 +1036,6 @@ public enum Warply {
public
void
requestToServerInternalNew
(
int
method
,
String
url
,
JSONObject
data
,
CallbackReceiver
<
JSONObject
>
listener
,
Object
tag
)
{
VolleyTransformer
vt
=
new
VolleyTransformer
(
listener
);
String
methodName
=
null
;
switch
(
method
)
{
...
...
@@ -1496,7 +1074,6 @@ public enum Warply {
private
void
requestToServerInternal
(
int
method
,
String
url
,
JSONObject
data
,
CallbackReceiver
<
JSONObject
>
listener
,
Object
tag
,
boolean
hasAuthHeaders
)
{
VolleyTransformer
vt
=
new
VolleyTransformer
(
listener
);
String
methodName
=
null
;
switch
(
method
)
{
...
...
@@ -1543,7 +1120,6 @@ public enum Warply {
*/
private
void
requestToServerInternal
(
int
method
,
String
url
,
JSONArray
data
,
CallbackReceiver
<
JSONObject
>
listener
,
Object
tag
)
{
VolleyTransformer
vt
=
new
VolleyTransformer
(
listener
);
String
methodName
=
null
;
switch
(
method
)
{
...
...
@@ -1633,137 +1209,6 @@ public enum Warply {
/*========================== OLD, REVERT IF NEED ==========================*/
}
private
void
requestToServerInternal
(
Context
context
,
int
method
,
String
url
,
JSONArray
data
,
CallbackReceiver
<
JSONObject
>
listener
,
Object
tag
)
{
VolleyTransformer
vt
=
new
VolleyTransformer
(
listener
);
String
methodName
=
null
;
switch
(
method
)
{
case
0
:
methodName
=
"GET"
;
break
;
case
1
:
methodName
=
"POST"
;
break
;
case
2
:
methodName
=
"PUT"
;
break
;
case
3
:
methodName
=
"DELETE"
;
break
;
}
if
(
mContext
!=
null
)
{
WarpUtils
.
log
(
"************* WARPLY "
+
methodName
+
" Context ********************"
);
WarpUtils
.
log
(
"[WARP Trace] HTTP Web Id: "
+
WarpUtils
.
getWebId
(
mContext
));
WarpUtils
.
log
(
"[WARP Trace] HTTP API Key: "
+
WarplyProperty
.
getAppUuid
(
mContext
));
WarpUtils
.
verbose
(
"[WARP Trace] HTTP "
+
methodName
+
" Request URL: "
+
url
);
if
(
data
!=
null
)
{
try
{
WarpUtils
.
verbose
(
"[WARP Trace] Request: "
+
data
.
toString
(
2
));
}
catch
(
JSONException
e
)
{
WarpUtils
.
warn
(
"[WARP Trace] Failed conversting JSON to string"
,
e
);
}
}
}
else
if
(
context
!=
null
)
{
WarpUtils
.
log
(
"************* WARPLY "
+
methodName
+
" Context ********************"
);
WarpUtils
.
log
(
"[WARP Trace] HTTP Web Id: "
+
WarpUtils
.
getWebId
(
context
));
WarpUtils
.
log
(
"[WARP Trace] HTTP API Key: "
+
WarplyProperty
.
getAppUuid
(
context
));
WarpUtils
.
verbose
(
"[WARP Trace] HTTP "
+
methodName
+
" Request URL: "
+
url
);
if
(
data
!=
null
)
{
try
{
WarpUtils
.
verbose
(
"[WARP Trace] Request: "
+
data
.
toString
(
2
));
}
catch
(
JSONException
e
)
{
WarpUtils
.
warn
(
"[WARP Trace] Failed conversting JSON to string"
,
e
);
}
}
}
/*========================== NEW, REPLACE WITH OLD IF NEED ==========================*/
if
(
data
!=
null
)
{
JSONArray
tempAnalytics
=
new
JSONArray
();
JSONArray
tempDeviceInfo
=
new
JSONArray
();
JSONArray
tempOther
=
new
JSONArray
();
if
(
data
.
length
()
>
0
)
{
for
(
int
i
=
0
;
i
<
data
.
length
();
i
++)
{
JSONObject
microappItem
=
data
.
optJSONObject
(
i
);
if
(
microappItem
!=
null
)
{
if
(
microappItem
.
has
(
"inapp_analytics"
))
{
tempAnalytics
.
put
(
microappItem
);
}
else
if
(
microappItem
.
has
(
"device_info"
)
||
microappItem
.
has
(
"application_data"
))
{
tempDeviceInfo
.
put
(
microappItem
);
}
else
{
tempOther
.
put
(
microappItem
);
}
}
}
}
if
(
INSTANCE
.
mRequestQueue
==
null
)
{
if
(
INSTANCE
.
mContext
!=
null
)
INSTANCE
.
mRequestQueue
=
Volley
.
newRequestQueue
(
INSTANCE
.
mContext
);
else
INSTANCE
.
mRequestQueue
=
Volley
.
newRequestQueue
(
context
);
}
if
(
tempAnalytics
!=
null
&&
tempAnalytics
.
length
()
>
0
)
{
String
urlAnalytics
=
""
;
if
(
mContext
!=
null
)
urlAnalytics
=
WarplyProperty
.
getBaseUrl
(
mContext
)
+
WarpConstants
.
WARPLY_ASYNC
+
WarpConstants
.
WARPLY_ANALYTICS
+
WarplyProperty
.
getAppUuid
(
mContext
)
+
"/"
;
else
urlAnalytics
=
WarplyProperty
.
getBaseUrl
(
context
)
+
WarpConstants
.
WARPLY_ASYNC
+
WarpConstants
.
WARPLY_ANALYTICS
+
WarplyProperty
.
getAppUuid
(
context
)
+
"/"
;
WarplyJsonArrayRequest
requestAnalytics
=
new
WarplyJsonArrayRequest
(
method
,
urlAnalytics
,
tempAnalytics
,
vt
,
vt
);
requestAnalytics
.
setTag
(
tag
);
if
(
mRequestQueue
==
null
)
{
if
(
mContext
!=
null
)
mRequestQueue
=
Volley
.
newRequestQueue
(
mContext
);
else
mRequestQueue
=
Volley
.
newRequestQueue
(
context
);
}
mRequestQueue
.
add
(
requestAnalytics
);
}
if
(
tempDeviceInfo
!=
null
&&
tempDeviceInfo
.
length
()
>
0
)
{
String
urlDeviceInfo
=
""
;
if
(
mContext
!=
null
)
urlDeviceInfo
=
WarplyProperty
.
getBaseUrl
(
mContext
)
+
WarpConstants
.
WARPLY_ASYNC
+
WarpConstants
.
WARPLY_DEVICE_INFO
+
WarplyProperty
.
getAppUuid
(
mContext
)
+
"/"
;
else
urlDeviceInfo
=
WarplyProperty
.
getBaseUrl
(
context
)
+
WarpConstants
.
WARPLY_ASYNC
+
WarpConstants
.
WARPLY_DEVICE_INFO
+
WarplyProperty
.
getAppUuid
(
context
)
+
"/"
;
WarplyJsonArrayRequest
requestDeviceInfo
=
new
WarplyJsonArrayRequest
(
method
,
urlDeviceInfo
,
tempDeviceInfo
,
vt
,
vt
);
requestDeviceInfo
.
setTag
(
tag
);
if
(
mRequestQueue
==
null
)
{
if
(
mContext
!=
null
)
mRequestQueue
=
Volley
.
newRequestQueue
(
mContext
);
else
mRequestQueue
=
Volley
.
newRequestQueue
(
context
);
}
mRequestQueue
.
add
(
requestDeviceInfo
);
}
if
(
tempOther
!=
null
&&
tempOther
.
length
()
>
0
)
{
WarplyJsonArrayRequest
request
=
new
WarplyJsonArrayRequest
(
method
,
url
,
tempOther
,
vt
,
vt
);
request
.
setTag
(
tag
);
if
(
mRequestQueue
==
null
)
{
if
(
mContext
!=
null
)
mRequestQueue
=
Volley
.
newRequestQueue
(
mContext
);
else
mRequestQueue
=
Volley
.
newRequestQueue
(
context
);
}
mRequestQueue
.
add
(
request
);
}
}
/*========================== NEW, REPLACE WITH OLD IF NEED ==========================*/
/*========================== OLD, REVERT IF NEED ==========================*/
// WarplyJsonArrayRequest request = new WarplyJsonArrayRequest(method, url, data, vt, vt);
// request.setTag(tag);
// mRequestQueue.add(request);
/*========================== OLD, REVERT IF NEED ==========================*/
}
private
void
postToServerInternal
(
JSONObject
data
,
CallbackReceiver
<
JSONObject
>
listener
,
Object
tag
)
{
String
url
=
buildWarplyRequestUrl
(
null
);
...
...
@@ -1922,7 +1367,7 @@ public enum Warply {
WarpUtils
.
log
(
"******************************************************"
);
if
(
mRegistrationListener
!=
null
)
mRegistrationListener
.
onSuccess
(
ServiceRegistrationCallback
.
REGISTERED_WARPLY
);
//
postDeviceInfoData();
postDeviceInfoData
();
postApplicationData
(
true
);
}
releaseRegisterLock
();
...
...
warply_android_sdk/src/main/java/ly/warp/sdk/activities/BaseFragmentActivity.java
View file @
395834c
...
...
@@ -51,7 +51,7 @@ public class BaseFragmentActivity extends FragmentActivity implements Navigation
mBottomNavigationView
=
findViewById
(
R
.
id
.
bt_tabs
);
if
(
WarplyDBHelper
.
getInstance
(
this
).
isTableNotEmpty
(
"auth"
))
{
WarplyManager
.
get
Campaigns
(
mCampaignsCallback
);
WarplyManager
.
get
SupermarketCampaign
(
mCampaignsCallback
);
}
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
TIRAMISU
)
{
...
...
warply_android_sdk/src/main/java/ly/warp/sdk/activities/WarpViewActivity.java
View file @
395834c
...
...
@@ -176,7 +176,10 @@ public class WarpViewActivity extends WarpBaseActivity {
@Subscribe
()
public
void
onMessageEvent
(
WarplyEventBusManager
event
)
{
if
(
event
.
getQuestionnaire
()
!=
null
)
{
setResult
(
RESULT_OK
,
new
Intent
());
finish
();
}
}
// ===========================================================
...
...
warply_android_sdk/src/main/java/ly/warp/sdk/fragments/HomeFragment.java
View file @
395834c
...
...
@@ -23,6 +23,7 @@ import ly.warp.sdk.R;
import
ly.warp.sdk.db.WarplyDBHelper
;
import
ly.warp.sdk.io.callbacks.CallbackReceiver
;
import
ly.warp.sdk.io.models.Campaign
;
import
ly.warp.sdk.utils.WarplyManagerHelper
;
import
ly.warp.sdk.utils.managers.WarplyManager
;
public
class
HomeFragment
extends
Fragment
implements
View
.
OnClickListener
,
SwipeRefreshLayout
.
OnRefreshListener
{
...
...
@@ -31,7 +32,7 @@ public class HomeFragment extends Fragment implements View.OnClickListener, Swip
private
TextView
mTvUsername
,
mTvUser
;
private
SwipeRefreshLayout
mSwipeRefresh
;
private
EditText
mEtGuid
;
private
LinearLayout
mLlAuthLogin
,
mLlAuthLogout
;
private
LinearLayout
mLlAuthLogin
,
mLlAuthLogout
,
mRlSmFlow
,
mRlSmMap
;
@Override
public
View
onCreateView
(
LayoutInflater
inflater
,
ViewGroup
container
,
Bundle
savedInstanceState
)
{
...
...
@@ -72,6 +73,10 @@ public class HomeFragment extends Fragment implements View.OnClickListener, Swip
mLlAuthLogout
=
view
.
findViewById
(
R
.
id
.
ll_auth_logout
);
mLlAuthLogout
.
setOnClickListener
(
this
);
mTvUser
=
view
.
findViewById
(
R
.
id
.
tv_login
);
mRlSmFlow
=
view
.
findViewById
(
R
.
id
.
ll_sm_flow
);
mRlSmFlow
.
setOnClickListener
(
this
);
mRlSmMap
=
view
.
findViewById
(
R
.
id
.
ll_sm_map
);
mRlSmMap
.
setOnClickListener
(
this
);
if
(!
WarplyDBHelper
.
getInstance
(
getActivity
()).
isTableNotEmpty
(
"auth"
))
{
mTvUser
.
setVisibility
(
View
.
GONE
);
...
...
@@ -94,7 +99,7 @@ public class HomeFragment extends Fragment implements View.OnClickListener, Swip
@Override
public
void
onRefresh
()
{
if
(
WarplyDBHelper
.
getInstance
(
getActivity
()).
isTableNotEmpty
(
"auth"
))
{
WarplyManager
.
get
Campaigns
(
mCampaignsCallback
);
WarplyManager
.
get
SupermarketCampaign
(
mCampaignsCallback
);
mSwipeRefresh
.
setRefreshing
(
false
);
}
else
{
mSwipeRefresh
.
setRefreshing
(
false
);
...
...
@@ -113,6 +118,14 @@ public class HomeFragment extends Fragment implements View.OnClickListener, Swip
if
(
view
.
getId
()
==
R
.
id
.
ll_auth_logout
)
{
mPbLoading
.
setVisibility
(
View
.
VISIBLE
);
WarplyManager
.
logout
(
mLogoutReceiver
);
return
;
}
if
(
view
.
getId
()
==
R
.
id
.
ll_sm_flow
)
{
WarplyManagerHelper
.
openSuperMarketsFlow
(
getContext
());
return
;
}
if
(
view
.
getId
()
==
R
.
id
.
ll_sm_map
)
{
WarplyManagerHelper
.
openSupermarketsMap
(
getContext
());
}
}
...
...
@@ -168,7 +181,7 @@ public class HomeFragment extends Fragment implements View.OnClickListener, Swip
// }
// }
WarplyManager
.
get
Campaigns
(
mCampaignsCallback
);
WarplyManager
.
get
SupermarketCampaign
(
mCampaignsCallback
);
}
@Override
...
...
warply_android_sdk/src/main/java/ly/warp/sdk/io/callbacks/InboxStatsHook.java
deleted
100644 → 0
View file @
a8c1f71
/*
* Copyright 2010-2013 Warply Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE WARPLY LTD ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL WARPLY LTD OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package
ly
.
warp
.
sdk
.
io
.
callbacks
;
import
org.json.JSONObject
;
import
ly.warp.sdk.io.models.InboxStats
;
public
class
InboxStatsHook
implements
CallbackReceiver
<
JSONObject
>
{
public
InboxStatsHook
(
CallbackReceiver
<
InboxStats
>
receiver
)
{
mReceiver
=
receiver
;
}
private
final
CallbackReceiver
<
InboxStats
>
mReceiver
;
@Override
public
void
onSuccess
(
JSONObject
result
)
{
mReceiver
.
onSuccess
(
new
InboxStats
(
result
));
}
@Override
public
void
onFailure
(
int
errorCode
)
{
mReceiver
.
onFailure
(
errorCode
);
}
}
warply_android_sdk/src/main/java/ly/warp/sdk/io/models/InboxStats.java
deleted
100644 → 0
View file @
a8c1f71
/*
* Copyright 2010-2013 Warply Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE WARPLY LTD ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL WARPLY LTD OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package
ly
.
warp
.
sdk
.
io
.
models
;
import
ly.warp.sdk.utils.WarpUtils
;
import
ly.warp.sdk.Warply
;
import
org.json.JSONException
;
import
org.json.JSONObject
;
public
class
InboxStats
{
/* Constants used to export the campaign in JSON formal and vice versa */
private
static
final
String
TOTAL_COUNT
=
"count"
;
private
static
final
String
NEW_COUNT
=
"new"
;
private
static
final
String
UNREAD_COUNT
=
"unread"
;
/* Member variables of the Campaign object */
private
int
totalCount
;
private
int
newCount
;
private
int
unreadCount
;
/**
* Basic constructor using a String, representing a JSON Object
*
* @param json
* The String, representing the JSON Object
* @throws JSONException
* Thrown if the String cannot be converted to JSON
*/
public
InboxStats
(
String
json
)
throws
JSONException
{
this
(
new
JSONObject
(
json
));
}
/**
* Constructor used to create an IboxStats object from a given JSON object
*
* @param jObj
* JSON Object used to create the Campaign
*/
public
InboxStats
(
JSONObject
jObj
)
{
JSONObject
inboxStatus
=
null
;
try
{
inboxStatus
=
jObj
.
getJSONObject
(
"context"
).
getJSONObject
(
"MAPP_OFFER"
);
}
catch
(
JSONException
e
)
{
WarpUtils
.
warn
(
"Exception on parsing Inbox Status JSON"
,
e
);
}
totalCount
=
0
;
newCount
=
0
;
unreadCount
=
0
;
if
(
inboxStatus
!=
null
)
{
if
(
inboxStatus
.
has
(
TOTAL_COUNT
))
totalCount
=
inboxStatus
.
optInt
(
TOTAL_COUNT
);
if
(
inboxStatus
.
has
(
NEW_COUNT
))
newCount
=
inboxStatus
.
optInt
(
NEW_COUNT
);
if
(
inboxStatus
.
has
(
UNREAD_COUNT
))
unreadCount
=
inboxStatus
.
optInt
(
UNREAD_COUNT
);
}
}
/**
* Converts IboxStats into a JSON Object
*
* @return The JSON Object created
*/
public
JSONObject
toJSONObject
()
{
JSONObject
jObj
=
new
JSONObject
();
try
{
jObj
.
putOpt
(
TOTAL_COUNT
,
totalCount
);
jObj
.
putOpt
(
NEW_COUNT
,
newCount
);
jObj
.
putOpt
(
UNREAD_COUNT
,
unreadCount
);
}
catch
(
JSONException
e
)
{
}
return
jObj
;
}
/**
* String representation of the IbnoxStats, as a JSON object
*/
@Override
public
String
toString
()
{
return
toJSONObject
().
toString
();
}
/**
* String representation of the IboxStats, as a human readable JSON object
*
* @return A human readable String representation
*/
public
String
toHumanReadableString
()
{
String
s
=
null
;
try
{
s
=
toJSONObject
().
toString
(
2
);
}
catch
(
JSONException
e
)
{
}
return
s
;
}
/**
* The total number of active campaigns - This is the number of campaigns
* that the {@link Warply#getInbox(ly.warp.sdk.io.callbacks.CallbackReceiver)
* Warply.getInbox} call with return
*/
public
int
getTotalCount
()
{
return
totalCount
;
}
/**
* The number of campaigns that have never been returned with a call to
* {@link Warply#getInbox(ly.warp.sdk.io.callbacks.CallbackReceiver) Warply.getInbox}
*/
public
int
getNewCount
()
{
return
newCount
;
}
/**
* The number of campaigns that have never been opened
*/
public
int
getUnreadCount
()
{
return
unreadCount
;
}
}
warply_android_sdk/src/main/java/ly/warp/sdk/io/models/QuestionnaireEventModel.java
0 → 100644
View file @
395834c
package
ly
.
warp
.
sdk
.
io
.
models
;
/**
* Created by Panagiotis Triantafyllou on 20-June-22.
*/
public
class
QuestionnaireEventModel
{
private
String
name
;
private
String
parameter
;
public
QuestionnaireEventModel
()
{
this
.
name
=
""
;
this
.
parameter
=
""
;
}
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
String
getParameter
()
{
return
parameter
;
}
public
void
setParameter
(
String
parameter
)
{
this
.
parameter
=
parameter
;
}
}
warply_android_sdk/src/main/java/ly/warp/sdk/utils/WarplyManagerHelper.java
View file @
395834c
...
...
@@ -55,7 +55,8 @@ public class WarplyManagerHelper {
// ===========================================================
private
static
CouponList
mCouponRedeemedList
=
new
CouponList
();
private
static
ArrayList
<
Campaign
>
mCampaignListAll
=
new
ArrayList
<
Campaign
>();
private
static
ArrayList
<
Campaign
>
mCampaignListAll
=
new
ArrayList
<
Campaign
>(),
mSupermarketCampaigns
=
new
ArrayList
<
Campaign
>();
// ===========================================================
// Methods for/from SuperClass/Interfaces
...
...
@@ -74,6 +75,11 @@ public class WarplyManagerHelper {
mCampaignListAll
.
addAll
(
campaignList
);
}
public
static
void
setSupermarketCampaigns
(
ArrayList
<
Campaign
>
campaignList
)
{
mSupermarketCampaigns
.
clear
();
mSupermarketCampaigns
.
addAll
(
campaignList
);
}
public
static
void
setCouponRedeemedList
(
CouponList
couponRedeemedList
)
{
mCouponRedeemedList
.
clear
();
mCouponRedeemedList
.
addAll
(
couponRedeemedList
);
...
...
@@ -111,7 +117,7 @@ public class WarplyManagerHelper {
}
public
static
void
openSuperMarketsFlow
(
Context
context
)
{
if
(
m
CampaignListAll
==
null
||
mCampaignListAll
.
isEmpty
())
{
if
(
m
SupermarketCampaigns
==
null
||
mSupermarketCampaigns
.
isEmpty
())
{
return
;
}
...
...
@@ -131,7 +137,7 @@ public class WarplyManagerHelper {
WarpUtils
.
setWebviewParams
(
context
,
params
);
context
.
startActivity
(
WarpViewActivity
.
createIntentFromURL
(
context
,
WarplyManagerHelper
.
constructCampaignUrl
(
m
CampaignListAll
.
get
(
0
))));
context
.
startActivity
(
WarpViewActivity
.
createIntentFromURL
(
context
,
WarplyManagerHelper
.
constructCampaignUrl
(
m
SupermarketCampaigns
.
get
(
0
))));
}
public
static
void
openSupermarketsMap
(
Context
context
)
{
...
...
warply_android_sdk/src/main/java/ly/warp/sdk/utils/managers/WarplyAnalyticsManager.java
View file @
395834c
...
...
@@ -25,23 +25,16 @@
package
ly
.
warp
.
sdk
.
utils
.
managers
;
import
android.content.Context
;
import
androidx.annotation.NonNull
;
import
androidx.annotation.Nullable
;
import
org.json.JSONException
;
import
org.json.JSONObject
;
import
ly.warp.sdk.Warply
;
import
ly.warp.sdk.io.callbacks.CallbackReceiver
;
import
ly.warp.sdk.io.models.CampaignList
;
import
ly.warp.sdk.io.models.PushCampaign
;
import
ly.warp.sdk.io.request.WarplyInboxRequest
;
import
ly.warp.sdk.utils.WarpUtils
;
import
ly.warp.sdk.utils.constants.WarpConstants
;
import
static
ly
.
warp
.
sdk
.
Warply
.
INSTANCE
;
import
static
ly
.
warp
.
sdk
.
Warply
.
getWarplyContext
;
public
class
WarplyAnalyticsManager
{
...
...
@@ -57,30 +50,6 @@ public class WarplyAnalyticsManager {
sendEvent
(
eventPage
,
eventId
,
metadata
,
false
);
}
public
static
void
logTrackersEvent
(
Context
context
,
String
eventType
,
String
eventName
)
{
if
(
WarpUtils
.
getTrackersEnabled
(
context
))
{
// Warply.getInitializer(context).init();
sendEvent
(
context
,
null
,
eventType
.
concat
(
":"
).
concat
(
eventName
),
null
,
false
);
}
}
/**
* Log screen events so after we can check if there are in app campaigns to show
* (per screen or all screens). After we send the event with priority we make
* a get_inbox request with extra parameters.
*
* @param eventPage
* @param eventId
* @param metadata
* @param force
* @param context
*/
public
static
void
logEventInApp
(
Context
context
,
@Nullable
String
eventPage
,
@NonNull
String
eventId
,
@Nullable
JSONObject
metadata
,
boolean
force
)
{
sendEventInApp
(
context
,
eventPage
,
eventId
,
metadata
,
force
);
}
/**
* Default method for logging events with high priority happening in a page
*
...
...
@@ -102,19 +71,6 @@ public class WarplyAnalyticsManager {
/*foreground ? "NB_WillEnterForeground" : "NB_DidEnterBackground"*/
);
}
public
static
void
logUserReceivedPush
(
String
sessionUUID
)
{
JSONObject
metadata
=
new
JSONObject
();
try
{
metadata
.
putOpt
(
"session_uuid"
,
sessionUUID
);
}
catch
(
JSONException
e
)
{
if
(
WarpConstants
.
DEBUG
)
{
e
.
printStackTrace
();
}
}
sendEvent
(
WarpConstants
.
MICROAPP_APPLICATION_PAGE_ID
,
"NB_PushReceived"
,
metadata
,
true
);
}
public
static
void
logUserReceivedPush
(
PushCampaign
pc
)
{
JSONObject
metadata
=
new
JSONObject
();
try
{
...
...
@@ -128,21 +84,11 @@ public class WarplyAnalyticsManager {
"NB_PushReceived"
,
metadata
,
false
);
}
// public static void logUserEngagedPush(JSONObject pushSessionUUID) {
// sendEvent(WarpConstants.MICROAPP_APPLICATION_PAGE_ID, "NB_PushAck",
// pushSessionUUID, true);
// }
public
static
void
logUserEngagedPush
(
JSONObject
pushSessionUUID
)
{
sendPushAckEvent
(
WarpConstants
.
MICROAPP_APPLICATION_PAGE_ID
,
"NB_PushAck"
,
pushSessionUUID
,
false
);
}
public
static
void
logUserReceivedPush
(
JSONObject
pushSessionUUID
)
{
sendEvent
(
WarpConstants
.
MICROAPP_APPLICATION_PAGE_ID
,
"NB_PushReceived"
,
pushSessionUUID
,
true
);
}
/**
* Send an event to the Warply server
*
...
...
@@ -174,81 +120,6 @@ public class WarplyAnalyticsManager {
WarpUtils
.
log
(
"analytics micro-app is not active"
);
}
private
static
void
sendEvent
(
Context
context
,
@Nullable
String
eventPage
,
String
eventId
,
@Nullable
JSONObject
metadata
,
boolean
force
)
{
boolean
isInAppAnalyticsMicroAppActive
=
WarplyServerPreferencesManager
.
isMicroAppActive
(
context
,
WarpConstants
.
MicroApp
.
CUSTOM_ANALYTICS
);
if
(
isInAppAnalyticsMicroAppActive
)
try
{
JSONObject
jObj
=
new
JSONObject
();
if
(
eventPage
!=
null
)
{
jObj
.
putOpt
(
"page_id"
,
eventPage
);
}
jObj
.
putOpt
(
"event_id"
,
eventId
);
jObj
.
putOpt
(
"time_submitted"
,
System
.
currentTimeMillis
()
/
1000
);
if
(
metadata
!=
null
)
{
jObj
.
putOpt
(
"action_metadata"
,
metadata
);
}
if
(
context
!=
null
)
Warply
.
postMicroappData
(
context
,
WarpConstants
.
MICROAPP_INAPP_ANALYTICS
,
jObj
,
force
);
}
catch
(
JSONException
e
)
{
if
(
WarpConstants
.
DEBUG
)
{
e
.
printStackTrace
();
}
}
else
WarpUtils
.
log
(
"analytics micro-app is not active"
);
}
/**
* Send an in app event to the Warply server and show a campaign per screen
*
* @param eventPage Event page ID
* @param eventId Event ID
* @param metadata Event metadata
* @param force If this event should be forced or not
*/
private
static
void
sendEventInApp
(
final
Context
context
,
@Nullable
String
eventPage
,
@NonNull
final
String
eventId
,
@Nullable
JSONObject
metadata
,
boolean
force
)
{
boolean
isInAppAnalyticsMicroAppActive
=
WarplyServerPreferencesManager
.
isMicroAppActive
(
WarpConstants
.
MicroApp
.
CUSTOM_ANALYTICS
);
if
(
isInAppAnalyticsMicroAppActive
)
{
try
{
JSONObject
jObj
=
new
JSONObject
();
if
(
eventPage
!=
null
)
{
jObj
.
putOpt
(
"page_id"
,
eventPage
);
}
jObj
.
putOpt
(
"event_id"
,
eventId
);
jObj
.
putOpt
(
"time_submitted"
,
System
.
currentTimeMillis
()
/
1000
);
if
(
metadata
!=
null
)
{
jObj
.
putOpt
(
"action_metadata"
,
metadata
);
}
Warply
.
postMicroappData
(
WarpConstants
.
MICROAPP_INAPP_ANALYTICS
,
jObj
,
force
);
}
catch
(
JSONException
e
)
{
if
(
WarpConstants
.
DEBUG
)
{
e
.
printStackTrace
();
}
}
}
else
WarpUtils
.
log
(
"analytics micro-app is not active"
);
// TODO: check for the interval else INSTANCE.getInAppCampaigns()
// if() {
WarplyInboxRequest
inboxFilterRequest
=
new
WarplyInboxRequest
().
setUseCache
(
false
);
Warply
.
getInboxInApp
(
inboxFilterRequest
,
new
CallbackReceiver
<
CampaignList
>()
{
@Override
public
void
onSuccess
(
CampaignList
result
)
{
INSTANCE
.
mInAppCampaigns
=
result
;
}
@Override
public
void
onFailure
(
int
errorCode
)
{
}
});
// } else {
//Warply.showInAppCampaign(context, eventId);
// }
}
private
static
void
sendPushReceivedEvent
(
@Nullable
String
eventPage
,
String
eventId
,
@Nullable
JSONObject
metadata
,
boolean
force
)
{
boolean
isInAppAnalyticsMicroAppActive
=
WarplyServerPreferencesManager
.
isMicroAppActive
(
WarpConstants
.
MicroApp
.
CUSTOM_ANALYTICS
);
...
...
warply_android_sdk/src/main/java/ly/warp/sdk/utils/managers/WarplyEventBusManager.java
View file @
395834c
...
...
@@ -2,6 +2,7 @@ package ly.warp.sdk.utils.managers;
import
ly.warp.sdk.io.models.LoyaltySDKDynatraceEventModel
;
import
ly.warp.sdk.io.models.LoyaltySDKFirebaseEventModel
;
import
ly.warp.sdk.io.models.QuestionnaireEventModel
;
import
ly.warp.sdk.io.models.WarplyWebviewActivityCallbackEventModel
;
import
ly.warp.sdk.io.models.WarplyWebviewCallbackEventModel
;
...
...
@@ -13,6 +14,7 @@ public class WarplyEventBusManager {
private
LoyaltySDKDynatraceEventModel
dynatraceEvent
;
private
WarplyWebviewCallbackEventModel
webviewCallback
;
private
WarplyWebviewActivityCallbackEventModel
webviewActivityCallback
;
private
QuestionnaireEventModel
questionnaire
;
public
WarplyEventBusManager
()
{
...
...
@@ -41,4 +43,12 @@ public class WarplyEventBusManager {
public
WarplyWebviewActivityCallbackEventModel
getWarplyWebviewActivityCallbackEventModel
()
{
return
webviewActivityCallback
;
}
public
WarplyEventBusManager
(
QuestionnaireEventModel
questionnaire
)
{
this
.
questionnaire
=
questionnaire
;
}
public
QuestionnaireEventModel
getQuestionnaire
()
{
return
questionnaire
;
}
}
...
...
warply_android_sdk/src/main/java/ly/warp/sdk/utils/managers/WarplyManager.java
View file @
395834c
...
...
@@ -237,6 +237,19 @@ public class WarplyManager {
WarpUtils
.
log
(
"[WARP Trace] WARPLY Cosmote User Request is active"
);
WarpUtils
.
log
(
"**************************************************"
);
if
(
WarplyDBHelper
.
getInstance
(
Warply
.
getWarplyContext
()).
isTableNotEmpty
(
"auth"
))
{
JSONObject
newResult
=
new
JSONObject
();
try
{
newResult
.
putOpt
(
"status"
,
1
);
newResult
.
putOpt
(
"message"
,
"Success"
);
receiver
.
onSuccess
(
newResult
);
}
catch
(
JSONException
e
)
{
e
.
printStackTrace
();
receiver
.
onFailure
(
2
);
}
return
;
}
ApiService
service
=
ApiClient
.
getRetrofitInstance
().
create
(
ApiService
.
class
);
String
timeStamp
=
DateFormat
.
format
(
"yyyy-MM-dd hh:mm:ss"
,
System
.
currentTimeMillis
()).
toString
();
...
...
@@ -315,6 +328,26 @@ public class WarplyManager {
WarpUtils
.
log
(
"[WARP Trace] WARPLY Verify Ticket Request is active"
);
WarpUtils
.
log
(
"**************************************************"
);
if
(
WarplyDBHelper
.
getInstance
(
Warply
.
getWarplyContext
()).
isTableNotEmpty
(
"auth"
))
{
JSONObject
newResult
=
new
JSONObject
();
try
{
newResult
.
putOpt
(
"status"
,
1
);
newResult
.
putOpt
(
"message"
,
"Success"
);
LoyaltySDKDynatraceEventModel
dynatraceEvent
=
new
LoyaltySDKDynatraceEventModel
();
dynatraceEvent
.
setEventName
(
"custom_success_login_loyalty"
);
EventBus
.
getDefault
().
post
(
new
WarplyEventBusManager
(
dynatraceEvent
));
receiver
.
onSuccess
(
newResult
);
}
catch
(
JSONException
e
)
{
LoyaltySDKDynatraceEventModel
dynatraceEvent
=
new
LoyaltySDKDynatraceEventModel
();
dynatraceEvent
.
setEventName
(
"custom_error_login_loyalty"
);
EventBus
.
getDefault
().
post
(
new
WarplyEventBusManager
(
dynatraceEvent
));
e
.
printStackTrace
();
receiver
.
onFailure
(
2
);
}
return
;
}
WarpUtils
.
setUserNonTelco
(
Warply
.
getWarplyContext
(),
false
);
WarpUtils
.
setUserTag
(
Warply
.
getWarplyContext
(),
""
);
...
...
@@ -1246,4 +1279,200 @@ public class WarplyManager {
}
},
executorService
);
}
private
static
/*void*/
ListenableFuture
<
ArrayList
<
Campaign
>>
getSupermarketCampaignRetro
(
ApiService
service
/*, final CallbackReceiver<ArrayList<Campaign>> receiver*/
)
{
SettableFuture
<
ArrayList
<
Campaign
>>
future
=
SettableFuture
.
create
();
String
timeStamp
=
DateFormat
.
format
(
"yyyy-MM-dd hh:mm:ss"
,
System
.
currentTimeMillis
()).
toString
();
String
apiKey
=
WarpUtils
.
getApiKey
(
Warply
.
getWarplyContext
());
String
webId
=
WarpUtils
.
getWebId
(
Warply
.
getWarplyContext
());
Map
<
String
,
Object
>
jsonParamsCampaigns
=
new
ArrayMap
<>();
Map
<
String
,
Object
>
jsonParams
=
new
ArrayMap
<>();
JSONObject
jFilters
=
new
JSONObject
();
JSONObject
jExtra
=
new
JSONObject
();
try
{
jFilters
.
putOpt
(
"communication_category"
,
"more_for_you"
);
jExtra
.
putOpt
(
"filter"
,
"supermarket"
);
jExtra
.
putOpt
(
"version"
,
"magenta"
);
jFilters
.
putOpt
(
"extra_fields"
,
jExtra
);
}
catch
(
JSONException
e
)
{
throw
new
RuntimeException
(
e
);
}
jsonParams
.
put
(
"action"
,
"retrieve"
);
jsonParams
.
put
(
"filters"
,
jFilters
);
jsonParams
.
put
(
"language"
,
WarplyProperty
.
getLanguage
(
Warply
.
getWarplyContext
()));
jsonParamsCampaigns
.
put
(
"campaigns"
,
jsonParams
);
RequestBody
campaignsRequest
=
RequestBody
.
create
(
MediaType
.
get
(
"application/json; charset=utf-8"
),
(
new
JSONObject
(
jsonParamsCampaigns
)).
toString
());
Call
<
ResponseBody
>
campaignsCall
=
service
.
getCampaigns
(
WarplyProperty
.
getAppUuid
(
Warply
.
getWarplyContext
()),
campaignsRequest
,
timeStamp
,
"android:"
+
Warply
.
getWarplyContext
().
getPackageName
(),
new
WarplyDeviceInfoCollector
(
Warply
.
getWarplyContext
()).
getUniqueDeviceId
(),
"mobile"
,
webId
,
WarpUtils
.
produceSignature
(
apiKey
+
timeStamp
)
);
campaignsCall
.
enqueue
(
new
Callback
<
ResponseBody
>()
{
@Override
public
void
onResponse
(
@NonNull
Call
<
ResponseBody
>
call
,
@NonNull
Response
<
ResponseBody
>
response
)
{
if
(
response
.
code
()
==
200
&&
response
.
body
()
!=
null
)
{
JSONObject
jobjCampaignsResponse
=
null
;
try
{
jobjCampaignsResponse
=
new
JSONObject
(
response
.
body
().
string
());
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
if
(
jobjCampaignsResponse
!=
null
&&
jobjCampaignsResponse
.
has
(
"status"
)
&&
jobjCampaignsResponse
.
optString
(
"status"
,
"2"
).
equals
(
"1"
))
{
LoyaltySDKDynatraceEventModel
dynatraceEvent
=
new
LoyaltySDKDynatraceEventModel
();
dynatraceEvent
.
setEventName
(
"custom_success_supermarket_campaign_loyalty"
);
EventBus
.
getDefault
().
post
(
new
WarplyEventBusManager
(
dynatraceEvent
));
JSONArray
jCampaignsBody
=
null
;
try
{
jCampaignsBody
=
jobjCampaignsResponse
.
optJSONObject
(
"context"
).
optJSONObject
(
"MAPP_CAMPAIGNING"
).
optJSONArray
(
"campaigns"
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
if
(
jCampaignsBody
!=
null
)
{
ArrayList
<
NewCampaign
>
tempCampaigns
=
new
ArrayList
<>();
ArrayList
<
Campaign
>
mCampaignsList
=
new
ArrayList
<>();
final
ExecutorService
executorCampaigns
=
Executors
.
newFixedThreadPool
(
1
);
JSONArray
finalCampaignsJBody
=
jCampaignsBody
;
executorCampaigns
.
submit
(()
->
{
for
(
int
i
=
0
;
i
<
finalCampaignsJBody
.
length
();
++
i
)
{
tempCampaigns
.
add
(
new
NewCampaign
(
finalCampaignsJBody
.
optJSONObject
(
i
)));
}
for
(
NewCampaign
newCamp
:
tempCampaigns
)
{
Campaign
camp
=
new
Campaign
();
camp
.
setIndexUrl
(
newCamp
.
getIndexUrl
());
camp
.
setLogoUrl
(
newCamp
.
getLogoUrl
());
camp
.
setMessage
(
newCamp
.
getMessage
());
camp
.
setOfferCategory
(
newCamp
.
getCommunicationCategory
());
camp
.
setSessionUUID
(
newCamp
.
getCommunicationUUID
());
camp
.
setTitle
(
newCamp
.
getTitle
());
camp
.
setSubtitle
(
newCamp
.
getSubtitle
());
camp
.
setSorting
(
newCamp
.
getSorting
());
camp
.
setNew
(
newCamp
.
getIsNew
());
camp
.
setType
(
newCamp
.
getCampaignType
());
camp
.
setEndDate
(
newCamp
.
getEndDate
());
camp
.
setStartDate
(
newCamp
.
getStartDate
());
camp
.
setShowExpiration
(
newCamp
.
isShowExpiration
());
camp
.
setCouponImg
(
newCamp
.
getCouponImg
());
camp
.
setFilter
(
newCamp
.
getFilter
());
try
{
camp
.
setExtraFields
(
newCamp
.
getExtraFields
().
toString
());
if
(!
TextUtils
.
isEmpty
(
newCamp
.
getExtraFields
().
toString
()))
{
JSONObject
extraFieldsResp
=
WarpJSONParser
.
getJSONFromString
(
newCamp
.
getExtraFields
().
toString
());
if
(
extraFieldsResp
!=
null
)
{
if
(
extraFieldsResp
.
has
(
"Banner_title"
))
{
camp
.
setBannerTitle
(
extraFieldsResp
.
optString
(
"Banner_title"
,
""
));
}
if
(
extraFieldsResp
.
has
(
"Banner_img"
))
{
camp
.
setBannerImage
(
extraFieldsResp
.
optString
(
"Banner_img"
,
""
));
}
if
(
extraFieldsResp
.
has
(
"category_id"
))
{
camp
.
setCategoryId
(
extraFieldsResp
.
optString
(
"category_id"
,
""
));
}
}
}
else
{
camp
.
setBannerImage
(
""
);
camp
.
setBannerTitle
(
""
);
camp
.
setCategoryId
(
""
);
}
}
catch
(
NullPointerException
e
)
{
camp
.
setExtraFields
(
""
);
camp
.
setBannerImage
(
""
);
camp
.
setBannerTitle
(
""
);
camp
.
setCategoryId
(
""
);
e
.
printStackTrace
();
}
try
{
camp
.
setCampaignTypeSettings
(
newCamp
.
getSettings
().
toString
());
}
catch
(
NullPointerException
e
)
{
camp
.
setCampaignTypeSettings
(
""
);
e
.
printStackTrace
();
}
mCampaignsList
.
add
(
camp
);
}
executorCampaigns
.
shutdownNow
();
// receiver.onSuccess(mCampaignsList);
future
.
set
(
mCampaignsList
);
});
}
}
else
{
LoyaltySDKDynatraceEventModel
dynatraceEvent
=
new
LoyaltySDKDynatraceEventModel
();
dynatraceEvent
.
setEventName
(
"custom_error_supermarket_campaign_loyalty"
);
EventBus
.
getDefault
().
post
(
new
WarplyEventBusManager
(
dynatraceEvent
));
// receiver.onFailure(2);
future
.
set
(
new
ArrayList
<
Campaign
>());
}
}
else
{
LoyaltySDKDynatraceEventModel
dynatraceEvent
=
new
LoyaltySDKDynatraceEventModel
();
dynatraceEvent
.
setEventName
(
"custom_error_supermarket_campaign_loyalty"
);
EventBus
.
getDefault
().
post
(
new
WarplyEventBusManager
(
dynatraceEvent
));
// receiver.onFailure(response.code());
// future.set(new ArrayList<Campaign>());
future
.
setException
(
new
Throwable
());
}
}
@Override
public
void
onFailure
(
@NonNull
Call
<
ResponseBody
>
call
,
@NonNull
Throwable
t
)
{
LoyaltySDKDynatraceEventModel
dynatraceEvent
=
new
LoyaltySDKDynatraceEventModel
();
dynatraceEvent
.
setEventName
(
"custom_error_supermarket_campaign_loyalty"
);
EventBus
.
getDefault
().
post
(
new
WarplyEventBusManager
(
dynatraceEvent
));
// receiver.onFailure(2);
// future.set(new ArrayList<Campaign>());
future
.
setException
(
new
Throwable
());
}
});
return
future
;
}
public
static
void
getSupermarketCampaign
(
final
CallbackReceiver
<
ArrayList
<
Campaign
>>
receiver
)
{
WarpUtils
.
log
(
"************* WARPLY Get Supermarket Campaigns Request ********************"
);
WarpUtils
.
log
(
"[WARP Trace] WARPLY Get Supermarket Campaigns Request is active"
);
WarpUtils
.
log
(
"**************************************************"
);
ApiService
service
=
ApiClient
.
getRetrofitInstance
().
create
(
ApiService
.
class
);
ListeningExecutorService
executorService
=
MoreExecutors
.
listeningDecorator
(
Executors
.
newFixedThreadPool
(
1
));
ListenableFuture
<
ArrayList
<
Campaign
>>
futureCampaigns
=
getSupermarketCampaignRetro
(
service
);
ListenableFuture
<
List
<
Object
>>
allResultsFuture
=
Futures
.
allAsList
(
futureCampaigns
);
ListenableFuture
<
ArrayList
<
Campaign
>>
mergedResultFuture
=
Futures
.
transformAsync
(
allResultsFuture
,
results
->
{
ArrayList
<
Campaign
>
resultCampaigns
=
(
ArrayList
<
Campaign
>)
results
.
get
(
0
);
return
executorService
.
submit
(()
->
resultCampaigns
);
},
executorService
);
Futures
.
addCallback
(
mergedResultFuture
,
new
FutureCallback
<
ArrayList
<
Campaign
>>()
{
@Override
public
void
onSuccess
(
ArrayList
<
Campaign
>
mergedResult
)
{
WarplyManagerHelper
.
setSupermarketCampaigns
(
mergedResult
);
executorService
.
shutdownNow
();
new
Handler
(
Looper
.
getMainLooper
()).
post
(()
->
receiver
.
onSuccess
(
mergedResult
));
}
@Override
public
void
onFailure
(
Throwable
throwable
)
{
executorService
.
shutdownNow
();
new
Handler
(
Looper
.
getMainLooper
()).
post
(()
->
receiver
.
onFailure
(
2
));
}
},
executorService
);
}
}
...
...
warply_android_sdk/src/main/java/ly/warp/sdk/views/WarpView.java
View file @
395834c
...
...
@@ -85,6 +85,7 @@ import ly.warp.sdk.activities.WarpViewActivity;
import
ly.warp.sdk.db.WarplyDBHelper
;
import
ly.warp.sdk.io.models.LoyaltySDKDynatraceEventModel
;
import
ly.warp.sdk.io.models.LoyaltySDKFirebaseEventModel
;
import
ly.warp.sdk.io.models.QuestionnaireEventModel
;
import
ly.warp.sdk.utils.WarpUtils
;
import
ly.warp.sdk.utils.WarplyProperty
;
import
ly.warp.sdk.utils.WarplyUrlHandler
;
...
...
@@ -457,6 +458,10 @@ public class WarpView extends WebView implements DefaultLifecycleObserver {
WarpViewActivity
.
setWebviewSupermarket
(
true
);
}
else
if
(
parts
[
1
].
equals
(
"closeArtwork"
))
{
WarpViewActivity
.
setWebviewSupermarket
(
false
);
QuestionnaireEventModel
questionnaireEvent
=
new
QuestionnaireEventModel
();
questionnaireEvent
.
setName
(
parts
[
1
]);
EventBus
.
getDefault
().
post
(
new
WarplyEventBusManager
(
questionnaireEvent
));
}
else
if
(
parts
[
1
].
equals
(
"request"
)
||
parts
[
1
].
equals
(
"response"
))
{
WarpUtils
.
log
(
"**************** WARPLY Webview Log START *****************"
);
WarpUtils
.
log
(
message
);
...
...
warply_android_sdk/src/main/res/layout/fragment_home.xml
View file @
395834c
...
...
@@ -98,6 +98,7 @@
</androidx.constraintlayout.widget.ConstraintLayout>
<RelativeLayout
android:id=
"@+id/rl_auth"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_below=
"@+id/rl_header"
...
...
@@ -126,7 +127,7 @@
android:textSize=
"20sp"
android:textStyle=
"bold"
android:visibility=
"gone"
tools:visibility=
"visible"
/>
tools:visibility=
"visible"
/>
<TextView
android:id=
"@+id/tv_login"
...
...
@@ -137,7 +138,7 @@
android:layout_marginStart=
"16dp"
android:textColor=
"@color/blue_dark"
android:textSize=
"20sp"
android:visibility=
"gone"
/>
android:visibility=
"gone"
/>
<LinearLayout
android:id=
"@+id/ll_auth_login"
...
...
@@ -192,9 +193,9 @@
android:layout_height=
"match_parent"
android:layout_centerInParent=
"true"
android:background=
"@android:color/transparent"
android:translationZ=
"100dp"
android:visibility=
"gone"
tools:visibility=
"visible"
android:translationZ=
"100dp"
>
tools:visibility=
"visible"
>
<ProgressBar
android:layout_width=
"48dp"
...
...
@@ -205,6 +206,60 @@
android:indeterminateTintMode=
"src_atop"
/>
</RelativeLayout>
</RelativeLayout>
<RelativeLayout
android:id=
"@+id/rl_sm_view"
android:layout_width=
"match_parent"
android:layout_height=
"70dp"
android:layout_below=
"@+id/rl_auth"
android:layout_marginHorizontal=
"8dp"
android:layout_marginTop=
"24dp"
android:layout_marginBottom=
"16dp"
android:background=
"@drawable/shape_cos_white"
>
<LinearLayout
android:id=
"@+id/ll_sm_flow"
android:layout_width=
"140dp"
android:layout_height=
"45dp"
android:layout_alignParentStart=
"true"
android:layout_centerVertical=
"true"
android:layout_marginStart=
"16dp"
android:background=
"@drawable/selector_button_green"
android:gravity=
"center"
android:orientation=
"horizontal"
>
<TextView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:gravity=
"center"
android:includeFontPadding=
"false"
android:text=
"@string/demo_sm_flow"
android:textColor=
"@color/white"
android:textSize=
"16sp"
/>
</LinearLayout>
<LinearLayout
android:id=
"@+id/ll_sm_map"
android:layout_width=
"140dp"
android:layout_height=
"45dp"
android:layout_alignParentEnd=
"true"
android:layout_centerVertical=
"true"
android:layout_marginEnd=
"16dp"
android:background=
"@drawable/selector_button_green"
android:gravity=
"center"
android:orientation=
"horizontal"
>
<TextView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:gravity=
"center"
android:includeFontPadding=
"false"
android:text=
"@string/demo_sm_map"
android:textColor=
"@color/white"
android:textSize=
"16sp"
/>
</LinearLayout>
</RelativeLayout>
</RelativeLayout>
</ScrollView>
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
...
...
warply_android_sdk/src/main/res/values/strings.xml
View file @
395834c
...
...
@@ -8,4 +8,6 @@
<string
name=
"cos_login_text"
>
Σύνδεση
</string>
<string
name=
"cos_logout_text"
>
Αποσύνδεση
</string>
<string
name=
"menu_home"
>
Αρχική
</string>
<string
name=
"demo_sm_flow"
>
Open SM Flow
</string>
<string
name=
"demo_sm_map"
>
Open SM Map
</string>
</resources>
...
...
Please
register
or
login
to post a comment