Panagiotis Triantafyllou

added map

......@@ -26,6 +26,10 @@
android:requestLegacyExternalStorage="true"
android:theme="@style/AppTheme">
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="@string/google_maps_key" />
<activity
android:name="warp.ly.android_sdk.activities.SplashActivity"
android:exported="true"
......
......@@ -81,6 +81,8 @@ dependencies {
//------------------------------ GMS -----------------------------//
implementation 'com.google.android.gms:play-services-base:18.7.2'
implementation 'com.google.android.gms:play-services-location:21.3.0'
implementation 'com.google.android.gms:play-services-maps:18.2.0'
implementation 'com.google.maps.android:android-maps-utils:0.5'
//------------------------------ Work Manager -----------------------------//
implementation 'androidx.work:work-runtime:2.10.3'
......
......@@ -63,6 +63,12 @@
android:theme="@style/SDKAppTheme" />
<activity
android:name=".activities.ShopsActivity"
android:exported="false"
android:screenOrientation="portrait"
android:theme="@style/SDKAppTheme" />
<activity
android:name=".dexter.PermissionsActivity"
android:exported="false"
android:launchMode="singleInstance"
......
......@@ -34,6 +34,7 @@ public class SingleCouponActivity extends Activity implements View.OnClickListen
// Constants
// ===========================================================
public static final String EXTRA_OFFER_ITEM = "coupon_item";
public static final String EXTRA_MERCHANT_UUID = "merchant_uuid";
// ===========================================================
// Fields
......@@ -44,7 +45,7 @@ public class SingleCouponActivity extends Activity implements View.OnClickListen
private TextView mTvSmallDescription;
private TextView mTvFullDescription;
private TextView mTvEndDate;
private LinearLayout mLlDate;
private LinearLayout mLlDate, mLlShopsButton;
private TextView mTvValue;
private TextView mTvMoreButton;
private ImageView mIvImage;
......@@ -96,6 +97,19 @@ public class SingleCouponActivity extends Activity implements View.OnClickListen
super.onResume();
}
@Override
public void onClick(View v) {
if (v.getId() == R.id.iv_back) {
onBackPressed();
return;
}
if (v.getId() == R.id.ll_shops) {
Intent myIntent = new Intent(SingleCouponActivity.this, ShopsActivity.class);
myIntent.putExtra(SingleCouponActivity.EXTRA_MERCHANT_UUID, mOfferItem.getMerchantUuid());
startActivity(myIntent);
}
}
// ===========================================================
// Methods
// ===========================================================
......@@ -104,6 +118,9 @@ public class SingleCouponActivity extends Activity implements View.OnClickListen
mIvBack = findViewById(R.id.iv_back);
mIvBack.setOnClickListener(this);
mLlShopsButton = findViewById(R.id.ll_shops);
mLlShopsButton.setOnClickListener(this);
// Initialize views
mTvSmallDescription = findViewById(R.id.tv_coupon_small_description);
mTvFullDescription = findViewById(R.id.tv_coupon_full_description);
......@@ -336,13 +353,6 @@ public class SingleCouponActivity extends Activity implements View.OnClickListen
}
}
@Override
public void onClick(View v) {
if (v.getId() == R.id.iv_back) {
onBackPressed();
}
}
// ===========================================================
// Inner and Anonymous Classes
// ===========================================================
......
......@@ -28,6 +28,9 @@ package ly.warp.sdk.io.models;
import android.os.Parcel;
import android.os.Parcelable;
import com.google.android.gms.maps.model.LatLng;
import com.google.maps.android.clustering.ClusterItem;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
......@@ -42,7 +45,7 @@ import ly.warp.sdk.utils.constants.WarpConstants;
* Created by Panagiotis Triantafyllou on 07-Dec-21.
*/
public class Merchant implements Parcelable, Serializable {
public class Merchant implements Parcelable, Serializable, ClusterItem {
private static final long serialVersionUID = -4754964462459705285L;
......@@ -73,6 +76,7 @@ public class Merchant implements Parcelable, Serializable {
private static final String CATEGORY_UUID = "category_uuid";
private static final String CREATED = "created";
private static final String PARENT = "parent";
private static final String PARENT_UUID = "parent_uuid";
private static final String IMG = "img";
private static final String IMG_PREVIEW = "img_preview";
private static final String ADMIN_NAME = "admin_name";
......@@ -125,6 +129,7 @@ public class Merchant implements Parcelable, Serializable {
private String category_uuid;
private String created;
private String parent;
private String parentUuid;
private JSONArray img;
private String img_preview;
private String admin_name;
......@@ -149,6 +154,7 @@ public class Merchant implements Parcelable, Serializable {
private String minPrice;
private String maxPrice;
private String urlName;
private LatLng coordinates;
/**
* Helper method to get a nullable String from a JSONObject.
......@@ -184,6 +190,7 @@ public class Merchant implements Parcelable, Serializable {
this.category_uuid = null;
this.created = null;
this.parent = null;
this.parentUuid = null;
this.img = null;
this.img_preview = null;
this.admin_name = null;
......@@ -208,6 +215,9 @@ public class Merchant implements Parcelable, Serializable {
this.minPrice = null;
this.maxPrice = null;
this.urlName = null;
this.coordinates = new LatLng(
this.latitude != null ? this.latitude : 0.0,
this.longitude != null ? this.longitude : 0.0);
}
public Merchant(boolean isUniversal) {
......@@ -269,6 +279,7 @@ public class Merchant implements Parcelable, Serializable {
this.category_uuid = optNullableString(json, CATEGORY_UUID);
this.created = optNullableString(json, CREATED);
this.parent = optNullableString(json, PARENT);
this.parentUuid = optNullableString(json, PARENT_UUID);
this.img = json.optJSONArray(IMG);
this.img_preview = optNullableString(json, IMG_PREVIEW);
this.admin_name = optNullableString(json, ADMIN_NAME);
......@@ -293,6 +304,9 @@ public class Merchant implements Parcelable, Serializable {
this.minPrice = optNullableString(json, MIN_PRICE);
this.maxPrice = optNullableString(json, MAX_PRICE);
this.urlName = optNullableString(json, URL_NAME);
this.coordinates = new LatLng(
this.latitude != null ? this.latitude : 0.0,
this.longitude != null ? this.longitude : 0.0);
}
}
......@@ -347,6 +361,7 @@ public class Merchant implements Parcelable, Serializable {
this.category_uuid = source.readString();
this.created = source.readString();
this.parent = source.readString();
this.parentUuid = source.readString();
try {
String imgStr = source.readString();
this.img = imgStr != null ? new JSONArray(imgStr) : null;
......@@ -393,6 +408,9 @@ public class Merchant implements Parcelable, Serializable {
this.minPrice = source.readString();
this.maxPrice = source.readString();
this.urlName = source.readString();
this.coordinates = new LatLng(
this.latitude != null ? this.latitude : 0.0,
this.longitude != null ? this.longitude : 0.0);
}
@Override
......@@ -422,6 +440,7 @@ public class Merchant implements Parcelable, Serializable {
dest.writeString(this.category_uuid);
dest.writeString(this.created);
dest.writeString(this.parent);
dest.writeString(this.parentUuid);
dest.writeString(this.img != null ? this.img.toString() : null);
dest.writeString(this.img_preview);
dest.writeString(this.admin_name);
......@@ -446,6 +465,7 @@ public class Merchant implements Parcelable, Serializable {
dest.writeString(this.minPrice);
dest.writeString(this.maxPrice);
dest.writeString(this.urlName);
dest.writeParcelable(coordinates, flags);
}
/**
......@@ -481,6 +501,7 @@ public class Merchant implements Parcelable, Serializable {
jObj.put(CATEGORY_UUID, this.category_uuid != null ? this.category_uuid : JSONObject.NULL);
jObj.put(CREATED, this.created != null ? this.created : JSONObject.NULL);
jObj.put(PARENT, this.parent != null ? this.parent : JSONObject.NULL);
jObj.put(PARENT_UUID, this.parentUuid != null ? this.parentUuid : JSONObject.NULL);
jObj.put(IMG, this.img != null ? this.img : JSONObject.NULL);
jObj.put(IMG_PREVIEW, this.img_preview != null ? this.img_preview : JSONObject.NULL);
jObj.put(ADMIN_NAME, this.admin_name != null ? this.admin_name : JSONObject.NULL);
......@@ -661,6 +682,10 @@ public class Merchant implements Parcelable, Serializable {
return parent;
}
public String getParentUuid() {
return parentUuid;
}
public ArrayList<String> getImg() {
return jsonArrayToList(img);
}
......@@ -869,6 +894,10 @@ public class Merchant implements Parcelable, Serializable {
this.parent = parent;
}
public void setParentUuid(String parentUuid) {
this.parentUuid = parentUuid;
}
public void setImg(JSONArray img) {
this.img = img;
}
......@@ -965,6 +994,10 @@ public class Merchant implements Parcelable, Serializable {
this.urlName = urlName;
}
public void setCoordinates(LatLng coordinates) {
this.coordinates = coordinates;
}
@Override
public int describeContents() {
return 0;
......@@ -989,4 +1022,17 @@ public class Merchant implements Parcelable, Serializable {
}
return listData;
}
@Override
public LatLng getPosition() {
return coordinates;
}
@Override
public String getTitle() {
return null;
}
@Override
public String getSnippet() {
return null;
}
}
......
......@@ -157,6 +157,17 @@ public interface ApiService {
@Header(WarpConstants.HEADER_WEB_ID) String webId,
@Header(WarpConstants.HEADER_SIGNATURE) String signature);
@Headers("Content-Type: application/json")
@POST("/api/mobile/v2/{appUuid}/context/")
Call<ResponseBody> getStores(@Path("appUuid") String appUuid,
@Body RequestBody request,
@Header(WarpConstants.HEADER_DATE) String timeStamp,
@Header(WarpConstants.HEADER_LOYALTY_BUNDLE_ID) String bundleId,
@Header(WarpConstants.HEADER_UNIQUE_DEVICE_ID) String deviceId,
@Header(WarpConstants.HEADER_CHANNEL) String channel,
@Header(WarpConstants.HEADER_WEB_ID) String webId,
@Header(WarpConstants.HEADER_SIGNATURE) String signature);
// ===========================================================
// Getter & Setter
// ===========================================================
......
package ly.warp.sdk.utils;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.ColorMatrix;
import android.graphics.ColorMatrixColorFilter;
import android.graphics.Paint;
import androidx.annotation.NonNull;
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
import com.bumptech.glide.load.resource.bitmap.BitmapTransformation;
import java.security.MessageDigest;
/**
* Glide transformation that renders a bitmap in grayscale
*/
public class GrayscaleTransformation extends BitmapTransformation {
private static final String ID = "ly.warp.sdk.utils.GrayscaleTransformation";
@Override
protected Bitmap transform(@NonNull BitmapPool pool, @NonNull Bitmap toTransform, int outWidth, int outHeight) {
Bitmap result = pool.get(toTransform.getWidth(), toTransform.getHeight(), Bitmap.Config.ARGB_8888);
if (result == null) {
result = Bitmap.createBitmap(toTransform.getWidth(), toTransform.getHeight(), Bitmap.Config.ARGB_8888);
}
ColorMatrix colorMatrix = new ColorMatrix();
colorMatrix.setSaturation(0f);
Paint paint = new Paint();
paint.setColorFilter(new ColorMatrixColorFilter(colorMatrix));
Canvas canvas = new Canvas(result);
canvas.drawBitmap(toTransform, 0, 0, paint);
return result;
}
@Override
public void updateDiskCacheKey(@NonNull MessageDigest messageDigest) {
messageDigest.update(ID.getBytes());
}
@Override
public boolean equals(Object o) {
return o instanceof GrayscaleTransformation;
}
@Override
public int hashCode() {
return ID.hashCode();
}
}
......@@ -25,6 +25,9 @@
package ly.warp.sdk.utils.constants;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.LatLngBounds;
public class WarpConstants {
/**
......@@ -87,6 +90,11 @@ public class WarpConstants {
public static boolean DEBUG;
public static String GCM_SENDER_ID;
public static final LatLngBounds GREECE_BOUNDS = new LatLngBounds(
new LatLng(34.75261, 19.33079),
new LatLng(41.97761, 28.62522)
);
/*
* if was received the campaign with this category need expires date define
* as 0 (for no show it in app need check on 0 or if the date is correct)
......
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white">
<LinearLayout
android:id="@+id/header_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="@color/white"
android:baselineAligned="false"
android:orientation="horizontal"
android:padding="16dp">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_vertical"
android:orientation="horizontal">
<ImageView
android:id="@+id/iv_back"
android:layout_width="16dp"
android:layout_height="16dp"
android:layout_marginEnd="24dp"
android:src="@drawable/ic_back" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="@+id/header_layout2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/header_layout"
android:background="@color/white"
android:orientation="vertical"
android:paddingHorizontal="16dp"
android:paddingBottom="16dp">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/tv_header_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:includeFontPadding="false"
android:text="@string/demo_partners_title"
android:textColor="@color/custom_black6"
android:textSize="28sp" />
</LinearLayout>
<LinearLayout
android:id="@+id/ll_search_filter_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:background="@drawable/shape_rectangle_rounded_grey4"
android:gravity="center"
android:paddingHorizontal="20dp"
android:paddingVertical="12dp">
<TextView
android:id="@+id/tv_search_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:includeFontPadding="false"
android:text="@string/demo_search_title"
android:textColor="@color/custom_black6"
android:textSize="14sp" />
<View
android:layout_width="12dp"
android:layout_height="match_parent" />
<ImageView
android:layout_width="16dp"
android:layout_height="16dp"
android:src="@drawable/demo_filter" />
</LinearLayout>
</LinearLayout>
<RelativeLayout
android:id="@+id/cl_loyalty_info_view_inner"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/header_layout2">
<fragment
android:id="@+id/mv_shops"
class="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</RelativeLayout>
</RelativeLayout>
\ No newline at end of file
......@@ -22,12 +22,6 @@
android:layout_height="260dp"
android:background="@color/custom_skyblue3">
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="coupon_code_content" />
<ImageView
android:id="@+id/iv_coupon_image"
android:layout_width="match_parent"
......@@ -254,6 +248,7 @@
</androidx.constraintlayout.widget.ConstraintLayout>
<LinearLayout
android:id="@+id/ll_shops"
android:layout_width="match_parent"
android:layout_height="55dp"
android:layout_marginTop="32dp"
......
<resources>
<string name="google_maps_key">AIzaSyB-K6OiUDT_X0zp2jYjqHg54ThxEuZtr9I</string>
<string name="webview_permission_title">Demo App</string>
<string name="webview_permission_message">Το Demo App ζητάει πρόσβαση στην τοποθεσία σας.</string>
<string name="lbl_ok">Οκ</string>
<string name="lbl_ok">ΟΚ</string>
<string name="lbl_cancel">Άκυρο</string>
<string name="lbl_stores">Καταστήματα συνεργάτη</string>
<string name="lbl_no_shops">Δεν υπάρχουν καταστήματα συνεργάτη.</string>
<string name="welcome_user">User</string>
<string name="menu_home">Αρχική</string>
<string name="demo_home">Αρχική οθόνη</string>
......@@ -36,4 +39,6 @@
<string name="demo_my_coupons_title">My coupons</string>
<string name="demo_my_coupons_header">My Coupons</string>
<string name="demo_coupon_expired">Expired</string>
<string name="demo_partners_title">Partner businesses</string>
<string name="demo_search_title">Αναζήτηση</string>
</resources>
......