Panagiotis Triantafyllou

redesign part3

......@@ -46,27 +46,15 @@ public class SingleCouponActivity extends Activity implements View.OnClickListen
private TextView mTvMoreButton;
private ImageView mIvImage;
private String mFullDescriptionText;
private boolean mIsDescriptionExpanded = false;
// Coupon code section
private LinearLayout mCouponCodeContainer;
private LinearLayout mCouponCodeHeader;
private LinearLayout mCouponCodeContent;
private ImageView mIvCouponArrow;
private ImageView mIvCopyCode;
private TextView mTvCouponCode;
private TextView mTvCouponCodeTitle;
private boolean mIsCouponCodeExpanded = false;
private TextView mTvCouponCodeTitle, mTvMerchantName;
// QR code section
private LinearLayout mQrCodeContainer;
private LinearLayout mQrCodeHeader;
private LinearLayout mQrCodeContent;
private ImageView mIvQrArrow;
private ImageView mIvQrCode;
private TextView mTvQrCodeTitle;
private boolean mIsQrCodeExpanded = false;
// Terms of Use section
private LinearLayout mTermsContainer;
......@@ -76,7 +64,7 @@ public class SingleCouponActivity extends Activity implements View.OnClickListen
private TextView mTvTermsText;
private boolean mIsTermsExpanded = false;
private TextView mTvHeaderTitle, mTvTermsTitle, mTvShopsTitle, mTvWebsiteTitle, mTVMoreTitle;
private TextView mTvTermsTitle, mTvShopsTitle, mTvWebsiteTitle;
// ===========================================================
......@@ -122,21 +110,12 @@ public class SingleCouponActivity extends Activity implements View.OnClickListen
mTvMoreButton = findViewById(R.id.tv_more_button);
// Initialize coupon code section
mCouponCodeContainer = findViewById(R.id.coupon_code_container);
mCouponCodeHeader = findViewById(R.id.coupon_code_header);
mCouponCodeContent = findViewById(R.id.coupon_code_content);
mIvCouponArrow = findViewById(R.id.iv_coupon_arrow);
mIvCopyCode = findViewById(R.id.iv_copy_code);
mTvCouponCode = findViewById(R.id.tv_coupon_code);
mTvCouponCodeTitle = findViewById(R.id.tv_coupon_code_title);
// Initialize QR code section
mQrCodeContainer = findViewById(R.id.qr_code_container);
mQrCodeHeader = findViewById(R.id.qr_code_header);
mQrCodeContent = findViewById(R.id.qr_code_content);
mIvQrArrow = findViewById(R.id.iv_qr_arrow);
mIvQrCode = findViewById(R.id.iv_qr_code);
mTvQrCodeTitle = findViewById(R.id.tv_qr_code_title);
// Initialize Terms of Use section
mTermsContainer = findViewById(R.id.terms_container);
......@@ -145,18 +124,18 @@ public class SingleCouponActivity extends Activity implements View.OnClickListen
mIvTermsArrow = findViewById(R.id.iv_terms_arrow);
mTvTermsText = findViewById(R.id.tv_terms_text);
mTvHeaderTitle = findViewById(R.id.tv_header_title);
mTvTermsTitle = findViewById(R.id.tv_terms_title);
mTvShopsTitle = findViewById(R.id.tv_shops_title);
mTvWebsiteTitle = findViewById(R.id.tv_website_title);
mTVMoreTitle = findViewById(R.id.tv_more_title);
mTvMerchantName = findViewById(R.id.tv_merchant_value);
WarpUtils.renderCustomFont(this, R.font.ping_lcg_bold, mTvHeaderTitle, mTvValue,
mTvCouponCode, mTvTermsTitle, mTvShopsTitle, mTvWebsiteTitle);
WarpUtils.renderCustomFont(this, R.font.ping_lcg_bold, mTvValue,
mTvCouponCode, mTvTermsTitle, mTvCouponCodeTitle,
mTvMerchantName, mTvEndDate, mTvMoreButton);
WarpUtils.renderCustomFont(this, R.font.ping_lcg_regular, mTvSmallDescription,
mTvEndDate, mTvFullDescription, mTvCouponCodeTitle, mTvQrCodeTitle, mTvTermsText,
mTVMoreTitle, mTvMoreButton);
mTvFullDescription, mTvTermsText,
mTvShopsTitle, mTvWebsiteTitle);
if (mOfferItem != null) {
if (mOfferItem.getExpiration() != null && !mOfferItem.getExpiration().isEmpty()) {
......@@ -178,6 +157,8 @@ public class SingleCouponActivity extends Activity implements View.OnClickListen
.into(mIvImage);
}
if (mOfferItem.getCouponsetDetails() != null && mOfferItem.getCouponsetDetails().getAdmin_name() != null && !TextUtils.isEmpty(mOfferItem.getCouponsetDetails().getAdmin_name()))
mTvMerchantName.setText(mOfferItem.getCouponsetDetails().getAdmin_name());
if (mOfferItem.getCouponsetDetails() != null && mOfferItem.getCouponsetDetails().getName() != null && !TextUtils.isEmpty(mOfferItem.getCouponsetDetails().getName()))
mTvValue.setText(mOfferItem.getCouponsetDetails().getName());
if (mOfferItem.getCouponsetDetails() != null && mOfferItem.getCouponsetDetails().getShort_description() != null && !TextUtils.isEmpty(mOfferItem.getCouponsetDetails().getShort_description()))
......@@ -193,9 +174,6 @@ public class SingleCouponActivity extends Activity implements View.OnClickListen
// Setup coupon code section
setupCouponCodeSection();
// Setup QR code section
setupQrCodeSection();
// Setup Terms of Use section
setupTermsSection();
}
......@@ -205,14 +183,14 @@ public class SingleCouponActivity extends Activity implements View.OnClickListen
try {
SimpleDateFormat inputFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault());
Date date = inputFormat.parse(endDate);
SimpleDateFormat outputFormat = new SimpleDateFormat("dd-MM", Locale.getDefault());
return "έως " + outputFormat.format(date);
SimpleDateFormat outputFormat = new SimpleDateFormat("MMMM d, yyyy", Locale.ENGLISH);
return outputFormat.format(date);
} catch (ParseException e) {
try {
SimpleDateFormat inputFormat2 = new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.getDefault());
Date date = inputFormat2.parse(endDate);
SimpleDateFormat outputFormat = new SimpleDateFormat("dd-MM", Locale.getDefault());
return "έως " + outputFormat.format(date);
SimpleDateFormat outputFormat = new SimpleDateFormat("MMMM d, yyyy", Locale.ENGLISH);
return outputFormat.format(date);
} catch (ParseException e2) {
return endDate;
}
......@@ -222,22 +200,6 @@ public class SingleCouponActivity extends Activity implements View.OnClickListen
private void setupCouponCodeSection() {
mTvCouponCode.setText(mOfferItem.getCoupon());
// Set click listener for the header to expand/collapse
mCouponCodeHeader.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
toggleCouponCodeExpansion();
}
});
// Set click listener for the entire container as well
mCouponCodeContainer.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
toggleCouponCodeExpansion();
}
});
// Set click listener for the copy button
mIvCopyCode.setOnClickListener(new View.OnClickListener() {
@Override
......@@ -247,20 +209,6 @@ public class SingleCouponActivity extends Activity implements View.OnClickListen
});
}
private void toggleCouponCodeExpansion() {
if (mIsCouponCodeExpanded) {
// Collapse the content
mCouponCodeContent.setVisibility(View.GONE);
mIvCouponArrow.setImageResource(R.drawable.ic_arrow_down);
mIsCouponCodeExpanded = false;
} else {
// Expand the content
mCouponCodeContent.setVisibility(View.VISIBLE);
mIvCouponArrow.setImageResource(R.drawable.ic_arrow_up);
mIsCouponCodeExpanded = true;
}
}
private void copyCouponCodeToClipboard() {
String couponCode = mTvCouponCode.getText().toString();
......@@ -313,38 +261,6 @@ public class SingleCouponActivity extends Activity implements View.OnClickListen
}
}
private void setupQrCodeSection() {
// Set click listener for the header to expand/collapse
mQrCodeHeader.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
toggleQrCodeExpansion();
}
});
// Set click listener for the entire container as well
mQrCodeContainer.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
toggleQrCodeExpansion();
}
});
}
private void toggleQrCodeExpansion() {
if (mIsQrCodeExpanded) {
// Collapse the content
mQrCodeContent.setVisibility(View.GONE);
mIvQrArrow.setImageResource(R.drawable.ic_arrow_down);
mIsQrCodeExpanded = false;
} else {
// Expand the content
mQrCodeContent.setVisibility(View.VISIBLE);
mIvQrArrow.setImageResource(R.drawable.ic_arrow_up);
mIsQrCodeExpanded = true;
}
}
private void setupTermsSection() {
// Set click listener for the header to expand/collapse
mTermsHeader.setOnClickListener(new View.OnClickListener() {
......@@ -367,12 +283,12 @@ public class SingleCouponActivity extends Activity implements View.OnClickListen
if (mIsTermsExpanded) {
// Collapse the content
mTermsContent.setVisibility(View.GONE);
mIvTermsArrow.setImageResource(R.drawable.ic_arrow_down);
mIvTermsArrow.animate().rotation(0f).setDuration(200).start();
mIsTermsExpanded = false;
} else {
// Expand the content
mTermsContent.setVisibility(View.VISIBLE);
mIvTermsArrow.setImageResource(R.drawable.ic_arrow_up);
mIvTermsArrow.animate().rotation(180f).setDuration(200).start();
mIsTermsExpanded = true;
}
}
......
......@@ -6,6 +6,7 @@ import android.os.Bundle;
import android.os.Parcelable;
import android.text.TextUtils;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
......@@ -52,6 +53,8 @@ public class SingleCouponsetActivity extends Activity implements View.OnClickLis
private LinearLayout mRedeemButton, mSuccessButton;
private boolean mIsDescriptionExpanded = false;
private RelativeLayout mPbLoading;
private View mSpacer;
private LinearLayout mLlCouponInfo;
// Terms of Use section
private LinearLayout mTermsContainer;
private LinearLayout mTermsHeader;
......@@ -137,6 +140,9 @@ public class SingleCouponsetActivity extends Activity implements View.OnClickLis
mTvRedeemTitle = findViewById(R.id.tv_redeem_title);
mTvSuccessRedeemTitle = findViewById(R.id.tv_success_redeem_title);
mSpacer = findViewById(R.id.v_spacer);
mLlCouponInfo = findViewById(R.id.ll_coupon_info);
WarpUtils.renderCustomFont(this, R.font.ping_lcg_bold, mTvValue,
mTvTermsTitle, mTvMoreButton, mTvMerchantName,
mTvEndDate);
......@@ -180,6 +186,19 @@ public class SingleCouponsetActivity extends Activity implements View.OnClickLis
// Setup Terms of Use section
setupTermsSection();
mLlCouponInfo.post(() -> {
int usedHeight = 0;
for (int i = 0; i < mLlCouponInfo.getChildCount(); i++) {
View child = mLlCouponInfo.getChildAt(i);
if (child != mSpacer) {
usedHeight += child.getMeasuredHeight();
}
}
ViewGroup.LayoutParams params = mSpacer.getLayoutParams();
params.height = (int) (usedHeight * 0.5);
mSpacer.setLayoutParams(params);
});
}
}
......@@ -241,12 +260,12 @@ public class SingleCouponsetActivity extends Activity implements View.OnClickLis
if (mIsTermsExpanded) {
// Collapse the content
mTermsContent.setVisibility(View.GONE);
mIvTermsArrow.setImageResource(R.drawable.ic_arrow_down);
mIvTermsArrow.animate().rotation(0f).setDuration(200).start();
mIsTermsExpanded = false;
} else {
// Expand the content
mTermsContent.setVisibility(View.VISIBLE);
mIvTermsArrow.setImageResource(R.drawable.ic_arrow_up);
mIvTermsArrow.animate().rotation(180f).setDuration(200).start();
mIsTermsExpanded = true;
}
}
......@@ -255,13 +274,13 @@ public class SingleCouponsetActivity extends Activity implements View.OnClickLis
try {
SimpleDateFormat inputFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault());
Date date = inputFormat.parse(endDate);
SimpleDateFormat outputFormat = new SimpleDateFormat("dd-MM", Locale.getDefault());
SimpleDateFormat outputFormat = new SimpleDateFormat("MMMM d, yyyy", Locale.ENGLISH);
return outputFormat.format(date);
} catch (ParseException e) {
try {
SimpleDateFormat inputFormat2 = new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.getDefault());
Date date = inputFormat2.parse(endDate);
SimpleDateFormat outputFormat = new SimpleDateFormat("dd-MM", Locale.getDefault());
SimpleDateFormat outputFormat = new SimpleDateFormat("MMMM d, yyyy", Locale.ENGLISH);
return outputFormat.format(date);
} catch (ParseException e2) {
return endDate;
......
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="1000dp" />
<solid
android:width="2dp"
android:color="@color/custom_skyblue4" />
</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="12dp" />
<solid
android:width="2dp"
android:color="@color/custom_skyblue4" />
</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="10dp" />
<solid android:color="@android:color/white" />
</shape>
\ No newline at end of file
......@@ -14,7 +14,7 @@
<LinearLayout
android:id="@+id/home_content_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_height="match_parent"
android:orientation="vertical">
<androidx.constraintlayout.widget.ConstraintLayout
......@@ -54,24 +54,23 @@
<LinearLayout
android:id="@+id/ll_coupon_info"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_height="0dp"
android:layout_weight="1"
android:layout_marginBottom="48dp"
android:orientation="vertical"
android:paddingHorizontal="16dp"
android:paddingVertical="16dp">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/cl_info"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal">
android:layout_height="wrap_content">
<LinearLayout
android:id="@+id/ll_info"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingEnd="16dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
......@@ -113,6 +112,7 @@
</androidx.constraintlayout.widget.ConstraintLayout>
<LinearLayout
android:id="@+id/ll_date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="22dp"
......@@ -164,11 +164,16 @@
android:textSize="15sp"
android:visibility="gone" />
<View
android:id="@+id/v_spacer"
android:layout_width="match_parent"
android:layout_height="0dp"
tools:layout_height="100dp"/>
<LinearLayout
android:id="@+id/ll_redeem_coupon"
android:layout_width="match_parent"
android:layout_height="55dp"
android:layout_marginTop="20dp"
android:background="@drawable/shape_rectangle_rounded_light_blue_tr"
android:gravity="center"
android:orientation="horizontal">
......@@ -187,7 +192,6 @@
android:id="@+id/ll_success_redeem"
android:layout_width="match_parent"
android:layout_height="55dp"
android:layout_marginTop="20dp"
android:background="@drawable/shape_rectangle_rounded_light_green"
android:gravity="center"
android:orientation="horizontal"
......
......@@ -10,17 +10,17 @@
<string name="demo_all">Όλα</string>
<string name="demo_offer">Προσφορά</string>
<string name="demo_more">View more</string>
<string name="demo_less">Λιγότερα</string>
<string name="demo_less">View less</string>
<string name="demo_purchases">για αγορές</string>
<string name="demo_valid_until">Valid until %1$s</string>
<string name="demo_coupon_code">Κωδικός Κουπονιού</string>
<string name="demo_coupon_code">Available code</string>
<string name="demo_qr_code">QR Κουπονιού</string>
<string name="demo_barcode_code">Barcode Κουπονιού</string>
<string name="demo_terms">Offer terms of use</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>
<string name="demo_shops">Store near me</string>
<string name="demo_website">View website</string>
<string name="demo_redeem">Get coupon</string>
<string name="demo_success_redeem">Saved to My Coupons</string>
<string name="demo_profile">Το προφίλ μου</string>
......