Panagiotis Triantafyllou

deh part2

Showing 54 changed files with 156 additions and 30 deletions

40.5 KB | W: | H:

21.4 KB | W: | H:

  • 2-up
  • Swipe
  • Onion skin
No preview for this file type
No preview for this file type
No preview for this file type
......@@ -39,6 +39,12 @@
android:theme="@style/SDKAppTheme" />
<activity
android:name=".activities.SingleCouponActivity"
android:exported="false"
android:screenOrientation="portrait"
android:theme="@style/SDKAppTheme" />
<activity
android:name=".dexter.PermissionsActivity"
android:exported="false"
android:launchMode="singleInstance"
......
package ly.warp.sdk.activities;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.TypedValue;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
......@@ -17,7 +17,6 @@ import ly.warp.sdk.io.models.DummyDataProvider;
import ly.warp.sdk.io.models.OfferCategory;
import ly.warp.sdk.io.models.OfferItem;
import ly.warp.sdk.utils.WarplyManagerHelper;
import ly.warp.sdk.utils.managers.WarplyManager;
import ly.warp.sdk.views.HorizontalSpaceItemDecoration;
public class HomeActivity extends Activity implements View.OnClickListener, OfferAdapter.OnOfferClickListener {
......@@ -72,8 +71,6 @@ public class HomeActivity extends Activity implements View.OnClickListener, Offe
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_home);
mIvBanner = findViewById(R.id.banner_icon);
initViews();
// Setup all category sections
......@@ -92,12 +89,32 @@ public class HomeActivity extends Activity implements View.OnClickListener, Offe
super.onResume();
}
@Override
public void onClick(View v) {
if (v.getId() == R.id.banner_icon) {
WarplyManagerHelper.openContest(this);
}
}
@Override
public void onOfferClick(OfferItem offerItem, int position) {
Intent myIntent = new Intent(HomeActivity.this, SingleCouponActivity.class);
myIntent.putExtra(SingleCouponActivity.EXTRA_OFFER_ITEM, offerItem);
startActivity(myIntent);
}
@Override
public void onFavoriteClick(OfferItem offerItem, int position) {
// Toast.makeText(this, "Favorite clicked for: " + offerItem.getTitle(), Toast.LENGTH_SHORT).show();
}
// ===========================================================
// Methods
// ===========================================================
private void initViews() {
// Initialize banner
mIvBanner = findViewById(R.id.banner_icon);
mIvBanner.setOnClickListener(this);
// Initialize Top Offers section
......@@ -341,23 +358,6 @@ public class HomeActivity extends Activity implements View.OnClickListener, Offe
mRvPurchases.setAdapter(mPurchasesAdapter);
}
@Override
public void onClick(View v) {
if (v.getId() == R.id.banner_icon) {
WarplyManagerHelper.openContest(this);
}
}
@Override
public void onOfferClick(OfferItem offerItem, int position) {
// Toast.makeText(this, "Offer clicked: " + offerItem.getTitle(), Toast.LENGTH_SHORT).show();
}
@Override
public void onFavoriteClick(OfferItem offerItem, int position) {
// Toast.makeText(this, "Favorite clicked for: " + offerItem.getTitle(), Toast.LENGTH_SHORT).show();
}
// ===========================================================
// Inner and Anonymous Classes
// ===========================================================
......
......@@ -14,7 +14,11 @@ import androidx.recyclerview.widget.RecyclerView;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.resource.bitmap.CenterCrop;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Locale;
import ly.warp.sdk.R;
import ly.warp.sdk.io.models.DummyDataProvider;
......@@ -99,12 +103,12 @@ public class OfferAdapter extends RecyclerView.Adapter<OfferAdapter.OfferViewHol
tvValidity = itemView.findViewById(R.id.tv_validity);
// Set click listeners
// itemView.setOnClickListener(v -> {
// int position = getAdapterPosition();
// if (listener != null && position != RecyclerView.NO_POSITION) {
// listener.onOfferClick(offerItems.get(position), position);
// }
// });
itemView.setOnClickListener(v -> {
int position = getAdapterPosition();
if (listener != null && position != RecyclerView.NO_POSITION) {
listener.onOfferClick(offerItems.get(position), position);
}
});
// ivFavorite.setOnClickListener(v -> {
// int position = getAdapterPosition();
......@@ -119,7 +123,7 @@ public class OfferAdapter extends RecyclerView.Adapter<OfferAdapter.OfferViewHol
tvTitle.setText(offerItem.getTitle());
tvDescription.setText(offerItem.getDescription());
tvPrice.setText(offerItem.getValue());
tvValidity.setText(offerItem.getEndDate());
tvValidity.setText(formatValidityDate(offerItem.getEndDate()));
// Set heart icon based on category
if (DummyDataProvider.CATEGORY_FAVORITES.equals(offerItem.getCategory())) {
......@@ -136,6 +140,26 @@ public class OfferAdapter extends RecyclerView.Adapter<OfferAdapter.OfferViewHol
}
/**
* Format the end date to "έως dd-MM" format
*
* @param endDate The end date in "dd/MM/yyyy" format
* @return Formatted date string
*/
private String formatValidityDate(String endDate) {
try {
SimpleDateFormat inputFormat = new SimpleDateFormat("dd/MM/yyyy", Locale.getDefault());
Date date = inputFormat.parse(endDate);
SimpleDateFormat outputFormat = new SimpleDateFormat("dd-MM", Locale.getDefault());
return "έως " + outputFormat.format(date);
} catch (ParseException e) {
// Fallback to original if parsing fails
return endDate;
}
}
/**
* Load offer image with rounded top corners using Glide
*
* @param imageName The image resource name
......
......@@ -9,6 +9,7 @@ public class OfferItem implements Serializable {
private String id;
private String title;
private String description;
private String fullDescription;
private String endDate;
private String value;
private String imageUrl;
......@@ -26,24 +27,43 @@ public class OfferItem implements Serializable {
*
* @param id Unique identifier for the offer
* @param title Title of the offer
* @param description Description of the offer
* @param description Short description of the offer
* @param fullDescription Detailed description of the offer (approximately 200 characters)
* @param endDate End date of the offer (formatted as string)
* @param value Value of the offer (formatted as string, e.g., "50%", "€20")
* @param imageUrl URL or resource name for the offer image
* @param logoUrl URL or resource name for the merchant logo
* @param category Category this offer belongs to
*/
public OfferItem(String id, String title, String description, String endDate,
public OfferItem(String id, String title, String description, String fullDescription, String endDate,
String value, String imageUrl, String logoUrl, String category) {
this.id = id;
this.title = title;
this.description = description;
this.fullDescription = fullDescription;
this.endDate = endDate;
this.value = value;
this.imageUrl = imageUrl;
this.logoUrl = logoUrl;
this.category = category;
}
/**
* Constructor for backward compatibility
*
* @param id Unique identifier for the offer
* @param title Title of the offer
* @param description Description of the offer
* @param endDate End date of the offer (formatted as string)
* @param value Value of the offer (formatted as string, e.g., "50%", "€20")
* @param imageUrl URL or resource name for the offer image
* @param logoUrl URL or resource name for the merchant logo
* @param category Category this offer belongs to
*/
public OfferItem(String id, String title, String description, String endDate,
String value, String imageUrl, String logoUrl, String category) {
this(id, title, description, description, endDate, value, imageUrl, logoUrl, category);
}
// Getters and Setters
......@@ -70,6 +90,14 @@ public class OfferItem implements Serializable {
public void setDescription(String description) {
this.description = description;
}
public String getFullDescription() {
return fullDescription;
}
public void setFullDescription(String fullDescription) {
this.fullDescription = fullDescription;
}
public String getEndDate() {
return endDate;
......
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/shape_cos_black_tr" android:state_pressed="true" />
<item android:drawable="@drawable/shape_cos_black" android:state_pressed="false" />
</selector>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/shape_transparent_black_border_tr" android:state_pressed="true" />
<item android:drawable="@drawable/shape_transparent_black_border" android:state_pressed="false" />
</selector>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="4dp" />
<solid
android:width="2dp"
android:color="@color/black2" />
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="4dp" />
<solid
android:width="2dp"
android:color="@color/black2_tr" />
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="4dp" />
<solid android:color="@android:color/transparent" />
<stroke
android:width="1dp"
android:color="@color/black2" />
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="4dp" />
<solid android:color="@android:color/transparent" />
<stroke
android:width="1dp"
android:color="@color/black2_tr" />
</shape>
\ No newline at end of file
......@@ -12,11 +12,17 @@
<color name="cos_skyblue2">#22A9B5</color>
<color name="blue_dark">#3A5266</color>
<color name="white">#FFFFFF</color>
<color name="white_tr">#66FFFFFF</color>
<color name="cos_green5">#79BF14</color>
<color name="black2">#000F1E</color>
<color name="black2_tr">#66000F1E</color>
<color name="black3">#00111B</color>
<color name="grey">#CCCCCC</color>
<color name="pink">#EE417D</color>
<color name="black4">#0D1B29</color>
<color name="black5">#020E1C</color>
<color name="pink2">#F2709D</color>
<color name="skyblue">#00A3E0</color>
<!-- Used in styles -->
<color name="cos_light_blue">#00A5E3</color>
......
......@@ -11,4 +11,16 @@
<string name="demo_sm_flow">Open SM Flow</string>
<string name="demo_sm_map">Open SM Map</string>
<string name="demo_all">Όλα</string>
<string name="demo_offer">Προσφορά</string>
<string name="demo_more">Περισσότερα</string>
<string name="demo_less">Λιγότερα</string>
<string name="demo_purchases">για αγορές</string>
<string name="demo_valid_until">Η προσφορά ισχύει έως %1$s</string>
<string name="demo_coupon_code">Κωδικός Κουπονιού</string>
<string name="demo_qr_code">QR Κουπονιού</string>
<string name="demo_terms">Όροι Χρήσης</string>
<string name="demo_copy_success">Ο κωδικός αντιγράφηκε στο πρόχειρο</string>
<string name="demo_lorem_ipsum">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</string>
<string name="demo_shops">Καταστήματα κοντά μου</string>
<string name="demo_website">Δες το website</string>
</resources>
......