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-11 11:32:33 +0300
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
8cae6c6ad0918feacb927f7fe9f940d49eca80cc
8cae6c6a
1 parent
94734480
uat changes 11_08_2022
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
406 additions
and
5 deletions
warply_android_sdk/build.gradle
warply_android_sdk/src/main/AndroidManifest.xml
warply_android_sdk/src/main/java/ly/warp/sdk/activities/ContextualActivity.java
warply_android_sdk/src/main/java/ly/warp/sdk/activities/GiftsForYouActivity.java
warply_android_sdk/src/main/java/ly/warp/sdk/activities/MoreForYouActivity.java
warply_android_sdk/src/main/res/layout/activity_contextual.xml
warply_android_sdk/build.gradle
View file @
8cae6c6
...
...
@@ -2,7 +2,7 @@ apply plugin: 'com.android.library'
ext
{
PUBLISH_GROUP_ID
=
'ly.warp'
PUBLISH_VERSION
=
'4.5.4-cosbeta4
5
'
PUBLISH_VERSION
=
'4.5.4-cosbeta4
6
'
PUBLISH_ARTIFACT_ID
=
'warply-android-sdk'
}
...
...
warply_android_sdk/src/main/AndroidManifest.xml
View file @
8cae6c6
...
...
@@ -84,6 +84,11 @@
android:screenOrientation=
"portrait"
/>
<activity
android:name=
"ly.warp.sdk.activities.ContextualActivity"
android:exported=
"false"
android:screenOrientation=
"portrait"
/>
<activity
android:name=
"ly.warp.sdk.dexter.PermissionsActivity"
android:exported=
"false"
android:launchMode=
"singleInstance"
...
...
warply_android_sdk/src/main/java/ly/warp/sdk/activities/ContextualActivity.java
0 → 100644
View file @
8cae6c6
package
ly
.
warp
.
sdk
.
activities
;
import
android.app.Activity
;
import
android.content.Context
;
import
android.os.Bundle
;
import
android.text.TextUtils
;
import
android.util.Log
;
import
android.view.LayoutInflater
;
import
android.view.View
;
import
android.view.ViewGroup
;
import
android.widget.ImageView
;
import
android.widget.LinearLayout
;
import
android.widget.TextView
;
import
androidx.appcompat.app.AlertDialog
;
import
com.bumptech.glide.Glide
;
import
com.bumptech.glide.load.engine.DiskCacheStrategy
;
import
com.google.android.material.bottomsheet.BottomSheetDialog
;
import
org.json.JSONArray
;
import
org.json.JSONException
;
import
org.json.JSONObject
;
import
ly.warp.sdk.R
;
import
ly.warp.sdk.io.callbacks.CallbackReceiver
;
import
ly.warp.sdk.io.models.Consumer
;
import
ly.warp.sdk.io.models.LoyaltyContextualOfferModel
;
import
ly.warp.sdk.io.request.CosmoteSubmitOrderRequest
;
import
ly.warp.sdk.io.request.WarplyConsumerRequest
;
import
ly.warp.sdk.utils.WarplyManagerHelper
;
import
ly.warp.sdk.utils.managers.WarplyManager
;
public
class
ContextualActivity
extends
Activity
implements
View
.
OnClickListener
{
// ===========================================================
// Constants
// ===========================================================
private
final
String
MSISDN_LIST
=
"msisdnList"
;
// ===========================================================
// Fields
// ===========================================================
private
ImageView
mIvBack
,
mIvCampaignPhoto
;
private
TextView
mTvCampaignTitle
,
mTvCampaignSubtitle
;
private
LoyaltyContextualOfferModel
mCCMS
=
new
LoyaltyContextualOfferModel
();
private
LinearLayout
mLlActivateOffer
;
private
Consumer
mConsumer
;
private
String
mSender
=
""
;
private
AlertDialog
mAlertDialogAskActivate
,
mAlertDialogErrorActivating
,
mAlertDialogSuccessActivating
;
// ===========================================================
// Methods for/from SuperClass/Interfaces
// ===========================================================
@Override
public
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
setContentView
(
R
.
layout
.
activity_contextual
);
mCCMS
=
(
LoyaltyContextualOfferModel
)
getIntent
().
getSerializableExtra
(
"ccms"
);
mIvBack
=
findViewById
(
R
.
id
.
iv_contextual_back
);
mTvCampaignTitle
=
findViewById
(
R
.
id
.
textView13
);
mIvCampaignPhoto
=
findViewById
(
R
.
id
.
imageView6
);
mTvCampaignSubtitle
=
findViewById
(
R
.
id
.
textView14
);
mLlActivateOffer
=
findViewById
(
R
.
id
.
ll_activate_button
);
initViews
();
}
@Override
public
void
onResume
()
{
super
.
onResume
();
new
Thread
(()
->
{
if
(!
Thread
.
currentThread
().
isInterrupted
())
{
WarplyManager
.
getConsumer
(
new
WarplyConsumerRequest
()
,
mConsumerCallback
);
}
Thread
.
currentThread
().
interrupt
();
}).
start
();
}
@Override
public
void
onClick
(
View
view
)
{
if
(
view
.
getId
()
==
R
.
id
.
iv_contextual_back
)
{
onBackPressed
();
return
;
}
if
(
view
.
getId
()
==
R
.
id
.
ll_activate_button
)
{
showActivationDialog
();
}
}
// ===========================================================
// Methods
// ===========================================================
private
void
initViews
()
{
mTvCampaignTitle
.
setText
(
mCCMS
.
getTitle
());
mTvCampaignSubtitle
.
setText
(
mCCMS
.
getSubtitle
());
if
(!
TextUtils
.
isEmpty
(
mCCMS
.
getImageUrl
()))
{
Glide
.
with
(
this
)
// .setDefaultRequestOptions(
// RequestOptions
// .placeholderOf(R.drawable.ic_default_contact_photo)
// .error(R.drawable.ic_default_contact_photo))
.
load
(
mCCMS
.
getImageUrl
())
.
diskCacheStrategy
(
DiskCacheStrategy
.
DATA
)
.
into
(
mIvCampaignPhoto
);
}
else
{
Glide
.
with
(
this
)
.
load
(
R
.
drawable
.
ic_cosmote_logo_horizontal_grey
)
.
into
(
mIvCampaignPhoto
);
}
mIvBack
.
setOnClickListener
(
this
);
mLlActivateOffer
.
setOnClickListener
(
this
);
}
private
void
showActivationDialog
()
{
final
BottomSheetDialog
bottomSheetDialog
=
new
BottomSheetDialog
(
this
);
bottomSheetDialog
.
setContentView
(
R
.
layout
.
dl_share
);
LinearLayout
parent
=
bottomSheetDialog
.
findViewById
(
R
.
id
.
ll_share_dialog_view_inner
);
ImageView
dialogClose
=
(
ImageView
)
bottomSheetDialog
.
findViewById
(
R
.
id
.
iv_sender_list_close
);
dialogClose
.
setOnClickListener
(
view
->
bottomSheetDialog
.
dismiss
());
if
(
mConsumer
!=
null
)
{
try
{
JSONObject
profMeta
=
new
JSONObject
(
mConsumer
.
getProfileMetadata
());
if
(
profMeta
!=
null
)
{
JSONArray
msisdnList
=
new
JSONArray
();
msisdnList
=
profMeta
.
optJSONArray
(
MSISDN_LIST
);
if
(
msisdnList
!=
null
&&
msisdnList
.
length
()
>
0
)
{
for
(
int
i
=
0
;
i
<
msisdnList
.
length
();
i
++)
{
LayoutInflater
vi
=
(
LayoutInflater
)
getApplicationContext
().
getSystemService
(
Context
.
LAYOUT_INFLATER_SERVICE
);
LinearLayout
v
=
(
LinearLayout
)
vi
.
inflate
(
R
.
layout
.
item_share
,
null
);
TextView
textView
=
(
TextView
)
v
.
findViewById
(
R
.
id
.
tv_phone_share
);
textView
.
setText
(
msisdnList
.
optString
(
i
));
textView
.
setOnClickListener
(
view
->
{
TextView
tv
=
(
TextView
)
view
;
mSender
=
tv
.
getText
().
toString
();
bottomSheetDialog
.
dismiss
();
askActivateDialog
();
});
parent
.
addView
(
v
,
0
,
new
ViewGroup
.
LayoutParams
(
ViewGroup
.
LayoutParams
.
MATCH_PARENT
,
ViewGroup
.
LayoutParams
.
WRAP_CONTENT
));
}
}
}
}
catch
(
JSONException
e
)
{
e
.
printStackTrace
();
}
}
bottomSheetDialog
.
show
();
}
private
void
activateGift
()
{
new
Thread
(()
->
{
if
(!
Thread
.
currentThread
().
isInterrupted
())
{
WarplyManager
.
submitOrder
(
new
CosmoteSubmitOrderRequest
()
.
setCommunicationUuid
(
""
)
.
setUserMsisdn
(
WarplyManagerHelper
.
getConsumer
().
getMsisdn
())
.
setBusinessService
(
mCCMS
.
getBusinessService
())
.
setOfferName
(
mCCMS
.
getOfferName
())
.
setProductType
(
mCCMS
.
getProductType
())
.
setProvDuration
(
mCCMS
.
getProvDuration
())
.
setNoOfRecurrance
(
mCCMS
.
getNoOfRecurrance
())
.
setPrice
(
mCCMS
.
getPrice
())
.
setDiscount
(
mCCMS
.
getDiscount
())
.
setVoiceCategory
(
mCCMS
.
getVoiceCategory
())
.
setDataCategory
(
mCCMS
.
getDataCategory
())
.
setMinsValue
(
mCCMS
.
getMinsValue
())
.
setDataValue
(
mCCMS
.
getDataValue
())
.
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
();
}).
start
();
}
private
void
askActivateDialog
()
{
mAlertDialogAskActivate
=
new
AlertDialog
.
Builder
(
this
)
.
setTitle
(
R
.
string
.
cos_dlg_activate_telco_title
)
.
setMessage
(
R
.
string
.
cos_dlg_activate_telco_subtitle
)
.
setPositiveButton
(
R
.
string
.
cos_dlg_positive_button
,
(
dialogPositive
,
whichPositive
)
->
{
activateGift
();
})
.
setNegativeButton
(
R
.
string
.
cos_dlg_negative_button2
,
(
dialogNegative
,
whichNegative
)
->
{
dialogNegative
.
dismiss
();
})
.
show
();
}
private
void
errorActivatingDialog
()
{
mAlertDialogErrorActivating
=
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
();
}
private
void
successActivatingDialog
()
{
mAlertDialogSuccessActivating
=
new
AlertDialog
.
Builder
(
this
)
.
setTitle
(
R
.
string
.
cos_dlg_activate_success_title
)
.
setMessage
(
R
.
string
.
cos_dlg_activate_success_subtitle
)
.
setPositiveButton
(
R
.
string
.
cos_dlg_positive_button2
,
(
dialogPositive
,
whichPositive
)
->
{
dialogPositive
.
dismiss
();
})
.
show
();
}
// ===========================================================
// Inner and Anonymous Classes
// ===========================================================
private
final
CallbackReceiver
<
Consumer
>
mConsumerCallback
=
new
CallbackReceiver
<
Consumer
>()
{
@Override
public
void
onSuccess
(
Consumer
result
)
{
mConsumer
=
result
;
}
@Override
public
void
onFailure
(
int
errorCode
)
{
Log
.
v
(
"TELCO_ACTIVITY"
,
String
.
valueOf
(
errorCode
));
}
};
private
CallbackReceiver
<
JSONObject
>
mSubmitCallback
=
new
CallbackReceiver
<
JSONObject
>()
{
@Override
public
void
onSuccess
(
JSONObject
result
)
{
int
status
=
result
.
optInt
(
"status"
,
2
);
runOnUiThread
(()
->
{
if
(
status
==
1
)
successActivatingDialog
();
else
errorActivatingDialog
();
});
}
@Override
public
void
onFailure
(
int
errorCode
)
{
runOnUiThread
(()
->
errorActivatingDialog
());
}
};
}
warply_android_sdk/src/main/java/ly/warp/sdk/activities/GiftsForYouActivity.java
View file @
8cae6c6
...
...
@@ -280,7 +280,9 @@ public class GiftsForYouActivity extends Activity implements View.OnClickListene
seasonalCLick
.
setImageUrl
(
dataItem
.
getSeasonalList
().
getImageUrl
());
EventBus
.
getDefault
().
post
(
new
WarplyEventBusManager
(
seasonalCLick
));
}
else
if
(
dataItem
.
getDataType
()
==
3
)
{
Intent
intent
=
new
Intent
(
GiftsForYouActivity
.
this
,
ContextualActivity
.
class
);
intent
.
putExtra
(
"ccms"
,
dataItem
.
getCCMS
());
startActivity
(
intent
);
}
})
.
doOnError
(
error
->
{
...
...
@@ -412,7 +414,9 @@ public class GiftsForYouActivity extends Activity implements View.OnClickListene
seasonalCLick
.
setImageUrl
(
dataItem
.
getSeasonalList
().
getImageUrl
());
EventBus
.
getDefault
().
post
(
new
WarplyEventBusManager
(
seasonalCLick
));
}
else
if
(
dataItem
.
getDataType
()
==
3
)
{
Intent
intent
=
new
Intent
(
GiftsForYouActivity
.
this
,
ContextualActivity
.
class
);
intent
.
putExtra
(
"ccms"
,
dataItem
.
getCCMS
());
startActivity
(
intent
);
}
})
.
doOnError
(
error
->
{
...
...
warply_android_sdk/src/main/java/ly/warp/sdk/activities/MoreForYouActivity.java
View file @
8cae6c6
...
...
@@ -200,7 +200,9 @@ public class MoreForYouActivity extends Activity implements View.OnClickListener
startActivity
(
WarpViewActivity
.
createIntentFromURL
(
this
,
WarplyManagerHelper
.
constructCampaignUrl
(
dataItem
.
getCampaign
())));
}
}
else
if
(
dataItem
.
getDataType
()
==
2
)
{
Intent
intent
=
new
Intent
(
MoreForYouActivity
.
this
,
ContextualActivity
.
class
);
intent
.
putExtra
(
"ccms"
,
dataItem
.
getCCMS
());
startActivity
(
intent
);
}
})
.
doOnError
(
error
->
{
...
...
@@ -269,7 +271,9 @@ public class MoreForYouActivity extends Activity implements View.OnClickListener
startActivity
(
WarpViewActivity
.
createIntentFromURL
(
this
,
WarplyManagerHelper
.
constructCampaignUrl
(
dataItem
.
getCampaign
())));
}
}
else
if
(
dataItem
.
getDataType
()
==
2
)
{
Intent
intent
=
new
Intent
(
MoreForYouActivity
.
this
,
ContextualActivity
.
class
);
intent
.
putExtra
(
"ccms"
,
dataItem
.
getCCMS
());
startActivity
(
intent
);
}
})
.
doOnError
(
error
->
{
...
...
warply_android_sdk/src/main/res/layout/activity_contextual.xml
0 → 100644
View file @
8cae6c6
<RelativeLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
xmlns:tools=
"http://schemas.android.com/tools"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:background=
"@android:color/white"
>
<androidx.constraintlayout.widget.ConstraintLayout
android:id=
"@+id/cl_loyalty_wallet_header"
android:layout_width=
"match_parent"
android:layout_height=
"50dp"
android:background=
"@android:color/white"
>
<ImageView
android:id=
"@+id/iv_contextual_back"
android:layout_width=
"20dp"
android:layout_height=
"20dp"
android:layout_marginStart=
"16dp"
android:src=
"@drawable/ic_back"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
/>
<TextView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:textColor=
"@color/grey"
android:textSize=
"17sp"
android:textStyle=
"bold"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
<ScrollView
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:fillViewport=
"true"
android:layout_below=
"@+id/cl_loyalty_wallet_header"
>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:background=
"@android:color/white"
>
<androidx.constraintlayout.widget.ConstraintLayout
android:id=
"@+id/cl_loyalty_info_view_inner"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:background=
"@drawable/shape_cos_loyalty_white"
android:paddingBottom=
"48dp"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
>
<com.github.siyamed.shapeimageview.mask.PorterShapeImageView
android:id=
"@+id/imageView6"
android:layout_width=
"match_parent"
android:layout_height=
"224dp"
android:layout_marginTop=
"4dp"
android:scaleType=
"centerCrop"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
app:siShape=
"@drawable/shape_top_left_rounded"
tools:src=
"@drawable/carousel_banner"
/>
<TextView
android:id=
"@+id/textView13"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"32dp"
android:gravity=
"center"
android:paddingHorizontal=
"32dp"
android:textColor=
"#415564"
android:textSize=
"18sp"
android:textStyle=
"bold"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintHorizontal_bias=
"0.509"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toBottomOf=
"@+id/imageView6"
tools:text=
"Πάρε δωρεάν μηνιαία πακέτα με πάνες στα supermarket Σκλαβενίτης!"
/>
<TextView
android:id=
"@+id/textView14"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"16dp"
android:gravity=
"center"
android:paddingHorizontal=
"32dp"
android:textColor=
"#415564"
android:textSize=
"16sp"
tools:text=
"test test"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toBottomOf=
"@+id/textView13"
/>
<LinearLayout
android:id=
"@+id/ll_activate_button"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginHorizontal=
"32dp"
android:background=
"@drawable/selector_button_green"
android:gravity=
"center"
android:orientation=
"horizontal"
android:paddingHorizontal=
"16dp"
android:paddingVertical=
"8dp"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
>
<TextView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:gravity=
"center"
android:text=
"@string/cos_dlg_positive_button"
android:textColor=
"@color/white"
android:textFontWeight=
"600"
android:textSize=
"17dp"
/>
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView>
</RelativeLayout>
Please
register
or
login
to post a comment