Panagiotis Triantafyllou

new keys

......@@ -36,7 +36,7 @@ public class SplashActivity extends BaseActivity {
public void onWarplyReady() {
if (!WarplyDBHelper.getInstance(SplashActivity.this).isTableNotEmpty("auth")) {
WarplyManager.getCosmoteUser(new WarplyCosmoteUserRequest()
.setGuid("7000000831"), //6012049321, 6012049322, 6012049323, 7000000831 history, 7000000826, 7000000831 shared coupons, prod 6006552990
.setGuid("7000000870"), //6012049321, 6012049322, 6012049323, 7000000831 history, 7000000826, 7000000831 shared coupons, prod 6006552990
mLoginReceiver);
} else {
startNextActivity();
......
......@@ -2,7 +2,7 @@ apply plugin: 'com.android.library'
ext {
PUBLISH_GROUP_ID = 'ly.warp'
PUBLISH_VERSION = '4.5.4-cosbeta95'
PUBLISH_VERSION = '4.5.4-cosbeta96'
PUBLISH_ARTIFACT_ID = 'warply-android-sdk'
}
......@@ -62,9 +62,9 @@ dependencies {
implementation 'com.google.firebase:firebase-messaging'
//------------------------------ GMS -----------------------------//
api 'com.google.android.gms:play-services-base:18.0.1'
implementation 'com.google.android.gms:play-services-location:19.0.1'
implementation 'com.google.android.gms:play-services-maps:18.0.2'
api 'com.google.android.gms:play-services-base:18.1.0'
implementation 'com.google.android.gms:play-services-location:21.0.0'
implementation 'com.google.android.gms:play-services-maps:18.1.0'
api 'com.google.maps.android:android-maps-utils:0.5'
//------------------------------ Work Manager -----------------------------//
......
......@@ -5,6 +5,7 @@ import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.text.Html;
......@@ -33,6 +34,7 @@ import io.github.inflationx.viewpump.ViewPumpContextWrapper;
import ly.warp.sdk.R;
import ly.warp.sdk.io.models.Coupon;
import ly.warp.sdk.io.models.Couponset;
import ly.warp.sdk.io.models.Merchant;
import ly.warp.sdk.services.EventCouponsService;
import ly.warp.sdk.utils.WarplyManagerHelper;
import ly.warp.sdk.utils.managers.WarplyAnalyticsManager;
......@@ -51,10 +53,11 @@ public class CouponInfoActivity extends Activity implements View.OnClickListener
private ImageView mIvBack, mIvCouponPhoto, mIvBarcode;
private TextView mTvTerms, mTvCouponCode, mTvCouponTitle, mTvCouponSubtitle, mTvCouponDate,
mTvTermsValue, mTvFullBarcode;
private LinearLayout mLlGiftIt, mLlShops, mLlBarcodeShown, mLlBarcodeContainer, mLlTerms;
private LinearLayout mLlGiftIt, mLlShops, mLlBarcodeShown, mLlBarcodeContainer, mLlTerms, mLlWebsite;
private Coupon mCoupon;
private Couponset mCouponset;
private boolean mIsBarcodeShown = false, mIsTermsShown = false, mIsFromWallet = false;
private Merchant mMerchant;
// ===========================================================
// Methods for/from SuperClass/Interfaces
......@@ -78,6 +81,7 @@ public class CouponInfoActivity extends Activity implements View.OnClickListener
mIvCouponPhoto = findViewById(R.id.imageView6);
mIvBarcode = findViewById(R.id.iv_barcode);
mLlShops = findViewById(R.id.ll_shops);
mLlWebsite = findViewById(R.id.ll_website);
mLlBarcodeShown = findViewById(R.id.ll_show_barcode);
mLlBarcodeContainer = findViewById(R.id.ll_barcode_container_items);
mLlTerms = findViewById(R.id.ll_terms_inner);
......@@ -129,9 +133,20 @@ public class CouponInfoActivity extends Activity implements View.OnClickListener
Intent intent = new Intent(CouponInfoActivity.this, ShopsActivity.class);
intent.putExtra("couponset", (Serializable) mCouponset);
intent.putExtra("merchant", (Serializable) mMerchant);
startActivity(intent);
return;
}
if (view.getId() == R.id.ll_website) {
WarplyAnalyticsManager.logTrackersEvent(this, "click", "SeeShopWebsite");
if (!TextUtils.isEmpty(mMerchant.getWebsite())) {
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(mMerchant.getWebsite()));
startActivity(intent);
}
return;
}
if (view.getId() == R.id.ll_show_barcode) {
if (mIsBarcodeShown) {
mLlBarcodeContainer.setVisibility(View.GONE);
......@@ -175,6 +190,10 @@ public class CouponInfoActivity extends Activity implements View.OnClickListener
// ===========================================================
private void initViews() {
mLlBarcodeShown.setVisibility(View.GONE);
mLlBarcodeContainer.setVisibility(View.GONE);
mIvBarcode.setVisibility(View.GONE);
mTvCouponCode.setText(mCoupon.getCoupon());
mTvCouponTitle.setText(mCoupon.getName());
// mTvCouponSubtitle.setText(mCoupon.getDescription());
......@@ -189,6 +208,24 @@ public class CouponInfoActivity extends Activity implements View.OnClickListener
}
if (mCouponset != null) {
if (WarplyManagerHelper.getMerchantList() != null && WarplyManagerHelper.getMerchantList().size() > 0) {
for (Merchant merchant : WarplyManagerHelper.getMerchantList()) {
if (merchant.getUuid().equals(mCouponset.getMerchantUuid())) {
mMerchant = merchant;
break;
}
}
// if (mMerchant != null) {
// if (mMerchant.getExtraFields() != null && mMerchant.getExtraFields().has("show_map") && (mMerchant.getExtraFields().optBoolean("show_map") || mMerchant.getExtraFields().optString("show_map").equals("true"))) {
mLlShops.setVisibility(View.VISIBLE);
// }
// if (mMerchant.getExtraFields() != null && mMerchant.getExtraFields().has("eshop") && (mMerchant.getExtraFields().optBoolean("eshop") || mMerchant.getExtraFields().optString("eshop").equals("true"))) {
// mLlWebsite.setVisibility(View.VISIBLE);
// }
// }
}
mTvCouponSubtitle.setText(mCouponset.getShortDescription());
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
mTvTermsValue.setText(Html.fromHtml(mCouponset.getTerms(), Html.FROM_HTML_MODE_COMPACT));
......@@ -225,6 +262,7 @@ public class CouponInfoActivity extends Activity implements View.OnClickListener
// mTvTerms.setPaintFlags(mTvTerms.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
mLlGiftIt.setOnClickListener(this);
mLlShops.setOnClickListener(this);
mLlWebsite.setOnClickListener(this);
mLlBarcodeShown.setOnClickListener(this);
mLlTerms.setOnClickListener(this);
......@@ -268,6 +306,8 @@ public class CouponInfoActivity extends Activity implements View.OnClickListener
} catch (Exception e) {
e.printStackTrace();
mLlBarcodeShown.setVisibility(View.GONE);
mLlBarcodeContainer.setVisibility(View.GONE);
mIvBarcode.setVisibility(View.GONE);
}
}
......
......@@ -16,6 +16,7 @@ import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AlertDialog;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import androidx.fragment.app.FragmentActivity;
......@@ -68,6 +69,8 @@ public class ShopsActivity extends FragmentActivity implements View.OnClickListe
private ClusterManager<Merchant> mClusterManager;
SupportMapFragment mMapView;
private MerchantList mMerchantList = new MerchantList();
private AlertDialog mAlertDialogNoShopsAvailable;
private Merchant mMerchant;
// ===========================================================
// Methods for/from SuperClass/Interfaces
......@@ -79,6 +82,7 @@ public class ShopsActivity extends FragmentActivity implements View.OnClickListe
setContentView(R.layout.activity_shops);
mCouponset = (Couponset) getIntent().getSerializableExtra("couponset");
mMerchant = (Merchant) getIntent().getSerializableExtra("merchant");
mIvBack = findViewById(R.id.iv_shops_back);
mMapView = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.mv_shops);
......@@ -254,11 +258,38 @@ public class ShopsActivity extends FragmentActivity implements View.OnClickListe
// Methods
// ===========================================================
private void showNoShopsAvailableDialog() {
mAlertDialogNoShopsAvailable = new AlertDialog.Builder(this)
.setTitle(R.string.cos_dlg_no_shops_title)
.setMessage(R.string.cos_dlg_no_shops)
.setPositiveButton(R.string.cos_dlg_no_shops_positive, (dialogPositive, whichPositive) -> {
dialogPositive.dismiss();
openWebsite();
})
.setNegativeButton(R.string.cos_dlg_negative_button2, (dialogNegative, whichNegative) -> {
dialogNegative.dismiss();
onBackPressed();
})
.show();
}
private void openWebsite() {
WarplyAnalyticsManager.logTrackersEvent(this, "click", "SeeShopWebsite");
if (!TextUtils.isEmpty(mMerchant.getWebsite())) {
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(mMerchant.getWebsite()));
startActivity(intent);
}
}
private final CallbackReceiver<MerchantList> mMerchantsCallback = new CallbackReceiver<MerchantList>() {
@Override
public void onSuccess(MerchantList result) {
mMerchantList.clear();
mMerchantList.addAll(result);
new Handler(Looper.getMainLooper()).post(() -> {
// if (mClusterManager != null) {
// mMap.clear();
......@@ -269,6 +300,18 @@ public class ShopsActivity extends FragmentActivity implements View.OnClickListe
// mClusterManager.cluster();
// }
int nonNullCoords = 0;
for (Merchant merchCoords : result) {
if (merchCoords.getLatitude() != 0.0 && merchCoords.getLongitude() != 0.0) {
nonNullCoords++;
}
}
if (result.size() == 0 || nonNullCoords == 0) {
showNoShopsAvailableDialog();
return;
}
for (Merchant merch : result) {
mMap.addMarker(new MarkerOptions()
.position(new LatLng(merch.getLatitude(), merch.getLongitude()))
......
......@@ -210,8 +210,8 @@ public class Merchant implements Parcelable, Serializable, ClusterItem {
this.description = json.optString(DESCRIPTION);
this.short_description = json.optString(SHORT_DESCRIPTION);
this.region = json.optString(REGION);
this.latitude = json.optDouble(LAT);
this.longitude = json.optDouble(LON);
this.latitude = json.isNull(LAT) ? 0.0 : json.optDouble(LAT);
this.longitude = json.isNull(LON) ? 0.0 : json.optDouble(LON);
this.image = json.optString(IMAGE);
this.extra_fields = json.optJSONObject(EXTRA_FIELDS);
this.active = json.optBoolean(ACTIVE);
......
......@@ -1224,6 +1224,7 @@ public class WarplyManagerHelper {
}
public static void setMerchantList(MerchantList merchantList) {
mMerchantList.clear();
mMerchantList = merchantList;
}
......
......@@ -19,6 +19,7 @@ import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.Locale;
import java.util.concurrent.TimeUnit;
import io.reactivex.Observable;
......@@ -121,7 +122,7 @@ public class SharedCouponAdapter extends RecyclerView.Adapter<SharedCouponAdapte
JSONObject extraFields = WarpJSONParser.getJSONFromString(couponItem.getTransactionMetadata());
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm");
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("E, MMM dd yyyy HH:mm:ss", Locale.US);
Date newDate = new Date();
try {
newDate = simpleDateFormat.parse(couponItem.getDate());
......
......@@ -93,6 +93,7 @@
<string name="cos_dlg_negative_button2">Άκυρο</string>
<string name="cos_profile_preferences">+Προτιμήσεις</string>
<string name="cos_shops">Δες τα καταστήματα</string>
<string name="cos_website">Δες το eshop</string>
<string name="cos_coupon_shops_title">Καταστήματα</string>
<string name="cos_coupon_gift">Kάνε δώρο</string>
<string name="cos_coupon_share_gift_title">Επίλεξε το κινητό από το οποίο θα γίνει η αποστολή και συμπλήρωσε το COSMOTE κινητό που θα λάβει το δώρο.</string>
......@@ -144,6 +145,9 @@
<string name="cos_share_no_assets">Για την αποστολή του δώρου σου χρειάζεται να έχεις κινητό COSMOTE.</string>
<string name="cos_dlg_coupon_depleted_title">H προσφορά δεν είναι πλέον διαθέσιμη</string>
<string name="cos_dlg_coupon_depleted_message">Μείνε συντονισμένος για νέες προσφορές και κουπόνια.</string>
<string name="cos_dlg_no_shops">Ο συνεργάτης διαθέτει μόνο ηλεκτρονικό κατάστημα για ηλεκτρονικές παραγγελίες.</string>
<string name="cos_dlg_no_shops_title">Καταστήματα συνεργάτη</string>
<string name="cos_dlg_no_shops_positive">Δες το eshop</string>
<string-array name="coupons_array">
<item>Κουπόνια</item>
......