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-07-22 15:45:42 +0300
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
00d8b333c90af66185be8eafa65632906e7d09c6
00d8b333
1 parent
e686a431
new questionnaire flow
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
113 additions
and
10 deletions
warply_android_sdk/build.gradle
warply_android_sdk/src/main/AndroidManifest.xml
warply_android_sdk/src/main/java/ly/warp/sdk/activities/WarpViewActivity.java
warply_android_sdk/src/main/java/ly/warp/sdk/services/EventQuestionnaireService.java
warply_android_sdk/src/main/java/ly/warp/sdk/utils/managers/WarplyManager.java
warply_android_sdk/build.gradle
View file @
00d8b33
...
...
@@ -2,7 +2,7 @@ apply plugin: 'com.android.library'
ext
{
PUBLISH_GROUP_ID
=
'ly.warp'
PUBLISH_VERSION
=
'4.5.4-cosbeta4
1
'
PUBLISH_VERSION
=
'4.5.4-cosbeta4
2
'
PUBLISH_ARTIFACT_ID
=
'warply-android-sdk'
}
...
...
warply_android_sdk/src/main/AndroidManifest.xml
View file @
00d8b33
...
...
@@ -152,6 +152,11 @@
android:permission=
"android.permission.BIND_JOB_SERVICE"
/>
<service
android:name=
"ly.warp.sdk.services.EventQuestionnaireService"
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/WarpViewActivity.java
View file @
00d8b33
...
...
@@ -33,8 +33,6 @@ import android.content.Intent;
import
android.graphics.Color
;
import
android.os.Build
;
import
android.os.Bundle
;
import
android.os.Handler
;
import
android.os.Looper
;
import
android.text.TextUtils
;
import
android.view.KeyEvent
;
import
android.view.View
;
...
...
@@ -56,11 +54,11 @@ import java.security.SecureRandom;
import
java.util.concurrent.ThreadLocalRandom
;
import
java.util.concurrent.TimeUnit
;
import
ly.warp.sdk.R
;
import
ly.warp.sdk.Warply
;
import
ly.warp.sdk.io.callbacks.CallbackReceiver
;
import
ly.warp.sdk.io.models.CouponList
;
import
ly.warp.sdk.io.request.WarplyUserCouponsRequest
;
import
ly.warp.sdk.services.EventQuestionnaireService
;
import
ly.warp.sdk.services.PushEventsClickedWorkerService
;
import
ly.warp.sdk.utils.WarpJSONParser
;
import
ly.warp.sdk.utils.WarpUtils
;
...
...
@@ -130,6 +128,8 @@ public class WarpViewActivity extends WarpBaseActivity {
public
void
onMessageEvent
(
WarplyEventBusManager
event
)
{
// EventBus.getDefault().unregister(this);
if
(
event
.
getQuestionnaire
()
!=
null
)
{
OneTimeWorkRequest
mywork
=
new
OneTimeWorkRequest
.
Builder
(
EventQuestionnaireService
.
class
).
build
();
WorkManager
.
getInstance
(
WarpViewActivity
.
this
).
enqueue
(
mywork
);
setResult
(
RESULT_OK
,
new
Intent
());
finish
();
}
...
...
warply_android_sdk/src/main/java/ly/warp/sdk/services/EventQuestionnaireService.java
0 → 100644
View file @
00d8b33
package
ly
.
warp
.
sdk
.
services
;
import
android.content.Context
;
import
androidx.annotation.NonNull
;
import
androidx.work.Worker
;
import
androidx.work.WorkerParameters
;
import
ly.warp.sdk.io.callbacks.CallbackReceiver
;
import
ly.warp.sdk.io.models.CampaignList
;
import
ly.warp.sdk.io.models.Consumer
;
import
ly.warp.sdk.io.request.WarplyConsumerRequest
;
import
ly.warp.sdk.io.request.WarplyGetCampaignsRequest
;
import
ly.warp.sdk.utils.WarpUtils
;
import
ly.warp.sdk.utils.WarplyManagerHelper
;
import
ly.warp.sdk.utils.managers.WarplyManager
;
/**
* Created by Panagiotis Triantafyllou on 22/Ιουλ/2022.
*/
public
class
EventQuestionnaireService
extends
Worker
{
public
EventQuestionnaireService
(
@NonNull
Context
context
,
@NonNull
WorkerParameters
workerParams
)
{
super
(
context
,
workerParams
);
}
@NonNull
@Override
public
Result
doWork
()
{
WarplyManager
.
getConsumer
(
new
WarplyConsumerRequest
(),
new
CallbackReceiver
<
Consumer
>()
{
@Override
public
void
onSuccess
(
Consumer
result
)
{
WarplyManagerHelper
.
setConsumer
(
result
);
WarplyManager
.
getCampaigns
(
new
WarplyGetCampaignsRequest
().
setLanguage
(
"en"
),
new
CallbackReceiver
<
CampaignList
>()
{
@Override
public
void
onSuccess
(
CampaignList
result
)
{
WarpUtils
.
log
(
"SUCCESS_QUESTIONNAIRE_EVENT"
);
}
@Override
public
void
onFailure
(
int
errorCode
)
{
WarpUtils
.
log
(
"ERROR_QUESTIONNAIRE_EVENT "
+
String
.
valueOf
(
errorCode
));
}
});
}
@Override
public
void
onFailure
(
int
errorCode
)
{
WarpUtils
.
log
(
"ERROR_QUESTIONNAIRE_CONSUMER_EVENT "
+
String
.
valueOf
(
errorCode
));
}
});
return
Result
.
success
();
}
}
warply_android_sdk/src/main/java/ly/warp/sdk/utils/managers/WarplyManager.java
View file @
00d8b33
...
...
@@ -1374,15 +1374,57 @@ public class WarplyManager {
CampaignList
campaignLoyaltyList
=
new
CampaignList
();
campaignLoyaltyList
.
clear
();
for
(
Campaign
camp
:
mNewCampaignList
)
{
try
{
JSONObject
extraFields
=
WarpJSONParser
.
getJSONFromString
(
camp
.
getExtraFields
());
if
(
extraFields
!=
null
)
{
if
(
extraFields
.
length
()
==
0
||
!(
extraFields
.
has
(
"ccms_offer"
)
||
extraFields
.
has
(
"type"
)))
{
if
(
camp
.
getOfferCategory
().
equals
(
"questionnaire"
))
{
if
(
WarplyManagerHelper
.
getConsumer
()
!=
null
)
{
JSONObject
profMetadata
=
WarpJSONParser
.
getJSONFromString
(
WarplyManagerHelper
.
getConsumer
().
getProfileMetadata
());
if
(
profMetadata
!=
null
)
{
if
(!
profMetadata
.
has
(
"answered"
))
{
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
);
}
}
}
else
{
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
);
}
}
}
else
{
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
);
}
}
}
catch
(
Exception
exception
)
{
campaignLoyaltyList
.
add
(
camp
);
}
else
{
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
);
}
}
}
WarplyManagerHelper
.
setCampaignList
(
mNewCampaignList
);
...
...
Please
register
or
login
to post a comment