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-06-20 20:19:09 +0300
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
abf6eabf5596f02e584887766f0890af6da4895f
abf6eabf
1 parent
c51e0a8f
additions
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
126 additions
and
71 deletions
warply_android_sdk/src/main/java/ly/warp/sdk/activities/LoyaltyWallet.java
warply_android_sdk/src/main/java/ly/warp/sdk/activities/WarpViewActivity.java
warply_android_sdk/src/main/java/ly/warp/sdk/io/models/QuestionnaireEventModel.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/WarplyEventBusManager.java
warply_android_sdk/src/main/java/ly/warp/sdk/views/WarpView.java
warply_android_sdk/src/main/java/ly/warp/sdk/activities/LoyaltyWallet.java
View file @
abf6eab
...
...
@@ -3,6 +3,7 @@ package ly.warp.sdk.activities;
import
android.app.Activity
;
import
android.content.Intent
;
import
android.os.Bundle
;
import
android.text.TextUtils
;
import
android.view.View
;
import
android.widget.ImageView
;
import
android.widget.LinearLayout
;
...
...
@@ -11,8 +12,6 @@ import android.widget.TextView;
import
androidx.constraintlayout.widget.ConstraintLayout
;
import
ly.warp.sdk.R
;
import
ly.warp.sdk.io.models.Campaign
;
import
ly.warp.sdk.io.models.CampaignList
;
import
ly.warp.sdk.io.models.Coupon
;
import
ly.warp.sdk.io.models.CouponList
;
import
ly.warp.sdk.utils.WarplyManagerHelper
;
...
...
@@ -49,13 +48,6 @@ public class LoyaltyWallet extends Activity implements View.OnClickListener {
mTvUsername
=
findViewById
(
R
.
id
.
tv_name
);
mLlQuestionnaire
=
findViewById
(
R
.
id
.
ll_user_questionnaire
);
mLlUserBadge
=
findViewById
(
R
.
id
.
ll_user_badge
);
/**** Old functionality ****/
// mClActiveCoupons = findViewById(R.id.cl_loyalty_coupon);
// mTvActiveCoupons = findViewById(R.id.tv_active_coupons);
// mClActiveRewards = findViewById(R.id.cl_loyalty_rewards);
// mLlAnalysisButton = findViewById(R.id.ll_analysis);
// mLlPastCoupons = findViewById(R.id.ll_old_coupons);
/**** Old functionality ****/
mTvActiveRewards
=
findViewById
(
R
.
id
.
tv_active_deals_text
);
mTvUserBadge
=
findViewById
(
R
.
id
.
tv_type
);
mClActiveGifts
=
findViewById
(
R
.
id
.
cl_mygifts
);
...
...
@@ -74,50 +66,10 @@ public class LoyaltyWallet extends Activity implements View.OnClickListener {
onBackPressed
();
return
;
}
/**** Old functionality ****/
// if (view.getId() == R.id.ll_analysis) {
// Intent intent = new Intent(this, LoyaltyActivity.class);
// startActivity(intent);
// return;
// }
/**** Old functionality ****/
if
(
view
.
getId
()
==
R
.
id
.
ll_user_questionnaire
)
{
CampaignList
cl
=
WarplyManagerHelper
.
getUniqueCampaignList
().
get
(
"more_for_you"
);
Campaign
camp
=
null
;
if
(
cl
!=
null
)
{
for
(
Campaign
cn
:
cl
)
{
if
(
cn
.
getSessionUUID
().
equals
(
"4fc2865e32bd4d5495a3dfdf1472da7f"
))
{
camp
=
cn
;
break
;
}
}
}
if
(
camp
==
null
)
return
;
startActivity
(
WarpViewActivity
.
createIntentFromURL
(
LoyaltyWallet
.
this
,
WarplyManagerHelper
.
constructCampaignUrl
(
camp
)));
if
(
view
.
getId
()
==
R
.
id
.
ll_user_questionnaire
||
view
.
getId
()
==
R
.
id
.
ll_user_badge
)
{
startActivity
(
WarpViewActivity
.
createIntentFromURL
(
LoyaltyWallet
.
this
,
WarplyManagerHelper
.
openQuestionnaire
()));
return
;
}
/**** Old functionality ****/
// if (view.getId() == R.id.cl_loyalty_coupon) {
// Intent intent = new Intent(LoyaltyWallet.this, ActiveCouponsActivity.class);
// intent.putExtra("couponlist", WarplyManagerHelper.getCouponList());
// startActivity(intent);
// return;
// }
// if (view.getId() == R.id.cl_loyalty_rewards) {
// Intent intent = new Intent(LoyaltyWallet.this, ActiveRewardsActivity.class);
// intent.putExtra("couponlist", WarplyManagerHelper.getCouponList());
// startActivity(intent);
// return;
// }
// if (view.getId() == R.id.ll_old_coupons) {
// Intent intent = new Intent(LoyaltyWallet.this, PastCouponsActivity.class);
// intent.putExtra("couponlist", WarplyManagerHelper.getCouponList());
// startActivity(intent);
// }
/**** Old functionality ****/
if
(
view
.
getId
()
==
R
.
id
.
cl_mygifts
)
{
Intent
intent
=
new
Intent
(
LoyaltyWallet
.
this
,
ActiveGiftsActivity
.
class
);
startActivity
(
intent
);
...
...
@@ -139,14 +91,12 @@ public class LoyaltyWallet extends Activity implements View.OnClickListener {
mTvUsername
.
setText
(
String
.
format
(
getResources
().
getString
(
R
.
string
.
cos_profile_loyalty_name
),
WarplyManagerHelper
.
getConsumer
().
getFirstName
(),
WarplyManagerHelper
.
getConsumer
().
getLastName
()));
if
(
WarplyManagerHelper
.
getConsumer
().
getProfileMetadata
()
!=
null
)
{
boolean
answered
=
WarplyManagerHelper
.
getConsumer
().
getProfileMetadata
().
optBoolean
(
"answered"
,
false
);
if
(
answered
)
{
//TODO: put badge also
if
(!
TextUtils
.
isEmpty
(
WarplyManagerHelper
.
getUserTag
()))
{
mTvUserBadge
.
setText
(
WarplyManagerHelper
.
getUserTag
());
mLlQuestionnaire
.
setVisibility
(
View
.
GONE
);
mLlUserBadge
.
setVisibility
(
View
.
VISIBLE
);
}
else
mLlQuestionnaire
.
setVisibility
(
View
.
VISIBLE
);
}
else
{
mLlUserBadge
.
setVisibility
(
View
.
GONE
);
mLlQuestionnaire
.
setVisibility
(
View
.
VISIBLE
);
}
}
...
...
@@ -154,16 +104,10 @@ public class LoyaltyWallet extends Activity implements View.OnClickListener {
mIvBack
.
setOnClickListener
(
this
);
// mTvAnalysisButton.setOnClickListener(this);
mLlQuestionnaire
.
setOnClickListener
(
this
);
/**** Old functionality ****/
// mTvActiveCoupons.setText(String.format(getResources().getString(R.string.cos_active_coupons), String.valueOf(cpnlist.size())));
// mClActiveCoupons.setOnClickListener(this);
// mClActiveRewards.setOnClickListener(this);
// mLlAnalysisButton.setOnClickListener(this);
// mLlPastCoupons.setOnClickListener(this);
/**** Old functionality ****/
//TODO: change the parameter, for testing purposes only
mTvActiveRewards
.
setText
(
String
.
format
(
getResources
().
getString
(
R
.
string
.
cos_active_rewards
),
String
.
valueOf
(
cpnlist
.
size
())));
mClActiveGifts
.
setOnClickListener
(
this
);
mLlUserBadge
.
setOnClickListener
(
this
);
}
// ===========================================================
...
...
warply_android_sdk/src/main/java/ly/warp/sdk/activities/WarpViewActivity.java
View file @
abf6eab
...
...
@@ -30,8 +30,11 @@ import android.content.Intent;
import
android.graphics.Color
;
import
android.os.Build
;
import
android.os.Bundle
;
import
androidx.annotation.NonNull
;
import
android.text.TextUtils
;
import
android.util.Log
;
import
android.view.KeyEvent
;
import
android.view.View
;
import
android.webkit.WebView
;
...
...
@@ -47,6 +50,7 @@ import androidx.work.Constraints;
import
androidx.work.NetworkType
;
import
androidx.work.OneTimeWorkRequest
;
import
androidx.work.WorkManager
;
import
ly.warp.sdk.Warply
;
import
ly.warp.sdk.services.PushEventsClickedWorkerService
;
import
ly.warp.sdk.utils.WarpJSONParser
;
...
...
@@ -54,12 +58,16 @@ import ly.warp.sdk.utils.WarpUtils;
import
ly.warp.sdk.utils.WarplyPreferences
;
import
ly.warp.sdk.utils.WarplyProperty
;
import
ly.warp.sdk.utils.managers.WarplyAnalyticsManager
;
import
ly.warp.sdk.utils.managers.WarplyEventBusManager
;
import
ly.warp.sdk.utils.managers.WarplySessionManager
;
import
ly.warp.sdk.views.WarpView
;
import
static
ly
.
warp
.
sdk
.
utils
.
constants
.
WarpConstants
.
RANDOM_MAX
;
import
static
ly
.
warp
.
sdk
.
utils
.
constants
.
WarpConstants
.
RANDOM_MIN
;
import
org.greenrobot.eventbus.EventBus
;
import
org.greenrobot.eventbus.Subscribe
;
public
class
WarpViewActivity
extends
WarpBaseActivity
{
// ===========================================================
...
...
@@ -92,12 +100,14 @@ public class WarpViewActivity extends WarpBaseActivity {
protected
void
onStart
()
{
super
.
onStart
();
WarplySessionManager
.
onStartActivity
(
this
);
EventBus
.
getDefault
().
register
(
this
);
}
@Override
protected
void
onStop
()
{
super
.
onStop
();
WarplySessionManager
.
onStopActivity
(
this
);
EventBus
.
getDefault
().
unregister
(
this
);
}
@Override
...
...
@@ -112,6 +122,14 @@ public class WarpViewActivity extends WarpBaseActivity {
return
super
.
onKeyDown
(
keyCode
,
event
);
}
@Subscribe
()
public
void
onMessageEvent
(
WarplyEventBusManager
event
)
{
EventBus
.
getDefault
().
unregister
(
this
);
if
(
event
.
getQuestionnaire
()
!=
null
)
EventBus
.
getDefault
().
post
(
new
WarplyEventBusManager
(
event
.
getQuestionnaire
()));
finish
();
}
// ===========================================================
// Methods
// ===========================================================
...
...
warply_android_sdk/src/main/java/ly/warp/sdk/io/models/QuestionnaireEventModel.java
0 → 100644
View file @
abf6eab
/*
* 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
;
/**
* 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/WarpUtils.java
View file @
abf6eab
...
...
@@ -131,11 +131,23 @@ public class WarpUtils {
+
"gifts_popup"
;
private
static
final
String
PREFERENCES_KEY_MORE_POPUP
=
PREFERENCES_PREFIX
+
"more_popup"
;
private
static
final
String
PREFERENCES_KEY_USER_TAG
=
PREFERENCES_PREFIX
+
"user_badge"
;
private
static
SharedPreferences
_prefs
;
/* Public methods */
public
static
String
getUserTag
(
Context
context
)
{
return
getPreferences
(
context
).
getString
(
PREFERENCES_KEY_USER_TAG
,
""
);
}
public
static
void
setUserTag
(
Context
context
,
String
userTag
)
{
SharedPreferences
.
Editor
editor
=
getPreferences
(
context
).
edit
();
editor
.
putString
(
PREFERENCES_KEY_USER_TAG
,
userTag
);
editor
.
apply
();
}
/**
* Method used to return the token of this device for the GCM service
*
...
...
warply_android_sdk/src/main/java/ly/warp/sdk/utils/WarplyManagerHelper.java
View file @
abf6eab
...
...
@@ -93,7 +93,6 @@ public class WarplyManagerHelper {
* Open Warply campaign with sharing id
*/
public
static
String
constructCampaignUrlForShare
(
Campaign
item
,
String
deeplink
)
{
item
.
setNew
(
false
);
String
url
=
item
.
getIndexUrl
()
+
"?web_id="
+
WarpUtils
.
getWebId
(
Warply
.
getWarplyContext
())
+
"&app_uuid="
+
WarplyProperty
.
getAppUuid
(
Warply
.
getWarplyContext
())
...
...
@@ -132,10 +131,12 @@ public class WarplyManagerHelper {
/**
* Open Questionnaire
*/
public
static
void
openQuestionnaire
()
{
public
static
String
openQuestionnaire
()
{
if
(
mUniqueCampaignList
!=
null
&&
mUniqueCampaignList
.
get
(
"questionnaire"
)
!=
null
&&
mUniqueCampaignList
.
get
(
"questionnaire"
).
size
()
>
0
)
{
constructCampaignUrl
(
mUniqueCampaignList
.
get
(
"questionnaire"
).
get
(
0
));
return
constructCampaignUrl
(
mUniqueCampaignList
.
get
(
"questionnaire"
).
get
(
0
));
}
return
""
;
}
/**
...
...
@@ -158,7 +159,7 @@ public class WarplyManagerHelper {
* Get user badge tag
*/
public
static
String
getUserTag
()
{
return
"traveller"
;
//TODO: change in production with actual code
return
WarpUtils
.
getUserTag
(
Warply
.
getWarplyContext
());
}
public
static
void
setDFYCouponPurchase
(
String
couponcode
,
String
merchantid
)
{
...
...
@@ -183,7 +184,7 @@ public class WarplyManagerHelper {
* Set the List with CCMS Campaigns
*/
public
static
void
setCCMSLoyaltyCampaigns
(
ArrayList
<
LoyaltyContextualOfferModel
>
list
)
{
//TODO: create
}
public
static
Consumer
getConsumer
()
{
...
...
warply_android_sdk/src/main/java/ly/warp/sdk/utils/managers/WarplyEventBusManager.java
View file @
abf6eab
...
...
@@ -5,6 +5,7 @@ import java.util.HashMap;
import
ly.warp.sdk.io.models.LoyaltyContextualOfferModel
;
import
ly.warp.sdk.io.models.LoyaltyGiftsForYouOfferClickEvent
;
import
ly.warp.sdk.io.models.LoyaltySDKFirebaseEventModel
;
import
ly.warp.sdk.io.models.QuestionnaireEventModel
;
import
ly.warp.sdk.io.models.WarplyCCMSEnabledModel
;
import
ly.warp.sdk.io.models.WarplyDealsAnalysisEventModel
;
import
ly.warp.sdk.io.models.WarplyPacingCardEventModel
;
...
...
@@ -23,6 +24,7 @@ public class WarplyEventBusManager {
private
WarplyDealsAnalysisEventModel
dealsAnalysis
;
private
WarplyCCMSEnabledModel
ccmsActivated
;
private
LoyaltyGiftsForYouOfferClickEvent
giftsYou
;
private
QuestionnaireEventModel
questionnaire
;
public
WarplyEventBusManager
()
{
...
...
@@ -32,6 +34,10 @@ public class WarplyEventBusManager {
this
.
eventName
=
eventName
;
}
public
WarplyEventBusManager
(
QuestionnaireEventModel
questionnaire
)
{
this
.
questionnaire
=
questionnaire
;
}
public
WarplyEventBusManager
(
LoyaltySDKFirebaseEventModel
fireEvent
)
{
this
.
fireEvent
=
fireEvent
;
}
...
...
@@ -117,4 +123,8 @@ public class WarplyEventBusManager {
public
LoyaltyGiftsForYouOfferClickEvent
getGiftsYou
()
{
return
giftsYou
;
}
public
QuestionnaireEventModel
getQuestionnaire
()
{
return
questionnaire
;
}
}
...
...
warply_android_sdk/src/main/java/ly/warp/sdk/views/WarpView.java
View file @
abf6eab
...
...
@@ -62,6 +62,7 @@ import java.util.LinkedHashMap;
import
java.util.Map
;
import
ly.warp.sdk.Warply
;
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
;
...
...
@@ -369,8 +370,20 @@ public class WarpView extends WebView {
// intent.putExtra(android.content.Intent.EXTRA_TEXT, message);
// getContext().startActivity(Intent.createChooser(intent, "Άνοιγμα με"));
if
(
message
.
contains
(
"event"
))
EventBus
.
getDefault
().
post
(
new
WarplyEventBusManager
(
message
));
if
(
message
.
contains
(
"event"
))
{
String
[]
parts
=
message
.
split
(
":"
);
if
(
parts
[
1
].
equals
(
"closeArtwork"
))
{
QuestionnaireEventModel
questionnaireEvent
=
new
QuestionnaireEventModel
();
questionnaireEvent
.
setName
(
parts
[
1
]);
EventBus
.
getDefault
().
post
(
new
WarplyEventBusManager
(
questionnaireEvent
));
}
else
if
(
parts
[
1
].
equals
(
"addUserTag"
))
{
QuestionnaireEventModel
questionnaireEvent
=
new
QuestionnaireEventModel
();
questionnaireEvent
.
setName
(
parts
[
1
]);
questionnaireEvent
.
setParameter
(
parts
[
2
]);
WarpUtils
.
setUserTag
(
Warply
.
getWarplyContext
(),
parts
[
2
]);
EventBus
.
getDefault
().
post
(
new
WarplyEventBusManager
(
questionnaireEvent
));
}
}
}
}
...
...
Please
register
or
login
to post a comment