Panagiotis Triantafyllou

latest changes and fixes

......@@ -52,7 +52,12 @@
android:screenOrientation="portrait" />
<activity
android:name="ly.warp.sdk.activities.ListForYouActivity"
android:name="ly.warp.sdk.activities.GiftsForYouActivity"
android:exported="false"
android:screenOrientation="portrait" />
<activity
android:name="ly.warp.sdk.activities.MoreForYouActivity"
android:exported="false"
android:screenOrientation="portrait" />
......
......@@ -21,7 +21,6 @@ import java.util.HashMap;
import ly.warp.sdk.R;
import ly.warp.sdk.Warply;
import ly.warp.sdk.db.WarplyDBHelper;
import ly.warp.sdk.fragments.HomeFragment;
import ly.warp.sdk.fragments.LoyaltyFragment;
import ly.warp.sdk.io.callbacks.CallbackReceiver;
......@@ -36,7 +35,6 @@ import ly.warp.sdk.io.request.WarplyConsumerRequest;
import ly.warp.sdk.io.request.WarplyGetCouponsetsRequest;
import ly.warp.sdk.io.request.WarplyInboxRequest;
import ly.warp.sdk.io.request.WarplyUserCouponsRequest;
import ly.warp.sdk.utils.WarpUtils;
import ly.warp.sdk.utils.WarplyManagerHelper;
import ly.warp.sdk.utils.WarplyProperty;
import ly.warp.sdk.utils.managers.WarplyManager;
......@@ -147,14 +145,7 @@ public class BaseFragmentActivity extends FragmentActivity implements Navigation
mLlRedeem.setOnClickListener(view -> {
if (mUniqueCampaignList != null && !mUniqueCampaignList.isEmpty()) {
if (mUniqueCampaignList.containsKey("lucky_draw") && mUniqueCampaignList.get("lucky_draw").size() > 0) {
String tempUrl = WarplyManagerHelper.constructCampaignUrl(mUniqueCampaignList.get("lucky_draw").get(0));
if (mConsumer != null)
tempUrl = tempUrl + "&auth_token=" + (mConsumer.getUuid());
else
tempUrl = tempUrl + "&auth_token=";
startActivity(WarpViewActivity.createIntentFromURL(this, tempUrl));
startActivity(WarpViewActivity.createIntentFromURL(this, WarplyManagerHelper.constructCampaignUrl(mUniqueCampaignList.get("lucky_draw").get(0))));
dialog.dismiss();
}
}
......
......@@ -67,14 +67,7 @@ public class BillPaymentActivity extends Activity implements View.OnClickListene
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
if (intent.hasExtra("channel")) {
String tempUrl = WarplyManagerHelper.constructCampaignUrl(WarplyManagerHelper.getUniqueCampaignList().get("lucky_draw").get(0));
if (WarplyManagerHelper.getConsumer() != null)
tempUrl = tempUrl + "&auth_token=" + (WarplyManagerHelper.getConsumer().getUuid());
else
tempUrl = tempUrl + "&auth_token=";
startActivity(WarpViewActivity.createIntentFromURL(this, tempUrl));
startActivity(WarpViewActivity.createIntentFromURL(this, WarplyManagerHelper.constructCampaignUrl(WarplyManagerHelper.getUniqueCampaignList().get("lucky_draw").get(0))));
}
}
......@@ -168,14 +161,7 @@ public class BillPaymentActivity extends Activity implements View.OnClickListene
mClLuckyDraw.setOnClickListener(view -> {
if (WarplyManagerHelper.getUniqueCampaignList() != null && !WarplyManagerHelper.getUniqueCampaignList().isEmpty()) {
if (WarplyManagerHelper.getUniqueCampaignList().containsKey("lucky_draw") && WarplyManagerHelper.getUniqueCampaignList().get("lucky_draw").size() > 0) {
String tempUrl = WarplyManagerHelper.constructCampaignUrl(WarplyManagerHelper.getUniqueCampaignList().get("lucky_draw").get(0));
if (WarplyManagerHelper.getConsumer() != null)
tempUrl = tempUrl + "&auth_token=" + (WarplyManagerHelper.getConsumer().getUuid());
else
tempUrl = tempUrl + "&auth_token=";
startActivity(WarpViewActivity.createIntentFromURL(this, tempUrl));
startActivity(WarpViewActivity.createIntentFromURL(this, WarplyManagerHelper.constructCampaignUrl(WarplyManagerHelper.getUniqueCampaignList().get("lucky_draw").get(0))));
dialog.dismiss();
}
}
......
......@@ -19,6 +19,7 @@ import org.json.JSONObject;
import ly.warp.sdk.R;
import ly.warp.sdk.io.callbacks.CallbackReceiver;
import ly.warp.sdk.io.models.Coupon;
import ly.warp.sdk.io.models.Couponset;
import ly.warp.sdk.io.request.WarplyRedeemCouponRequest;
import ly.warp.sdk.utils.managers.WarplyManager;
......@@ -39,6 +40,7 @@ public class CouponsetInfoActivity extends Activity implements View.OnClickListe
private Couponset mCouponset;
private LinearLayout mLlRedeem;
private ProgressBar mPbLoading;
private Coupon mCoupon;
// ===========================================================
// Methods for/from SuperClass/Interfaces
......@@ -111,7 +113,16 @@ public class CouponsetInfoActivity extends Activity implements View.OnClickListe
@Override
public void onSuccess(JSONObject result) {
mPbLoading.setVisibility(View.GONE);
int status = result.optInt("status");
if (status == 1) {
mCoupon = new Coupon(result.optJSONObject("result"));
mCoupon.setDescription(mCouponset.getShortDescription());
mCoupon.setImage(mCouponset.getImgPreview());
mCoupon.setName(mCouponset.getName());
showDialog(true, 1);
} else {
showDialog(false, status);
}
}
@Override
......@@ -150,7 +161,7 @@ public class CouponsetInfoActivity extends Activity implements View.OnClickListe
mLlButton.setOnClickListener(view -> {
dialog.dismiss();
if (success) {
//TODO: go to coupon
onBackPressed();
}
});
}
......
......@@ -25,7 +25,7 @@ import ly.warp.sdk.views.adapters.CouponsetsAdapter;
import ly.warp.sdk.views.adapters.ProfileCampaignAdapter;
public class ListForYouActivity extends Activity implements View.OnClickListener {
public class GiftsForYouActivity extends Activity implements View.OnClickListener {
// ===========================================================
// Constants
......@@ -50,7 +50,7 @@ public class ListForYouActivity extends Activity implements View.OnClickListener
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_list_for_you);
setContentView(R.layout.activity_gifts_for_you);
getCampaignsBySubcategory();
......@@ -95,14 +95,7 @@ public class ListForYouActivity extends Activity implements View.OnClickListener
mRecyclerGifts.setAdapter(mAdapterGifts);
mAdapterGifts.getPositionClicks()
.doOnNext(gift -> {
String tempUrl = WarplyManagerHelper.constructCampaignUrl(gift);
if (WarplyManagerHelper.getConsumer() != null)
tempUrl = tempUrl + "&auth_token=" + (WarplyManagerHelper.getConsumer().getUuid());
else
tempUrl = tempUrl + "&auth_token=";
startActivity(WarpViewActivity.createIntentFromURL(this, tempUrl));
startActivity(WarpViewActivity.createIntentFromURL(this, WarplyManagerHelper.constructCampaignUrl(gift)));
})
.doOnError(error -> {
})
......@@ -117,14 +110,7 @@ public class ListForYouActivity extends Activity implements View.OnClickListener
mRecyclerRewards.setAdapter(mAdapterRewards);
mAdapterRewards.getPositionClicks()
.doOnNext(reward -> {
String tempUrl = WarplyManagerHelper.constructCampaignUrl(reward);
if (WarplyManagerHelper.getConsumer() != null)
tempUrl = tempUrl + "&auth_token=" + (WarplyManagerHelper.getConsumer().getUuid());
else
tempUrl = tempUrl + "&auth_token=";
startActivity(WarpViewActivity.createIntentFromURL(this, tempUrl));
startActivity(WarpViewActivity.createIntentFromURL(this, WarplyManagerHelper.constructCampaignUrl(reward)));
})
.doOnError(error -> {
})
......@@ -139,11 +125,7 @@ public class ListForYouActivity extends Activity implements View.OnClickListener
mRecyclerCoupons.setAdapter(mAdapterCoupons);
mAdapterCoupons.getPositionClicks()
.doOnNext(couponset -> {
// Intent intent = new Intent(ListForYouActivity.this, CouponInfoActivity.class);
// intent.putExtra("coupon", (Serializable) coupon);
// startActivity(intent);
Intent intent = new Intent(ListForYouActivity.this, CouponsetInfoActivity.class);
Intent intent = new Intent(GiftsForYouActivity.this, CouponsetInfoActivity.class);
intent.putExtra("couponset", (Serializable) couponset);
startActivity(intent);
})
......
......@@ -92,14 +92,7 @@ public class LoyaltyActivity extends Activity implements View.OnClickListener,
if (camp == null)
return;
String tempUrl = WarplyManagerHelper.constructCampaignUrl(camp);
if (WarplyManagerHelper.getConsumer() != null)
tempUrl = tempUrl + "&auth_token=" + (WarplyManagerHelper.getConsumer().getUuid());
else
tempUrl = tempUrl + "&auth_token=";
startActivity(WarpViewActivity.createIntentFromURL(LoyaltyActivity.this, tempUrl));
startActivity(WarpViewActivity.createIntentFromURL(LoyaltyActivity.this, WarplyManagerHelper.constructCampaignUrl(camp)));
}
}
......
package ly.warp.sdk.activities;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import ly.warp.sdk.R;
import ly.warp.sdk.utils.WarplyManagerHelper;
import ly.warp.sdk.views.adapters.ProfileCampaignAdapter;
public class MoreForYouActivity extends Activity implements View.OnClickListener {
// ===========================================================
// Constants
// ===========================================================
// ===========================================================
// Fields
// ===========================================================
private ImageView mIvBack;
private RecyclerView mRecyclerMore;
private TextView mTvTitle;
private ProfileCampaignAdapter mAdapterMore;
// ===========================================================
// Methods for/from SuperClass/Interfaces
// ===========================================================
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_more_for_you);
mIvBack = findViewById(R.id.iv_list_close);
mTvTitle = findViewById(R.id.textView3);
mRecyclerMore = findViewById(R.id.rv_more);
initViews();
}
@Override
public void onResume() {
super.onResume();
}
@Override
public void onClick(View view) {
if (view.getId() == R.id.iv_list_close) {
onBackPressed();
}
}
// ===========================================================
// Methods
// ===========================================================
private void initViews() {
mIvBack.setOnClickListener(this);
mTvTitle.setText(getIntent().getStringExtra("title"));
if (WarplyManagerHelper.getUniqueCampaignList().get("more_for_you") != null && WarplyManagerHelper.getUniqueCampaignList().get("more_for_you").size() > 0) {
mRecyclerMore.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false));
mAdapterMore = new ProfileCampaignAdapter(this, WarplyManagerHelper.getUniqueCampaignList().get("more_for_you"));
mRecyclerMore.setAdapter(mAdapterMore);
mAdapterMore.getPositionClicks()
.doOnNext(gift -> {
startActivity(WarpViewActivity.createIntentFromURL(this, WarplyManagerHelper.constructCampaignUrl(gift)));
})
.doOnError(error -> {
})
.subscribe();
} else {
mRecyclerMore.setVisibility(View.GONE);
}
}
// ===========================================================
// Inner and Anonymous Classes
// ===========================================================
}
......@@ -77,14 +77,7 @@ public class HomeFragment extends Fragment implements View.OnClickListener {
mRecyclerCampaigns.setAdapter(mAdapterCampaigns);
mAdapterCampaigns.getPositionClicks()
.doOnNext(campaign -> {
String tempUrl = WarplyManagerHelper.constructCampaignUrl(campaign);
if (WarplyManagerHelper.getConsumer() != null)
tempUrl = tempUrl + "&auth_token=" + (WarplyManagerHelper.getConsumer().getUuid());
else
tempUrl = tempUrl + "&auth_token=";
startActivity(WarpViewActivity.createIntentFromURL(getContext(), tempUrl));
startActivity(WarpViewActivity.createIntentFromURL(getContext(), WarplyManagerHelper.constructCampaignUrl(campaign)));
})
.doOnError(error -> {
})
......
......@@ -15,8 +15,9 @@ import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import ly.warp.sdk.R;
import ly.warp.sdk.activities.ListForYouActivity;
import ly.warp.sdk.activities.GiftsForYouActivity;
import ly.warp.sdk.activities.LoyaltyActivity;
import ly.warp.sdk.activities.MoreForYouActivity;
import ly.warp.sdk.activities.WarpViewActivity;
import ly.warp.sdk.utils.WarplyManagerHelper;
import ly.warp.sdk.views.adapters.ProfileCampaignAdapter;
......@@ -73,14 +74,7 @@ public class LoyaltyFragment extends Fragment implements View.OnClickListener {
mRecyclerDeals.setAdapter(mAdapterDeals);
mAdapterDeals.getPositionClicks()
.doOnNext(deal -> {
String tempUrl = WarplyManagerHelper.constructCampaignUrl(deal);
if (WarplyManagerHelper.getConsumer() != null)
tempUrl = tempUrl + "&auth_token=" + (WarplyManagerHelper.getConsumer().getUuid());
else
tempUrl = tempUrl + "&auth_token=";
startActivity(WarpViewActivity.createIntentFromURL(getContext(), tempUrl));
startActivity(WarpViewActivity.createIntentFromURL(getContext(), WarplyManagerHelper.constructCampaignUrl(deal)));
})
.doOnError(error -> {
})
......@@ -97,14 +91,7 @@ public class LoyaltyFragment extends Fragment implements View.OnClickListener {
mRecyclerGifts.setAdapter(mAdapterGifts);
mAdapterGifts.getPositionClicks()
.doOnNext(gift -> {
String tempUrl = WarplyManagerHelper.constructCampaignUrl(gift);
if (WarplyManagerHelper.getConsumer() != null)
tempUrl = tempUrl + "&auth_token=" + (WarplyManagerHelper.getConsumer().getUuid());
else
tempUrl = tempUrl + "&auth_token=";
startActivity(WarpViewActivity.createIntentFromURL(getContext(), tempUrl));
startActivity(WarpViewActivity.createIntentFromURL(getContext(), WarplyManagerHelper.constructCampaignUrl(gift)));
})
.doOnError(error -> {
})
......@@ -121,14 +108,7 @@ public class LoyaltyFragment extends Fragment implements View.OnClickListener {
mRecyclerMore.setAdapter(mAdapterMore);
mAdapterMore.getPositionClicks()
.doOnNext(more -> {
String tempUrl = WarplyManagerHelper.constructCampaignUrl(more);
if (WarplyManagerHelper.getConsumer() != null)
tempUrl = tempUrl + "&auth_token=" + (WarplyManagerHelper.getConsumer().getUuid());
else
tempUrl = tempUrl + "&auth_token=";
startActivity(WarpViewActivity.createIntentFromURL(getContext(), tempUrl));
startActivity(WarpViewActivity.createIntentFromURL(getContext(), WarplyManagerHelper.constructCampaignUrl(more)));
})
.doOnError(error -> {
})
......@@ -146,9 +126,16 @@ public class LoyaltyFragment extends Fragment implements View.OnClickListener {
return;
}
if (view.getId() == R.id.iv_more2) {
Intent intent = new Intent(getContext(), ListForYouActivity.class);
Intent intent = new Intent(getContext(), GiftsForYouActivity.class);
intent.putExtra("title", getString(R.string.cos_gifts_title));
startActivity(intent);
return;
}
if (view.getId() == R.id.iv_more3) {
Intent intent = new Intent(getContext(), MoreForYouActivity.class);
intent.putExtra("title", getString(R.string.cos_more_title));
startActivity(intent);
return;
}
}
......
......@@ -68,6 +68,7 @@ public class Campaign implements Parcelable, Serializable {
private static final String DELIVERY_METHOD = "delivery_method";
private static final String DISPLAY_TYPE = "display_type";
private static final String ACTIONS = "actions";
private static final String BUS_ID = "busId";
/* Member variables of the Campaign object */
......@@ -83,7 +84,7 @@ public class Campaign implements Parcelable, Serializable {
private final String title;
private final int sorting;
private final int opened;
private final boolean isNew;
private boolean isNew;
private final String logoUrl;
private final String extraFields;
private final String type;
......@@ -92,6 +93,7 @@ public class Campaign implements Parcelable, Serializable {
private String deliveryMethod;
private String displayType;
private String indexUrl;
private String busId;
private ArrayList<CampaignAction> actions = new ArrayList<>();
/**
......@@ -138,6 +140,7 @@ public class Campaign implements Parcelable, Serializable {
this.show = json.optBoolean(SHOW);
this.deliveryMethod = json.optString(DELIVERY_METHOD);
this.displayType = json.optString(DISPLAY_TYPE);
this.busId = json.optString(BUS_ID);
JSONArray actions = json.optJSONArray(ACTIONS);
if (actions != null) {
......@@ -172,6 +175,7 @@ public class Campaign implements Parcelable, Serializable {
this.deliveryMethod = source.readString();
this.displayType = source.readString();
this.actions = source.readArrayList(CampaignAction.class.getClassLoader());
this.busId = source.readString();
}
@Override
......@@ -198,6 +202,7 @@ public class Campaign implements Parcelable, Serializable {
dest.writeString(deliveryMethod);
dest.writeString(displayType);
dest.writeList(actions);
dest.writeString(busId);
}
/**
......@@ -230,6 +235,7 @@ public class Campaign implements Parcelable, Serializable {
jObj.putOpt(SHOW, this.show);
jObj.putOpt(DELIVERY_METHOD, this.deliveryMethod);
jObj.putOpt(DISPLAY_TYPE, this.displayType);
jObj.put(BUS_ID, this.busId);
} catch (JSONException e) {
if (WarpConstants.DEBUG) {
e.printStackTrace();
......@@ -447,6 +453,18 @@ public class Campaign implements Parcelable, Serializable {
return actions;
}
public String getBusId() {
return busId;
}
public void setBusId(String busId) {
this.busId = busId;
}
public void setNew(boolean aNew) {
isNew = aNew;
}
@Override
public int describeContents() {
return 0;
......
......@@ -46,6 +46,7 @@ public class WarplyManagerHelper {
private static CouponsetsList mCouponsetsList = new CouponsetsList();
public static String constructCampaignUrl(Campaign item) {
item.setNew(false);
String url = item.getIndexUrl()
+ "?web_id=" + WarpUtils.getWebId(Warply.getWarplyContext())
+ "&app_uuid=" + WarplyProperty.getAppUuid(Warply.getWarplyContext())
......@@ -55,6 +56,12 @@ public class WarplyManagerHelper {
+ "&refresh_token=" + WarplyDBHelper.getInstance(Warply.getWarplyContext()).getAuthValue("refresh_token")
+ "&client_id=" + WarplyDBHelper.getInstance(Warply.getWarplyContext()).getClientValue("client_id")
+ "&client_secret=" + WarplyDBHelper.getInstance(Warply.getWarplyContext()).getClientValue("client_secret");
if (mConsumer != null)
url = url + "&auth_token=" + (mConsumer.getUuid());
else
url = url + "&auth_token=";
return url;
}
......
......@@ -23,7 +23,7 @@
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/cos_profile_reward"
android:text="@string/cos_profile_title"
android:textColor="@color/grey"
android:textSize="17sp"
android:textStyle="bold"
......
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/white"
android:fillViewport="true">
<!-- <LinearLayout-->
<!-- android:id="@+id/cl_bill_payment"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="match_parent"-->
<!-- android:orientation="vertical">-->
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/cl_more_header"
android:layout_width="match_parent"
android:layout_height="80dp"
app:layout_constraintTop_toTopOf="parent">
<ImageView
android:id="@+id/iv_list_close"
android:layout_width="21dp"
android:layout_height="20dp"
android:layout_marginStart="24dp"
android:layout_marginTop="4dp"
android:src="@drawable/ic_back"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@+id/textView3" />
<TextView
android:id="@+id/textView3"
android:layout_width="206dp"
android:layout_height="32dp"
android:gravity="center"
android:textColor="@color/grey"
android:textSize="17sp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.356"
app:layout_constraintStart_toEndOf="@+id/iv_list_close"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/cl_more_header"
android:background="@drawable/shape_cos_profile_gradient"
android:orientation="vertical"
android:paddingBottom="24dp">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_more"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="24dp"
android:clipToPadding="false"
android:orientation="vertical"
android:paddingEnd="24dp" />
<!-- <androidx.constraintlayout.widget.ConstraintLayout-->
<!-- android:id="@+id/cl_recycler_inner3"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_below="@+id/cl_recycler_inner2"-->
<!-- android:layout_marginTop="36dp"-->
<!-- android:paddingBottom="4dp"-->
<!-- app:layout_constraintLeft_toLeftOf="parent"-->
<!-- app:layout_constraintRight_toRightOf="parent"-->
<!-- app:layout_constraintTop_toTopOf="parent">-->
<!-- <TextView-->
<!-- android:id="@+id/tv_coupons_title"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_marginStart="10dp"-->
<!-- android:text="@string/cos_coupons_title"-->
<!-- android:textColor="@android:color/white"-->
<!-- android:textSize="18sp"-->
<!-- android:textStyle="bold"-->
<!-- app:layout_constraintStart_toStartOf="parent"-->
<!-- app:layout_constraintTop_toTopOf="parent" />-->
<!-- </androidx.constraintlayout.widget.ConstraintLayout>-->
</RelativeLayout>
<!-- </LinearLayout>-->
</RelativeLayout>
\ No newline at end of file
......@@ -11,6 +11,7 @@
<string name="cos_profile_type">Traveller</string>
<string name="header_add">Προσθήκη</string>
<string name="cos_profile_reward">My Loyalty\nWallet</string>
<string name="cos_profile_title">My Loyalty Wallet</string>
<string name="cos_deals_title">Deals for You</string>
<string name="cos_profile_more">Δες περισσότερα</string>
<string name="cos_gifts_title">Gifts for You</string>
......