Panagiotis Triantafyllou

all couponsets screen

......@@ -69,6 +69,12 @@
android:theme="@style/SDKAppTheme" />
<activity
android:name=".activities.CouponsetsActivity"
android:exported="false"
android:screenOrientation="portrait"
android:theme="@style/SDKAppTheme" />
<activity
android:name=".dexter.PermissionsActivity"
android:exported="false"
android:launchMode="singleInstance"
......@@ -78,7 +84,7 @@
<activity
android:name=".activities.BaseFragmentActivity"
android:exported="true"
android:screenOrientation="portrait"/>
android:screenOrientation="portrait" />
<!-- Service used for updating user's location. -->
<service
......@@ -96,22 +102,22 @@
android:exported="false" />
<!-- FCM Service for push notifications -->
<!-- <service-->
<!-- android:name="ly.warp.sdk.services.FCMBaseMessagingService"-->
<!-- android:exported="false">-->
<!-- <intent-filter>-->
<!-- <action android:name="com.google.firebase.MESSAGING_EVENT" />-->
<!-- </intent-filter>-->
<!-- </service>-->
<!-- <service-->
<!-- android:name="ly.warp.sdk.services.FCMBaseMessagingService"-->
<!-- android:exported="false">-->
<!-- <intent-filter>-->
<!-- <action android:name="com.google.firebase.MESSAGING_EVENT" />-->
<!-- </intent-filter>-->
<!-- </service>-->
<!-- Service used for handling Huawei Push Notifications, comment if we are in Google build -->
<!-- <service-->
<!-- android:name="ly.warp.sdk.services.HMSBaseMessagingService"-->
<!-- android:exported="false">-->
<!-- <intent-filter>-->
<!-- <action android:name="com.huawei.push.action.MESSAGING_EVENT" />-->
<!-- </intent-filter>-->
<!-- </service>-->
<!-- <service-->
<!-- android:name="ly.warp.sdk.services.HMSBaseMessagingService"-->
<!-- android:exported="false">-->
<!-- <intent-filter>-->
<!-- <action android:name="com.huawei.push.action.MESSAGING_EVENT" />-->
<!-- </intent-filter>-->
<!-- </service>-->
<receiver
android:name="ly.warp.sdk.receivers.ConnectivityChangedReceiver"
......
package ly.warp.sdk.activities;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Parcelable;
import android.util.TypedValue;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import ly.warp.sdk.R;
import ly.warp.sdk.io.adapters.CouponsetAdapter;
import ly.warp.sdk.io.models.Couponset;
import ly.warp.sdk.utils.WarpUtils;
import ly.warp.sdk.utils.WarplyManagerHelper;
import ly.warp.sdk.views.GridSpaceItemDecoration;
import ly.warp.sdk.views.VerticalSpaceItemDecoration;
public class CouponsetsActivity extends Activity implements View.OnClickListener {
// ===========================================================
// Constants
// ===========================================================
public static final String EXTRA_CATEGORY = "category";
// ===========================================================
// Fields
// ===========================================================
private ImageView mIvBack;
private RecyclerView mRvCouponsets;
private CouponsetAdapter mCouponsetsAdapter;
private TextView mTvHeaderTitle, mTvSearchTitle;
private String mCouponsetsCategory = "";
// ===========================================================
// Methods for/from SuperClass/Interfaces
// ===========================================================
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_couponsets);
Intent intent = getIntent();
if (intent != null && intent.hasExtra(EXTRA_CATEGORY)) {
mCouponsetsCategory = intent.getStringExtra(EXTRA_CATEGORY);
}
initViews();
WarpUtils.applyEdgeToEdge(this,
findViewById(R.id.header_layout),
null);
}
@Override
public void onResume() {
super.onResume();
}
@Override
public void onClick(View v) {
if (v.getId() == R.id.iv_back) {
onBackPressed();
}
}
// ===========================================================
// Methods
// ===========================================================
private void initViews() {
mIvBack = findViewById(R.id.iv_back);
mIvBack.setOnClickListener(this);
mRvCouponsets = findViewById(R.id.rv_couponsets);
mTvHeaderTitle = findViewById(R.id.tv_header_title);
mTvHeaderTitle.setText(mCouponsetsCategory);
mTvSearchTitle = findViewById(R.id.tv_search_title);
WarpUtils.renderCustomFont(this, R.font.ping_lcg_bold, mTvHeaderTitle);
WarpUtils.renderCustomFont(this, R.font.ping_lcg_regular, mTvSearchTitle);
setupCouponsetsSection();
}
private void setupCouponsetsSection() {
LinkedHashMap<String, ArrayList<Couponset>> categorizedMap = WarplyManagerHelper.getCouponsetCategorizedMap();
if (categorizedMap == null || categorizedMap.isEmpty()) return;
ArrayList<Couponset> couponsets = categorizedMap.get(mCouponsetsCategory);
if (couponsets == null || couponsets.isEmpty()) return;
GridLayoutManager layoutManager = new GridLayoutManager(this, 2);
mRvCouponsets.setLayoutManager(layoutManager);
mRvCouponsets.setHasFixedSize(true);
int columnSpacingPx = (int) TypedValue.applyDimension(
TypedValue.COMPLEX_UNIT_DIP, 12, getResources().getDisplayMetrics());
int rowSpacingPx = (int) TypedValue.applyDimension(
TypedValue.COMPLEX_UNIT_DIP, 16, getResources().getDisplayMetrics());
mRvCouponsets.addItemDecoration(new GridSpaceItemDecoration(2, columnSpacingPx, rowSpacingPx));
mCouponsetsAdapter = new CouponsetAdapter(this, couponsets, true);
mCouponsetsAdapter.setOnCouponsetClickListener((couponset, position) -> {
Intent myIntent = new Intent(CouponsetsActivity.this, SingleCouponsetActivity.class);
myIntent.putExtra(SingleCouponsetActivity.EXTRA_OFFER_ITEM, (Parcelable) couponset);
startActivity(myIntent);
});
mRvCouponsets.setAdapter(mCouponsetsAdapter);
}
// ===========================================================
// Inner and Anonymous Classes
// ===========================================================
}
......@@ -109,6 +109,13 @@ public class HomeActivity extends Activity implements View.OnClickListener, Coup
if (v.getId() == R.id.ll_my_coupons) {
Intent myIntent = new Intent(HomeActivity.this, CouponsActivity.class);
startActivity(myIntent);
return;
}
if (v.getId() == R.id.ll_all) {
String categoryName = (String) v.getTag();
Intent myIntent = new Intent(HomeActivity.this, CouponsetsActivity.class);
myIntent.putExtra(CouponsetsActivity.EXTRA_CATEGORY, categoryName);
startActivity(myIntent);
}
}
......@@ -311,6 +318,10 @@ public class HomeActivity extends Activity implements View.OnClickListener, Coup
tvTitle.setText(titleText);
WarpUtils.renderCustomFont(this, R.font.ping_lcg_bold, tvTitle);
LinearLayout llAllButton = sectionView.findViewById(R.id.ll_all);
llAllButton.setTag(categoryName);
llAllButton.setOnClickListener(this);
TextView tvAll = sectionView.findViewById(R.id.tv_section_all);
WarpUtils.renderCustomFont(this, R.font.ping_lcg_regular, tvAll);
......
......@@ -46,7 +46,6 @@ import java.util.ArrayList;
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.Merchant;
import ly.warp.sdk.utils.WarpUtils;
import ly.warp.sdk.utils.constants.WarpConstants;
......@@ -67,7 +66,6 @@ public class ShopsActivity extends FragmentActivity implements View.OnClickListe
// ===========================================================
private ImageView mIvBack;
private Coupon mCoupon;
private GoogleMap mMap;
private ClusterManager<Merchant> mClusterManager;
private SupportMapFragment mMapView;
......
......@@ -31,6 +31,7 @@ public class CouponsetAdapter extends RecyclerView.Adapter<CouponsetAdapter.Coup
private final List<Couponset> couponsets;
private final Context context;
private final boolean isGrid;
private OnCouponsetClickListener listener;
public interface OnCouponsetClickListener {
......@@ -40,6 +41,13 @@ public class CouponsetAdapter extends RecyclerView.Adapter<CouponsetAdapter.Coup
public CouponsetAdapter(Context context, List<Couponset> couponsets) {
this.context = context;
this.couponsets = couponsets;
this.isGrid = false;
}
public CouponsetAdapter(Context context, List<Couponset> couponsets, boolean isGrid) {
this.context = context;
this.couponsets = couponsets;
this.isGrid = isGrid;
}
public void setOnCouponsetClickListener(OnCouponsetClickListener listener) {
......@@ -49,7 +57,8 @@ public class CouponsetAdapter extends RecyclerView.Adapter<CouponsetAdapter.Coup
@NonNull
@Override
public CouponsetViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View view = LayoutInflater.from(context).inflate(R.layout.demo_item_offer, parent, false);
int layoutRes = isGrid ? R.layout.demo_item_offer_grid : R.layout.demo_item_offer;
View view = LayoutInflater.from(context).inflate(layoutRes, parent, false);
return new CouponsetViewHolder(view);
}
......@@ -134,7 +143,7 @@ public class CouponsetAdapter extends RecyclerView.Adapter<CouponsetAdapter.Coup
private void loadCouponsetImage(String imageUrl) {
if (imageUrl != null && !imageUrl.isEmpty()) {
int radiusInPixels = (int) TypedValue.applyDimension(
TypedValue.COMPLEX_UNIT_DIP, 9,
TypedValue.COMPLEX_UNIT_DIP, 12,
context.getResources().getDisplayMetrics());
Glide.with(context)
......
package ly.warp.sdk.views;
import android.graphics.Rect;
import android.view.View;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
/**
* ItemDecoration for adding equal spacing between columns and rows in a GridLayoutManager.
*/
public class GridSpaceItemDecoration extends RecyclerView.ItemDecoration {
private final int spanCount;
private final int columnSpacing;
private final int rowSpacing;
/**
* @param spanCount Number of columns in the grid
* @param columnSpacing Horizontal space between columns in pixels
* @param rowSpacing Vertical space between rows in pixels
*/
public GridSpaceItemDecoration(int spanCount, int columnSpacing, int rowSpacing) {
this.spanCount = spanCount;
this.columnSpacing = columnSpacing;
this.rowSpacing = rowSpacing;
}
@Override
public void getItemOffsets(@NonNull Rect outRect, @NonNull View view,
@NonNull RecyclerView parent, @NonNull RecyclerView.State state) {
int position = parent.getChildAdapterPosition(view);
int column = position % spanCount;
// Distribute column spacing evenly so all items have equal width
outRect.left = column * columnSpacing / spanCount;
outRect.right = columnSpacing - (column + 1) * columnSpacing / spanCount;
// Add top spacing for all rows except the first
if (position >= spanCount) {
outRect.top = rowSpacing;
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:topLeftRadius="12dp" android:topRightRadius="12dp" />
<solid
android:color="@color/custom_grey11" />
</shape>
\ No newline at end of file
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white">
<androidx.core.widget.NestedScrollView
android:id="@+id/profile_scrollview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<LinearLayout
android:id="@+id/profile_content_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<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: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:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingHorizontal="16dp">
<TextView
android:id="@+id/tv_header_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:includeFontPadding="false"
android:textColor="@color/custom_black6"
android:textSize="28sp" />
</LinearLayout>
<RelativeLayout
android:id="@+id/header_layout2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white"
android:gravity="center_vertical"
android:layout_marginTop="12dp"
android:paddingHorizontal="16dp">
<LinearLayout
android:id="@+id/ll_search_filter_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/shape_rectangle_rounded_grey4"
android:gravity="center"
android:layout_alignParentStart="true"
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>
<ImageView
android:id="@+id/profile_icon"
android:layout_width="46dp"
android:layout_height="46dp"
android:layout_alignParentEnd="true"
android:background="@drawable/shape_rectangle_rounded_grey"
android:padding="14dp"
android:src="@drawable/demo_location_black" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/my_coupons_section"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="24dp"
android:layout_marginBottom="48dp"
android:background="@color/white"
android:paddingBottom="16dp">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_couponsets"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipToPadding="false"
android:nestedScrollingEnabled="false"
android:paddingHorizontal="16dp" />
</RelativeLayout>
</LinearLayout>
</androidx.core.widget.NestedScrollView>
</RelativeLayout>
......@@ -10,6 +10,7 @@
android:id="@+id/iv_offer_image"
android:layout_width="match_parent"
android:layout_height="130dp"
android:background="@drawable/shape_rectangle_rounded_grey5"
android:scaleType="centerCrop" />
<TextView
......@@ -43,10 +44,10 @@
android:id="@+id/tv_title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:includeFontPadding="false"
android:maxLines="1"
android:textColor="@color/custom_black2"
android:textSize="15sp"
android:includeFontPadding="false"
app:layout_constraintEnd_toStartOf="@+id/gl_vertical_70"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
......@@ -57,8 +58,8 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="2dp"
android:maxLines="2"
android:includeFontPadding="false"
android:maxLines="2"
android:textColor="@color/custom_black3"
android:textSize="13sp"
app:layout_constraintEnd_toStartOf="@+id/gl_vertical_70"
......@@ -73,12 +74,12 @@
android:layout_alignParentStart="true"
android:layout_centerVertical="true"
android:layout_marginTop="12dp"
android:maxLines="1"
android:includeFontPadding="false"
android:maxLines="1"
android:textColor="@color/custom_grey4"
android:textSize="12sp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
tools:text="έως 30-09" />
<ImageView
......
<?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"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="230dp"
android:background="@drawable/demo_shape_white_border_grey">
<ImageView
android:id="@+id/iv_offer_image"
android:layout_width="match_parent"
android:layout_height="130dp"
android:background="@drawable/shape_rectangle_rounded_grey5"
android:scaleType="centerCrop" />
<TextView
android:id="@+id/tv_price"
android:layout_width="54dp"
android:layout_height="54dp"
android:layout_alignParentEnd="true"
android:layout_margin="8dp"
android:background="@drawable/demo_shape_grey"
android:gravity="center"
android:includeFontPadding="false"
android:textColor="@android:color/white"
android:textSize="16sp"
tools:text="17,95€" />
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/iv_offer_image"
android:orientation="vertical"
android:padding="12dp">
<androidx.constraintlayout.widget.Guideline
android:id="@+id/gl_vertical_70"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_percent="0.7" />
<TextView
android:id="@+id/tv_title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:includeFontPadding="false"
android:maxLines="1"
android:textColor="@color/custom_black2"
android:textSize="15sp"
app:layout_constraintEnd_toStartOf="@+id/gl_vertical_70"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:text="Móvo 17,95" />
<TextView
android:id="@+id/tv_description"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="2dp"
android:includeFontPadding="false"
android:maxLines="2"
android:textColor="@color/custom_black3"
android:textSize="13sp"
app:layout_constraintEnd_toStartOf="@+id/gl_vertical_70"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tv_title"
tools:text="2 πίτσες &amp; Coca-COLA 1,5lt" />
<TextView
android:id="@+id/tv_validity"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_centerVertical="true"
android:layout_marginTop="12dp"
android:includeFontPadding="false"
android:maxLines="1"
android:textColor="@color/custom_grey4"
android:textSize="12sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
tools:text="έως 30-09" />
<ImageView
android:id="@+id/iv_logo"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:scaleType="centerInside"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:src="@drawable/demo_avis" />
</androidx.constraintlayout.widget.ConstraintLayout>
</RelativeLayout>
......@@ -42,4 +42,5 @@
<color name="custom_gold">#573300</color>
<color name="custom_grey9">#ADB3B8</color>
<color name="custom_grey10">#ECEDEF</color>
<color name="custom_grey11">#E7E7E7</color>
</resources>
......