Panagiotis Triantafyllou

uat changes 11_08_2022

...@@ -2,7 +2,7 @@ apply plugin: 'com.android.library' ...@@ -2,7 +2,7 @@ apply plugin: 'com.android.library'
2 2
3 ext { 3 ext {
4 PUBLISH_GROUP_ID = 'ly.warp' 4 PUBLISH_GROUP_ID = 'ly.warp'
5 - PUBLISH_VERSION = '4.5.4-cosbeta45' 5 + PUBLISH_VERSION = '4.5.4-cosbeta46'
6 PUBLISH_ARTIFACT_ID = 'warply-android-sdk' 6 PUBLISH_ARTIFACT_ID = 'warply-android-sdk'
7 } 7 }
8 8
......
...@@ -84,6 +84,11 @@ ...@@ -84,6 +84,11 @@
84 android:screenOrientation="portrait" /> 84 android:screenOrientation="portrait" />
85 85
86 <activity 86 <activity
87 + android:name="ly.warp.sdk.activities.ContextualActivity"
88 + android:exported="false"
89 + android:screenOrientation="portrait" />
90 +
91 + <activity
87 android:name="ly.warp.sdk.dexter.PermissionsActivity" 92 android:name="ly.warp.sdk.dexter.PermissionsActivity"
88 android:exported="false" 93 android:exported="false"
89 android:launchMode="singleInstance" 94 android:launchMode="singleInstance"
......
1 +package ly.warp.sdk.activities;
2 +
3 +import android.app.Activity;
4 +import android.content.Context;
5 +import android.os.Bundle;
6 +import android.text.TextUtils;
7 +import android.util.Log;
8 +import android.view.LayoutInflater;
9 +import android.view.View;
10 +import android.view.ViewGroup;
11 +import android.widget.ImageView;
12 +import android.widget.LinearLayout;
13 +import android.widget.TextView;
14 +
15 +import androidx.appcompat.app.AlertDialog;
16 +
17 +import com.bumptech.glide.Glide;
18 +import com.bumptech.glide.load.engine.DiskCacheStrategy;
19 +import com.google.android.material.bottomsheet.BottomSheetDialog;
20 +
21 +import org.json.JSONArray;
22 +import org.json.JSONException;
23 +import org.json.JSONObject;
24 +
25 +import ly.warp.sdk.R;
26 +import ly.warp.sdk.io.callbacks.CallbackReceiver;
27 +import ly.warp.sdk.io.models.Consumer;
28 +import ly.warp.sdk.io.models.LoyaltyContextualOfferModel;
29 +import ly.warp.sdk.io.request.CosmoteSubmitOrderRequest;
30 +import ly.warp.sdk.io.request.WarplyConsumerRequest;
31 +import ly.warp.sdk.utils.WarplyManagerHelper;
32 +import ly.warp.sdk.utils.managers.WarplyManager;
33 +
34 +
35 +public class ContextualActivity extends Activity implements View.OnClickListener {
36 +
37 + // ===========================================================
38 + // Constants
39 + // ===========================================================
40 +
41 + private final String MSISDN_LIST = "msisdnList";
42 +
43 + // ===========================================================
44 + // Fields
45 + // ===========================================================
46 +
47 + private ImageView mIvBack, mIvCampaignPhoto;
48 + private TextView mTvCampaignTitle, mTvCampaignSubtitle;
49 + private LoyaltyContextualOfferModel mCCMS = new LoyaltyContextualOfferModel();
50 + private LinearLayout mLlActivateOffer;
51 + private Consumer mConsumer;
52 + private String mSender = "";
53 + private AlertDialog mAlertDialogAskActivate, mAlertDialogErrorActivating, mAlertDialogSuccessActivating;
54 +
55 + // ===========================================================
56 + // Methods for/from SuperClass/Interfaces
57 + // ===========================================================
58 +
59 + @Override
60 + public void onCreate(Bundle savedInstanceState) {
61 + super.onCreate(savedInstanceState);
62 + setContentView(R.layout.activity_contextual);
63 +
64 + mCCMS = (LoyaltyContextualOfferModel) getIntent().getSerializableExtra("ccms");
65 +
66 + mIvBack = findViewById(R.id.iv_contextual_back);
67 + mTvCampaignTitle = findViewById(R.id.textView13);
68 + mIvCampaignPhoto = findViewById(R.id.imageView6);
69 + mTvCampaignSubtitle = findViewById(R.id.textView14);
70 + mLlActivateOffer = findViewById(R.id.ll_activate_button);
71 +
72 + initViews();
73 + }
74 +
75 + @Override
76 + public void onResume() {
77 + super.onResume();
78 +
79 + new Thread(() -> {
80 + if (!Thread.currentThread().isInterrupted()) {
81 + WarplyManager.getConsumer(new WarplyConsumerRequest()
82 + , mConsumerCallback);
83 + }
84 + Thread.currentThread().interrupt();
85 + }).start();
86 + }
87 +
88 + @Override
89 + public void onClick(View view) {
90 + if (view.getId() == R.id.iv_contextual_back) {
91 + onBackPressed();
92 + return;
93 + }
94 + if (view.getId() == R.id.ll_activate_button) {
95 + showActivationDialog();
96 + }
97 + }
98 +
99 + // ===========================================================
100 + // Methods
101 + // ===========================================================
102 +
103 + private void initViews() {
104 + mTvCampaignTitle.setText(mCCMS.getTitle());
105 + mTvCampaignSubtitle.setText(mCCMS.getSubtitle());
106 +
107 + if (!TextUtils.isEmpty(mCCMS.getImageUrl())) {
108 + Glide.with(this)
109 +// .setDefaultRequestOptions(
110 +// RequestOptions
111 +// .placeholderOf(R.drawable.ic_default_contact_photo)
112 +// .error(R.drawable.ic_default_contact_photo))
113 + .load(mCCMS.getImageUrl())
114 + .diskCacheStrategy(DiskCacheStrategy.DATA)
115 + .into(mIvCampaignPhoto);
116 + } else {
117 + Glide.with(this)
118 + .load(R.drawable.ic_cosmote_logo_horizontal_grey)
119 + .into(mIvCampaignPhoto);
120 + }
121 + mIvBack.setOnClickListener(this);
122 + mLlActivateOffer.setOnClickListener(this);
123 + }
124 +
125 + private void showActivationDialog() {
126 + final BottomSheetDialog bottomSheetDialog = new BottomSheetDialog(this);
127 + bottomSheetDialog.setContentView(R.layout.dl_share);
128 + LinearLayout parent = bottomSheetDialog.findViewById(R.id.ll_share_dialog_view_inner);
129 +
130 + ImageView dialogClose = (ImageView) bottomSheetDialog.findViewById(R.id.iv_sender_list_close);
131 + dialogClose.setOnClickListener(view -> bottomSheetDialog.dismiss());
132 +
133 + if (mConsumer != null) {
134 + try {
135 + JSONObject profMeta = new JSONObject(mConsumer.getProfileMetadata());
136 + if (profMeta != null) {
137 + JSONArray msisdnList = new JSONArray();
138 + msisdnList = profMeta.optJSONArray(MSISDN_LIST);
139 + if (msisdnList != null && msisdnList.length() > 0) {
140 + for (int i = 0; i < msisdnList.length(); i++) {
141 + LayoutInflater vi = (LayoutInflater) getApplicationContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
142 + LinearLayout v = (LinearLayout) vi.inflate(R.layout.item_share, null);
143 + TextView textView = (TextView) v.findViewById(R.id.tv_phone_share);
144 + textView.setText(msisdnList.optString(i));
145 + textView.setOnClickListener(view -> {
146 + TextView tv = (TextView) view;
147 + mSender = tv.getText().toString();
148 + bottomSheetDialog.dismiss();
149 + askActivateDialog();
150 + });
151 + parent.addView(v, 0, new ViewGroup.LayoutParams(
152 + ViewGroup.LayoutParams.MATCH_PARENT,
153 + ViewGroup.LayoutParams.WRAP_CONTENT));
154 + }
155 + }
156 + }
157 + } catch (JSONException e) {
158 + e.printStackTrace();
159 + }
160 + }
161 +
162 + bottomSheetDialog.show();
163 + }
164 +
165 + private void activateGift() {
166 + new Thread(() -> {
167 + if (!Thread.currentThread().isInterrupted()) {
168 + WarplyManager.submitOrder(new CosmoteSubmitOrderRequest()
169 + .setCommunicationUuid("")
170 + .setUserMsisdn(WarplyManagerHelper.getConsumer().getMsisdn())
171 + .setBusinessService(mCCMS.getBusinessService())
172 + .setOfferName(mCCMS.getOfferName())
173 + .setProductType(mCCMS.getProductType())
174 + .setProvDuration(mCCMS.getProvDuration())
175 + .setNoOfRecurrance(mCCMS.getNoOfRecurrance())
176 + .setPrice(mCCMS.getPrice())
177 + .setDiscount(mCCMS.getDiscount())
178 + .setVoiceCategory(mCCMS.getVoiceCategory())
179 + .setDataCategory(mCCMS.getDataCategory())
180 + .setMinsValue(mCCMS.getMinsValue())
181 + .setDataValue(mCCMS.getDataValue())
182 + .setProvStepValueMins(mCCMS.getProvStepValueMins())
183 + .setOfferAudienceLevel(mCCMS.getOfferAudienceLevel())
184 + .setUACIOfferTrackingCode(mCCMS.getUACIOfferTrackingCode())
185 + .setOfferCode1(mCCMS.getOfferCode1())
186 + .setScore(mCCMS.getScore())
187 + .setZone(mCCMS.getZone())
188 + .setWave(mCCMS.getWave())
189 + .setValidity(mCCMS.getValidity())
190 + .setTreatmentCode(mCCMS.getTreatmentCode()),
191 + mSubmitCallback);
192 + }
193 + Thread.currentThread().interrupt();
194 + }).start();
195 + }
196 +
197 + private void askActivateDialog() {
198 + mAlertDialogAskActivate = new AlertDialog.Builder(this)
199 + .setTitle(R.string.cos_dlg_activate_telco_title)
200 + .setMessage(R.string.cos_dlg_activate_telco_subtitle)
201 + .setPositiveButton(R.string.cos_dlg_positive_button, (dialogPositive, whichPositive) -> {
202 + activateGift();
203 + })
204 + .setNegativeButton(R.string.cos_dlg_negative_button2, (dialogNegative, whichNegative) -> {
205 + dialogNegative.dismiss();
206 + })
207 + .show();
208 + }
209 +
210 + private void errorActivatingDialog() {
211 + mAlertDialogErrorActivating = new AlertDialog.Builder(this)
212 + .setTitle(R.string.cos_dlg_error_title)
213 + .setMessage(R.string.cos_dlg_error_subtitle)
214 + .setPositiveButton(R.string.cos_dlg_positive_button2, (dialogPositive, whichPositive) -> {
215 + dialogPositive.dismiss();
216 + })
217 + .show();
218 + }
219 +
220 + private void successActivatingDialog() {
221 + mAlertDialogSuccessActivating = new AlertDialog.Builder(this)
222 + .setTitle(R.string.cos_dlg_activate_success_title)
223 + .setMessage(R.string.cos_dlg_activate_success_subtitle)
224 + .setPositiveButton(R.string.cos_dlg_positive_button2, (dialogPositive, whichPositive) -> {
225 + dialogPositive.dismiss();
226 + })
227 + .show();
228 + }
229 +
230 + // ===========================================================
231 + // Inner and Anonymous Classes
232 + // ===========================================================
233 +
234 + private final CallbackReceiver<Consumer> mConsumerCallback = new CallbackReceiver<Consumer>() {
235 + @Override
236 + public void onSuccess(Consumer result) {
237 + mConsumer = result;
238 + }
239 +
240 + @Override
241 + public void onFailure(int errorCode) {
242 + Log.v("TELCO_ACTIVITY", String.valueOf(errorCode));
243 + }
244 + };
245 +
246 + private CallbackReceiver<JSONObject> mSubmitCallback = new CallbackReceiver<JSONObject>() {
247 + @Override
248 + public void onSuccess(JSONObject result) {
249 + int status = result.optInt("status", 2);
250 + runOnUiThread(() -> {
251 + if (status == 1)
252 + successActivatingDialog();
253 + else
254 + errorActivatingDialog();
255 + });
256 + }
257 +
258 + @Override
259 + public void onFailure(int errorCode) {
260 + runOnUiThread(() -> errorActivatingDialog());
261 + }
262 + };
263 +}
...@@ -280,7 +280,9 @@ public class GiftsForYouActivity extends Activity implements View.OnClickListene ...@@ -280,7 +280,9 @@ public class GiftsForYouActivity extends Activity implements View.OnClickListene
280 seasonalCLick.setImageUrl(dataItem.getSeasonalList().getImageUrl()); 280 seasonalCLick.setImageUrl(dataItem.getSeasonalList().getImageUrl());
281 EventBus.getDefault().post(new WarplyEventBusManager(seasonalCLick)); 281 EventBus.getDefault().post(new WarplyEventBusManager(seasonalCLick));
282 } else if (dataItem.getDataType() == 3) { 282 } else if (dataItem.getDataType() == 3) {
283 - 283 + Intent intent = new Intent(GiftsForYouActivity.this, ContextualActivity.class);
284 + intent.putExtra("ccms", dataItem.getCCMS());
285 + startActivity(intent);
284 } 286 }
285 }) 287 })
286 .doOnError(error -> { 288 .doOnError(error -> {
...@@ -412,7 +414,9 @@ public class GiftsForYouActivity extends Activity implements View.OnClickListene ...@@ -412,7 +414,9 @@ public class GiftsForYouActivity extends Activity implements View.OnClickListene
412 seasonalCLick.setImageUrl(dataItem.getSeasonalList().getImageUrl()); 414 seasonalCLick.setImageUrl(dataItem.getSeasonalList().getImageUrl());
413 EventBus.getDefault().post(new WarplyEventBusManager(seasonalCLick)); 415 EventBus.getDefault().post(new WarplyEventBusManager(seasonalCLick));
414 } else if (dataItem.getDataType() == 3) { 416 } else if (dataItem.getDataType() == 3) {
415 - 417 + Intent intent = new Intent(GiftsForYouActivity.this, ContextualActivity.class);
418 + intent.putExtra("ccms", dataItem.getCCMS());
419 + startActivity(intent);
416 } 420 }
417 }) 421 })
418 .doOnError(error -> { 422 .doOnError(error -> {
......
...@@ -200,7 +200,9 @@ public class MoreForYouActivity extends Activity implements View.OnClickListener ...@@ -200,7 +200,9 @@ public class MoreForYouActivity extends Activity implements View.OnClickListener
200 startActivity(WarpViewActivity.createIntentFromURL(this, WarplyManagerHelper.constructCampaignUrl(dataItem.getCampaign()))); 200 startActivity(WarpViewActivity.createIntentFromURL(this, WarplyManagerHelper.constructCampaignUrl(dataItem.getCampaign())));
201 } 201 }
202 } else if (dataItem.getDataType() == 2) { 202 } else if (dataItem.getDataType() == 2) {
203 - 203 + Intent intent = new Intent(MoreForYouActivity.this, ContextualActivity.class);
204 + intent.putExtra("ccms", dataItem.getCCMS());
205 + startActivity(intent);
204 } 206 }
205 }) 207 })
206 .doOnError(error -> { 208 .doOnError(error -> {
...@@ -269,7 +271,9 @@ public class MoreForYouActivity extends Activity implements View.OnClickListener ...@@ -269,7 +271,9 @@ public class MoreForYouActivity extends Activity implements View.OnClickListener
269 startActivity(WarpViewActivity.createIntentFromURL(this, WarplyManagerHelper.constructCampaignUrl(dataItem.getCampaign()))); 271 startActivity(WarpViewActivity.createIntentFromURL(this, WarplyManagerHelper.constructCampaignUrl(dataItem.getCampaign())));
270 } 272 }
271 } else if (dataItem.getDataType() == 2) { 273 } else if (dataItem.getDataType() == 2) {
272 - 274 + Intent intent = new Intent(MoreForYouActivity.this, ContextualActivity.class);
275 + intent.putExtra("ccms", dataItem.getCCMS());
276 + startActivity(intent);
273 } 277 }
274 }) 278 })
275 .doOnError(error -> { 279 .doOnError(error -> {
......
1 +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
2 + xmlns:app="http://schemas.android.com/apk/res-auto"
3 + xmlns:tools="http://schemas.android.com/tools"
4 + android:layout_width="match_parent"
5 + android:layout_height="match_parent"
6 + android:background="@android:color/white">
7 +
8 + <androidx.constraintlayout.widget.ConstraintLayout
9 + android:id="@+id/cl_loyalty_wallet_header"
10 + android:layout_width="match_parent"
11 + android:layout_height="50dp"
12 + android:background="@android:color/white">
13 +
14 + <ImageView
15 + android:id="@+id/iv_contextual_back"
16 + android:layout_width="20dp"
17 + android:layout_height="20dp"
18 + android:layout_marginStart="16dp"
19 + android:src="@drawable/ic_back"
20 + app:layout_constraintBottom_toBottomOf="parent"
21 + app:layout_constraintStart_toStartOf="parent"
22 + app:layout_constraintTop_toTopOf="parent" />
23 +
24 + <TextView
25 + android:layout_width="wrap_content"
26 + android:layout_height="wrap_content"
27 + android:textColor="@color/grey"
28 + android:textSize="17sp"
29 + android:textStyle="bold"
30 + app:layout_constraintBottom_toBottomOf="parent"
31 + app:layout_constraintEnd_toEndOf="parent"
32 + app:layout_constraintStart_toStartOf="parent"
33 + app:layout_constraintTop_toTopOf="parent" />
34 + </androidx.constraintlayout.widget.ConstraintLayout>
35 +
36 + <ScrollView
37 + android:layout_width="match_parent"
38 + android:layout_height="match_parent"
39 + android:fillViewport="true"
40 + android:layout_below="@+id/cl_loyalty_wallet_header">
41 +
42 + <androidx.constraintlayout.widget.ConstraintLayout
43 + android:layout_width="match_parent"
44 + android:layout_height="match_parent"
45 + android:background="@android:color/white">
46 +
47 + <androidx.constraintlayout.widget.ConstraintLayout
48 + android:id="@+id/cl_loyalty_info_view_inner"
49 + android:layout_width="match_parent"
50 + android:layout_height="match_parent"
51 + android:background="@drawable/shape_cos_loyalty_white"
52 + android:paddingBottom="48dp"
53 + app:layout_constraintEnd_toEndOf="parent"
54 + app:layout_constraintStart_toStartOf="parent"
55 + app:layout_constraintTop_toTopOf="parent">
56 +
57 + <com.github.siyamed.shapeimageview.mask.PorterShapeImageView
58 + android:id="@+id/imageView6"
59 + android:layout_width="match_parent"
60 + android:layout_height="224dp"
61 + android:layout_marginTop="4dp"
62 + android:scaleType="centerCrop"
63 + app:layout_constraintStart_toStartOf="parent"
64 + app:layout_constraintTop_toTopOf="parent"
65 + app:siShape="@drawable/shape_top_left_rounded"
66 + tools:src="@drawable/carousel_banner" />
67 +
68 + <TextView
69 + android:id="@+id/textView13"
70 + android:layout_width="match_parent"
71 + android:layout_height="wrap_content"
72 + android:layout_marginTop="32dp"
73 + android:gravity="center"
74 + android:paddingHorizontal="32dp"
75 + android:textColor="#415564"
76 + android:textSize="18sp"
77 + android:textStyle="bold"
78 + app:layout_constraintEnd_toEndOf="parent"
79 + app:layout_constraintHorizontal_bias="0.509"
80 + app:layout_constraintStart_toStartOf="parent"
81 + app:layout_constraintTop_toBottomOf="@+id/imageView6"
82 + tools:text="Πάρε δωρεάν μηνιαία πακέτα με πάνες στα supermarket Σκλαβενίτης!" />
83 +
84 + <TextView
85 + android:id="@+id/textView14"
86 + android:layout_width="match_parent"
87 + android:layout_height="wrap_content"
88 + android:layout_marginTop="16dp"
89 + android:gravity="center"
90 + android:paddingHorizontal="32dp"
91 + android:textColor="#415564"
92 + android:textSize="16sp"
93 + tools:text="test test"
94 + app:layout_constraintEnd_toEndOf="parent"
95 + app:layout_constraintStart_toStartOf="parent"
96 + app:layout_constraintTop_toBottomOf="@+id/textView13" />
97 +
98 + <LinearLayout
99 + android:id="@+id/ll_activate_button"
100 + android:layout_width="wrap_content"
101 + android:layout_height="wrap_content"
102 + android:layout_marginHorizontal="32dp"
103 + android:background="@drawable/selector_button_green"
104 + android:gravity="center"
105 + android:orientation="horizontal"
106 + android:paddingHorizontal="16dp"
107 + android:paddingVertical="8dp"
108 + app:layout_constraintBottom_toBottomOf="parent"
109 + app:layout_constraintEnd_toEndOf="parent"
110 + app:layout_constraintStart_toStartOf="parent">
111 +
112 + <TextView
113 + android:layout_width="wrap_content"
114 + android:layout_height="wrap_content"
115 + android:gravity="center"
116 + android:text="@string/cos_dlg_positive_button"
117 + android:textColor="@color/white"
118 + android:textFontWeight="600"
119 + android:textSize="17dp" />
120 + </LinearLayout>
121 +
122 + </androidx.constraintlayout.widget.ConstraintLayout>
123 + </androidx.constraintlayout.widget.ConstraintLayout>
124 + </ScrollView>
125 +</RelativeLayout>