thkouk00

barcode added in couponInfo

......@@ -44,6 +44,10 @@ dependencies {
api 'de.hdodenhof:circleimageview:3.1.0'
api group: 'io.reactivex.rxjava2', name: 'rxjava', version: '2.2.21'
api 'com.google.android.material:material:1.5.0'
api group: 'com.google.zxing', name: 'core', version: '3.4.1'
api group: 'com.google.zxing', name: 'javase', version: '3.4.1'
//------------------------------ Firebase -----------------------------//
api platform('com.google.firebase:firebase-bom:29.0.3')
......
......@@ -2,6 +2,8 @@ package ly.warp.sdk.activities;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.graphics.Paint;
import android.os.Bundle;
import android.text.TextUtils;
......@@ -12,6 +14,11 @@ import android.widget.TextView;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.WriterException;
import com.google.zxing.common.BitMatrix;
import com.google.zxing.oned.EAN13Writer;
import com.google.zxing.qrcode.QRCodeWriter;
import java.text.ParseException;
import java.text.SimpleDateFormat;
......@@ -31,8 +38,8 @@ public class CouponInfoActivity extends Activity implements View.OnClickListener
// Fields
// ===========================================================
private ImageView mIvBack, mIvCoupoPhoto;
private TextView mTvTerms, mTvCouponCode, mTvCouponTitle, mTvCouponSubtitle, mTvCouponDate;
private ImageView mIvBack, mIvCouponPhoto, mIvBarcode;
private TextView mTvTerms, mTvCouponCode, mTvCouponTitle, mTvCouponSubtitle, mTvCouponDate, mTvBarcodeCode;
private LinearLayout mLlGiftIt;
private Coupon mCoupon;
......@@ -54,7 +61,8 @@ public class CouponInfoActivity extends Activity implements View.OnClickListener
mTvCouponTitle = findViewById(R.id.textView13);
mTvCouponSubtitle = findViewById(R.id.textView14);
mTvCouponDate = findViewById(R.id.textView17);
mIvCoupoPhoto = findViewById(R.id.imageView6);
mIvCouponPhoto = findViewById(R.id.imageView6);
mIvBarcode = findViewById(R.id.iv_barcode);
initViews();
}
......@@ -104,15 +112,36 @@ public class CouponInfoActivity extends Activity implements View.OnClickListener
// .error(R.drawable.ic_default_contact_photo))
.load(mCoupon.getImage())
.diskCacheStrategy(DiskCacheStrategy.DATA)
.into(mIvCoupoPhoto);
.into(mIvCouponPhoto);
} else {
Glide.with(this)
.load(R.drawable.ic_cosmote_logo_horizontal_grey)
.into(mIvCoupoPhoto);
.into(mIvCouponPhoto);
}
mIvBack.setOnClickListener(this);
mTvTerms.setPaintFlags(mTvTerms.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
mLlGiftIt.setOnClickListener(this);
createBarcodeBitmap(mCoupon.getCoupon());
}
private void createBarcodeBitmap(String barcodeString) {
EAN13Writer writer = new EAN13Writer();
try {
BitMatrix bitMatrix = writer.encode(barcodeString, BarcodeFormat.EAN_13, 1024, 512);
int width = bitMatrix.getWidth();
int height = bitMatrix.getHeight();
Bitmap bmp = Bitmap.createBitmap(width, height, Bitmap.Config.RGB_565);
for (int x = 0; x < width; x++) {
for (int y = 0; y < height; y++) {
bmp.setPixel(x, y, bitMatrix.get(x, y) ? Color.BLACK : Color.WHITE);
}
}
mIvBarcode.setImageBitmap(bmp);
} catch (Exception e) {
e.printStackTrace();
}
}
// ===========================================================
......
......@@ -70,14 +70,14 @@
android:layout_height="wrap_content"
android:layout_marginTop="32dp"
android:paddingHorizontal="32dp"
tools:text="Πάρε δωρεάν μηνιαία πακέτα με πάνες στα supermarket Σκλαβενίτης!"
android:textColor="#415564"
android:textSize="18sp"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.509"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/imageView6" />
app:layout_constraintTop_toBottomOf="@+id/imageView6"
tools:text="Πάρε δωρεάν μηνιαία πακέτα με πάνες στα supermarket Σκλαβενίτης!" />
<TextView
android:id="@+id/textView14"
......@@ -85,12 +85,12 @@
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:paddingHorizontal="32dp"
tools:text="Χρησιμοποίησε τον παρακάτω κωδικό και πάρε δωρεάν πακέτο πάνες Pampers αποκλειστικά στα Supermarket Σκλαβενίτης"
android:textColor="#415564"
android:textSize="16sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView13" />
app:layout_constraintTop_toBottomOf="@+id/textView13"
tools:text="Χρησιμοποίησε τον παρακάτω κωδικό και πάρε δωρεάν πακέτο πάνες Pampers αποκλειστικά στα Supermarket Σκλαβενίτης" />
<TextView
android:id="@+id/textView15"
......@@ -114,24 +114,45 @@
android:layout_marginTop="12dp"
android:background="@drawable/banner_border_light_blue"
android:gravity="center"
tools:text="1A2C378"
android:textColor="#415564"
android:textSize="25dp"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView15" />
app:layout_constraintTop_toBottomOf="@+id/textView15"
tools:text="1A2C378" />
<View
android:id="@+id/view4"
android:layout_width="320dp"
android:layout_height="0.8dp"
android:layout_marginTop="20dp"
android:background="#E6E6E6"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.505"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/iv_barcode" />
<View
android:id="@+id/view5"
android:layout_width="320dp"
android:layout_height="0.8dp"
android:layout_marginTop="16dp"
android:background="#E6E6E6"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView16" />
<TextView
android:id="@+id/textView17"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="24dp"
tools:text="@string/cos_coupon_date"
android:layout_marginTop="40dp"
android:textColor="#415564"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView16" />
app:layout_constraintTop_toBottomOf="@+id/view4"
tools:text="@string/cos_coupon_date" />
<LinearLayout
android:id="@+id/ll_gift_it"
......@@ -151,7 +172,7 @@
android:layout_height="25dp"
android:layout_marginRight="15dp"
android:adjustViewBounds="true"
android:src="@drawable/phone_white" />
android:src="@drawable/gift_icon" />
<TextView
android:layout_width="wrap_content"
......@@ -200,6 +221,18 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/ll_get_gift" />
<ImageView
android:id="@+id/iv_barcode"
android:layout_width="284dp"
android:layout_height="86dp"
android:layout_marginTop="16dp"
android:scaleType="fitXY"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.496"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/view5"
tools:srcCompat="@tools:sample/avatars" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView>
......