Showing
5 changed files
with
100 additions
and
32 deletions
... | @@ -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-cosbeta28' | 5 | + PUBLISH_VERSION = '4.5.4-cosbeta28i' |
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; | ||
5 | import android.os.Bundle; | 4 | import android.os.Bundle; |
6 | import android.text.Html; | 5 | import android.text.Html; |
7 | import android.text.TextUtils; | 6 | import android.text.TextUtils; |
... | @@ -11,6 +10,8 @@ import android.widget.LinearLayout; | ... | @@ -11,6 +10,8 @@ import android.widget.LinearLayout; |
11 | import android.widget.ProgressBar; | 10 | import android.widget.ProgressBar; |
12 | import android.widget.TextView; | 11 | import android.widget.TextView; |
13 | 12 | ||
13 | +import androidx.appcompat.app.AlertDialog; | ||
14 | + | ||
14 | import com.bumptech.glide.Glide; | 15 | import com.bumptech.glide.Glide; |
15 | import com.bumptech.glide.load.engine.DiskCacheStrategy; | 16 | import com.bumptech.glide.load.engine.DiskCacheStrategy; |
16 | 17 | ||
... | @@ -19,8 +20,10 @@ import org.json.JSONObject; | ... | @@ -19,8 +20,10 @@ import org.json.JSONObject; |
19 | import ly.warp.sdk.R; | 20 | import ly.warp.sdk.R; |
20 | import ly.warp.sdk.io.callbacks.CallbackReceiver; | 21 | import ly.warp.sdk.io.callbacks.CallbackReceiver; |
21 | import ly.warp.sdk.io.models.Coupon; | 22 | import ly.warp.sdk.io.models.Coupon; |
23 | +import ly.warp.sdk.io.models.CouponList; | ||
22 | import ly.warp.sdk.io.models.Couponset; | 24 | import ly.warp.sdk.io.models.Couponset; |
23 | import ly.warp.sdk.io.request.WarplyRedeemCouponRequest; | 25 | import ly.warp.sdk.io.request.WarplyRedeemCouponRequest; |
26 | +import ly.warp.sdk.io.request.WarplyUserCouponsRequest; | ||
24 | import ly.warp.sdk.utils.managers.WarplyManager; | 27 | import ly.warp.sdk.utils.managers.WarplyManager; |
25 | 28 | ||
26 | 29 | ||
... | @@ -41,6 +44,7 @@ public class CouponsetInfoActivity extends Activity implements View.OnClickListe | ... | @@ -41,6 +44,7 @@ public class CouponsetInfoActivity extends Activity implements View.OnClickListe |
41 | private ProgressBar mPbLoading; | 44 | private ProgressBar mPbLoading; |
42 | private Coupon mCoupon; | 45 | private Coupon mCoupon; |
43 | private boolean mIsTermsPressed = false; | 46 | private boolean mIsTermsPressed = false; |
47 | + private AlertDialog mAlertDialogCouponset; | ||
44 | 48 | ||
45 | // =========================================================== | 49 | // =========================================================== |
46 | // Methods for/from SuperClass/Interfaces | 50 | // Methods for/from SuperClass/Interfaces |
... | @@ -136,6 +140,11 @@ public class CouponsetInfoActivity extends Activity implements View.OnClickListe | ... | @@ -136,6 +140,11 @@ public class CouponsetInfoActivity extends Activity implements View.OnClickListe |
136 | mCoupon.setDescription(mCouponset.getShortDescription()); | 140 | mCoupon.setDescription(mCouponset.getShortDescription()); |
137 | mCoupon.setImage(mCouponset.getImgPreview()); | 141 | mCoupon.setImage(mCouponset.getImgPreview()); |
138 | mCoupon.setName(mCouponset.getName()); | 142 | mCoupon.setName(mCouponset.getName()); |
143 | + new Thread(() -> { | ||
144 | + if (!Thread.currentThread().isInterrupted()) { | ||
145 | + WarplyManager.getUserCouponsWithCouponsets(new WarplyUserCouponsRequest(), mUserCouponsReceiver); | ||
146 | + } | ||
147 | + }).start(); | ||
139 | showDialog(true, 1); | 148 | showDialog(true, 1); |
140 | } else { | 149 | } else { |
141 | showDialog(false, status); | 150 | showDialog(false, status); |
... | @@ -150,41 +159,60 @@ public class CouponsetInfoActivity extends Activity implements View.OnClickListe | ... | @@ -150,41 +159,60 @@ public class CouponsetInfoActivity extends Activity implements View.OnClickListe |
150 | }; | 159 | }; |
151 | 160 | ||
152 | private void showDialog(boolean success, int status) { | 161 | private void showDialog(boolean success, int status) { |
153 | - Dialog dialog = new Dialog(this, R.style.PopUpDialog); | ||
154 | - dialog.setContentView(R.layout.dlg_success); | ||
155 | - dialog.getWindow().setBackgroundDrawableResource(R.drawable.banner_border_white); | ||
156 | - dialog.show(); | ||
157 | - | ||
158 | - LinearLayout mLlButton = dialog.findViewById(R.id.ll_dl_redeem); | ||
159 | - TextView tvTitle = dialog.findViewById(R.id.tv_dl_title); | ||
160 | - TextView tvSubtitle = dialog.findViewById(R.id.tv_dl_subtitle); | ||
161 | - | ||
162 | if (success) { | 162 | if (success) { |
163 | - tvTitle.setText(getString(R.string.cos_dlg_success_title)); | 163 | + mAlertDialogCouponset = new AlertDialog.Builder(this) |
164 | - tvSubtitle.setText(getString(R.string.cos_dlg_success_subtitle)); | 164 | + .setTitle(R.string.cos_dlg_success_couponset_title) |
165 | + .setMessage(R.string.cos_dlg_success_couponset_subtitle) | ||
166 | + .setPositiveButton(R.string.cos_dlg_positive_button2, (dialogPositive, whichPositive) -> { | ||
167 | + dialogPositive.dismiss(); | ||
168 | + if (success) { | ||
169 | + onBackPressed(); | ||
170 | + } | ||
171 | + }) | ||
172 | + .show(); | ||
165 | } else { | 173 | } else { |
166 | if (status == 3) { | 174 | if (status == 3) { |
167 | - tvTitle.setText(getString(R.string.cos_dlg_error_title)); | 175 | + mAlertDialogCouponset = new AlertDialog.Builder(this) |
168 | - tvSubtitle.setText(getString(R.string.cos_dlg_error_subtitle_non_buyable)); | 176 | + .setTitle(R.string.cos_dlg_error_title) |
177 | + .setMessage(R.string.cos_dlg_error_subtitle_non_buyable) | ||
178 | + .setPositiveButton(R.string.cos_dlg_positive_button2, (dialogPositive, whichPositive) -> { | ||
179 | + dialogPositive.dismiss(); | ||
180 | + }) | ||
181 | + .show(); | ||
169 | } else if (status == 5) { | 182 | } else if (status == 5) { |
170 | - tvTitle.setText(getString(R.string.cos_dlg_error_title)); | 183 | + mAlertDialogCouponset = new AlertDialog.Builder(this) |
171 | - tvSubtitle.setText(getString(R.string.cos_dlg_error_subtitle_no_points)); | 184 | + .setTitle(R.string.cos_dlg_error_title) |
185 | + .setMessage(R.string.cos_dlg_error_subtitle_no_points) | ||
186 | + .setPositiveButton(R.string.cos_dlg_positive_button2, (dialogPositive, whichPositive) -> { | ||
187 | + dialogPositive.dismiss(); | ||
188 | + }) | ||
189 | + .show(); | ||
172 | } else { | 190 | } else { |
173 | - tvTitle.setText(getString(R.string.cos_dlg_error_title)); | 191 | + mAlertDialogCouponset = new AlertDialog.Builder(this) |
174 | - tvSubtitle.setText(getString(R.string.cos_dlg_error_subtitle)); | 192 | + .setTitle(R.string.cos_dlg_error_title) |
193 | + .setMessage(R.string.cos_dlg_error_subtitle) | ||
194 | + .setPositiveButton(R.string.cos_dlg_positive_button2, (dialogPositive, whichPositive) -> { | ||
195 | + dialogPositive.dismiss(); | ||
196 | + }) | ||
197 | + .show(); | ||
175 | } | 198 | } |
176 | } | 199 | } |
177 | - | ||
178 | - mLlButton.setOnClickListener(view -> { | ||
179 | - dialog.dismiss(); | ||
180 | - if (success) { | ||
181 | - onBackPressed(); | ||
182 | - } | ||
183 | - }); | ||
184 | } | 200 | } |
185 | 201 | ||
186 | // =========================================================== | 202 | // =========================================================== |
187 | // Inner and Anonymous Classes | 203 | // Inner and Anonymous Classes |
188 | // =========================================================== | 204 | // =========================================================== |
189 | 205 | ||
206 | + private final CallbackReceiver<CouponList> mUserCouponsReceiver = new CallbackReceiver<CouponList>() { | ||
207 | + @Override | ||
208 | + public void onSuccess(CouponList result) { | ||
209 | + Thread.currentThread().interrupt(); | ||
210 | + } | ||
211 | + | ||
212 | + @Override | ||
213 | + public void onFailure(int errorCode) { | ||
214 | + Thread.currentThread().interrupt(); | ||
215 | + } | ||
216 | + }; | ||
217 | + | ||
190 | } | 218 | } | ... | ... |
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.content.Intent; | ||
4 | import android.os.Bundle; | 5 | import android.os.Bundle; |
5 | import android.text.TextUtils; | 6 | import android.text.TextUtils; |
6 | import android.util.Log; | 7 | import android.util.Log; |
... | @@ -15,6 +16,7 @@ import androidx.recyclerview.widget.RecyclerView; | ... | @@ -15,6 +16,7 @@ import androidx.recyclerview.widget.RecyclerView; |
15 | import org.greenrobot.eventbus.EventBus; | 16 | import org.greenrobot.eventbus.EventBus; |
16 | import org.json.JSONObject; | 17 | import org.json.JSONObject; |
17 | 18 | ||
19 | +import java.io.Serializable; | ||
18 | import java.util.ArrayList; | 20 | import java.util.ArrayList; |
19 | import java.util.HashMap; | 21 | import java.util.HashMap; |
20 | import java.util.HashSet; | 22 | import java.util.HashSet; |
... | @@ -22,6 +24,7 @@ import java.util.HashSet; | ... | @@ -22,6 +24,7 @@ import java.util.HashSet; |
22 | import ly.warp.sdk.R; | 24 | import ly.warp.sdk.R; |
23 | import ly.warp.sdk.io.models.Campaign; | 25 | import ly.warp.sdk.io.models.Campaign; |
24 | import ly.warp.sdk.io.models.CampaignList; | 26 | import ly.warp.sdk.io.models.CampaignList; |
27 | +import ly.warp.sdk.io.models.Couponset; | ||
25 | import ly.warp.sdk.io.models.LoyaltyContextualOfferModel; | 28 | import ly.warp.sdk.io.models.LoyaltyContextualOfferModel; |
26 | import ly.warp.sdk.io.models.LoyaltyGiftsForYouOfferClickEvent; | 29 | import ly.warp.sdk.io.models.LoyaltyGiftsForYouOfferClickEvent; |
27 | import ly.warp.sdk.io.models.LoyaltyGiftsForYouPackage; | 30 | import ly.warp.sdk.io.models.LoyaltyGiftsForYouPackage; |
... | @@ -130,6 +133,31 @@ public class GiftsForYouActivity extends Activity implements View.OnClickListene | ... | @@ -130,6 +133,31 @@ public class GiftsForYouActivity extends Activity implements View.OnClickListene |
130 | if (dataItem.getDataType() == 1) { | 133 | if (dataItem.getDataType() == 1) { |
131 | EventBus.getDefault().post(new WarplyEventBusManager(new LoyaltyGiftsForYouOfferClickEvent())); | 134 | EventBus.getDefault().post(new WarplyEventBusManager(new LoyaltyGiftsForYouOfferClickEvent())); |
132 | 135 | ||
136 | + if (dataItem.getCampaign().getType().equals("coupon")) { | ||
137 | + try { | ||
138 | + JSONObject campaignSettings = WarpJSONParser.getJSONFromString(dataItem.getCampaign().getCampaignTypeSettings()); | ||
139 | + if (campaignSettings != null) { | ||
140 | + if (campaignSettings.has("couponset")) { | ||
141 | + String cpnUuid = campaignSettings.optString("couponset"); | ||
142 | + for (Couponset cpns : WarplyManagerHelper.getCouponsets()) { | ||
143 | + if (cpns.getUuid().equals(cpnUuid)) { | ||
144 | + Intent intent = new Intent(GiftsForYouActivity.this, CouponsetInfoActivity.class); | ||
145 | + intent.putExtra("couponset", (Serializable) cpns); | ||
146 | + startActivity(intent); | ||
147 | + break; | ||
148 | + } | ||
149 | + } | ||
150 | + } else { | ||
151 | + startActivity(WarpViewActivity.createIntentFromURL(this, WarplyManagerHelper.constructCampaignUrl(dataItem.getCampaign()))); | ||
152 | + } | ||
153 | + } | ||
154 | + } catch (Exception exception) { | ||
155 | + exception.printStackTrace(); | ||
156 | + } | ||
157 | + | ||
158 | + return; | ||
159 | + } | ||
160 | + | ||
133 | try { | 161 | try { |
134 | JSONObject extraFields = WarpJSONParser.getJSONFromString(dataItem.getCampaign().getExtraFields()); | 162 | JSONObject extraFields = WarpJSONParser.getJSONFromString(dataItem.getCampaign().getExtraFields()); |
135 | if (extraFields != null) { | 163 | if (extraFields != null) { | ... | ... |
... | @@ -69,6 +69,7 @@ public class Campaign implements Parcelable, Serializable { | ... | @@ -69,6 +69,7 @@ public class Campaign implements Parcelable, Serializable { |
69 | private static final String DISPLAY_TYPE = "display_type"; | 69 | private static final String DISPLAY_TYPE = "display_type"; |
70 | private static final String ACTIONS = "actions"; | 70 | private static final String ACTIONS = "actions"; |
71 | private static final String BUS_ID = "busId"; | 71 | private static final String BUS_ID = "busId"; |
72 | + private static final String CAMPAIGN_TYPE_SETTINGS = "campaign_type_settings"; | ||
72 | 73 | ||
73 | /* Member variables of the Campaign object */ | 74 | /* Member variables of the Campaign object */ |
74 | 75 | ||
... | @@ -95,6 +96,7 @@ public class Campaign implements Parcelable, Serializable { | ... | @@ -95,6 +96,7 @@ public class Campaign implements Parcelable, Serializable { |
95 | private String indexUrl; | 96 | private String indexUrl; |
96 | private String busId; | 97 | private String busId; |
97 | private ArrayList<CampaignAction> actions = new ArrayList<>(); | 98 | private ArrayList<CampaignAction> actions = new ArrayList<>(); |
99 | + private final String campaignTypeSettings; | ||
98 | 100 | ||
99 | /** | 101 | /** |
100 | * Basic constructor used to create an object from a String, representing a | 102 | * Basic constructor used to create an object from a String, representing a |
... | @@ -141,6 +143,7 @@ public class Campaign implements Parcelable, Serializable { | ... | @@ -141,6 +143,7 @@ public class Campaign implements Parcelable, Serializable { |
141 | this.deliveryMethod = json.optString(DELIVERY_METHOD); | 143 | this.deliveryMethod = json.optString(DELIVERY_METHOD); |
142 | this.displayType = json.optString(DISPLAY_TYPE); | 144 | this.displayType = json.optString(DISPLAY_TYPE); |
143 | this.busId = json.optString(BUS_ID); | 145 | this.busId = json.optString(BUS_ID); |
146 | + this.campaignTypeSettings = json.optString(CAMPAIGN_TYPE_SETTINGS); | ||
144 | 147 | ||
145 | JSONArray actions = json.optJSONArray(ACTIONS); | 148 | JSONArray actions = json.optJSONArray(ACTIONS); |
146 | if (actions != null) { | 149 | if (actions != null) { |
... | @@ -176,6 +179,7 @@ public class Campaign implements Parcelable, Serializable { | ... | @@ -176,6 +179,7 @@ public class Campaign implements Parcelable, Serializable { |
176 | this.displayType = source.readString(); | 179 | this.displayType = source.readString(); |
177 | this.actions = source.readArrayList(CampaignAction.class.getClassLoader()); | 180 | this.actions = source.readArrayList(CampaignAction.class.getClassLoader()); |
178 | this.busId = source.readString(); | 181 | this.busId = source.readString(); |
182 | + this.campaignTypeSettings = source.readString(); | ||
179 | } | 183 | } |
180 | 184 | ||
181 | @Override | 185 | @Override |
... | @@ -195,14 +199,15 @@ public class Campaign implements Parcelable, Serializable { | ... | @@ -195,14 +199,15 @@ public class Campaign implements Parcelable, Serializable { |
195 | dest.writeInt(this.opened); | 199 | dest.writeInt(this.opened); |
196 | dest.writeInt(this.isNew ? 1 : 0); | 200 | dest.writeInt(this.isNew ? 1 : 0); |
197 | dest.writeString(this.logoUrl); | 201 | dest.writeString(this.logoUrl); |
198 | - dest.writeString(extraFields); | 202 | + dest.writeString(this.extraFields); |
199 | - dest.writeString(type); | 203 | + dest.writeString(this.type); |
200 | dest.writeInt(this.expired ? 1 : 0); | 204 | dest.writeInt(this.expired ? 1 : 0); |
201 | dest.writeInt(this.show ? 1 : 0); | 205 | dest.writeInt(this.show ? 1 : 0); |
202 | - dest.writeString(deliveryMethod); | 206 | + dest.writeString(this.deliveryMethod); |
203 | - dest.writeString(displayType); | 207 | + dest.writeString(this.displayType); |
204 | - dest.writeList(actions); | 208 | + dest.writeList(this.actions); |
205 | - dest.writeString(busId); | 209 | + dest.writeString(this.busId); |
210 | + dest.writeString(this.campaignTypeSettings); | ||
206 | } | 211 | } |
207 | 212 | ||
208 | /** | 213 | /** |
... | @@ -236,6 +241,7 @@ public class Campaign implements Parcelable, Serializable { | ... | @@ -236,6 +241,7 @@ public class Campaign implements Parcelable, Serializable { |
236 | jObj.putOpt(DELIVERY_METHOD, this.deliveryMethod); | 241 | jObj.putOpt(DELIVERY_METHOD, this.deliveryMethod); |
237 | jObj.putOpt(DISPLAY_TYPE, this.displayType); | 242 | jObj.putOpt(DISPLAY_TYPE, this.displayType); |
238 | jObj.put(BUS_ID, this.busId); | 243 | jObj.put(BUS_ID, this.busId); |
244 | + jObj.put(CAMPAIGN_TYPE_SETTINGS, this.campaignTypeSettings); | ||
239 | } catch (JSONException e) { | 245 | } catch (JSONException e) { |
240 | if (WarpConstants.DEBUG) { | 246 | if (WarpConstants.DEBUG) { |
241 | e.printStackTrace(); | 247 | e.printStackTrace(); |
... | @@ -465,6 +471,10 @@ public class Campaign implements Parcelable, Serializable { | ... | @@ -465,6 +471,10 @@ public class Campaign implements Parcelable, Serializable { |
465 | isNew = aNew; | 471 | isNew = aNew; |
466 | } | 472 | } |
467 | 473 | ||
474 | + public String getCampaignTypeSettings() { | ||
475 | + return campaignTypeSettings; | ||
476 | + } | ||
477 | + | ||
468 | @Override | 478 | @Override |
469 | public int describeContents() { | 479 | public int describeContents() { |
470 | return 0; | 480 | return 0; | ... | ... |
... | @@ -102,6 +102,8 @@ | ... | @@ -102,6 +102,8 @@ |
102 | <string name="cos_dlg_positive_coupon_subtitle">Είσαι σίγουρος ότι θέλεις να κάνεις δώρο το κουπόνι σου;</string> | 102 | <string name="cos_dlg_positive_coupon_subtitle">Είσαι σίγουρος ότι θέλεις να κάνεις δώρο το κουπόνι σου;</string> |
103 | <string name="cos_dlg_negative_button3">Αποστολή</string> | 103 | <string name="cos_dlg_negative_button3">Αποστολή</string> |
104 | <string name="cos_dlg_error_subtitle2">Τα πεδία δεν είναι σωστά</string> | 104 | <string name="cos_dlg_error_subtitle2">Τα πεδία δεν είναι σωστά</string> |
105 | + <string name="cos_dlg_success_couponset_title">Το κουπόνι σου ενεργοποιήθηκε</string> | ||
106 | + <string name="cos_dlg_success_couponset_subtitle">Μπορείς να το βρεις στην αρχική οθόνη της εφαρμογής και στην ενότητα ενεργά δώρα!</string> | ||
105 | 107 | ||
106 | <string-array name="coupons_array"> | 108 | <string-array name="coupons_array"> |
107 | <item>Κουπόνια</item> | 109 | <item>Κουπόνια</item> | ... | ... |
-
Please register or login to post a comment