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
2022-08-03 18:49:43 +0300
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
321db686884fa4f55f254b63ab58afd5b83479f3
321db686
1 parent
de697913
uat fixes and changes
Show whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
1064 additions
and
177 deletions
app/src/main/java/warp/ly/android_sdk/activities/SplashActivity.java
warply_android_sdk/src/main/AndroidManifest.xml
warply_android_sdk/src/main/java/ly/warp/sdk/activities/LoyaltyWallet.java
warply_android_sdk/src/main/java/ly/warp/sdk/activities/TelcoActivity.java
warply_android_sdk/src/main/java/ly/warp/sdk/activities/WarpViewActivity.java
warply_android_sdk/src/main/java/ly/warp/sdk/io/request/CosmotePostEventRequest.java
warply_android_sdk/src/main/java/ly/warp/sdk/io/request/CosmoteSubmitOrderRequest.java
warply_android_sdk/src/main/java/ly/warp/sdk/io/request/PacingCalculateRequest.java
warply_android_sdk/src/main/java/ly/warp/sdk/services/WarplyHealthService.java
warply_android_sdk/src/main/java/ly/warp/sdk/utils/WarpUtils.java
warply_android_sdk/src/main/java/ly/warp/sdk/utils/WarplyManagerHelper.java
warply_android_sdk/src/main/java/ly/warp/sdk/utils/managers/WarplyHealthManager.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/activity_loyalty_wallet.xml
app/src/main/java/warp/ly/android_sdk/activities/SplashActivity.java
View file @
321db68
...
...
@@ -42,7 +42,7 @@ public class SplashActivity extends BaseActivity {
// );
WarplyManager
.
getCosmoteUser
(
new
WarplyCosmoteUserRequest
()
.
setGuid
(
"601204932
3
"
),
//6012049321, 6012049322, 6012049323
.
setGuid
(
"601204932
1
"
),
//6012049321, 6012049322, 6012049323
mLoginReceiver
);
// WarplyManager.verifyTicket(new WarplyVerifyTicketRequest()
...
...
warply_android_sdk/src/main/AndroidManifest.xml
View file @
321db68
...
...
@@ -157,6 +157,11 @@
android:permission=
"android.permission.BIND_JOB_SERVICE"
/>
<service
android:name=
"ly.warp.sdk.services.WarplyHealthService"
android:exported=
"false"
android:permission=
"android.permission.BIND_JOB_SERVICE"
/>
<service
android:name=
"ly.warp.sdk.services.WarplyBeaconsRangingService"
android:exported=
"false"
/>
...
...
warply_android_sdk/src/main/java/ly/warp/sdk/activities/LoyaltyWallet.java
View file @
321db68
...
...
@@ -45,7 +45,7 @@ public class LoyaltyWallet extends Activity implements View.OnClickListener {
private
ImageView
mIvBack
,
mIvDealsLogo
,
mIvProfilePhoto
;
private
TextView
mTvUsername
,
mTvDealsValue
,
mTvDealsValueAll
,
mTvUserBadge
,
mTvGiftsValue
,
mTvGiftsValueAll
,
mTvActiveCode
,
mTvActiveDate
,
mTvActiveTitle
;
mTvActiveTitle
,
mTvActiveCouponsHeader
;
private
ConstraintLayout
mClDealsBanner
,
mClDealsView
,
mClGiftsBanner
;
private
LinearLayout
mLlQuestionnaire
,
mLlUserBadge
;
...
...
@@ -79,6 +79,7 @@ public class LoyaltyWallet extends Activity implements View.OnClickListener {
mClDealsView
=
findViewById
(
R
.
id
.
cl_mygifts
);
mIvProfilePhoto
=
findViewById
(
R
.
id
.
iv_profile_photo
);
mTvActiveTitle
=
findViewById
(
R
.
id
.
tv_active_gifts
);
mTvActiveCouponsHeader
=
findViewById
(
R
.
id
.
tv_active_coupons_header
);
if
(
WarplyManagerHelper
.
getActiveDFYCoupons
()
!=
null
)
{
Collections
.
sort
(
WarplyManagerHelper
.
getActiveDFYCoupons
(),
new
Comparator
<
ActiveDFYCouponModel
>()
{
...
...
@@ -116,6 +117,7 @@ public class LoyaltyWallet extends Activity implements View.OnClickListener {
}
if
(
view
.
getId
()
==
R
.
id
.
ll_user_questionnaire
||
view
.
getId
()
==
R
.
id
.
ll_user_badge
)
{
startActivityForResult
(
WarpViewActivity
.
createIntentFromURL
(
LoyaltyWallet
.
this
,
WarplyManagerHelper
.
openQuestionnaire
()),
1000
);
// startActivity(WarpViewActivity.createIntentFromURL(LoyaltyWallet.this, WarplyManagerHelper.openPacing()));
return
;
}
if
(
view
.
getId
()
==
R
.
id
.
cl_deals_cos
)
{
...
...
@@ -171,15 +173,24 @@ public class LoyaltyWallet extends Activity implements View.OnClickListener {
.
subscribe
();
}
if
(
WarplyManagerHelper
.
getLoyaltyBadge
()
!=
null
)
{
WarpUtils
.
log
(
"LOYALTY_BADGE_COUNT: "
+
String
.
valueOf
(
WarplyManagerHelper
.
getLoyaltyBadge
().
getCouponCount
()));
WarpUtils
.
log
(
"LOYALTY_BADGE_SUM: "
+
String
.
valueOf
(
WarplyManagerHelper
.
getLoyaltyBadge
().
getValue
()));
if
(
WarplyManagerHelper
.
getDealsCouponsSum
()
>
0
)
{
mTvDealsValue
.
setText
(
String
.
format
(
getString
(
R
.
string
.
cos_value
),
String
.
valueOf
(
/*couponDfyValue*/
WarplyManagerHelper
.
getDealsCouponsSum
())));
mTvDealsValueAll
.
setText
(
String
.
format
(
getString
(
R
.
string
.
cos_deals_win_title_cos
),
String
.
valueOf
(
/*couponDfyValue*/
WarplyManagerHelper
.
getDealsCouponsSum
())));
}
else
{
mClDealsBanner
.
setVisibility
(
View
.
GONE
);
}
if
(
WarplyManagerHelper
.
getLoyaltyBadge
()
!=
null
)
{
if
(
WarplyManagerHelper
.
getLoyaltyBadge
().
getCouponCount
()
>
0
)
{
mTvGiftsValue
.
setText
(
String
.
format
(
getString
(
R
.
string
.
cos_value
),
String
.
valueOf
(
WarplyManagerHelper
.
getLoyaltyBadge
().
getValue
())));
mTvGiftsValueAll
.
setText
(
String
.
format
(
getString
(
R
.
string
.
cos_deals_win_title
),
String
.
valueOf
(
WarplyManagerHelper
.
getLoyaltyBadge
().
getValue
()),
String
.
valueOf
(
WarplyManagerHelper
.
getLoyaltyBadge
().
getCouponCount
())));
mTvDealsValue
.
setText
(
String
.
format
(
getString
(
R
.
string
.
cos_value
),
String
.
valueOf
(
/*couponDfyValue*/
WarplyManagerHelper
.
getDealsCouponsSum
())));
mTvDealsValueAll
.
setText
(
String
.
format
(
getString
(
R
.
string
.
cos_deals_win_title_cos
),
String
.
valueOf
(
/*couponDfyValue*/
WarplyManagerHelper
.
getDealsCouponsSum
())));
}
else
{
mClGiftsBanner
.
setVisibility
(
View
.
GONE
);
}
}
else
{
mClGiftsBanner
.
setVisibility
(
View
.
GONE
);
}
if
(
WarplyManagerHelper
.
getActiveDFYCoupons
()
!=
null
&&
WarplyManagerHelper
.
getActiveDFYCoupons
().
size
()
>
0
)
{
String
codes
=
""
;
if
(
WarplyManagerHelper
.
getActiveDFYCoupons
().
size
()
==
1
)
{
...
...
@@ -208,6 +219,7 @@ public class LoyaltyWallet extends Activity implements View.OnClickListener {
// e.printStackTrace();
// }
}
else
{
mTvActiveCouponsHeader
.
setVisibility
(
View
.
GONE
);
mIvDealsLogo
.
setVisibility
(
View
.
GONE
);
mClDealsView
.
setVisibility
(
View
.
GONE
);
}
...
...
warply_android_sdk/src/main/java/ly/warp/sdk/activities/TelcoActivity.java
View file @
321db68
...
...
@@ -183,7 +183,15 @@ public class TelcoActivity extends Activity implements View.OnClickListener {
.
setDataCategory
(
mCCMS
.
getDataCategory
())
.
setMinsValue
(
mCCMS
.
getMinsValue
())
.
setDataValue
(
mCCMS
.
getDataValue
())
.
setProvStepValueMins
(
mCCMS
.
getProvStepValueMins
()),
.
setProvStepValueMins
(
mCCMS
.
getProvStepValueMins
())
.
setOfferAudienceLevel
(
mCCMS
.
getOfferAudienceLevel
())
.
setUACIOfferTrackingCode
(
mCCMS
.
getUACIOfferTrackingCode
())
.
setOfferCode1
(
mCCMS
.
getOfferCode1
())
.
setScore
(
mCCMS
.
getScore
())
.
setZone
(
mCCMS
.
getZone
())
.
setWave
(
mCCMS
.
getWave
())
.
setValidity
(
mCCMS
.
getValidity
())
.
setTreatmentCode
(
mCCMS
.
getTreatmentCode
()),
mSubmitCallback
);
}
Thread
.
currentThread
().
interrupt
();
...
...
@@ -250,25 +258,25 @@ public class TelcoActivity extends Activity implements View.OnClickListener {
errorActivatingDialog
();
});
if
(
status
==
1
)
{
new
Thread
(()
->
{
if
(!
Thread
.
currentThread
().
isInterrupted
())
{
WarplyManager
.
postEvent
(
new
CosmotePostEventRequest
()
.
setCommunicationUuid
(
mLoyalty
.
getSessionUUID
())
.
setUserMsisdn
(
mSender
)
.
setOfferAudienceLevel
(
mCCMS
.
getOfferAudienceLevel
())
.
setUACIOfferTrackingCode
(
mCCMS
.
getUACIOfferTrackingCode
())
.
setOfferCode1
(
mCCMS
.
getOfferCode1
())
.
setScore
(
mCCMS
.
getScore
())
.
setZone
(
mCCMS
.
getZone
())
.
setWave
(
mCCMS
.
getWave
())
.
setValidity
(
mCCMS
.
getValidity
())
.
setTreatmentCode
(
mCCMS
.
getTreatmentCode
()),
mPostCallback
);
}
Thread
.
currentThread
().
interrupt
();
}).
start
();
}
//
if (status == 1) {
//
new Thread(() -> {
//
if (!Thread.currentThread().isInterrupted()) {
//
WarplyManager.postEvent(new CosmotePostEventRequest()
//
.setCommunicationUuid(mLoyalty.getSessionUUID())
//
.setUserMsisdn(mSender)
//
.setOfferAudienceLevel(mCCMS.getOfferAudienceLevel())
//
.setUACIOfferTrackingCode(mCCMS.getUACIOfferTrackingCode())
//
.setOfferCode1(mCCMS.getOfferCode1())
//
.setScore(mCCMS.getScore())
//
.setZone(mCCMS.getZone())
//
.setWave(mCCMS.getWave())
//
.setValidity(mCCMS.getValidity())
//
.setTreatmentCode(mCCMS.getTreatmentCode()),
//
mPostCallback);
//
}
//
Thread.currentThread().interrupt();
//
}).start();
//
}
}
@Override
...
...
@@ -277,16 +285,16 @@ public class TelcoActivity extends Activity implements View.OnClickListener {
}
};
private
CallbackReceiver
<
JSONObject
>
mPostCallback
=
new
CallbackReceiver
<
JSONObject
>()
{
@Override
public
void
onSuccess
(
JSONObject
result
)
{
Thread
.
currentThread
().
interrupt
();
}
@Override
public
void
onFailure
(
int
errorCode
)
{
WarpUtils
.
log
(
"POST_EVENT_ERROR "
+
String
.
valueOf
(
errorCode
));
Thread
.
currentThread
().
interrupt
();
}
};
//
private CallbackReceiver<JSONObject> mPostCallback = new CallbackReceiver<JSONObject>() {
//
@Override
//
public void onSuccess(JSONObject result) {
//
Thread.currentThread().interrupt();
//
}
//
//
@Override
//
public void onFailure(int errorCode) {
//
WarpUtils.log("POST_EVENT_ERROR " + String.valueOf(errorCode));
//
Thread.currentThread().interrupt();
//
}
//
};
}
...
...
warply_android_sdk/src/main/java/ly/warp/sdk/activities/WarpViewActivity.java
View file @
321db68
...
...
@@ -49,6 +49,7 @@ import androidx.work.WorkManager;
import
org.greenrobot.eventbus.EventBus
;
import
org.greenrobot.eventbus.Subscribe
;
import
org.json.JSONObject
;
import
java.security.SecureRandom
;
import
java.util.concurrent.ThreadLocalRandom
;
...
...
@@ -113,6 +114,12 @@ public class WarpViewActivity extends WarpBaseActivity {
}
@Override
protected
void
onDestroy
()
{
super
.
onDestroy
();
WarpUtils
.
setWebviewParams
(
this
,
new
JSONObject
());
}
@Override
public
boolean
onKeyDown
(
int
keyCode
,
@NonNull
KeyEvent
event
)
{
if
(
keyCode
==
KeyEvent
.
KEYCODE_BACK
)
{
if
(
mWarpView
.
canGoBack
())
{
...
...
warply_android_sdk/src/main/java/ly/warp/sdk/io/request/CosmotePostEventRequest.java
View file @
321db68
...
...
@@ -155,7 +155,7 @@ public class CosmotePostEventRequest {
* Call this to set how often the cached data will be updated.
*
* @param updateInterval The time that data will be cached
* @return
WarplyConsumer
Request
* @return
CosmotePostEvent
Request
*/
public
CosmotePostEventRequest
setCacheUpdateInterval
(
long
updateInterval
)
{
...
...
@@ -181,7 +181,7 @@ public class CosmotePostEventRequest {
*
* @param useCache <p>true - the Application is using Cache</p>
* <p>false - the Application is not using Cache</p>
* @return
WarplyConsumer
Request
* @return
CosmotePostEvent
Request
*/
public
CosmotePostEventRequest
setUseCache
(
boolean
useCache
)
{
...
...
@@ -335,7 +335,7 @@ public class CosmotePostEventRequest {
}
public
String
getSignature
()
{
String
signature
=
mFilters
!=
null
&&
mFilters
.
size
()
>
0
?
String
.
valueOf
(
mFilters
.
hashCode
())
:
"default_co
nsumer
_request"
;
String
signature
=
mFilters
!=
null
&&
mFilters
.
size
()
>
0
?
String
.
valueOf
(
mFilters
.
hashCode
())
:
"default_co
smote_post_event
_request"
;
try
{
byte
[]
hash
=
MessageDigest
.
getInstance
(
"SHA-256"
).
digest
(
signature
.
getBytes
(
"UTF-8"
));
signature
=
Base64
.
encodeToString
(
hash
,
Base64
.
NO_WRAP
);
...
...
warply_android_sdk/src/main/java/ly/warp/sdk/io/request/CosmoteSubmitOrderRequest.java
View file @
321db68
...
...
@@ -2,6 +2,7 @@ package ly.warp.sdk.io.request;
import
android.util.Base64
;
import
org.json.JSONArray
;
import
org.json.JSONException
;
import
org.json.JSONObject
;
...
...
@@ -42,6 +43,7 @@ public class CosmoteSubmitOrderRequest {
private
final
String
KEY_MINS_VALUE
=
"minsValue"
;
private
final
String
KEY_DATA_VALUE
=
"dataValue"
;
private
final
String
KEY_PROV_STEP_VALUE_MINS
=
"provStepValueMins"
;
private
final
String
KEY_PARAMETERS
=
"parameters"
;
// ===========================================================
// Fields
...
...
@@ -63,6 +65,14 @@ public class CosmoteSubmitOrderRequest {
private
String
mMinsValue
=
""
;
private
String
mDataValue
=
""
;
private
String
mProvStepValueMins
=
""
;
private
String
mOfferAudienceLevel
=
""
;
private
String
mUACIOfferTrackingCode
=
""
;
private
String
mOfferCode1
=
""
;
private
String
mScore
=
""
;
private
String
mZone
=
""
;
private
String
mWave
=
""
;
private
String
mValidity
=
""
;
private
String
mTreatmentCode
=
""
;
// ===========================================================
// Constructor
...
...
@@ -178,6 +188,46 @@ public class CosmoteSubmitOrderRequest {
return
this
;
}
public
CosmoteSubmitOrderRequest
setOfferAudienceLevel
(
String
offerAudienceLevel
)
{
this
.
mOfferAudienceLevel
=
offerAudienceLevel
;
return
this
;
}
public
CosmoteSubmitOrderRequest
setUACIOfferTrackingCode
(
String
uaciOfferTrackingCode
)
{
this
.
mUACIOfferTrackingCode
=
uaciOfferTrackingCode
;
return
this
;
}
public
CosmoteSubmitOrderRequest
setOfferCode1
(
String
offerCode1
)
{
this
.
mOfferCode1
=
offerCode1
;
return
this
;
}
public
CosmoteSubmitOrderRequest
setScore
(
String
score
)
{
this
.
mScore
=
score
;
return
this
;
}
public
CosmoteSubmitOrderRequest
setZone
(
String
zone
)
{
this
.
mZone
=
zone
;
return
this
;
}
public
CosmoteSubmitOrderRequest
setWave
(
String
wave
)
{
this
.
mWave
=
wave
;
return
this
;
}
public
CosmoteSubmitOrderRequest
setValidity
(
String
validity
)
{
this
.
mValidity
=
validity
;
return
this
;
}
public
CosmoteSubmitOrderRequest
setTreatmentCode
(
String
treatmentCode
)
{
this
.
mTreatmentCode
=
treatmentCode
;
return
this
;
}
/**
* Call this to get how often the cached data will be updated.
*
...
...
@@ -191,7 +241,7 @@ public class CosmoteSubmitOrderRequest {
* Call this to set how often the cached data will be updated.
*
* @param updateInterval The time that data will be cached
* @return CosmoteS
haring
Request
* @return CosmoteS
ubmitOrder
Request
*/
public
CosmoteSubmitOrderRequest
setCacheUpdateInterval
(
long
updateInterval
)
{
...
...
@@ -217,7 +267,7 @@ public class CosmoteSubmitOrderRequest {
*
* @param useCache <p>true - the Application is using Cache</p>
* <p>false - the Application is not using Cache</p>
* @return CosmoteS
haring
Request
* @return CosmoteS
ubmitOrder
Request
*/
public
CosmoteSubmitOrderRequest
setUseCache
(
boolean
useCache
)
{
...
...
@@ -257,6 +307,123 @@ public class CosmoteSubmitOrderRequest {
extraData
.
putOpt
(
KEY_MINS_VALUE
,
mMinsValue
);
extraData
.
putOpt
(
KEY_DATA_VALUE
,
mDataValue
);
extraData
.
putOpt
(
KEY_PROV_STEP_VALUE_MINS
,
mProvStepValueMins
);
extraData
.
putOpt
(
"InteractiveChannel"
,
"COSMOTE_OMNI"
);
extraData
.
putOpt
(
"InteractionPoint"
,
mZone
);
extraData
.
putOpt
(
"Session_ID"
,
mCommunicationUuid
);
extraData
.
putOpt
(
"OfferAudienceLevel"
,
mOfferAudienceLevel
);
extraData
.
putOpt
(
"MSISDN"
,
mOfferAudienceLevel
.
equals
(
"msisdn"
)
?
mUserMsisdn
:
""
);
extraData
.
putOpt
(
"GUID"
,
""
);
JSONArray
parameters
=
new
JSONArray
();
JSONObject
param1
=
new
JSONObject
();
param1
.
putOpt
(
"Name"
,
"UACIOfferTrackingCode"
);
param1
.
putOpt
(
"Value"
,
mUACIOfferTrackingCode
);
param1
.
putOpt
(
"Type"
,
"string"
);
parameters
.
put
(
param1
);
JSONObject
param2
=
new
JSONObject
();
param2
.
putOpt
(
"Name"
,
"UACICustomLoggerTableName"
);
param2
.
putOpt
(
"Value"
,
"VW_WHITELIST"
);
param2
.
putOpt
(
"Type"
,
"string"
);
parameters
.
put
(
param2
);
JSONObject
param3
=
new
JSONObject
();
param3
.
putOpt
(
"Name"
,
"MSISDN"
);
param3
.
putOpt
(
"Value"
,
mUserMsisdn
);
param3
.
putOpt
(
"Type"
,
"string"
);
parameters
.
put
(
param3
);
JSONObject
param4
=
new
JSONObject
();
param4
.
putOpt
(
"Name"
,
"OFFERCODE1"
);
param4
.
putOpt
(
"Value"
,
mOfferCode1
);
param4
.
putOpt
(
"Type"
,
"string"
);
parameters
.
put
(
param4
);
JSONObject
param5
=
new
JSONObject
();
param5
.
putOpt
(
"Name"
,
"SCORE"
);
param5
.
putOpt
(
"Value"
,
mScore
);
param5
.
putOpt
(
"Type"
,
"INT"
);
parameters
.
put
(
param5
);
JSONObject
param6
=
new
JSONObject
();
param6
.
putOpt
(
"Name"
,
"PREDICATE"
);
param6
.
putOpt
(
"Value"
,
"0"
);
param6
.
putOpt
(
"Type"
,
"string"
);
parameters
.
put
(
param6
);
JSONObject
param7
=
new
JSONObject
();
param7
.
putOpt
(
"Name"
,
"ZONE"
);
param7
.
putOpt
(
"Value"
,
mZone
);
param7
.
putOpt
(
"Type"
,
"string"
);
parameters
.
put
(
param7
);
JSONObject
param8
=
new
JSONObject
();
param8
.
putOpt
(
"Name"
,
"APPLICATIONNAME"
);
param8
.
putOpt
(
"Value"
,
mZone
);
param8
.
putOpt
(
"Type"
,
"string"
);
parameters
.
put
(
param8
);
JSONObject
param9
=
new
JSONObject
();
param9
.
putOpt
(
"Name"
,
"Session_ID"
);
param9
.
putOpt
(
"Value"
,
mCommunicationUuid
);
param9
.
putOpt
(
"Type"
,
"string"
);
parameters
.
put
(
param9
);
JSONObject
param10
=
new
JSONObject
();
param10
.
putOpt
(
"Name"
,
"CAMPAIGN_CODE"
);
param10
.
putOpt
(
"Value"
,
"MCC_00006"
);
param10
.
putOpt
(
"Type"
,
"string"
);
parameters
.
put
(
param10
);
JSONObject
param11
=
new
JSONObject
();
param11
.
putOpt
(
"Name"
,
"CAMPAIGN_TYPE"
);
param11
.
putOpt
(
"Value"
,
"Inbound"
);
param11
.
putOpt
(
"Type"
,
"string"
);
parameters
.
put
(
param11
);
JSONObject
param12
=
new
JSONObject
();
param12
.
putOpt
(
"Name"
,
"UACIResponseTypeCode"
);
param12
.
putOpt
(
"Value"
,
"CON"
);
param12
.
putOpt
(
"Type"
,
"string"
);
parameters
.
put
(
param12
);
JSONObject
param13
=
new
JSONObject
();
param13
.
putOpt
(
"Name"
,
"CHANNEL"
);
param13
.
putOpt
(
"Value"
,
"ONE_APP"
);
param13
.
putOpt
(
"Type"
,
"string"
);
parameters
.
put
(
param13
);
JSONObject
param14
=
new
JSONObject
();
param14
.
putOpt
(
"Name"
,
"WAVE"
);
param14
.
putOpt
(
"Value"
,
mWave
);
param14
.
putOpt
(
"Type"
,
"string"
);
parameters
.
put
(
param14
);
JSONObject
param15
=
new
JSONObject
();
param15
.
putOpt
(
"Name"
,
"RESPONSECHANNEL"
);
param15
.
putOpt
(
"Value"
,
"ONE_APP"
);
param15
.
putOpt
(
"Type"
,
"string"
);
parameters
.
put
(
param15
);
JSONObject
param16
=
new
JSONObject
();
param16
.
putOpt
(
"Name"
,
"VALIDITY"
);
param16
.
putOpt
(
"Value"
,
mValidity
);
param16
.
putOpt
(
"Type"
,
"INT"
);
parameters
.
put
(
param16
);
JSONObject
param17
=
new
JSONObject
();
param17
.
putOpt
(
"Name"
,
"TREATMENT_CODE"
);
param17
.
putOpt
(
"Value"
,
mTreatmentCode
);
param17
.
putOpt
(
"Type"
,
"string"
);
parameters
.
put
(
param17
);
JSONObject
param18
=
new
JSONObject
();
param18
.
putOpt
(
"Name"
,
"EventName"
);
param18
.
putOpt
(
"Value"
,
"INTEREST_P"
);
param18
.
putOpt
(
"Type"
,
"string"
);
parameters
.
put
(
param18
);
extraData
.
putOpt
(
KEY_PARAMETERS
,
parameters
);
extraJson
.
putOpt
(
KEY_EXTRA_DATA
,
extraData
);
bodyJsonObject
.
putOpt
(
KEY_MAPP
,
extraJson
);
...
...
@@ -268,7 +435,7 @@ public class CosmoteSubmitOrderRequest {
}
public
String
getSignature
()
{
String
signature
=
mFilters
!=
null
&&
mFilters
.
size
()
>
0
?
String
.
valueOf
(
mFilters
.
hashCode
())
:
"default_cosmote_s
haring
_request"
;
String
signature
=
mFilters
!=
null
&&
mFilters
.
size
()
>
0
?
String
.
valueOf
(
mFilters
.
hashCode
())
:
"default_cosmote_s
ubmit_order
_request"
;
try
{
byte
[]
hash
=
MessageDigest
.
getInstance
(
"SHA-256"
).
digest
(
signature
.
getBytes
(
"UTF-8"
));
signature
=
Base64
.
encodeToString
(
hash
,
Base64
.
NO_WRAP
);
...
...
warply_android_sdk/src/main/java/ly/warp/sdk/io/request/PacingCalculateRequest.java
0 → 100644
View file @
321db68
package
ly
.
warp
.
sdk
.
io
.
request
;
import
android.util.Base64
;
import
org.json.JSONException
;
import
org.json.JSONObject
;
import
java.io.UnsupportedEncodingException
;
import
java.security.MessageDigest
;
import
java.security.NoSuchAlgorithmException
;
import
java.util.HashMap
;
import
ly.warp.sdk.utils.constants.WarpConstants
;
/**
* Created by Panagiotis Triantafyllou on 02-Aug-22.
*/
public
class
PacingCalculateRequest
{
// ===========================================================
// Constants
// ===========================================================
private
final
String
KEY_MAPP
=
"consumer_data"
;
private
final
String
KEY_ACTION
=
"action"
;
private
final
String
KEY_ACTION_VALUE
=
"integration"
;
private
final
String
KEY_METHOD
=
"method"
;
private
final
String
KEY_METHOD_VALUE
=
"steps"
;
private
final
String
KEY_OPERATION
=
"operation"
;
private
final
String
KEY_OPERATION_VALUE
=
"add"
;
private
final
String
KEY_DATA
=
"data"
;
// ===========================================================
// Fields
// ===========================================================
private
HashMap
<
String
,
String
>
mFilters
;
private
long
mCacheUpdateInterval
=
0
;
private
String
mDate
=
""
;
private
int
mCounter
=
0
;
// ===========================================================
// Constructor
// ===========================================================
/**
* Default constructor of WarplyConsumerRequest, initializes an empty filters HashMap
*/
public
PacingCalculateRequest
()
{
mFilters
=
new
HashMap
<>();
}
public
PacingCalculateRequest
(
PacingCalculateRequest
copy
)
{
if
(
copy
!=
null
)
{
this
.
mFilters
=
copy
.
mFilters
;
this
.
mCacheUpdateInterval
=
copy
.
mCacheUpdateInterval
;
}
}
// ===========================================================
// Methods for/from SuperClass/Interfaces
// ===========================================================
@Override
public
boolean
equals
(
Object
object
)
{
if
(
object
instanceof
PacingCalculateRequest
)
{
PacingCalculateRequest
other
=
(
PacingCalculateRequest
)
object
;
return
other
==
this
||
(
this
.
mFilters
==
other
.
mFilters
||
(
this
.
mFilters
!=
null
&&
this
.
mFilters
.
equals
(
other
.
mFilters
)));
}
return
false
;
}
@Override
public
int
hashCode
()
{
return
mFilters
.
hashCode
();
}
// ===========================================================
// Methods
// ===========================================================
// ===========================================================
// Getter & Setter
// ===========================================================
public
PacingCalculateRequest
setDate
(
String
date
)
{
this
.
mDate
=
date
;
return
this
;
}
public
PacingCalculateRequest
setCounter
(
int
counter
)
{
this
.
mCounter
=
counter
;
return
this
;
}
/**
* Call this to get how often the cached data will be updated.
*
* @return mCacheUpdateInterval
*/
public
long
getCacheUpdateInterval
()
{
return
mCacheUpdateInterval
;
}
/**
* Call this to set how often the cached data will be updated.
*
* @param updateInterval The time that data will be cached
* @return PacingCalculateRequest
*/
public
PacingCalculateRequest
setCacheUpdateInterval
(
long
updateInterval
)
{
this
.
mCacheUpdateInterval
=
updateInterval
;
if
(
mCacheUpdateInterval
<
0
)
{
mCacheUpdateInterval
=
0
;
}
return
this
;
}
/**
* Call this to check if the Application uses Cache
*
* @return <p>true - the Application is using Cache</p>
* <p>false - the Application is not using Cache</p>
*/
public
boolean
isUseCache
()
{
return
mCacheUpdateInterval
>
0
;
}
/**
* Call this to check whether the cached data need to be updated
*
* @param useCache <p>true - the Application is using Cache</p>
* <p>false - the Application is not using Cache</p>
* @return PacingCalculateRequest
*/
public
PacingCalculateRequest
setUseCache
(
boolean
useCache
)
{
if
(
useCache
)
{
mCacheUpdateInterval
=
mCacheUpdateInterval
>
0
?
mCacheUpdateInterval
:
WarpConstants
.
INBOX_UPDATE_INTERVAL
;
}
else
{
mCacheUpdateInterval
=
0
;
}
return
this
;
}
/**
* Call this to build the offers Json object
*
* @return bodyJsonObject
*/
public
JSONObject
toJson
()
{
JSONObject
bodyJsonObject
=
new
JSONObject
();
try
{
JSONObject
extraJson
=
new
JSONObject
();
extraJson
.
putOpt
(
KEY_ACTION
,
KEY_ACTION_VALUE
);
extraJson
.
putOpt
(
KEY_METHOD
,
KEY_METHOD_VALUE
);
extraJson
.
putOpt
(
KEY_OPERATION
,
KEY_OPERATION_VALUE
);
JSONObject
data
=
new
JSONObject
();
data
.
putOpt
(
"event"
,
"steps"
);
data
.
putOpt
(
"type"
,
"counter"
);
data
.
putOpt
(
"counter"
,
mCounter
);
data
.
putOpt
(
"date"
,
mDate
);
extraJson
.
putOpt
(
KEY_DATA
,
data
);
bodyJsonObject
.
putOpt
(
KEY_MAPP
,
extraJson
);
}
catch
(
JSONException
e
)
{
if
(
WarpConstants
.
DEBUG
)
e
.
printStackTrace
();
}
return
bodyJsonObject
;
}
public
String
getSignature
()
{
String
signature
=
mFilters
!=
null
&&
mFilters
.
size
()
>
0
?
String
.
valueOf
(
mFilters
.
hashCode
())
:
"default_pacing_calculate_request"
;
try
{
byte
[]
hash
=
MessageDigest
.
getInstance
(
"SHA-256"
).
digest
(
signature
.
getBytes
(
"UTF-8"
));
signature
=
Base64
.
encodeToString
(
hash
,
Base64
.
NO_WRAP
);
}
catch
(
NullPointerException
|
NoSuchAlgorithmException
|
UnsupportedEncodingException
e
)
{
e
.
printStackTrace
();
}
return
signature
;
}
}
warply_android_sdk/src/main/java/ly/warp/sdk/services/WarplyHealthService.java
0 → 100644
View file @
321db68
package
ly
.
warp
.
sdk
.
services
;
import
android.app.Service
;
import
android.content.Context
;
import
android.content.Intent
;
import
android.hardware.Sensor
;
import
android.hardware.SensorEvent
;
import
android.hardware.SensorEventListener
;
import
android.hardware.SensorManager
;
import
android.os.IBinder
;
import
androidx.annotation.NonNull
;
import
androidx.annotation.Nullable
;
import
androidx.work.Worker
;
import
androidx.work.WorkerParameters
;
import
org.greenrobot.eventbus.EventBus
;
import
org.json.JSONObject
;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.util.Date
;
import
java.util.Locale
;
import
ly.warp.sdk.io.callbacks.CallbackReceiver
;
import
ly.warp.sdk.io.callbacks.WarplyHealthCallback
;
import
ly.warp.sdk.io.models.ContexualEventModel
;
import
ly.warp.sdk.io.request.PacingCalculateRequest
;
import
ly.warp.sdk.utils.WarpUtils
;
import
ly.warp.sdk.utils.managers.WarplyEventBusManager
;
import
ly.warp.sdk.utils.managers.WarplyHealthManager
;
import
ly.warp.sdk.utils.managers.WarplyManager
;
/**
* Created by Panagiotis Triantafyllou on 03/Aug/2022.
*/
public
class
WarplyHealthService
extends
/*Worker*/
Service
implements
SensorEventListener
{
// ===========================================================
// Constants
// ===========================================================
// ===========================================================
// Fields
// ===========================================================
private
Context
mContext
;
private
SensorManager
mSensorManager
;
private
Sensor
mSensor
;
private
int
mSteps
=
0
;
private
final
int
ACCEL_RING_SIZE
=
50
;
private
final
int
VEL_RING_SIZE
=
10
;
// change this threshold according to your sensitivity preferences
private
final
float
STEP_THRESHOLD
=
20
f
;
private
final
int
STEP_DELAY_NS
=
250000000
;
private
int
accelRingCounter
=
0
;
private
float
[]
accelRingX
=
new
float
[
ACCEL_RING_SIZE
];
private
float
[]
accelRingY
=
new
float
[
ACCEL_RING_SIZE
];
private
float
[]
accelRingZ
=
new
float
[
ACCEL_RING_SIZE
];
private
int
velRingCounter
=
0
;
private
float
[]
velRing
=
new
float
[
VEL_RING_SIZE
];
private
long
lastStepTimeNs
=
0
;
private
float
oldVelocityEstimate
=
0
;
// if we want to send the steps back to an activity/fragment/service etc
// private static WarplyHealthCallback mHealthCallback;
// ===========================================================
// Contructors
// ===========================================================
// public WarplyHealthService(@NonNull Context context, @NonNull WorkerParameters workerParams) {
// super(context, workerParams);
//
// mContext = context;
// mSensorManager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE);
// mSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
// registerStepSensor();
// }
// ===========================================================
// Methods for/from SuperClass/Interfaces
// ===========================================================
@Override
public
void
onCreate
()
{
super
.
onCreate
();
mSensorManager
=
(
SensorManager
)
getSystemService
(
Context
.
SENSOR_SERVICE
);
mSensor
=
mSensorManager
.
getDefaultSensor
(
Sensor
.
TYPE_ACCELEROMETER
);
registerStepSensor
();
}
@Override
public
int
onStartCommand
(
Intent
intent
,
int
flags
,
int
startId
)
{
new
Thread
(
()
->
{
while
(
true
)
{
sendSteps
();
try
{
Thread
.
sleep
(
10000
);
}
catch
(
InterruptedException
e
)
{
e
.
printStackTrace
();
}
}
}
).
start
();
return
super
.
onStartCommand
(
intent
,
flags
,
startId
);
}
@Override
public
void
onDestroy
()
{
super
.
onDestroy
();
unregisterStepSensor
();
}
@Nullable
@Override
public
IBinder
onBind
(
Intent
intent
)
{
return
null
;
}
// @NonNull
// @Override
// public Result doWork() {
// sendSteps();
// return Result.success();
// }
// @Override
// public void onStopped() {
// super.onStopped();
//
// unregisterStepSensor();
//
// if (WarpUtils.getStepsCounter(mContext) > 0) {
// sendSteps();
// }
// }
@Override
public
void
onSensorChanged
(
SensorEvent
sensorEvent
)
{
if
(
sensorEvent
.
sensor
.
getType
()
==
Sensor
.
TYPE_ACCELEROMETER
)
{
updateSteps
(
sensorEvent
.
timestamp
,
sensorEvent
.
values
[
0
],
sensorEvent
.
values
[
1
],
sensorEvent
.
values
[
2
]);
}
}
@Override
public
void
onAccuracyChanged
(
Sensor
sensor
,
int
i
)
{
}
// ===========================================================
// Methods
// ===========================================================
public
void
registerStepSensor
()
{
mSensorManager
.
registerListener
(
this
,
mSensor
,
SensorManager
.
SENSOR_DELAY_GAME
);
}
public
void
unregisterStepSensor
()
{
mSensorManager
.
unregisterListener
(
this
);
}
private
void
updateSteps
(
long
timeNs
,
float
x
,
float
y
,
float
z
)
{
float
[]
currentAccel
=
new
float
[
3
];
currentAccel
[
0
]
=
x
;
currentAccel
[
1
]
=
y
;
currentAccel
[
2
]
=
z
;
// First step is to update our guess of where the global z vector is.
accelRingCounter
++;
accelRingX
[
accelRingCounter
%
ACCEL_RING_SIZE
]
=
currentAccel
[
0
];
accelRingY
[
accelRingCounter
%
ACCEL_RING_SIZE
]
=
currentAccel
[
1
];
accelRingZ
[
accelRingCounter
%
ACCEL_RING_SIZE
]
=
currentAccel
[
2
];
float
[]
worldZ
=
new
float
[
3
];
worldZ
[
0
]
=
sum
(
accelRingX
)
/
Math
.
min
(
accelRingCounter
,
ACCEL_RING_SIZE
);
worldZ
[
1
]
=
sum
(
accelRingY
)
/
Math
.
min
(
accelRingCounter
,
ACCEL_RING_SIZE
);
worldZ
[
2
]
=
sum
(
accelRingZ
)
/
Math
.
min
(
accelRingCounter
,
ACCEL_RING_SIZE
);
float
normalization_factor
=
norm
(
worldZ
);
worldZ
[
0
]
=
worldZ
[
0
]
/
normalization_factor
;
worldZ
[
1
]
=
worldZ
[
1
]
/
normalization_factor
;
worldZ
[
2
]
=
worldZ
[
2
]
/
normalization_factor
;
float
currentZ
=
dot
(
worldZ
,
currentAccel
)
-
normalization_factor
;
velRingCounter
++;
velRing
[
velRingCounter
%
VEL_RING_SIZE
]
=
currentZ
;
float
velocityEstimate
=
sum
(
velRing
);
if
(
velocityEstimate
>
STEP_THRESHOLD
&&
oldVelocityEstimate
<=
STEP_THRESHOLD
&&
(
timeNs
-
lastStepTimeNs
>
STEP_DELAY_NS
))
{
mSteps
++;
WarpUtils
.
setStepsCounter
(
mContext
,
mSteps
);
// if we want to send the steps back to an activity/fragment/service etc
// mHealthCallback.onStepCount(mSteps);
lastStepTimeNs
=
timeNs
;
}
oldVelocityEstimate
=
velocityEstimate
;
}
private
float
sum
(
float
[]
array
)
{
float
retval
=
0
;
for
(
float
v
:
array
)
{
retval
+=
v
;
}
return
retval
;
}
private
float
[]
cross
(
float
[]
arrayA
,
float
[]
arrayB
)
{
float
[]
retArray
=
new
float
[
3
];
retArray
[
0
]
=
arrayA
[
1
]
*
arrayB
[
2
]
-
arrayA
[
2
]
*
arrayB
[
1
];
retArray
[
1
]
=
arrayA
[
2
]
*
arrayB
[
0
]
-
arrayA
[
0
]
*
arrayB
[
2
];
retArray
[
2
]
=
arrayA
[
0
]
*
arrayB
[
1
]
-
arrayA
[
1
]
*
arrayB
[
0
];
return
retArray
;
}
private
float
norm
(
float
[]
array
)
{
float
retval
=
0
;
for
(
float
v
:
array
)
{
retval
+=
v
*
v
;
}
return
(
float
)
Math
.
sqrt
(
retval
);
}
private
float
dot
(
float
[]
a
,
float
[]
b
)
{
return
a
[
0
]
*
b
[
0
]
+
a
[
1
]
*
b
[
1
]
+
a
[
2
]
*
b
[
2
];
}
private
float
[]
normalize
(
float
[]
a
)
{
float
[]
retval
=
new
float
[
a
.
length
];
float
norm
=
norm
(
a
);
for
(
int
i
=
0
;
i
<
a
.
length
;
i
++)
{
retval
[
i
]
=
a
[
i
]
/
norm
;
}
return
retval
;
}
private
void
sendSteps
()
{
String
date
=
new
SimpleDateFormat
(
"yyyy-MM-dd hh:mm:ss"
,
Locale
.
getDefault
()).
format
(
new
Date
());
WarplyManager
.
setPacingDetails
(
new
PacingCalculateRequest
()
.
setCounter
(
WarpUtils
.
getStepsCounter
(
mContext
))
.
setDate
(
date
),
new
CallbackReceiver
<
JSONObject
>()
{
@Override
public
void
onSuccess
(
JSONObject
result
)
{
WarpUtils
.
log
(
"Warply Health Service success"
);
int
status
=
result
.
optInt
(
"status"
,
2
);
if
(
status
==
1
)
{
mSteps
=
0
;
WarpUtils
.
setStepsCounter
(
mContext
,
0
);
}
}
@Override
public
void
onFailure
(
int
errorCode
)
{
WarpUtils
.
log
(
"Warply Health Service error: "
+
String
.
valueOf
(
errorCode
));
}
});
}
}
warply_android_sdk/src/main/java/ly/warp/sdk/utils/WarpUtils.java
View file @
321db68
...
...
@@ -133,6 +133,10 @@ public class WarpUtils {
+
"more_popup"
;
private
static
final
String
PREFERENCES_KEY_USER_TAG
=
PREFERENCES_PREFIX
+
"user_badge"
;
private
static
final
String
PREFERENCES_KEY_WEBVIEW_PARAMS
=
PREFERENCES_PREFIX
+
"webview_params"
;
private
static
final
String
PREFERENCES_STEPS_COUNTER
=
PREFERENCES_PREFIX
+
"steps_counter"
;
private
static
SharedPreferences
_prefs
;
...
...
@@ -586,6 +590,28 @@ public class WarpUtils {
editor
.
apply
();
}
public
static
void
setWebviewParams
(
Context
context
,
JSONObject
params
)
{
SharedPreferences
.
Editor
editor
=
getPreferences
(
context
).
edit
();
editor
.
putString
(
PREFERENCES_KEY_WEBVIEW_PARAMS
,
params
.
toString
());
editor
.
apply
();
}
public
static
String
getWebviewParams
(
Context
context
)
{
SharedPreferences
prefs
=
getPreferences
(
context
);
return
prefs
.
getString
(
PREFERENCES_KEY_WEBVIEW_PARAMS
,
""
);
}
public
static
void
setStepsCounter
(
Context
context
,
int
counter
)
{
SharedPreferences
.
Editor
editor
=
getPreferences
(
context
).
edit
();
editor
.
putInt
(
PREFERENCES_STEPS_COUNTER
,
counter
);
editor
.
apply
();
}
public
static
int
getStepsCounter
(
Context
context
)
{
SharedPreferences
prefs
=
getPreferences
(
context
);
return
prefs
.
getInt
(
PREFERENCES_STEPS_COUNTER
,
0
);
}
public
static
JSONObject
getDeviceInfoObject
(
Context
context
)
{
SharedPreferences
prefs
=
getPreferences
(
context
);
try
{
...
...
warply_android_sdk/src/main/java/ly/warp/sdk/utils/WarplyManagerHelper.java
View file @
321db68
...
...
@@ -34,6 +34,8 @@ import androidx.appcompat.app.AlertDialog;
import
androidx.work.OneTimeWorkRequest
;
import
androidx.work.WorkManager
;
import
org.json.JSONArray
;
import
org.json.JSONException
;
import
org.json.JSONObject
;
import
java.io.Serializable
;
...
...
@@ -108,20 +110,31 @@ public class WarplyManagerHelper {
*/
public
static
String
constructCampaignUrl
(
Campaign
item
)
{
item
.
setNew
(
false
);
String
url
=
item
.
getIndexUrl
()
+
"?web_id="
+
WarpUtils
.
getWebId
(
Warply
.
getWarplyContext
())
+
"&app_uuid="
+
WarplyProperty
.
getAppUuid
(
Warply
.
getWarplyContext
())
+
"&api_key="
+
WarpUtils
.
getApiKey
(
Warply
.
getWarplyContext
())
+
"&session_uuid="
+
item
.
getSessionUUID
()
+
"&access_token="
+
WarplyDBHelper
.
getInstance
(
Warply
.
getWarplyContext
()).
getAuthValue
(
"access_token"
)
+
"&refresh_token="
+
WarplyDBHelper
.
getInstance
(
Warply
.
getWarplyContext
()).
getAuthValue
(
"refresh_token"
)
+
"&client_id="
+
WarplyDBHelper
.
getInstance
(
Warply
.
getWarplyContext
()).
getClientValue
(
"client_id"
)
+
"&client_secret="
+
WarplyDBHelper
.
getInstance
(
Warply
.
getWarplyContext
()).
getClientValue
(
"client_secret"
);
// if (mConsumer != null)
// url = url + "&auth_token=" + (mConsumer.getUuid());
// else
// url = url + "&auth_token=";
String
url
=
item
.
getIndexUrl
();
// + "?web_id=" + WarpUtils.getWebId(Warply.getWarplyContext())
// + "&app_uuid=" + WarplyProperty.getAppUuid(Warply.getWarplyContext())
// + "&api_key=" + WarpUtils.getApiKey(Warply.getWarplyContext())
// + "&session_uuid=" + item.getSessionUUID()
// + "&access_token=" + WarplyDBHelper.getInstance(Warply.getWarplyContext()).getAuthValue("access_token")
// + "&refresh_token=" + WarplyDBHelper.getInstance(Warply.getWarplyContext()).getAuthValue("refresh_token")
// + "&client_id=" + WarplyDBHelper.getInstance(Warply.getWarplyContext()).getClientValue("client_id")
// + "&client_secret=" + WarplyDBHelper.getInstance(Warply.getWarplyContext()).getClientValue("client_secret");
JSONObject
params
=
new
JSONObject
();
try
{
params
.
putOpt
(
"web_id"
,
WarpUtils
.
getWebId
(
Warply
.
getWarplyContext
()));
params
.
putOpt
(
"app_uuid"
,
WarplyProperty
.
getAppUuid
(
Warply
.
getWarplyContext
()));
params
.
putOpt
(
"api_key"
,
WarpUtils
.
getApiKey
(
Warply
.
getWarplyContext
()));
params
.
putOpt
(
"session_uuid"
,
item
.
getSessionUUID
());
params
.
putOpt
(
"access_token"
,
WarplyDBHelper
.
getInstance
(
Warply
.
getWarplyContext
()).
getAuthValue
(
"access_token"
));
params
.
putOpt
(
"refresh_token"
,
WarplyDBHelper
.
getInstance
(
Warply
.
getWarplyContext
()).
getAuthValue
(
"refresh_token"
));
params
.
putOpt
(
"client_id"
,
WarplyDBHelper
.
getInstance
(
Warply
.
getWarplyContext
()).
getClientValue
(
"client_id"
));
params
.
putOpt
(
"client_secret"
,
WarplyDBHelper
.
getInstance
(
Warply
.
getWarplyContext
()).
getClientValue
(
"client_secret"
));
}
catch
(
JSONException
e
)
{
e
.
printStackTrace
();
}
WarpUtils
.
setWebviewParams
(
Warply
.
getWarplyContext
(),
params
);
return
url
;
}
...
...
@@ -296,43 +309,75 @@ public class WarplyManagerHelper {
assets
=
assets
.
substring
(
0
,
assets
.
length
()
-
1
);
}
}
String
url
=
item
.
getIndexUrl
()
+
"?web_id="
+
WarpUtils
.
getWebId
(
Warply
.
getWarplyContext
())
+
"&app_uuid="
+
WarplyProperty
.
getAppUuid
(
Warply
.
getWarplyContext
())
+
"&api_key="
+
WarpUtils
.
getApiKey
(
Warply
.
getWarplyContext
())
+
"&session_uuid="
+
item
.
getSessionUUID
()
+
"&access_token="
+
WarplyDBHelper
.
getInstance
(
Warply
.
getWarplyContext
()).
getAuthValue
(
"access_token"
)
+
"&refresh_token="
+
WarplyDBHelper
.
getInstance
(
Warply
.
getWarplyContext
()).
getAuthValue
(
"refresh_token"
)
+
"&client_id="
+
WarplyDBHelper
.
getInstance
(
Warply
.
getWarplyContext
()).
getClientValue
(
"client_id"
)
+
"&client_secret="
+
WarplyDBHelper
.
getInstance
(
Warply
.
getWarplyContext
()).
getClientValue
(
"client_secret"
)
+
"&Session_ID="
+
ccmsItem
.
getSessionId
()
+
"&businessService="
+
ccmsItem
.
getBusinessService
()
+
"&offerName="
+
ccmsItem
.
getOfferName
()
+
"&productType="
+
ccmsItem
.
getProductType
()
+
"&provDuration="
+
ccmsItem
.
getProvDuration
()
+
"&noOfRecurrance="
+
ccmsItem
.
getNoOfRecurrance
()
+
"&price="
+
ccmsItem
.
getPrice
()
+
"&discount="
+
ccmsItem
.
getDiscount
()
+
"&voiceCategory="
+
ccmsItem
.
getVoiceCategory
()
+
"&dataCategory="
+
ccmsItem
.
getDataCategory
()
+
"&minsValue="
+
ccmsItem
.
getMinsValue
()
+
"&dataValue="
+
ccmsItem
.
getDataValue
()
+
"&provStepValueMins="
+
ccmsItem
.
getProvStepValueMins
()
+
"&UACIOfferTrackingCode="
+
ccmsItem
.
getUACIOfferTrackingCode
()
+
"&OFFERCODE1="
+
ccmsItem
.
getOfferCode1
()
+
"&SCORE="
+
ccmsItem
.
getScore
()
+
"&WAVE="
+
ccmsItem
.
getWave
()
+
"&VALIDITY="
+
ccmsItem
.
getValidity
()
+
"&TREATMENT_CODE="
+
ccmsItem
.
getTreatmentCode
()
+
"&OfferAudienceLevel="
+
ccmsItem
.
getOfferAudienceLevel
()
+
"&ASSETS="
+
assets
+
"&ZONE="
+
ccmsItem
.
getZone
();
// if (mConsumer != null)
// url = url + "&auth_token=" + (mConsumer.getUuid());
// else
// url = url + "&auth_token=";
String
url
=
item
.
getIndexUrl
();
// + "?web_id=" + WarpUtils.getWebId(Warply.getWarplyContext())
// + "&app_uuid=" + WarplyProperty.getAppUuid(Warply.getWarplyContext())
// + "&api_key=" + WarpUtils.getApiKey(Warply.getWarplyContext())
// + "&session_uuid=" + item.getSessionUUID()
// + "&access_token=" + WarplyDBHelper.getInstance(Warply.getWarplyContext()).getAuthValue("access_token")
// + "&refresh_token=" + WarplyDBHelper.getInstance(Warply.getWarplyContext()).getAuthValue("refresh_token")
// + "&client_id=" + WarplyDBHelper.getInstance(Warply.getWarplyContext()).getClientValue("client_id")
// + "&client_secret=" + WarplyDBHelper.getInstance(Warply.getWarplyContext()).getClientValue("client_secret")
// + "&Session_ID=" + ccmsItem.getSessionId()
// + "&businessService=" + ccmsItem.getBusinessService()
// + "&offerName=" + ccmsItem.getOfferName()
// + "&productType=" + ccmsItem.getProductType()
// + "&provDuration=" + ccmsItem.getProvDuration()
// + "&noOfRecurrance=" + ccmsItem.getNoOfRecurrance()
// + "&price=" + ccmsItem.getPrice()
// + "&discount=" + ccmsItem.getDiscount()
// + "&voiceCategory=" + ccmsItem.getVoiceCategory()
// + "&dataCategory=" + ccmsItem.getDataCategory()
// + "&minsValue=" + ccmsItem.getMinsValue()
// + "&dataValue=" + ccmsItem.getDataValue()
// + "&provStepValueMins=" + ccmsItem.getProvStepValueMins()
// + "&UACIOfferTrackingCode=" + ccmsItem.getUACIOfferTrackingCode()
// + "&OFFERCODE1=" + ccmsItem.getOfferCode1()
// + "&SCORE=" + ccmsItem.getScore()
// + "&WAVE=" + ccmsItem.getWave()
// + "&VALIDITY=" + ccmsItem.getValidity()
// + "&TREATMENT_CODE=" + ccmsItem.getTreatmentCode()
// + "&OfferAudienceLevel=" + ccmsItem.getOfferAudienceLevel()
// + "&ASSETS=" + assets
// + "&ZONE=" + ccmsItem.getZone();
JSONObject
params
=
new
JSONObject
();
try
{
params
.
putOpt
(
"web_id"
,
WarpUtils
.
getWebId
(
Warply
.
getWarplyContext
()));
params
.
putOpt
(
"app_uuid"
,
WarplyProperty
.
getAppUuid
(
Warply
.
getWarplyContext
()));
params
.
putOpt
(
"api_key"
,
WarpUtils
.
getApiKey
(
Warply
.
getWarplyContext
()));
params
.
putOpt
(
"session_uuid"
,
item
.
getSessionUUID
());
params
.
putOpt
(
"access_token"
,
WarplyDBHelper
.
getInstance
(
Warply
.
getWarplyContext
()).
getAuthValue
(
"access_token"
));
params
.
putOpt
(
"refresh_token"
,
WarplyDBHelper
.
getInstance
(
Warply
.
getWarplyContext
()).
getAuthValue
(
"refresh_token"
));
params
.
putOpt
(
"client_id"
,
WarplyDBHelper
.
getInstance
(
Warply
.
getWarplyContext
()).
getClientValue
(
"client_id"
));
params
.
putOpt
(
"client_secret"
,
WarplyDBHelper
.
getInstance
(
Warply
.
getWarplyContext
()).
getClientValue
(
"client_secret"
));
params
.
putOpt
(
"Session_ID"
,
ccmsItem
.
getSessionId
());
params
.
putOpt
(
"businessService"
,
ccmsItem
.
getBusinessService
());
params
.
putOpt
(
"offerName"
,
ccmsItem
.
getOfferName
());
params
.
putOpt
(
"productType"
,
ccmsItem
.
getProductType
());
params
.
putOpt
(
"provDuration"
,
ccmsItem
.
getProvDuration
());
params
.
putOpt
(
"noOfRecurrance"
,
ccmsItem
.
getNoOfRecurrance
());
params
.
putOpt
(
"price"
,
ccmsItem
.
getPrice
());
params
.
putOpt
(
"discount"
,
ccmsItem
.
getDiscount
());
params
.
putOpt
(
"voiceCategory"
,
ccmsItem
.
getVoiceCategory
());
params
.
putOpt
(
"dataCategory"
,
ccmsItem
.
getDataCategory
());
params
.
putOpt
(
"minsValue"
,
ccmsItem
.
getMinsValue
());
params
.
putOpt
(
"dataValue"
,
ccmsItem
.
getDataValue
());
params
.
putOpt
(
"provStepValueMins"
,
ccmsItem
.
getProvStepValueMins
());
params
.
putOpt
(
"UACIOfferTrackingCode"
,
ccmsItem
.
getUACIOfferTrackingCode
());
params
.
putOpt
(
"OFFERCODE1"
,
ccmsItem
.
getOfferCode1
());
params
.
putOpt
(
"SCORE"
,
ccmsItem
.
getScore
());
params
.
putOpt
(
"WAVE"
,
ccmsItem
.
getWave
());
params
.
putOpt
(
"VALIDITY"
,
ccmsItem
.
getValidity
());
params
.
putOpt
(
"TREATMENT_CODE"
,
ccmsItem
.
getTreatmentCode
());
params
.
putOpt
(
"OfferAudienceLevel"
,
ccmsItem
.
getOfferAudienceLevel
());
params
.
putOpt
(
"ASSETS"
,
assets
);
params
.
putOpt
(
"ZONE"
,
ccmsItem
.
getZone
());
}
catch
(
JSONException
e
)
{
e
.
printStackTrace
();
}
WarpUtils
.
setWebviewParams
(
Warply
.
getWarplyContext
(),
params
);
return
url
;
}
...
...
@@ -362,37 +407,75 @@ public class WarplyManagerHelper {
}
}
url
=
camp
.
getIndexUrl
()
+
"?web_id="
+
WarpUtils
.
getWebId
(
Warply
.
getWarplyContext
())
+
"&app_uuid="
+
WarplyProperty
.
getAppUuid
(
Warply
.
getWarplyContext
())
+
"&api_key="
+
WarpUtils
.
getApiKey
(
Warply
.
getWarplyContext
())
+
"&session_uuid="
+
camp
.
getSessionUUID
()
+
"&access_token="
+
WarplyDBHelper
.
getInstance
(
Warply
.
getWarplyContext
()).
getAuthValue
(
"access_token"
)
+
"&refresh_token="
+
WarplyDBHelper
.
getInstance
(
Warply
.
getWarplyContext
()).
getAuthValue
(
"refresh_token"
)
+
"&client_id="
+
WarplyDBHelper
.
getInstance
(
Warply
.
getWarplyContext
()).
getClientValue
(
"client_id"
)
+
"&client_secret="
+
WarplyDBHelper
.
getInstance
(
Warply
.
getWarplyContext
()).
getClientValue
(
"client_secret"
)
+
"&Session_ID="
+
item
.
getSessionId
()
+
"&businessService="
+
item
.
getBusinessService
()
+
"&offerName="
+
item
.
getOfferName
()
+
"&productType="
+
item
.
getProductType
()
+
"&provDuration="
+
item
.
getProvDuration
()
+
"&noOfRecurrance="
+
item
.
getNoOfRecurrance
()
+
"&price="
+
item
.
getPrice
()
+
"&discount="
+
item
.
getDiscount
()
+
"&voiceCategory="
+
item
.
getVoiceCategory
()
+
"&dataCategory="
+
item
.
getDataCategory
()
+
"&minsValue="
+
item
.
getMinsValue
()
+
"&dataValue="
+
item
.
getDataValue
()
+
"&provStepValueMins="
+
item
.
getProvStepValueMins
()
+
"&UACIOfferTrackingCode="
+
item
.
getUACIOfferTrackingCode
()
+
"&OFFERCODE1="
+
item
.
getOfferCode1
()
+
"&SCORE="
+
item
.
getScore
()
+
"&WAVE="
+
item
.
getWave
()
+
"&VALIDITY="
+
item
.
getValidity
()
+
"&TREATMENT_CODE="
+
item
.
getTreatmentCode
()
+
"&OfferAudienceLevel="
+
item
.
getOfferAudienceLevel
()
+
"&ASSETS="
+
assets
+
"&ZONE="
+
item
.
getZone
();
url
=
camp
.
getIndexUrl
();
// + "?web_id=" + WarpUtils.getWebId(Warply.getWarplyContext())
// + "&app_uuid=" + WarplyProperty.getAppUuid(Warply.getWarplyContext())
// + "&api_key=" + WarpUtils.getApiKey(Warply.getWarplyContext())
// + "&session_uuid=" + camp.getSessionUUID()
// + "&access_token=" + WarplyDBHelper.getInstance(Warply.getWarplyContext()).getAuthValue("access_token")
// + "&refresh_token=" + WarplyDBHelper.getInstance(Warply.getWarplyContext()).getAuthValue("refresh_token")
// + "&client_id=" + WarplyDBHelper.getInstance(Warply.getWarplyContext()).getClientValue("client_id")
// + "&client_secret=" + WarplyDBHelper.getInstance(Warply.getWarplyContext()).getClientValue("client_secret")
// + "&Session_ID=" + item.getSessionId()
// + "&businessService=" + item.getBusinessService()
// + "&offerName=" + item.getOfferName()
// + "&productType=" + item.getProductType()
// + "&provDuration=" + item.getProvDuration()
// + "&noOfRecurrance=" + item.getNoOfRecurrance()
// + "&price=" + item.getPrice()
// + "&discount=" + item.getDiscount()
// + "&voiceCategory=" + item.getVoiceCategory()
// + "&dataCategory=" + item.getDataCategory()
// + "&minsValue=" + item.getMinsValue()
// + "&dataValue=" + item.getDataValue()
// + "&provStepValueMins=" + item.getProvStepValueMins()
// + "&UACIOfferTrackingCode=" + item.getUACIOfferTrackingCode()
// + "&OFFERCODE1=" + item.getOfferCode1()
// + "&SCORE=" + item.getScore()
// + "&WAVE=" + item.getWave()
// + "&VALIDITY=" + item.getValidity()
// + "&TREATMENT_CODE=" + item.getTreatmentCode()
// + "&OfferAudienceLevel=" + item.getOfferAudienceLevel()
// + "&ASSETS=" + assets
// + "&ZONE=" + item.getZone();
JSONObject
params
=
new
JSONObject
();
try
{
params
.
putOpt
(
"web_id"
,
WarpUtils
.
getWebId
(
Warply
.
getWarplyContext
()));
params
.
putOpt
(
"app_uuid"
,
WarplyProperty
.
getAppUuid
(
Warply
.
getWarplyContext
()));
params
.
putOpt
(
"api_key"
,
WarpUtils
.
getApiKey
(
Warply
.
getWarplyContext
()));
params
.
putOpt
(
"session_uuid"
,
camp
.
getSessionUUID
());
params
.
putOpt
(
"access_token"
,
WarplyDBHelper
.
getInstance
(
Warply
.
getWarplyContext
()).
getAuthValue
(
"access_token"
));
params
.
putOpt
(
"refresh_token"
,
WarplyDBHelper
.
getInstance
(
Warply
.
getWarplyContext
()).
getAuthValue
(
"refresh_token"
));
params
.
putOpt
(
"client_id"
,
WarplyDBHelper
.
getInstance
(
Warply
.
getWarplyContext
()).
getClientValue
(
"client_id"
));
params
.
putOpt
(
"client_secret"
,
WarplyDBHelper
.
getInstance
(
Warply
.
getWarplyContext
()).
getClientValue
(
"client_secret"
));
params
.
putOpt
(
"Session_ID"
,
item
.
getSessionId
());
params
.
putOpt
(
"businessService"
,
item
.
getBusinessService
());
params
.
putOpt
(
"offerName"
,
item
.
getOfferName
());
params
.
putOpt
(
"productType"
,
item
.
getProductType
());
params
.
putOpt
(
"provDuration"
,
item
.
getProvDuration
());
params
.
putOpt
(
"noOfRecurrance"
,
item
.
getNoOfRecurrance
());
params
.
putOpt
(
"price"
,
item
.
getPrice
());
params
.
putOpt
(
"discount"
,
item
.
getDiscount
());
params
.
putOpt
(
"voiceCategory"
,
item
.
getVoiceCategory
());
params
.
putOpt
(
"dataCategory"
,
item
.
getDataCategory
());
params
.
putOpt
(
"minsValue"
,
item
.
getMinsValue
());
params
.
putOpt
(
"dataValue"
,
item
.
getDataValue
());
params
.
putOpt
(
"provStepValueMins"
,
item
.
getProvStepValueMins
());
params
.
putOpt
(
"UACIOfferTrackingCode"
,
item
.
getUACIOfferTrackingCode
());
params
.
putOpt
(
"OFFERCODE1"
,
item
.
getOfferCode1
());
params
.
putOpt
(
"SCORE"
,
item
.
getScore
());
params
.
putOpt
(
"WAVE"
,
item
.
getWave
());
params
.
putOpt
(
"VALIDITY"
,
item
.
getValidity
());
params
.
putOpt
(
"TREATMENT_CODE"
,
item
.
getTreatmentCode
());
params
.
putOpt
(
"OfferAudienceLevel"
,
item
.
getOfferAudienceLevel
());
params
.
putOpt
(
"ASSETS"
,
assets
);
params
.
putOpt
(
"ZONE"
,
item
.
getZone
());
}
catch
(
JSONException
e
)
{
e
.
printStackTrace
();
}
WarpUtils
.
setWebviewParams
(
Warply
.
getWarplyContext
(),
params
);
break
;
}
}
...
...
@@ -404,11 +487,6 @@ public class WarplyManagerHelper {
}
}
// if (mConsumer != null)
// url = url + "&auth_token=" + (mConsumer.getUuid());
// else
// url = url + "&auth_token=";
return
url
;
}
...
...
@@ -432,37 +510,75 @@ public class WarplyManagerHelper {
}
}
String
url
=
camp
.
getIndexUrl
()
+
"?web_id="
+
WarpUtils
.
getWebId
(
Warply
.
getWarplyContext
())
+
"&app_uuid="
+
WarplyProperty
.
getAppUuid
(
Warply
.
getWarplyContext
())
+
"&api_key="
+
WarpUtils
.
getApiKey
(
Warply
.
getWarplyContext
())
+
"&session_uuid="
+
camp
.
getSessionUUID
()
+
"&access_token="
+
WarplyDBHelper
.
getInstance
(
Warply
.
getWarplyContext
()).
getAuthValue
(
"access_token"
)
+
"&refresh_token="
+
WarplyDBHelper
.
getInstance
(
Warply
.
getWarplyContext
()).
getAuthValue
(
"refresh_token"
)
+
"&client_id="
+
WarplyDBHelper
.
getInstance
(
Warply
.
getWarplyContext
()).
getClientValue
(
"client_id"
)
+
"&client_secret="
+
WarplyDBHelper
.
getInstance
(
Warply
.
getWarplyContext
()).
getClientValue
(
"client_secret"
)
+
"&Session_ID="
+
item
.
getSessionId
()
+
"&businessService="
+
item
.
getBusinessService
()
+
"&offerName="
+
item
.
getOfferName
()
+
"&productType="
+
item
.
getProductType
()
+
"&provDuration="
+
item
.
getProvDuration
()
+
"&noOfRecurrance="
+
item
.
getNoOfRecurrance
()
+
"&price="
+
item
.
getPrice
()
+
"&discount="
+
item
.
getDiscount
()
+
"&voiceCategory="
+
item
.
getVoiceCategory
()
+
"&dataCategory="
+
item
.
getDataCategory
()
+
"&minsValue="
+
item
.
getMinsValue
()
+
"&dataValue="
+
item
.
getDataValue
()
+
"&provStepValueMins="
+
item
.
getProvStepValueMins
()
+
"&UACIOfferTrackingCode="
+
item
.
getUACIOfferTrackingCode
()
+
"&OFFERCODE1="
+
item
.
getOfferCode1
()
+
"&SCORE="
+
item
.
getScore
()
+
"&WAVE="
+
item
.
getWave
()
+
"&VALIDITY="
+
item
.
getValidity
()
+
"&TREATMENT_CODE="
+
item
.
getTreatmentCode
()
+
"&OfferAudienceLevel="
+
item
.
getOfferAudienceLevel
()
+
"&ASSETS="
+
assets
+
"&ZONE="
+
item
.
getZone
();
String
url
=
camp
.
getIndexUrl
();
// + "?web_id=" + WarpUtils.getWebId(Warply.getWarplyContext())
// + "&app_uuid=" + WarplyProperty.getAppUuid(Warply.getWarplyContext())
// + "&api_key=" + WarpUtils.getApiKey(Warply.getWarplyContext())
// + "&session_uuid=" + camp.getSessionUUID()
// + "&access_token=" + WarplyDBHelper.getInstance(Warply.getWarplyContext()).getAuthValue("access_token")
// + "&refresh_token=" + WarplyDBHelper.getInstance(Warply.getWarplyContext()).getAuthValue("refresh_token")
// + "&client_id=" + WarplyDBHelper.getInstance(Warply.getWarplyContext()).getClientValue("client_id")
// + "&client_secret=" + WarplyDBHelper.getInstance(Warply.getWarplyContext()).getClientValue("client_secret")
// + "&Session_ID=" + item.getSessionId()
// + "&businessService=" + item.getBusinessService()
// + "&offerName=" + item.getOfferName()
// + "&productType=" + item.getProductType()
// + "&provDuration=" + item.getProvDuration()
// + "&noOfRecurrance=" + item.getNoOfRecurrance()
// + "&price=" + item.getPrice()
// + "&discount=" + item.getDiscount()
// + "&voiceCategory=" + item.getVoiceCategory()
// + "&dataCategory=" + item.getDataCategory()
// + "&minsValue=" + item.getMinsValue()
// + "&dataValue=" + item.getDataValue()
// + "&provStepValueMins=" + item.getProvStepValueMins()
// + "&UACIOfferTrackingCode=" + item.getUACIOfferTrackingCode()
// + "&OFFERCODE1=" + item.getOfferCode1()
// + "&SCORE=" + item.getScore()
// + "&WAVE=" + item.getWave()
// + "&VALIDITY=" + item.getValidity()
// + "&TREATMENT_CODE=" + item.getTreatmentCode()
// + "&OfferAudienceLevel=" + item.getOfferAudienceLevel()
// + "&ASSETS=" + assets
// + "&ZONE=" + item.getZone();
JSONObject
params
=
new
JSONObject
();
try
{
params
.
putOpt
(
"web_id"
,
WarpUtils
.
getWebId
(
Warply
.
getWarplyContext
()));
params
.
putOpt
(
"app_uuid"
,
WarplyProperty
.
getAppUuid
(
Warply
.
getWarplyContext
()));
params
.
putOpt
(
"api_key"
,
WarpUtils
.
getApiKey
(
Warply
.
getWarplyContext
()));
params
.
putOpt
(
"session_uuid"
,
camp
.
getSessionUUID
());
params
.
putOpt
(
"access_token"
,
WarplyDBHelper
.
getInstance
(
Warply
.
getWarplyContext
()).
getAuthValue
(
"access_token"
));
params
.
putOpt
(
"refresh_token"
,
WarplyDBHelper
.
getInstance
(
Warply
.
getWarplyContext
()).
getAuthValue
(
"refresh_token"
));
params
.
putOpt
(
"client_id"
,
WarplyDBHelper
.
getInstance
(
Warply
.
getWarplyContext
()).
getClientValue
(
"client_id"
));
params
.
putOpt
(
"client_secret"
,
WarplyDBHelper
.
getInstance
(
Warply
.
getWarplyContext
()).
getClientValue
(
"client_secret"
));
params
.
putOpt
(
"Session_ID"
,
item
.
getSessionId
());
params
.
putOpt
(
"businessService"
,
item
.
getBusinessService
());
params
.
putOpt
(
"offerName"
,
item
.
getOfferName
());
params
.
putOpt
(
"productType"
,
item
.
getProductType
());
params
.
putOpt
(
"provDuration"
,
item
.
getProvDuration
());
params
.
putOpt
(
"noOfRecurrance"
,
item
.
getNoOfRecurrance
());
params
.
putOpt
(
"price"
,
item
.
getPrice
());
params
.
putOpt
(
"discount"
,
item
.
getDiscount
());
params
.
putOpt
(
"voiceCategory"
,
item
.
getVoiceCategory
());
params
.
putOpt
(
"dataCategory"
,
item
.
getDataCategory
());
params
.
putOpt
(
"minsValue"
,
item
.
getMinsValue
());
params
.
putOpt
(
"dataValue"
,
item
.
getDataValue
());
params
.
putOpt
(
"provStepValueMins"
,
item
.
getProvStepValueMins
());
params
.
putOpt
(
"UACIOfferTrackingCode"
,
item
.
getUACIOfferTrackingCode
());
params
.
putOpt
(
"OFFERCODE1"
,
item
.
getOfferCode1
());
params
.
putOpt
(
"SCORE"
,
item
.
getScore
());
params
.
putOpt
(
"WAVE"
,
item
.
getWave
());
params
.
putOpt
(
"VALIDITY"
,
item
.
getValidity
());
params
.
putOpt
(
"TREATMENT_CODE"
,
item
.
getTreatmentCode
());
params
.
putOpt
(
"OfferAudienceLevel"
,
item
.
getOfferAudienceLevel
());
params
.
putOpt
(
"ASSETS"
,
assets
);
params
.
putOpt
(
"ZONE"
,
item
.
getZone
());
}
catch
(
JSONException
e
)
{
e
.
printStackTrace
();
}
WarpUtils
.
setWebviewParams
(
Warply
.
getWarplyContext
(),
params
);
context
.
startActivity
(
WarpViewActivity
.
createIntentFromURL
(
context
,
url
));
break
;
...
...
warply_android_sdk/src/main/java/ly/warp/sdk/utils/managers/WarplyHealthManager.java
View file @
321db68
...
...
@@ -127,8 +127,8 @@ public class WarplyHealthManager implements SensorEventListener {
if
(
velocityEstimate
>
STEP_THRESHOLD
&&
oldVelocityEstimate
<=
STEP_THRESHOLD
&&
(
timeNs
-
lastStepTimeNs
>
STEP_DELAY_NS
))
{
//TODO: if we want to send the steps back to an activity/fragment/service etc
mSteps
++;
// if we want to send the steps back to an activity/fragment/service etc
mHealthCallback
.
onStepCount
(
mSteps
);
lastStepTimeNs
=
timeNs
;
}
...
...
warply_android_sdk/src/main/java/ly/warp/sdk/utils/managers/WarplyManager.java
View file @
321db68
...
...
@@ -30,6 +30,8 @@ import org.json.JSONException;
import
org.json.JSONObject
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.Comparator
;
import
ly.warp.sdk.Warply
;
import
ly.warp.sdk.db.WarplyDBHelper
;
...
...
@@ -78,6 +80,7 @@ import ly.warp.sdk.io.request.CosmotePostEventRequest;
import
ly.warp.sdk.io.request.CosmoteRetrieveSharingRequest
;
import
ly.warp.sdk.io.request.CosmoteSharingRequest
;
import
ly.warp.sdk.io.request.CosmoteSubmitOrderRequest
;
import
ly.warp.sdk.io.request.PacingCalculateRequest
;
import
ly.warp.sdk.io.request.PacingDetailsRequest
;
import
ly.warp.sdk.io.request.WarplyAddAddressRequest
;
import
ly.warp.sdk.io.request.WarplyAddCardRequest
;
...
...
@@ -1371,6 +1374,7 @@ public class WarplyManager {
@Override
public
void
onSuccess
(
CampaignList
result
)
{
mNewCampaignList
.
addAll
(
result
);
Collections
.
sort
(
mNewCampaignList
,
(
obj1
,
obj2
)
->
Integer
.
compare
(
obj1
.
getSorting
(),
obj2
.
getSorting
()));
CampaignList
campaignLoyaltyList
=
new
CampaignList
();
campaignLoyaltyList
.
clear
();
for
(
Campaign
camp
:
mNewCampaignList
)
{
...
...
@@ -2301,6 +2305,23 @@ public class WarplyManager {
@Override
public
void
onFailure
(
int
errorCode
)
{
if
(
errorCode
==
401
)
{
refreshToken
(
new
WarplyRefreshTokenRequest
(),
new
CallbackReceiver
<
JSONObject
>()
{
@Override
public
void
onSuccess
(
JSONObject
result
)
{
int
status
=
result
.
optInt
(
"status"
,
2
);
if
(
status
==
1
)
submitOrder
(
request
,
receiver
);
else
receiver
.
onFailure
(
status
);
}
@Override
public
void
onFailure
(
int
errorCode
)
{
receiver
.
onFailure
(
errorCode
);
}
});
}
else
receiver
.
onFailure
(
errorCode
);
}
});
...
...
@@ -2359,6 +2380,62 @@ public class WarplyManager {
@Override
public
void
onFailure
(
int
errorCode
)
{
if
(
errorCode
==
401
)
{
refreshToken
(
new
WarplyRefreshTokenRequest
(),
new
CallbackReceiver
<
JSONObject
>()
{
@Override
public
void
onSuccess
(
JSONObject
result
)
{
int
status
=
result
.
optInt
(
"status"
,
2
);
if
(
status
==
1
)
postEvent
(
request
,
receiver
);
else
receiver
.
onFailure
(
status
);
}
@Override
public
void
onFailure
(
int
errorCode
)
{
receiver
.
onFailure
(
errorCode
);
}
});
}
else
receiver
.
onFailure
(
errorCode
);
}
});
}
public
static
void
setPacingDetails
(
PacingCalculateRequest
request
,
final
CallbackReceiver
<
JSONObject
>
receiver
)
{
WarpUtils
.
log
(
"************* WARPLY Post Event Request ********************"
);
WarpUtils
.
log
(
"[WARP Trace] WARPLY Post Event Request is active"
);
WarpUtils
.
log
(
"**************************************************"
);
Warply
.
postReceiveMicroappData
(
true
,
"context"
,
request
.
toJson
(),
new
CallbackReceiver
<
JSONObject
>()
{
@Override
public
void
onSuccess
(
JSONObject
result
)
{
int
status
=
result
.
optInt
(
"status"
,
2
);
if
(
status
==
1
)
{
receiver
.
onSuccess
(
result
);
}
else
receiver
.
onFailure
(
status
);
}
@Override
public
void
onFailure
(
int
errorCode
)
{
if
(
errorCode
==
401
)
{
refreshToken
(
new
WarplyRefreshTokenRequest
(),
new
CallbackReceiver
<
JSONObject
>()
{
@Override
public
void
onSuccess
(
JSONObject
result
)
{
int
status
=
result
.
optInt
(
"status"
,
2
);
if
(
status
==
1
)
setPacingDetails
(
request
,
receiver
);
else
receiver
.
onFailure
(
status
);
}
@Override
public
void
onFailure
(
int
errorCode
)
{
receiver
.
onFailure
(
errorCode
);
}
});
}
else
receiver
.
onFailure
(
errorCode
);
}
});
...
...
warply_android_sdk/src/main/java/ly/warp/sdk/views/WarpView.java
View file @
321db68
...
...
@@ -35,13 +35,8 @@ import android.content.pm.ApplicationInfo;
import
android.net.Uri
;
import
android.net.http.SslError
;
import
android.os.Build
;
import
androidx.core.content.ContextCompat
;
import
androidx.work.WorkManager
;
import
android.text.TextUtils
;
import
android.util.AttributeSet
;
import
android.util.Log
;
import
android.webkit.GeolocationPermissions.Callback
;
import
android.webkit.JavascriptInterface
;
import
android.webkit.SslErrorHandler
;
...
...
@@ -51,6 +46,10 @@ import android.webkit.WebView;
import
android.webkit.WebViewClient
;
import
android.widget.Toast
;
import
androidx.core.content.ContextCompat
;
import
androidx.work.PeriodicWorkRequest
;
import
androidx.work.WorkManager
;
import
org.greenrobot.eventbus.EventBus
;
import
org.json.JSONArray
;
import
org.json.JSONException
;
...
...
@@ -61,14 +60,13 @@ import java.net.URLDecoder;
import
java.util.HashMap
;
import
java.util.LinkedHashMap
;
import
java.util.Map
;
import
java.util.concurrent.TimeUnit
;
import
ly.warp.sdk.Warply
;
import
ly.warp.sdk.io.models.CouponEventModel
;
import
ly.warp.sdk.io.models.QuestionnaireEventModel
;
import
ly.warp.sdk.io.models.WarplyPacingCardEventModel
;
import
ly.warp.sdk.io.models.WarplyPacingCardServiceEnabledModel
;
import
ly.warp.sdk.io.models.WarplyPacingEventModel
;
import
ly.warp.sdk.services.
UpdateUserLocation
Service
;
import
ly.warp.sdk.services.
WarplyHealth
Service
;
import
ly.warp.sdk.utils.WarpUtils
;
import
ly.warp.sdk.utils.WarplyProperty
;
import
ly.warp.sdk.utils.WarplyUrlHandler
;
...
...
@@ -84,6 +82,7 @@ public class WarpView extends WebView {
private
static
final
String
URL_ACTION_MAIL
=
"mailto"
;
private
static
final
String
URL_ACTION_MARKET
=
"market"
;
private
static
final
String
URL_ACTION_MARKET_AUTHORITY
=
"play.google.com"
;
private
static
final
String
TAG_STEPS_WORKER
=
"ly.warp.sdk.services.WarplyHealthService"
;
// ===========================================================
// Fields
...
...
@@ -371,11 +370,6 @@ public class WarpView extends WebView {
public
class
JSInterface
{
@JavascriptInterface
public
void
sendMessage
(
String
message
)
{
// Intent intent = new Intent(android.content.Intent.ACTION_SEND);
// intent.setType("text/plain");
// intent.putExtra(android.content.Intent.EXTRA_TEXT, message);
// getContext().startActivity(Intent.createChooser(intent, "Άνοιγμα με"));
if
(
message
.
contains
(
"event"
))
{
String
[]
parts
=
message
.
split
(
":"
);
if
(
parts
[
1
].
equals
(
"closeArtwork"
))
{
...
...
@@ -423,10 +417,20 @@ public class WarpView extends WebView {
pacingService.setEnabled(true);
EventBus.getDefault().post(new WarplyEventBusManager(pacingService));
}*/
else
if
(
parts
[
1
].
equals
(
"steps"
)
&&
parts
[
2
].
equals
(
"shortcutEnabled"
))
{
// PeriodicWorkRequest stepsWorker = new PeriodicWorkRequest.Builder(WarplyHealthService.class, 15, TimeUnit.MINUTES)
// .build();
// WorkManager.getInstance(Warply.getWarplyContext()).enqueue(stepsWorker);
Intent
stepsServiceIntent
=
new
Intent
(
Warply
.
getWarplyContext
(),
WarplyHealthService
.
class
);
Warply
.
getWarplyContext
().
startService
(
stepsServiceIntent
);
WarplyPacingEventModel
pacingVisible
=
new
WarplyPacingEventModel
();
pacingVisible
.
setVisible
(
true
);
EventBus
.
getDefault
().
post
(
new
WarplyEventBusManager
(
pacingVisible
));
}
else
if
(
parts
[
1
].
equals
(
"steps"
)
&&
parts
[
2
].
equals
(
"shortcutDisabled"
))
{
// WorkManager.getInstance(Warply.getWarplyContext()).cancelAllWork();
Intent
stepsServiceIntent
=
new
Intent
(
Warply
.
getWarplyContext
(),
WarplyHealthService
.
class
);
Warply
.
getWarplyContext
().
stopService
(
stepsServiceIntent
);
WarplyPacingEventModel
pacingVisible
=
new
WarplyPacingEventModel
();
pacingVisible
.
setVisible
(
false
);
EventBus
.
getDefault
().
post
(
new
WarplyEventBusManager
(
pacingVisible
));
...
...
@@ -500,7 +504,10 @@ public class WarpView extends WebView {
@Override
public
void
onPageFinished
(
WebView
view
,
String
url
)
{
String
scriptSource
=
"passParams("
+
WarpUtils
.
getWebviewParams
(
getContext
())
+
");"
;
view
.
evaluateJavascript
(
scriptSource
,
s
->
{
});
if
(
url
.
contains
(
"about:blank"
))
{
WarpView
.
this
.
clearHistory
();
}
...
...
warply_android_sdk/src/main/res/layout/activity_loyalty_wallet.xml
View file @
321db68
...
...
@@ -386,6 +386,7 @@
</androidx.constraintlayout.widget.ConstraintLayout>
<TextView
android:id=
"@+id/tv_active_coupons_header"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"start"
...
...
Please
register
or
login
to post a comment