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
2024-04-10 19:05:21 +0300
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
ca6013fab97a3b3ad748c8411ba42b7979f736be
ca6013fa
1 parent
be02b90c
more fixes
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
131 additions
and
8 deletions
warply_android_sdk/src/main/java/ly/warp/sdk/activities/ContextualActivity.java
warply_android_sdk/src/main/java/ly/warp/sdk/views/WarpView.java
warply_android_sdk/src/main/res/layout/activity_contextual.xml
warply_android_sdk/src/main/java/ly/warp/sdk/activities/ContextualActivity.java
View file @
ca6013f
...
...
@@ -4,6 +4,7 @@ import android.app.Activity;
import
android.content.Context
;
import
android.os.Bundle
;
import
android.text.TextUtils
;
import
android.text.method.LinkMovementMethod
;
import
android.util.Log
;
import
android.view.LayoutInflater
;
import
android.view.View
;
...
...
@@ -13,6 +14,9 @@ import android.widget.LinearLayout;
import
android.widget.TextView
;
import
androidx.appcompat.app.AlertDialog
;
import
androidx.core.text.HtmlCompat
;
import
androidx.work.OneTimeWorkRequest
;
import
androidx.work.WorkManager
;
import
com.bumptech.glide.Glide
;
import
com.bumptech.glide.load.engine.DiskCacheStrategy
;
...
...
@@ -23,14 +27,20 @@ import org.json.JSONArray;
import
org.json.JSONException
;
import
org.json.JSONObject
;
import
java.util.ArrayList
;
import
ly.warp.sdk.R
;
import
ly.warp.sdk.io.callbacks.CallbackReceiver
;
import
ly.warp.sdk.io.models.Campaign
;
import
ly.warp.sdk.io.models.Consumer
;
import
ly.warp.sdk.io.models.CouponList
;
import
ly.warp.sdk.io.models.LoyaltyContextualOfferModel
;
import
ly.warp.sdk.io.models.LoyaltySDKFirebaseEventModel
;
import
ly.warp.sdk.io.models.WarplyCCMSEnabledModel
;
import
ly.warp.sdk.io.models.WarplyCouponsChangedEventModel
;
import
ly.warp.sdk.io.request.CosmoteSubmitOrderRequest
;
import
ly.warp.sdk.io.request.WarplyConsumerRequest
;
import
ly.warp.sdk.services.EventCampaignService
;
import
ly.warp.sdk.utils.managers.WarplyAnalyticsManager
;
import
ly.warp.sdk.utils.managers.WarplyEventBusManager
;
import
ly.warp.sdk.utils.managers.WarplyManager
;
...
...
@@ -48,11 +58,12 @@ public class ContextualActivity extends Activity implements View.OnClickListener
// Fields
// ===========================================================
private
ImageView
mIvBack
,
mIvCampaignPhoto
;
private
TextView
mTvCampaignTitle
,
mTvCampaignSubtitle
;
private
ImageView
mIvBack
,
mIvCampaignPhoto
,
mIvTermsArrow
;
private
TextView
mTvCampaignTitle
,
mTvCampaignSubtitle
,
mTvTerms
,
mTvTermsValue
;
private
LoyaltyContextualOfferModel
mCCMS
=
new
LoyaltyContextualOfferModel
();
private
LinearLayout
mLlActivateOffer
;
private
LinearLayout
mLlActivateOffer
,
mLlTerms
;
private
Consumer
mConsumer
;
private
boolean
mIsTermsPressed
=
false
;
private
String
mSender
=
""
;
private
AlertDialog
mAlertDialogAskActivate
,
mAlertDialogErrorActivating
,
mAlertDialogSuccessActivating
;
...
...
@@ -72,6 +83,10 @@ public class ContextualActivity extends Activity implements View.OnClickListener
mIvCampaignPhoto
=
findViewById
(
R
.
id
.
imageView6
);
mTvCampaignSubtitle
=
findViewById
(
R
.
id
.
textView14
);
mLlActivateOffer
=
findViewById
(
R
.
id
.
ll_activate_button
);
mTvTerms
=
findViewById
(
R
.
id
.
tv_terms
);
mLlTerms
=
findViewById
(
R
.
id
.
ll_terms_inner
);
mIvTermsArrow
=
findViewById
(
R
.
id
.
iv_terms_arrow
);
mTvTermsValue
=
findViewById
(
R
.
id
.
tv_terms_value
);
initViews
();
}
...
...
@@ -98,6 +113,18 @@ public class ContextualActivity extends Activity implements View.OnClickListener
}
if
(
view
.
getId
()
==
R
.
id
.
ll_activate_button
)
{
showActivationDialog
();
return
;
}
if
(
view
.
getId
()
==
R
.
id
.
ll_terms_inner
)
{
if
(
mIsTermsPressed
)
{
mIsTermsPressed
=
false
;
mTvTermsValue
.
setVisibility
(
View
.
GONE
);
mIvTermsArrow
.
setImageDrawable
(
getDrawable
(
R
.
drawable
.
ic_down_dark_new
));
}
else
{
mIsTermsPressed
=
true
;
mTvTermsValue
.
setVisibility
(
View
.
VISIBLE
);
mIvTermsArrow
.
setImageDrawable
(
getDrawable
(
R
.
drawable
.
ic_up_dark_new
));
}
}
}
...
...
@@ -108,6 +135,10 @@ public class ContextualActivity extends Activity implements View.OnClickListener
private
void
initViews
()
{
mTvCampaignTitle
.
setText
(
mCCMS
.
getTitleOffer
());
mTvCampaignSubtitle
.
setText
(
mCCMS
.
getDescription
());
mLlTerms
.
setOnClickListener
(
this
);
// mTvTermsValue.setText(HtmlCompat.fromHtml(mCCMS.getTermsAndConditions(), HtmlCompat.FROM_HTML_MODE_COMPACT));
// mTvTermsValue.setMovementMethod(LinkMovementMethod.getInstance());
mTvTermsValue
.
setText
(
mCCMS
.
getTermsAndConditions
());
if
(!
TextUtils
.
isEmpty
(
mCCMS
.
getImageUrl
()))
{
Glide
.
with
(
this
)
...
...
@@ -277,6 +308,7 @@ public class ContextualActivity extends Activity implements View.OnClickListener
.
setMessage
(
R
.
string
.
cos_dlg_activate_success_subtitle
)
.
setPositiveButton
(
R
.
string
.
cos_dlg_positive_button2
,
(
dialogPositive
,
whichPositive
)
->
{
dialogPositive
.
dismiss
();
onBackPressed
();
})
.
show
();
}
...
...
@@ -303,9 +335,11 @@ public class ContextualActivity extends Activity implements View.OnClickListener
public
void
onSuccess
(
JSONObject
result
)
{
int
status
=
result
.
optInt
(
"status"
,
2
);
// runOnUiThread(() -> {
if
(
status
==
1
)
if
(
status
==
1
)
{
successActivatingDialog
();
else
WarplyManager
.
getUserCouponsWithCouponsets
(
mUserCouponsReceiver
);
WarplyManager
.
getCampaigns
(
mCampaignsCallback
);
}
else
errorActivatingDialog
();
// });
}
...
...
@@ -316,4 +350,31 @@ public class ContextualActivity extends Activity implements View.OnClickListener
errorActivatingDialog
();
}
};
private
final
CallbackReceiver
<
CouponList
>
mUserCouponsReceiver
=
new
CallbackReceiver
<
CouponList
>()
{
@Override
public
void
onSuccess
(
CouponList
result
)
{
WarplyCouponsChangedEventModel
couponsChanged
=
new
WarplyCouponsChangedEventModel
();
couponsChanged
.
setChanged
(
true
);
EventBus
.
getDefault
().
post
(
new
WarplyEventBusManager
(
couponsChanged
));
}
@Override
public
void
onFailure
(
int
errorCode
)
{
}
};
private
CallbackReceiver
<
ArrayList
<
Campaign
>>
mCampaignsCallback
=
new
CallbackReceiver
<
ArrayList
<
Campaign
>>()
{
@Override
public
void
onSuccess
(
ArrayList
<
Campaign
>
result
)
{
OneTimeWorkRequest
mywork
=
new
OneTimeWorkRequest
.
Builder
(
EventCampaignService
.
class
).
build
();
WorkManager
.
getInstance
(
ContextualActivity
.
this
).
enqueue
(
mywork
);
}
@Override
public
void
onFailure
(
int
errorCode
)
{
}
};
}
...
...
warply_android_sdk/src/main/java/ly/warp/sdk/views/WarpView.java
View file @
ca6013f
...
...
@@ -139,7 +139,7 @@ public class WarpView extends WebView implements DefaultLifecycleObserver {
private
Activity
WarpActivity
;
private
String
geolocationOrigin
=
""
;
private
Callback
geolocationCallback
;
private
static
boolean
mWebviewLoaded
=
false
;
private
static
boolean
mWebviewLoaded
=
false
,
mWebviewSupermarket
=
false
;
// ===========================================================
// Constructors
...
...
@@ -159,6 +159,7 @@ public class WarpView extends WebView implements DefaultLifecycleObserver {
ProcessLifecycleOwner
.
get
().
getLifecycle
().
addObserver
(
this
);
WarpActivity
=
activity
;
mWebviewLoaded
=
false
;
mWebviewSupermarket
=
false
;
init
();
}
...
...
@@ -436,6 +437,13 @@ public class WarpView extends WebView implements DefaultLifecycleObserver {
});
}
if
(
mWebviewSupermarket
)
{
String
scriptSourceInit
=
"webviewDidFocusRefresh("
+
String
.
valueOf
(
mWebviewSupermarket
)
+
");"
;
WarpView
.
this
.
evaluateJavascript
(
scriptSourceInit
,
s
->
{
});
mWebviewSupermarket
=
false
;
}
}
@Override
...
...
@@ -472,7 +480,10 @@ public class WarpView extends WebView implements DefaultLifecycleObserver {
public
void
sendMessage
(
String
message
)
{
if
(
message
.
contains
(
"event"
))
{
String
[]
parts
=
message
.
split
(
":"
);
if
(
parts
[
1
].
equals
(
"closeArtwork"
))
{
if
(
parts
[
1
].
equals
(
"webviewRefresh"
))
{
mWebviewSupermarket
=
true
;
}
else
if
(
parts
[
1
].
equals
(
"closeArtwork"
))
{
mWebviewSupermarket
=
false
;
QuestionnaireEventModel
questionnaireEvent
=
new
QuestionnaireEventModel
();
questionnaireEvent
.
setName
(
parts
[
1
]);
EventBus
.
getDefault
().
post
(
new
WarplyEventBusManager
(
questionnaireEvent
));
...
...
warply_android_sdk/src/main/res/layout/activity_contextual.xml
View file @
ca6013f
...
...
@@ -101,10 +101,11 @@
android:id=
"@+id/ll_activate_button"
android:layout_width=
"160dp"
android:layout_height=
"55dp"
android:layout_marginTop=
"27dp"
android:background=
"@drawable/selector_button_green"
android:gravity=
"center"
android:orientation=
"horizontal"
app:layout_constraint
Bottom_toBottomOf=
"parent
"
app:layout_constraint
Top_toBottomOf=
"@+id/textView14
"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
>
...
...
@@ -119,6 +120,56 @@
android:textSize=
"16sp"
/>
</LinearLayout>
<RelativeLayout
android:id=
"@+id/rl_terms"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"32dp"
android:gravity=
"center"
app:layout_constraintTop_toBottomOf=
"@+id/ll_activate_button"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
>
<LinearLayout
android:id=
"@+id/ll_terms_inner"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_centerHorizontal=
"true"
android:gravity=
"center"
android:orientation=
"horizontal"
>
<TextView
android:id=
"@+id/tv_terms"
fontPath=
"fonts/PeridotPE-Bold.ttf"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"@string/cos_coupon_terms_title"
android:textColor=
"@color/cos_light_black"
android:textSize=
"15sp"
/>
<ImageView
android:id=
"@+id/iv_terms_arrow"
android:layout_width=
"14dp"
android:layout_height=
"14dp"
android:layout_marginTop=
"3dp"
android:layout_marginStart=
"6dp"
android:src=
"@drawable/ic_down_dark_new"
/>
</LinearLayout>
<TextView
android:id=
"@+id/tv_terms_value"
fontPath=
"fonts/PeridotPE-Regular.ttf"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_below=
"@+id/ll_terms_inner"
android:layout_marginHorizontal=
"32dp"
android:layout_marginTop=
"16dp"
android:textColor=
"@color/cos_light_black"
android:textSize=
"14sp"
android:visibility=
"gone"
tools:text=
"@string/cos_coupon_date"
tools:visibility=
"visible"
/>
</RelativeLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView>
...
...
Please
register
or
login
to post a comment