Panagiotis Triantafyllou

new version

...@@ -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-cosbeta23' 5 + PUBLISH_VERSION = '4.5.4-cosbeta24'
6 PUBLISH_ARTIFACT_ID = 'warply-android-sdk' 6 PUBLISH_ARTIFACT_ID = 'warply-android-sdk'
7 } 7 }
8 8
......
1 package ly.warp.sdk.activities; 1 package ly.warp.sdk.activities;
2 2
3 import android.app.Activity; 3 import android.app.Activity;
4 -import android.app.Dialog; 4 +import android.content.Context;
5 +import android.content.Intent;
5 import android.os.Bundle; 6 import android.os.Bundle;
6 import android.text.TextUtils; 7 import android.text.TextUtils;
7 import android.util.Log; 8 import android.util.Log;
9 +import android.view.LayoutInflater;
8 import android.view.View; 10 import android.view.View;
11 +import android.view.ViewGroup;
12 +import android.widget.EditText;
9 import android.widget.ImageView; 13 import android.widget.ImageView;
10 import android.widget.LinearLayout; 14 import android.widget.LinearLayout;
11 import android.widget.RelativeLayout; 15 import android.widget.RelativeLayout;
12 import android.widget.TextView; 16 import android.widget.TextView;
13 17
18 +import androidx.appcompat.app.AlertDialog;
19 +
14 import com.bumptech.glide.Glide; 20 import com.bumptech.glide.Glide;
15 import com.bumptech.glide.load.engine.DiskCacheStrategy; 21 import com.bumptech.glide.load.engine.DiskCacheStrategy;
22 +import com.google.android.material.bottomsheet.BottomSheetDialog;
23 +
24 +import org.json.JSONArray;
25 +import org.json.JSONException;
26 +import org.json.JSONObject;
27 +
28 +import java.util.ArrayList;
16 29
17 import ly.warp.sdk.R; 30 import ly.warp.sdk.R;
18 import ly.warp.sdk.io.callbacks.CallbackReceiver; 31 import ly.warp.sdk.io.callbacks.CallbackReceiver;
19 import ly.warp.sdk.io.models.Consumer; 32 import ly.warp.sdk.io.models.Consumer;
20 import ly.warp.sdk.io.models.Coupon; 33 import ly.warp.sdk.io.models.Coupon;
34 +import ly.warp.sdk.io.request.CosmoteCouponSharingRequest;
35 +import ly.warp.sdk.io.request.CosmoteRetrieveSharingRequest;
21 import ly.warp.sdk.io.request.WarplyConsumerRequest; 36 import ly.warp.sdk.io.request.WarplyConsumerRequest;
22 import ly.warp.sdk.utils.managers.WarplyManager; 37 import ly.warp.sdk.utils.managers.WarplyManager;
23 38
...@@ -28,16 +43,21 @@ public class CouponShareActivity extends Activity implements View.OnClickListene ...@@ -28,16 +43,21 @@ public class CouponShareActivity extends Activity implements View.OnClickListene
28 // Constants 43 // Constants
29 // =========================================================== 44 // ===========================================================
30 45
46 + private final String MSISDN_LIST = "msisdnList";
47 +
31 // =========================================================== 48 // ===========================================================
32 // Fields 49 // Fields
33 // =========================================================== 50 // ===========================================================
34 51
35 private ImageView mIvBack, mIvCouponPhoto; 52 private ImageView mIvBack, mIvCouponPhoto;
36 - private TextView mTvCouponTitle; 53 + private TextView mTvCouponTitle, mTvPhoneHeader;
37 private Coupon mCoupon; 54 private Coupon mCoupon;
38 private Consumer mConsumer; 55 private Consumer mConsumer;
39 private RelativeLayout mRlSenderView; 56 private RelativeLayout mRlSenderView;
40 private LinearLayout mLlShareButton; 57 private LinearLayout mLlShareButton;
58 + private String mSender = "";
59 + private EditText mEdtReceiver;
60 + private AlertDialog mAlertDialogSuccessSharing, mAlertDialogErrorSharing, mAlertDialogCouponAskSharing;
41 61
42 // =========================================================== 62 // ===========================================================
43 // Methods for/from SuperClass/Interfaces 63 // Methods for/from SuperClass/Interfaces
...@@ -55,6 +75,8 @@ public class CouponShareActivity extends Activity implements View.OnClickListene ...@@ -55,6 +75,8 @@ public class CouponShareActivity extends Activity implements View.OnClickListene
55 mIvCouponPhoto = findViewById(R.id.imageView6); 75 mIvCouponPhoto = findViewById(R.id.imageView6);
56 mRlSenderView = findViewById(R.id.ll_share_view); 76 mRlSenderView = findViewById(R.id.ll_share_view);
57 mLlShareButton = findViewById(R.id.ll_share_button); 77 mLlShareButton = findViewById(R.id.ll_share_button);
78 + mTvPhoneHeader = findViewById(R.id.tv_phone);
79 + mEdtReceiver = findViewById(R.id.et_phone);
58 80
59 initViews(); 81 initViews();
60 } 82 }
...@@ -83,7 +105,11 @@ public class CouponShareActivity extends Activity implements View.OnClickListene ...@@ -83,7 +105,11 @@ public class CouponShareActivity extends Activity implements View.OnClickListene
83 return; 105 return;
84 } 106 }
85 if (view.getId() == R.id.ll_share_button) { 107 if (view.getId() == R.id.ll_share_button) {
86 - 108 + if (!TextUtils.isEmpty(mSender) && !mTvPhoneHeader.getText().toString().equals(R.string.cos_coupon_share_sender)) {
109 + askSharingDialog();
110 + } else {
111 + errorSharingDialog2();
112 + }
87 } 113 }
88 } 114 }
89 115
...@@ -114,24 +140,95 @@ public class CouponShareActivity extends Activity implements View.OnClickListene ...@@ -114,24 +140,95 @@ public class CouponShareActivity extends Activity implements View.OnClickListene
114 } 140 }
115 141
116 private void showSharingDialog() { 142 private void showSharingDialog() {
117 - Dialog dialog = new Dialog(this, R.style.PopUpDialog); 143 + final BottomSheetDialog bottomSheetDialog = new BottomSheetDialog(this);
118 - dialog.setContentView(R.layout.dl_dialog); 144 + bottomSheetDialog.setContentView(R.layout.dl_share);
119 - dialog.getWindow().setBackgroundDrawableResource(R.drawable.banner_border_white); 145 + LinearLayout parent = bottomSheetDialog.findViewById(R.id.ll_share_dialog_view_inner);
120 - dialog.show(); 146 +
121 - 147 + ImageView dialogClose = (ImageView) bottomSheetDialog.findViewById(R.id.iv_sender_list_close);
122 -// TextView mTvDlTitle = dialog.findViewById(R.id.tv_dl_subtitle); 148 + dialogClose.setOnClickListener(view -> bottomSheetDialog.dismiss());
123 -// LinearLayout mLlRedeem = dialog.findViewById(R.id.ll_dl_redeem); 149 +
124 -// 150 + if (mConsumer != null) {
125 -// mTvDlTitle.setText(String.format(getResources().getString(R.string.cos_dl_title), parameter)); 151 + try {
126 - 152 + JSONObject profMeta = new JSONObject(mConsumer.getProfileMetadata());
127 -// mLlRedeem.setOnClickListener(view -> { 153 + if (profMeta != null) {
128 -// if (mUniqueCampaignList != null && !mUniqueCampaignList.isEmpty()) { 154 + JSONArray msisdnList = new JSONArray();
129 -// if (mUniqueCampaignList.containsKey("lucky_draw") && mUniqueCampaignList.get("lucky_draw").size() > 0) { 155 + msisdnList = profMeta.optJSONArray(MSISDN_LIST);
130 -// startActivity(WarpViewActivity.createIntentFromURL(this, WarplyManagerHelper.constructCampaignUrl(mUniqueCampaignList.get("lucky_draw").get(0)))); 156 + if (msisdnList != null && msisdnList.length() > 0) {
131 -// dialog.dismiss(); 157 + for (int i = 0; i < msisdnList.length(); i++) {
132 -// } 158 + LayoutInflater vi = (LayoutInflater) getApplicationContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
133 -// } 159 + LinearLayout v = (LinearLayout) vi.inflate(R.layout.item_share, null);
134 -// }); 160 + TextView textView = (TextView) v.findViewById(R.id.tv_phone_share);
161 + textView.setText(msisdnList.optString(i));
162 + textView.setOnClickListener(view -> {
163 + TextView tv = (TextView) view;
164 + mTvPhoneHeader.setText(tv.getText().toString());
165 + mSender = tv.getText().toString();
166 + bottomSheetDialog.dismiss();
167 + });
168 + parent.addView(v, 0, new ViewGroup.LayoutParams(
169 + ViewGroup.LayoutParams.MATCH_PARENT,
170 + ViewGroup.LayoutParams.WRAP_CONTENT));
171 + }
172 + }
173 + }
174 + } catch (JSONException e) {
175 + e.printStackTrace();
176 + }
177 + }
178 +
179 + bottomSheetDialog.show();
180 + }
181 +
182 + private void acceptSharingDialog() {
183 + mAlertDialogSuccessSharing = new AlertDialog.Builder(this)
184 + .setTitle(R.string.cos_dlg_success_title)
185 + .setMessage(R.string.cos_dlg_positive_coupon_text)
186 + .setPositiveButton(R.string.cos_dlg_positive_button2, (dialogPositive, whichPositive) -> {
187 + dialogPositive.dismiss();
188 + })
189 + .show();
190 + }
191 +
192 + private void errorSharingDialog() {
193 + mAlertDialogErrorSharing = new AlertDialog.Builder(this)
194 + .setTitle(R.string.cos_dlg_error_title)
195 + .setMessage(R.string.cos_dlg_error_subtitle)
196 + .setPositiveButton(R.string.cos_dlg_positive_button2, (dialogPositive, whichPositive) -> {
197 + dialogPositive.dismiss();
198 + })
199 + .show();
200 + }
201 +
202 + private void errorSharingDialog2() {
203 + mAlertDialogErrorSharing = new AlertDialog.Builder(this)
204 + .setTitle(R.string.cos_dlg_error_title)
205 + .setMessage(R.string.cos_dlg_error_subtitle2)
206 + .setPositiveButton(R.string.cos_dlg_positive_button2, (dialogPositive, whichPositive) -> {
207 + dialogPositive.dismiss();
208 + })
209 + .show();
210 + }
211 +
212 + private void askSharingDialog() {
213 + mAlertDialogCouponAskSharing = new AlertDialog.Builder(this)
214 + .setTitle(R.string.cos_dlg_positive_coupon_title)
215 + .setMessage(R.string.cos_dlg_positive_coupon_subtitle)
216 + .setPositiveButton(R.string.cos_dlg_negative_button3, (dialogPositive, whichPositive) -> {
217 + new Thread(() -> {
218 + if (!Thread.currentThread().isInterrupted()) {
219 + WarplyManager.cosmoteCouponSharing(new CosmoteCouponSharingRequest()
220 + .setCoupon(mCoupon.getCoupon())
221 + .setSender(mSender)
222 + .setReceiver(mEdtReceiver.getText().toString())
223 + , mCouponSharingCallback);
224 + }
225 + Thread.currentThread().interrupt();
226 + }).start();
227 + })
228 + .setNegativeButton(R.string.cos_dlg_negative_button2, (dialogNegative, whichNegative) -> {
229 + dialogNegative.dismiss();
230 + })
231 + .show();
135 } 232 }
136 233
137 private final CallbackReceiver<Consumer> mConsumerCallback = new CallbackReceiver<Consumer>() { 234 private final CallbackReceiver<Consumer> mConsumerCallback = new CallbackReceiver<Consumer>() {
...@@ -146,6 +243,25 @@ public class CouponShareActivity extends Activity implements View.OnClickListene ...@@ -146,6 +243,25 @@ public class CouponShareActivity extends Activity implements View.OnClickListene
146 } 243 }
147 }; 244 };
148 245
246 + private final CallbackReceiver<JSONObject> mCouponSharingCallback = 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 + acceptSharingDialog();
253 + else
254 + errorSharingDialog();
255 + });
256 + }
257 +
258 + @Override
259 + public void onFailure(int errorCode) {
260 + Log.v("COUPON_SHARE", String.valueOf(errorCode));
261 + runOnUiThread(() -> errorSharingDialog());
262 + }
263 + };
264 +
149 // =========================================================== 265 // ===========================================================
150 // Inner and Anonymous Classes 266 // Inner and Anonymous Classes
151 // =========================================================== 267 // ===========================================================
......
...@@ -3,6 +3,7 @@ package ly.warp.sdk.activities; ...@@ -3,6 +3,7 @@ package ly.warp.sdk.activities;
3 import android.app.Activity; 3 import android.app.Activity;
4 import android.os.Bundle; 4 import android.os.Bundle;
5 import android.text.TextUtils; 5 import android.text.TextUtils;
6 +import android.util.Log;
6 import android.view.View; 7 import android.view.View;
7 import android.widget.ImageView; 8 import android.widget.ImageView;
8 import android.widget.LinearLayout; 9 import android.widget.LinearLayout;
...@@ -143,6 +144,7 @@ public class GiftsForYouActivity extends Activity implements View.OnClickListene ...@@ -143,6 +144,7 @@ public class GiftsForYouActivity extends Activity implements View.OnClickListene
143 144
144 private ArrayList<MergedGifts> mergeDatasets(CampaignList campaignList, ArrayList<LoyaltyGiftsForYouPackage> seasonalList) { 145 private ArrayList<MergedGifts> mergeDatasets(CampaignList campaignList, ArrayList<LoyaltyGiftsForYouPackage> seasonalList) {
145 if (campaignList != null && campaignList.size() > 0) { 146 if (campaignList != null && campaignList.size() > 0) {
147 + Log.v("GIFTS_FOR_YOU", String.valueOf(campaignList.size()));
146 for (Campaign campaign : campaignList) { 148 for (Campaign campaign : campaignList) {
147 MergedGifts data = new MergedGifts(); 149 MergedGifts data = new MergedGifts();
148 data.setCampaign(campaign); 150 data.setCampaign(campaign);
......
...@@ -2,6 +2,7 @@ package ly.warp.sdk.activities; ...@@ -2,6 +2,7 @@ package ly.warp.sdk.activities;
2 2
3 import android.app.Activity; 3 import android.app.Activity;
4 import android.os.Bundle; 4 import android.os.Bundle;
5 +import android.util.Log;
5 import android.view.View; 6 import android.view.View;
6 import android.widget.ImageView; 7 import android.widget.ImageView;
7 import android.widget.LinearLayout; 8 import android.widget.LinearLayout;
...@@ -85,6 +86,7 @@ public class MoreForYouActivity extends Activity implements View.OnClickListener ...@@ -85,6 +86,7 @@ public class MoreForYouActivity extends Activity implements View.OnClickListener
85 // mLlMorePopup.setVisibility(View.VISIBLE); 86 // mLlMorePopup.setVisibility(View.VISIBLE);
86 87
87 if (WarplyManagerHelper.getUniqueCampaignList().get("more_for_you") != null && WarplyManagerHelper.getUniqueCampaignList().get("more_for_you").size() > 0) { 88 if (WarplyManagerHelper.getUniqueCampaignList().get("more_for_you") != null && WarplyManagerHelper.getUniqueCampaignList().get("more_for_you").size() > 0) {
89 + Log.v("MORE_FOR_YOU", String.valueOf(WarplyManagerHelper.getUniqueCampaignList().get("more_for_you").size()));
88 mRecyclerMore.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false)); 90 mRecyclerMore.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));
89 mAdapterMore = new ProfileCampaignAdapter(this, WarplyManagerHelper.getUniqueCampaignList().get("more_for_you"), true); 91 mAdapterMore = new ProfileCampaignAdapter(this, WarplyManagerHelper.getUniqueCampaignList().get("more_for_you"), true);
90 mRecyclerMore.setAdapter(mAdapterMore); 92 mRecyclerMore.setAdapter(mAdapterMore);
......
...@@ -102,7 +102,7 @@ public class Consumer implements Parcelable, Serializable { ...@@ -102,7 +102,7 @@ public class Consumer implements Parcelable, Serializable {
102 private String nickname = ""; 102 private String nickname = "";
103 private JSONObject optin = new JSONObject(); 103 private JSONObject optin = new JSONObject();
104 private boolean passwordSet = false; 104 private boolean passwordSet = false;
105 - private JSONObject profileMetadata = new JSONObject(); 105 + private String profileMetadata = "";
106 private double redeemedPoints = 0.0d; 106 private double redeemedPoints = 0.0d;
107 private double retrievedPoints = 0.0d; 107 private double retrievedPoints = 0.0d;
108 private String salutation = ""; 108 private String salutation = "";
...@@ -160,7 +160,7 @@ public class Consumer implements Parcelable, Serializable { ...@@ -160,7 +160,7 @@ public class Consumer implements Parcelable, Serializable {
160 this.sms_segmentation = this.optin.optBoolean(KEY_PERSON_SMS); 160 this.sms_segmentation = this.optin.optBoolean(KEY_PERSON_SMS);
161 } 161 }
162 this.passwordSet = json.optBoolean(PASSWORD_SET); 162 this.passwordSet = json.optBoolean(PASSWORD_SET);
163 - this.profileMetadata = json.optJSONObject(PROFILE_METADATA); 163 + this.profileMetadata = json.optString(PROFILE_METADATA);
164 this.redeemedPoints = json.optDouble(REDEEMED_POINTS); 164 this.redeemedPoints = json.optDouble(REDEEMED_POINTS);
165 this.retrievedPoints = json.optDouble(RETRIEVED_POINTS); 165 this.retrievedPoints = json.optDouble(RETRIEVED_POINTS);
166 this.salutation = json.optString(SALUTATION); 166 this.salutation = json.optString(SALUTATION);
...@@ -389,7 +389,7 @@ public class Consumer implements Parcelable, Serializable { ...@@ -389,7 +389,7 @@ public class Consumer implements Parcelable, Serializable {
389 return passwordSet; 389 return passwordSet;
390 } 390 }
391 391
392 - public JSONObject getProfileMetadata() { 392 + public String getProfileMetadata() {
393 return profileMetadata; 393 return profileMetadata;
394 } 394 }
395 395
......
1 +package ly.warp.sdk.io.request;
2 +
3 +import android.util.Base64;
4 +
5 +import org.json.JSONException;
6 +import org.json.JSONObject;
7 +
8 +import java.io.UnsupportedEncodingException;
9 +import java.security.MessageDigest;
10 +import java.security.NoSuchAlgorithmException;
11 +import java.util.HashMap;
12 +
13 +import ly.warp.sdk.utils.constants.WarpConstants;
14 +
15 +/**
16 + * Created by Panagiotis Triantafyllou on 04-July-22.
17 + */
18 +
19 +public class CosmoteCouponSharingRequest {
20 +
21 + // ===========================================================
22 + // Constants
23 + // ===========================================================
24 +
25 + private final String KEY_MAPP = "coupon";
26 + private final String KEY_ACTION = "action";
27 + private final String KEY_ACTION_VALUE = "share";
28 + private final String KEY_COUPON = "coupon";
29 + private final String KEY_SENDER = "sender_msisdn";
30 + private final String KEY_RECEIVER = "receiver_msisdn";
31 +
32 + // ===========================================================
33 + // Fields
34 + // ===========================================================
35 +
36 + private HashMap<String, String> mFilters;
37 + private long mCacheUpdateInterval = 0;
38 + private String mCoupon = "";
39 + private String mSender = "";
40 + private String mReceiver = "";
41 +
42 + // ===========================================================
43 + // Constructor
44 + // ===========================================================
45 +
46 + /**
47 + * Default constructor of CosmoteCouponSharingRequest, initializes an empty filters HashMap
48 + */
49 + public CosmoteCouponSharingRequest() {
50 + mFilters = new HashMap<>();
51 + }
52 +
53 + public CosmoteCouponSharingRequest(CosmoteCouponSharingRequest copy) {
54 + if (copy != null) {
55 + this.mFilters = copy.mFilters;
56 + this.mCacheUpdateInterval = copy.mCacheUpdateInterval;
57 + }
58 + }
59 +
60 + // ===========================================================
61 + // Methods for/from SuperClass/Interfaces
62 + // ===========================================================
63 +
64 + @Override
65 + public boolean equals(Object object) {
66 + if (object instanceof CosmoteCouponSharingRequest) {
67 + CosmoteCouponSharingRequest other = (CosmoteCouponSharingRequest) object;
68 + return other == this || (this.mFilters == other.mFilters || (this.mFilters != null && this.mFilters.equals(other.mFilters)));
69 + }
70 + return false;
71 + }
72 +
73 + @Override
74 + public int hashCode() {
75 + return mFilters.hashCode();
76 + }
77 +
78 + // ===========================================================
79 + // Methods
80 + // ===========================================================
81 +
82 + // ===========================================================
83 + // Getter & Setter
84 + // ===========================================================
85 +
86 + public CosmoteCouponSharingRequest setCoupon(String coupon) {
87 + mCoupon = coupon;
88 + return this;
89 + }
90 +
91 + public CosmoteCouponSharingRequest setSender(String sender) {
92 + mSender = sender;
93 + return this;
94 + }
95 +
96 + public CosmoteCouponSharingRequest setReceiver(String receiver) {
97 + mReceiver = receiver;
98 + return this;
99 + }
100 +
101 + /**
102 + * Call this to get how often the cached data will be updated.
103 + *
104 + * @return mCacheUpdateInterval
105 + */
106 + public long getCacheUpdateInterval() {
107 + return mCacheUpdateInterval;
108 + }
109 +
110 + /**
111 + * Call this to set how often the cached data will be updated.
112 + *
113 + * @param updateInterval The time that data will be cached
114 + * @return CosmoteCouponSharingRequest
115 + */
116 + public CosmoteCouponSharingRequest setCacheUpdateInterval(long updateInterval) {
117 +
118 + this.mCacheUpdateInterval = updateInterval;
119 + if (mCacheUpdateInterval < 0) {
120 + mCacheUpdateInterval = 0;
121 + }
122 + return this;
123 + }
124 +
125 + /**
126 + * Call this to check if the Application uses Cache
127 + *
128 + * @return <p>true - the Application is using Cache</p>
129 + * <p>false - the Application is not using Cache</p>
130 + */
131 + public boolean isUseCache() {
132 + return mCacheUpdateInterval > 0;
133 + }
134 +
135 + /**
136 + * Call this to check whether the cached data need to be updated
137 + *
138 + * @param useCache <p>true - the Application is using Cache</p>
139 + * <p>false - the Application is not using Cache</p>
140 + * @return CosmoteCouponSharingRequest
141 + */
142 + public CosmoteCouponSharingRequest setUseCache(boolean useCache) {
143 +
144 + if (useCache) {
145 + mCacheUpdateInterval = mCacheUpdateInterval > 0 ? mCacheUpdateInterval
146 + : WarpConstants.INBOX_UPDATE_INTERVAL;
147 + } else {
148 + mCacheUpdateInterval = 0;
149 + }
150 + return this;
151 + }
152 +
153 + /**
154 + * Call this to build the offers Json object
155 + *
156 + * @return bodyJsonObject
157 + */
158 + public JSONObject toJson() {
159 + JSONObject bodyJsonObject = new JSONObject();
160 + try {
161 + JSONObject extraJson = new JSONObject();
162 + extraJson.putOpt(KEY_ACTION, KEY_ACTION_VALUE);
163 + extraJson.putOpt(KEY_COUPON, mCoupon);
164 + extraJson.putOpt(KEY_SENDER, mSender);
165 + extraJson.putOpt(KEY_RECEIVER, mReceiver);
166 + bodyJsonObject.putOpt(KEY_MAPP, extraJson);
167 + } catch (JSONException e) {
168 + if (WarpConstants.DEBUG)
169 + e.printStackTrace();
170 + }
171 + return bodyJsonObject;
172 + }
173 +
174 + public String getSignature() {
175 + String signature = mFilters != null && mFilters.size() > 0 ? String.valueOf(mFilters.hashCode()) : "default_cosmote_coupon_sharing_request";
176 + try {
177 + byte[] hash = MessageDigest.getInstance("SHA-256").digest(signature.getBytes("UTF-8"));
178 + signature = Base64.encodeToString(hash, Base64.NO_WRAP);
179 + } catch (NullPointerException | NoSuchAlgorithmException
180 + | UnsupportedEncodingException e) {
181 + e.printStackTrace();
182 + }
183 + return signature;
184 + }
185 +}
...@@ -273,6 +273,16 @@ public class WarplyManagerHelper { ...@@ -273,6 +273,16 @@ public class WarplyManagerHelper {
273 Log.v("CCMS_PRESSED", ccmsItem.getId() + " " + ccmsItem.getOfferName()); 273 Log.v("CCMS_PRESSED", ccmsItem.getId() + " " + ccmsItem.getOfferName());
274 item.setNew(false); 274 item.setNew(false);
275 String tempAudienceLevel = ccmsItem.getEligibleAssets() != null && ccmsItem.getEligibleAssets().size() > 0 ? "MSISDN" : "GUID"; 275 String tempAudienceLevel = ccmsItem.getEligibleAssets() != null && ccmsItem.getEligibleAssets().size() > 0 ? "MSISDN" : "GUID";
276 + String assets = "";
277 + if (ccmsItem.getEligibleAssets() != null && ccmsItem.getEligibleAssets().size() > 0) {
278 + for (String singleAsset : ccmsItem.getEligibleAssets()) {
279 + assets = assets + singleAsset + ",";
280 + }
281 +
282 + if (!TextUtils.isEmpty(assets)) {
283 + assets = assets.substring(0, assets.length() - 1);
284 + }
285 + }
276 String url = item.getIndexUrl() 286 String url = item.getIndexUrl()
277 + "?web_id=" + WarpUtils.getWebId(Warply.getWarplyContext()) 287 + "?web_id=" + WarpUtils.getWebId(Warply.getWarplyContext())
278 + "&app_uuid=" + WarplyProperty.getAppUuid(Warply.getWarplyContext()) 288 + "&app_uuid=" + WarplyProperty.getAppUuid(Warply.getWarplyContext())
...@@ -301,7 +311,8 @@ public class WarplyManagerHelper { ...@@ -301,7 +311,8 @@ public class WarplyManagerHelper {
301 + "&WAVE=" + ccmsItem.getWave() 311 + "&WAVE=" + ccmsItem.getWave()
302 + "&VALIDITY=" + ccmsItem.getValidity() 312 + "&VALIDITY=" + ccmsItem.getValidity()
303 + "&TREATMENT_CODE=" + ccmsItem.getTreatmentCode() 313 + "&TREATMENT_CODE=" + ccmsItem.getTreatmentCode()
304 - + "&OfferAudienceLevel=" + tempAudienceLevel; 314 + + "&OfferAudienceLevel=" + tempAudienceLevel
315 + + "&ASSETS=" + assets;
305 316
306 317
307 // if (mConsumer != null) 318 // if (mConsumer != null)
...@@ -328,6 +339,16 @@ public class WarplyManagerHelper { ...@@ -328,6 +339,16 @@ public class WarplyManagerHelper {
328 if (camp.getSessionUUID().equals(item.getLoyaltyCampaignId())) { 339 if (camp.getSessionUUID().equals(item.getLoyaltyCampaignId())) {
329 Log.v("CCMS_PRESSED", item.getId() + " " + item.getOfferName()); 340 Log.v("CCMS_PRESSED", item.getId() + " " + item.getOfferName());
330 String tempAudienceLevel = item.getEligibleAssets() != null && item.getEligibleAssets().size() > 0 ? "MSISDN" : "GUID"; 341 String tempAudienceLevel = item.getEligibleAssets() != null && item.getEligibleAssets().size() > 0 ? "MSISDN" : "GUID";
342 + String assets = "";
343 + if (item.getEligibleAssets() != null && item.getEligibleAssets().size() > 0) {
344 + for (String singleAsset : item.getEligibleAssets()) {
345 + assets = assets + singleAsset + ",";
346 + }
347 +
348 + if (!TextUtils.isEmpty(assets)) {
349 + assets = assets.substring(0, assets.length() - 1);
350 + }
351 + }
331 url = camp.getIndexUrl() 352 url = camp.getIndexUrl()
332 + "?web_id=" + WarpUtils.getWebId(Warply.getWarplyContext()) 353 + "?web_id=" + WarpUtils.getWebId(Warply.getWarplyContext())
333 + "&app_uuid=" + WarplyProperty.getAppUuid(Warply.getWarplyContext()) 354 + "&app_uuid=" + WarplyProperty.getAppUuid(Warply.getWarplyContext())
...@@ -356,7 +377,8 @@ public class WarplyManagerHelper { ...@@ -356,7 +377,8 @@ public class WarplyManagerHelper {
356 + "&WAVE=" + item.getWave() 377 + "&WAVE=" + item.getWave()
357 + "&VALIDITY=" + item.getValidity() 378 + "&VALIDITY=" + item.getValidity()
358 + "&TREATMENT_CODE=" + item.getTreatmentCode() 379 + "&TREATMENT_CODE=" + item.getTreatmentCode()
359 - + "&OfferAudienceLevel=" + tempAudienceLevel; 380 + + "&OfferAudienceLevel=" + tempAudienceLevel
381 + + "&ASSETS=" + assets;
360 break; 382 break;
361 } 383 }
362 } 384 }
...@@ -515,10 +537,6 @@ public class WarplyManagerHelper { ...@@ -515,10 +537,6 @@ public class WarplyManagerHelper {
515 return WarpUtils.getUserTag(Warply.getWarplyContext()); 537 return WarpUtils.getUserTag(Warply.getWarplyContext());
516 } 538 }
517 539
518 - public static void setDFYCouponPurchase(String couponcode, String merchantid) {
519 -
520 - }
521 -
522 /** 540 /**
523 * Set the List with active D4Y coupons 541 * Set the List with active D4Y coupons
524 */ 542 */
......
...@@ -64,6 +64,7 @@ import ly.warp.sdk.io.models.ProductList; ...@@ -64,6 +64,7 @@ import ly.warp.sdk.io.models.ProductList;
64 import ly.warp.sdk.io.models.TagsCategoriesList; 64 import ly.warp.sdk.io.models.TagsCategoriesList;
65 import ly.warp.sdk.io.models.TagsList; 65 import ly.warp.sdk.io.models.TagsList;
66 import ly.warp.sdk.io.models.TransactionsList; 66 import ly.warp.sdk.io.models.TransactionsList;
67 +import ly.warp.sdk.io.request.CosmoteCouponSharingRequest;
67 import ly.warp.sdk.io.request.CosmoteRetrieveSharingRequest; 68 import ly.warp.sdk.io.request.CosmoteRetrieveSharingRequest;
68 import ly.warp.sdk.io.request.CosmoteSharingRequest; 69 import ly.warp.sdk.io.request.CosmoteSharingRequest;
69 import ly.warp.sdk.io.request.PacingDetailsRequest; 70 import ly.warp.sdk.io.request.PacingDetailsRequest;
...@@ -1484,4 +1485,43 @@ public class WarplyManager { ...@@ -1484,4 +1485,43 @@ public class WarplyManager {
1484 }, 1485 },
1485 request.getSignature())); 1486 request.getSignature()));
1486 } 1487 }
1488 +
1489 + public static void cosmoteCouponSharing(CosmoteCouponSharingRequest request, final CallbackReceiver<JSONObject> receiver) {
1490 + WarpUtils.log("************* WARPLY Cosmote Coupon Sharing Request ********************");
1491 + WarpUtils.log("[WARP Trace] WARPLY Cosmote Coupon Sharing Request is active");
1492 + WarpUtils.log("**************************************************");
1493 +
1494 + Warply.postReceiveMicroappData(true, "context", request.toJson(), new CallbackReceiver<JSONObject>() {
1495 + @Override
1496 + public void onSuccess(JSONObject result) {
1497 + int status = result.optInt("status", 2);
1498 + if (status == 1)
1499 + receiver.onSuccess(result);
1500 + else
1501 + receiver.onFailure(status);
1502 + }
1503 +
1504 + @Override
1505 + public void onFailure(int errorCode) {
1506 + if (errorCode == 401) {
1507 + refreshToken(new WarplyRefreshTokenRequest(), new CallbackReceiver<JSONObject>() {
1508 + @Override
1509 + public void onSuccess(JSONObject result) {
1510 + int status = result.optInt("status", 2);
1511 + if (status == 1)
1512 + cosmoteCouponSharing(request, receiver);
1513 + else
1514 + receiver.onFailure(status);
1515 + }
1516 +
1517 + @Override
1518 + public void onFailure(int errorCode) {
1519 + receiver.onFailure(errorCode);
1520 + }
1521 + });
1522 + } else
1523 + receiver.onFailure(errorCode);
1524 + }
1525 + });
1526 + }
1487 } 1527 }
......
1 +<?xml version="1.0" encoding="utf-8"?>
2 +<shape xmlns:android="http://schemas.android.com/apk/res/android">
3 + <solid android:color="#FFFFFF" />
4 + <corners
5 + android:topLeftRadius="12dp"
6 + android:topRightRadius="12dp" />
7 +</shape>
...\ No newline at end of file ...\ No newline at end of file
1 +<?xml version="1.0" encoding="utf-8"?>
2 +<shape xmlns:android="http://schemas.android.com/apk/res/android"
3 + android:shape="rectangle">
4 + <corners
5 + android:topLeftRadius="12dp"
6 + android:topRightRadius="12dp" />
7 +
8 + <solid android:color="@android:color/white" />
9 +</shape>
...\ No newline at end of file ...\ No newline at end of file
...@@ -9,8 +9,8 @@ ...@@ -9,8 +9,8 @@
9 android:id="@+id/cl_bill_header" 9 android:id="@+id/cl_bill_header"
10 android:layout_width="match_parent" 10 android:layout_width="match_parent"
11 android:layout_height="80dp" 11 android:layout_height="80dp"
12 - app:layout_constraintTop_toTopOf="parent" 12 + android:background="@android:color/white"
13 - android:background="@android:color/white"> 13 + app:layout_constraintTop_toTopOf="parent">
14 14
15 <ImageView 15 <ImageView
16 android:id="@+id/iv_coupons_close" 16 android:id="@+id/iv_coupons_close"
...@@ -19,9 +19,9 @@ ...@@ -19,9 +19,9 @@
19 android:layout_marginStart="24dp" 19 android:layout_marginStart="24dp"
20 android:layout_marginTop="4dp" 20 android:layout_marginTop="4dp"
21 android:src="@drawable/ic_back" 21 android:src="@drawable/ic_back"
22 + app:layout_constraintBottom_toBottomOf="parent"
22 app:layout_constraintStart_toStartOf="parent" 23 app:layout_constraintStart_toStartOf="parent"
23 - app:layout_constraintTop_toTopOf="parent" 24 + app:layout_constraintTop_toTopOf="parent" />
24 - app:layout_constraintBottom_toBottomOf="parent"/>
25 25
26 <TextView 26 <TextView
27 android:id="@+id/textView3" 27 android:id="@+id/textView3"
...@@ -43,14 +43,13 @@ ...@@ -43,14 +43,13 @@
43 android:layout_height="match_parent" 43 android:layout_height="match_parent"
44 android:layout_below="@+id/cl_bill_header" 44 android:layout_below="@+id/cl_bill_header"
45 android:layout_marginTop="1dp" 45 android:layout_marginTop="1dp"
46 - android:background="@drawable/shape_cos_loyalty" 46 + android:background="@drawable/shape_cos_loyalty">
47 - android:orientation="vertical">
48 47
49 <androidx.recyclerview.widget.RecyclerView 48 <androidx.recyclerview.widget.RecyclerView
50 android:id="@+id/rv_active_coupons" 49 android:id="@+id/rv_active_coupons"
51 android:layout_width="match_parent" 50 android:layout_width="match_parent"
52 android:layout_height="0dp" 51 android:layout_height="0dp"
53 - android:paddingTop="48dp" 52 + android:paddingTop="44dp"
54 app:layout_constraintBottom_toBottomOf="parent" 53 app:layout_constraintBottom_toBottomOf="parent"
55 app:layout_constraintEnd_toEndOf="parent" 54 app:layout_constraintEnd_toEndOf="parent"
56 app:layout_constraintStart_toStartOf="parent" 55 app:layout_constraintStart_toStartOf="parent"
...@@ -65,6 +64,6 @@ ...@@ -65,6 +64,6 @@
65 android:text="@string/cos_no_active_coupons" 64 android:text="@string/cos_no_active_coupons"
66 android:textColor="@color/grey" 65 android:textColor="@color/grey"
67 android:textSize="18sp" 66 android:textSize="18sp"
68 - android:visibility="gone" 67 + android:textStyle="bold"
69 - android:textStyle="bold" /> 68 + android:visibility="gone" />
70 </RelativeLayout> 69 </RelativeLayout>
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -165,7 +165,6 @@ ...@@ -165,7 +165,6 @@
165 android:layout_marginTop="64dp" 165 android:layout_marginTop="64dp"
166 android:background="@drawable/selector_button_green" 166 android:background="@drawable/selector_button_green"
167 android:gravity="center" 167 android:gravity="center"
168 - android:visibility="invisible"
169 android:orientation="horizontal" 168 android:orientation="horizontal"
170 android:paddingVertical="8dp" 169 android:paddingVertical="8dp"
171 app:layout_constraintEnd_toEndOf="parent" 170 app:layout_constraintEnd_toEndOf="parent"
......
...@@ -117,13 +117,11 @@ ...@@ -117,13 +117,11 @@
117 117
118 <ImageView 118 <ImageView
119 android:id="@+id/iv_arrow_down" 119 android:id="@+id/iv_arrow_down"
120 - android:layout_width="wrap_content" 120 + android:layout_width="16dp"
121 - android:layout_height="wrap_content" 121 + android:layout_height="16dp"
122 android:layout_alignParentEnd="true" 122 android:layout_alignParentEnd="true"
123 android:layout_centerVertical="true" 123 android:layout_centerVertical="true"
124 - android:rotation="90" 124 + android:src="@drawable/ic_arrow_down_dark" />
125 - android:src="@drawable/ic_arrow_right_white"
126 - android:tint="@color/blue_dark" />
127 </RelativeLayout> 125 </RelativeLayout>
128 126
129 <View 127 <View
...@@ -154,8 +152,8 @@ ...@@ -154,8 +152,8 @@
154 android:layout_centerVertical="true" 152 android:layout_centerVertical="true"
155 android:background="@android:color/transparent" 153 android:background="@android:color/transparent"
156 android:hint="@string/cos_coupon_share_hint" 154 android:hint="@string/cos_coupon_share_hint"
157 - android:textColor="@color/grey"
158 android:inputType="phone" 155 android:inputType="phone"
156 + android:textColor="@color/grey"
159 android:textColorHint="@color/cos_grey8" 157 android:textColorHint="@color/cos_grey8"
160 android:textSize="16sp" /> 158 android:textSize="16sp" />
161 </RelativeLayout> 159 </RelativeLayout>
...@@ -176,11 +174,11 @@ ...@@ -176,11 +174,11 @@
176 android:layout_height="wrap_content" 174 android:layout_height="wrap_content"
177 android:layout_marginHorizontal="32dp" 175 android:layout_marginHorizontal="32dp"
178 android:layout_marginTop="64dp" 176 android:layout_marginTop="64dp"
179 - android:paddingVertical="8dp"
180 - android:paddingHorizontal="16dp"
181 android:background="@drawable/selector_button_green" 177 android:background="@drawable/selector_button_green"
182 android:gravity="center" 178 android:gravity="center"
183 android:orientation="horizontal" 179 android:orientation="horizontal"
180 + android:paddingHorizontal="16dp"
181 + android:paddingVertical="8dp"
184 app:layout_constraintEnd_toEndOf="parent" 182 app:layout_constraintEnd_toEndOf="parent"
185 app:layout_constraintStart_toStartOf="parent" 183 app:layout_constraintStart_toStartOf="parent"
186 app:layout_constraintTop_toBottomOf="@+id/v_separator2"> 184 app:layout_constraintTop_toBottomOf="@+id/v_separator2">
...@@ -191,8 +189,8 @@ ...@@ -191,8 +189,8 @@
191 android:gravity="center" 189 android:gravity="center"
192 android:text="@string/cos_coupon_share_button" 190 android:text="@string/cos_coupon_share_button"
193 android:textColor="@color/white" 191 android:textColor="@color/white"
194 - android:textSize="17dp" 192 + android:textFontWeight="600"
195 - android:textFontWeight="600" /> 193 + android:textSize="17dp" />
196 </LinearLayout> 194 </LinearLayout>
197 </androidx.constraintlayout.widget.ConstraintLayout> 195 </androidx.constraintlayout.widget.ConstraintLayout>
198 </androidx.constraintlayout.widget.ConstraintLayout> 196 </androidx.constraintlayout.widget.ConstraintLayout>
......
1 +<?xml version="1.0" encoding="utf-8"?>
2 +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3 + android:id="@+id/rl_share_dialog_view"
4 + android:layout_width="match_parent"
5 + android:layout_height="match_parent"
6 + android:orientation="vertical">
7 +
8 + <RelativeLayout
9 + android:id="@+id/rl_sender_list"
10 + android:layout_width="match_parent"
11 + android:layout_height="wrap_content"
12 + android:layout_marginBottom="24dp"
13 + android:background="@drawable/shape_cos_white_rounded_top"
14 + android:paddingTop="16dp">
15 +
16 + <TextView
17 + android:id="@+id/tv_sender_value"
18 + android:layout_width="wrap_content"
19 + android:layout_height="wrap_content"
20 + android:layout_alignParentStart="true"
21 + android:layout_marginStart="24dp"
22 + android:text="@string/cos_coupon_share_sender"
23 + android:textColor="@color/grey"
24 + android:textSize="16sp"
25 + android:textStyle="bold" />
26 +
27 + <ImageView
28 + android:id="@+id/iv_sender_list_close"
29 + android:layout_width="16dp"
30 + android:layout_height="16dp"
31 + android:layout_alignParentEnd="true"
32 + android:layout_marginEnd="24dp"
33 + android:src="@drawable/ic_close" />
34 + </RelativeLayout>
35 +
36 + <LinearLayout
37 + android:id="@+id/ll_share_dialog_view_inner"
38 + android:layout_width="match_parent"
39 + android:layout_height="wrap_content"
40 + android:layout_marginHorizontal="12dp"
41 + android:orientation="vertical">
42 +
43 + </LinearLayout>
44 +</LinearLayout>
...\ No newline at end of file ...\ No newline at end of file
1 +<?xml version="1.0" encoding="utf-8"?>
2 +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3 + xmlns:app="http://schemas.android.com/apk/res-auto"
4 + xmlns:tools="http://schemas.android.com/tools"
5 + android:layout_width="match_parent"
6 + android:layout_height="wrap_content"
7 + android:orientation="vertical">
8 +
9 + <RelativeLayout
10 + android:id="@+id/ll_share_view2"
11 + android:layout_width="match_parent"
12 + android:layout_height="wrap_content"
13 + android:layout_marginHorizontal="24dp"
14 + android:layout_marginTop="16dp">
15 +
16 + <TextView
17 + android:id="@+id/tv_phone_share"
18 + android:layout_width="match_parent"
19 + android:layout_height="wrap_content"
20 + android:layout_alignParentStart="true"
21 + android:layout_centerVertical="true"
22 + android:background="@android:color/transparent"
23 + android:textColor="@color/grey"
24 + android:textFontWeight="600"
25 + android:textSize="16sp"
26 + tools:text="6987654322" />
27 + </RelativeLayout>
28 +
29 + <View
30 + android:id="@+id/v_separator2"
31 + android:layout_width="match_parent"
32 + android:layout_height="1dp"
33 + android:layout_marginTop="20dp"
34 + android:background="@color/cos_grey7"
35 + app:layout_constraintEnd_toEndOf="@+id/ll_share_view2"
36 + app:layout_constraintStart_toStartOf="@+id/ll_share_view2"
37 + app:layout_constraintTop_toBottomOf="@+id/ll_share_view2" />
38 +</LinearLayout>
...\ No newline at end of file ...\ No newline at end of file
...@@ -96,7 +96,12 @@ ...@@ -96,7 +96,12 @@
96 <string name="cos_coupon_share_hint">Καταχώρηση τηλεφώνου</string> 96 <string name="cos_coupon_share_hint">Καταχώρηση τηλεφώνου</string>
97 <string name="cos_coupon_share_button">Αποστολή με SMS</string> 97 <string name="cos_coupon_share_button">Αποστολή με SMS</string>
98 <string name="cod_dlg_reject_title">Απόρριψη δώρου</string> 98 <string name="cod_dlg_reject_title">Απόρριψη δώρου</string>
99 - <string name="cod_dlg_reject_subtitle">To δώρο αππορίφθηκε</string> 99 + <string name="cod_dlg_reject_subtitle">To δώρο απορρίφθηκε</string>
100 + <string name="cos_dlg_positive_coupon_text">Μόλις έκανες δώρο ένα κουπόνι!</string>
101 + <string name="cos_dlg_positive_coupon_title">Στείλε δώρο</string>
102 + <string name="cos_dlg_positive_coupon_subtitle">Είσαι σίγουρος ότι θέλεις να κάνεις δώρο το κουπόνι σου;</string>
103 + <string name="cos_dlg_negative_button3">Αποστολή</string>
104 + <string name="cos_dlg_error_subtitle2">Τα πεδία δεν είναι σωστά</string>
100 105
101 <string-array name="coupons_array"> 106 <string-array name="coupons_array">
102 <item>Κουπόνια</item> 107 <item>Κουπόνια</item>
......