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-11 15:31:42 +0300
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
84b4a7221ca4479bc870fec4da0912b3017828dd
84b4a722
1 parent
de0fbcde
new internal version
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
100 additions
and
32 deletions
warply_android_sdk/build.gradle
warply_android_sdk/src/main/java/ly/warp/sdk/activities/CouponsetInfoActivity.java
warply_android_sdk/src/main/java/ly/warp/sdk/activities/GiftsForYouActivity.java
warply_android_sdk/src/main/java/ly/warp/sdk/io/models/Campaign.java
warply_android_sdk/src/main/res/values/strings.xml
warply_android_sdk/build.gradle
View file @
84b4a72
...
...
@@ -2,7 +2,7 @@ apply plugin: 'com.android.library'
ext
{
PUBLISH_GROUP_ID
=
'ly.warp'
PUBLISH_VERSION
=
'4.5.4-cosbeta28'
PUBLISH_VERSION
=
'4.5.4-cosbeta28
i
'
PUBLISH_ARTIFACT_ID
=
'warply-android-sdk'
}
...
...
warply_android_sdk/src/main/java/ly/warp/sdk/activities/CouponsetInfoActivity.java
View file @
84b4a72
package
ly
.
warp
.
sdk
.
activities
;
import
android.app.Activity
;
import
android.app.Dialog
;
import
android.os.Bundle
;
import
android.text.Html
;
import
android.text.TextUtils
;
...
...
@@ -11,6 +10,8 @@ import android.widget.LinearLayout;
import
android.widget.ProgressBar
;
import
android.widget.TextView
;
import
androidx.appcompat.app.AlertDialog
;
import
com.bumptech.glide.Glide
;
import
com.bumptech.glide.load.engine.DiskCacheStrategy
;
...
...
@@ -19,8 +20,10 @@ import org.json.JSONObject;
import
ly.warp.sdk.R
;
import
ly.warp.sdk.io.callbacks.CallbackReceiver
;
import
ly.warp.sdk.io.models.Coupon
;
import
ly.warp.sdk.io.models.CouponList
;
import
ly.warp.sdk.io.models.Couponset
;
import
ly.warp.sdk.io.request.WarplyRedeemCouponRequest
;
import
ly.warp.sdk.io.request.WarplyUserCouponsRequest
;
import
ly.warp.sdk.utils.managers.WarplyManager
;
...
...
@@ -41,6 +44,7 @@ public class CouponsetInfoActivity extends Activity implements View.OnClickListe
private
ProgressBar
mPbLoading
;
private
Coupon
mCoupon
;
private
boolean
mIsTermsPressed
=
false
;
private
AlertDialog
mAlertDialogCouponset
;
// ===========================================================
// Methods for/from SuperClass/Interfaces
...
...
@@ -136,6 +140,11 @@ public class CouponsetInfoActivity extends Activity implements View.OnClickListe
mCoupon
.
setDescription
(
mCouponset
.
getShortDescription
());
mCoupon
.
setImage
(
mCouponset
.
getImgPreview
());
mCoupon
.
setName
(
mCouponset
.
getName
());
new
Thread
(()
->
{
if
(!
Thread
.
currentThread
().
isInterrupted
())
{
WarplyManager
.
getUserCouponsWithCouponsets
(
new
WarplyUserCouponsRequest
(),
mUserCouponsReceiver
);
}
}).
start
();
showDialog
(
true
,
1
);
}
else
{
showDialog
(
false
,
status
);
...
...
@@ -150,41 +159,60 @@ public class CouponsetInfoActivity extends Activity implements View.OnClickListe
};
private
void
showDialog
(
boolean
success
,
int
status
)
{
Dialog
dialog
=
new
Dialog
(
this
,
R
.
style
.
PopUpDialog
);
dialog
.
setContentView
(
R
.
layout
.
dlg_success
);
dialog
.
getWindow
().
setBackgroundDrawableResource
(
R
.
drawable
.
banner_border_white
);
dialog
.
show
();
LinearLayout
mLlButton
=
dialog
.
findViewById
(
R
.
id
.
ll_dl_redeem
);
TextView
tvTitle
=
dialog
.
findViewById
(
R
.
id
.
tv_dl_title
);
TextView
tvSubtitle
=
dialog
.
findViewById
(
R
.
id
.
tv_dl_subtitle
);
if
(
success
)
{
tvTitle
.
setText
(
getString
(
R
.
string
.
cos_dlg_success_title
));
tvSubtitle
.
setText
(
getString
(
R
.
string
.
cos_dlg_success_subtitle
));
mAlertDialogCouponset
=
new
AlertDialog
.
Builder
(
this
)
.
setTitle
(
R
.
string
.
cos_dlg_success_couponset_title
)
.
setMessage
(
R
.
string
.
cos_dlg_success_couponset_subtitle
)
.
setPositiveButton
(
R
.
string
.
cos_dlg_positive_button2
,
(
dialogPositive
,
whichPositive
)
->
{
dialogPositive
.
dismiss
();
if
(
success
)
{
onBackPressed
();
}
})
.
show
();
}
else
{
if
(
status
==
3
)
{
tvTitle
.
setText
(
getString
(
R
.
string
.
cos_dlg_error_title
));
tvSubtitle
.
setText
(
getString
(
R
.
string
.
cos_dlg_error_subtitle_non_buyable
));
mAlertDialogCouponset
=
new
AlertDialog
.
Builder
(
this
)
.
setTitle
(
R
.
string
.
cos_dlg_error_title
)
.
setMessage
(
R
.
string
.
cos_dlg_error_subtitle_non_buyable
)
.
setPositiveButton
(
R
.
string
.
cos_dlg_positive_button2
,
(
dialogPositive
,
whichPositive
)
->
{
dialogPositive
.
dismiss
();
})
.
show
();
}
else
if
(
status
==
5
)
{
tvTitle
.
setText
(
getString
(
R
.
string
.
cos_dlg_error_title
));
tvSubtitle
.
setText
(
getString
(
R
.
string
.
cos_dlg_error_subtitle_no_points
));
mAlertDialogCouponset
=
new
AlertDialog
.
Builder
(
this
)
.
setTitle
(
R
.
string
.
cos_dlg_error_title
)
.
setMessage
(
R
.
string
.
cos_dlg_error_subtitle_no_points
)
.
setPositiveButton
(
R
.
string
.
cos_dlg_positive_button2
,
(
dialogPositive
,
whichPositive
)
->
{
dialogPositive
.
dismiss
();
})
.
show
();
}
else
{
tvTitle
.
setText
(
getString
(
R
.
string
.
cos_dlg_error_title
));
tvSubtitle
.
setText
(
getString
(
R
.
string
.
cos_dlg_error_subtitle
));
mAlertDialogCouponset
=
new
AlertDialog
.
Builder
(
this
)
.
setTitle
(
R
.
string
.
cos_dlg_error_title
)
.
setMessage
(
R
.
string
.
cos_dlg_error_subtitle
)
.
setPositiveButton
(
R
.
string
.
cos_dlg_positive_button2
,
(
dialogPositive
,
whichPositive
)
->
{
dialogPositive
.
dismiss
();
})
.
show
();
}
}
mLlButton
.
setOnClickListener
(
view
->
{
dialog
.
dismiss
();
if
(
success
)
{
onBackPressed
();
}
});
}
// ===========================================================
// Inner and Anonymous Classes
// ===========================================================
private
final
CallbackReceiver
<
CouponList
>
mUserCouponsReceiver
=
new
CallbackReceiver
<
CouponList
>()
{
@Override
public
void
onSuccess
(
CouponList
result
)
{
Thread
.
currentThread
().
interrupt
();
}
@Override
public
void
onFailure
(
int
errorCode
)
{
Thread
.
currentThread
().
interrupt
();
}
};
}
...
...
warply_android_sdk/src/main/java/ly/warp/sdk/activities/GiftsForYouActivity.java
View file @
84b4a72
package
ly
.
warp
.
sdk
.
activities
;
import
android.app.Activity
;
import
android.content.Intent
;
import
android.os.Bundle
;
import
android.text.TextUtils
;
import
android.util.Log
;
...
...
@@ -15,6 +16,7 @@ import androidx.recyclerview.widget.RecyclerView;
import
org.greenrobot.eventbus.EventBus
;
import
org.json.JSONObject
;
import
java.io.Serializable
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.HashSet
;
...
...
@@ -22,6 +24,7 @@ import java.util.HashSet;
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.Couponset
;
import
ly.warp.sdk.io.models.LoyaltyContextualOfferModel
;
import
ly.warp.sdk.io.models.LoyaltyGiftsForYouOfferClickEvent
;
import
ly.warp.sdk.io.models.LoyaltyGiftsForYouPackage
;
...
...
@@ -130,6 +133,31 @@ public class GiftsForYouActivity extends Activity implements View.OnClickListene
if
(
dataItem
.
getDataType
()
==
1
)
{
EventBus
.
getDefault
().
post
(
new
WarplyEventBusManager
(
new
LoyaltyGiftsForYouOfferClickEvent
()));
if
(
dataItem
.
getCampaign
().
getType
().
equals
(
"coupon"
))
{
try
{
JSONObject
campaignSettings
=
WarpJSONParser
.
getJSONFromString
(
dataItem
.
getCampaign
().
getCampaignTypeSettings
());
if
(
campaignSettings
!=
null
)
{
if
(
campaignSettings
.
has
(
"couponset"
))
{
String
cpnUuid
=
campaignSettings
.
optString
(
"couponset"
);
for
(
Couponset
cpns
:
WarplyManagerHelper
.
getCouponsets
())
{
if
(
cpns
.
getUuid
().
equals
(
cpnUuid
))
{
Intent
intent
=
new
Intent
(
GiftsForYouActivity
.
this
,
CouponsetInfoActivity
.
class
);
intent
.
putExtra
(
"couponset"
,
(
Serializable
)
cpns
);
startActivity
(
intent
);
break
;
}
}
}
else
{
startActivity
(
WarpViewActivity
.
createIntentFromURL
(
this
,
WarplyManagerHelper
.
constructCampaignUrl
(
dataItem
.
getCampaign
())));
}
}
}
catch
(
Exception
exception
)
{
exception
.
printStackTrace
();
}
return
;
}
try
{
JSONObject
extraFields
=
WarpJSONParser
.
getJSONFromString
(
dataItem
.
getCampaign
().
getExtraFields
());
if
(
extraFields
!=
null
)
{
...
...
warply_android_sdk/src/main/java/ly/warp/sdk/io/models/Campaign.java
View file @
84b4a72
...
...
@@ -69,6 +69,7 @@ public class Campaign implements Parcelable, Serializable {
private
static
final
String
DISPLAY_TYPE
=
"display_type"
;
private
static
final
String
ACTIONS
=
"actions"
;
private
static
final
String
BUS_ID
=
"busId"
;
private
static
final
String
CAMPAIGN_TYPE_SETTINGS
=
"campaign_type_settings"
;
/* Member variables of the Campaign object */
...
...
@@ -95,6 +96,7 @@ public class Campaign implements Parcelable, Serializable {
private
String
indexUrl
;
private
String
busId
;
private
ArrayList
<
CampaignAction
>
actions
=
new
ArrayList
<>();
private
final
String
campaignTypeSettings
;
/**
* Basic constructor used to create an object from a String, representing a
...
...
@@ -141,6 +143,7 @@ public class Campaign implements Parcelable, Serializable {
this
.
deliveryMethod
=
json
.
optString
(
DELIVERY_METHOD
);
this
.
displayType
=
json
.
optString
(
DISPLAY_TYPE
);
this
.
busId
=
json
.
optString
(
BUS_ID
);
this
.
campaignTypeSettings
=
json
.
optString
(
CAMPAIGN_TYPE_SETTINGS
);
JSONArray
actions
=
json
.
optJSONArray
(
ACTIONS
);
if
(
actions
!=
null
)
{
...
...
@@ -176,6 +179,7 @@ public class Campaign implements Parcelable, Serializable {
this
.
displayType
=
source
.
readString
();
this
.
actions
=
source
.
readArrayList
(
CampaignAction
.
class
.
getClassLoader
());
this
.
busId
=
source
.
readString
();
this
.
campaignTypeSettings
=
source
.
readString
();
}
@Override
...
...
@@ -195,14 +199,15 @@ public class Campaign implements Parcelable, Serializable {
dest
.
writeInt
(
this
.
opened
);
dest
.
writeInt
(
this
.
isNew
?
1
:
0
);
dest
.
writeString
(
this
.
logoUrl
);
dest
.
writeString
(
extraFields
);
dest
.
writeString
(
type
);
dest
.
writeString
(
this
.
extraFields
);
dest
.
writeString
(
t
his
.
t
ype
);
dest
.
writeInt
(
this
.
expired
?
1
:
0
);
dest
.
writeInt
(
this
.
show
?
1
:
0
);
dest
.
writeString
(
deliveryMethod
);
dest
.
writeString
(
displayType
);
dest
.
writeList
(
actions
);
dest
.
writeString
(
busId
);
dest
.
writeString
(
this
.
deliveryMethod
);
dest
.
writeString
(
this
.
displayType
);
dest
.
writeList
(
this
.
actions
);
dest
.
writeString
(
this
.
busId
);
dest
.
writeString
(
this
.
campaignTypeSettings
);
}
/**
...
...
@@ -236,6 +241,7 @@ public class Campaign implements Parcelable, Serializable {
jObj
.
putOpt
(
DELIVERY_METHOD
,
this
.
deliveryMethod
);
jObj
.
putOpt
(
DISPLAY_TYPE
,
this
.
displayType
);
jObj
.
put
(
BUS_ID
,
this
.
busId
);
jObj
.
put
(
CAMPAIGN_TYPE_SETTINGS
,
this
.
campaignTypeSettings
);
}
catch
(
JSONException
e
)
{
if
(
WarpConstants
.
DEBUG
)
{
e
.
printStackTrace
();
...
...
@@ -465,6 +471,10 @@ public class Campaign implements Parcelable, Serializable {
isNew
=
aNew
;
}
public
String
getCampaignTypeSettings
()
{
return
campaignTypeSettings
;
}
@Override
public
int
describeContents
()
{
return
0
;
...
...
warply_android_sdk/src/main/res/values/strings.xml
View file @
84b4a72
...
...
@@ -102,6 +102,8 @@
<string
name=
"cos_dlg_positive_coupon_subtitle"
>
Είσαι σίγουρος ότι θέλεις να κάνεις δώρο το κουπόνι σου;
</string>
<string
name=
"cos_dlg_negative_button3"
>
Αποστολή
</string>
<string
name=
"cos_dlg_error_subtitle2"
>
Τα πεδία δεν είναι σωστά
</string>
<string
name=
"cos_dlg_success_couponset_title"
>
Το κουπόνι σου ενεργοποιήθηκε
</string>
<string
name=
"cos_dlg_success_couponset_subtitle"
>
Μπορείς να το βρεις στην αρχική οθόνη της εφαρμογής και στην ενότητα ενεργά δώρα!
</string>
<string-array
name=
"coupons_array"
>
<item>
Κουπόνια
</item>
...
...
Please
register
or
login
to post a comment