Showing
4 changed files
with
81 additions
and
15 deletions
... | @@ -44,6 +44,10 @@ dependencies { | ... | @@ -44,6 +44,10 @@ dependencies { |
44 | api 'de.hdodenhof:circleimageview:3.1.0' | 44 | api 'de.hdodenhof:circleimageview:3.1.0' |
45 | api group: 'io.reactivex.rxjava2', name: 'rxjava', version: '2.2.21' | 45 | api group: 'io.reactivex.rxjava2', name: 'rxjava', version: '2.2.21' |
46 | api 'com.google.android.material:material:1.5.0' | 46 | api 'com.google.android.material:material:1.5.0' |
47 | + api group: 'com.google.zxing', name: 'core', version: '3.4.1' | ||
48 | + api group: 'com.google.zxing', name: 'javase', version: '3.4.1' | ||
49 | + | ||
50 | + | ||
47 | 51 | ||
48 | //------------------------------ Firebase -----------------------------// | 52 | //------------------------------ Firebase -----------------------------// |
49 | api platform('com.google.firebase:firebase-bom:29.0.3') | 53 | api platform('com.google.firebase:firebase-bom:29.0.3') | ... | ... |
... | @@ -2,6 +2,8 @@ package ly.warp.sdk.activities; | ... | @@ -2,6 +2,8 @@ package ly.warp.sdk.activities; |
2 | 2 | ||
3 | import android.app.Activity; | 3 | import android.app.Activity; |
4 | import android.content.Intent; | 4 | import android.content.Intent; |
5 | +import android.graphics.Bitmap; | ||
6 | +import android.graphics.Color; | ||
5 | import android.graphics.Paint; | 7 | import android.graphics.Paint; |
6 | import android.os.Bundle; | 8 | import android.os.Bundle; |
7 | import android.text.TextUtils; | 9 | import android.text.TextUtils; |
... | @@ -12,6 +14,11 @@ import android.widget.TextView; | ... | @@ -12,6 +14,11 @@ import android.widget.TextView; |
12 | 14 | ||
13 | import com.bumptech.glide.Glide; | 15 | import com.bumptech.glide.Glide; |
14 | import com.bumptech.glide.load.engine.DiskCacheStrategy; | 16 | import com.bumptech.glide.load.engine.DiskCacheStrategy; |
17 | +import com.google.zxing.BarcodeFormat; | ||
18 | +import com.google.zxing.WriterException; | ||
19 | +import com.google.zxing.common.BitMatrix; | ||
20 | +import com.google.zxing.oned.EAN13Writer; | ||
21 | +import com.google.zxing.qrcode.QRCodeWriter; | ||
15 | 22 | ||
16 | import java.text.ParseException; | 23 | import java.text.ParseException; |
17 | import java.text.SimpleDateFormat; | 24 | import java.text.SimpleDateFormat; |
... | @@ -31,8 +38,8 @@ public class CouponInfoActivity extends Activity implements View.OnClickListener | ... | @@ -31,8 +38,8 @@ public class CouponInfoActivity extends Activity implements View.OnClickListener |
31 | // Fields | 38 | // Fields |
32 | // =========================================================== | 39 | // =========================================================== |
33 | 40 | ||
34 | - private ImageView mIvBack, mIvCoupoPhoto; | 41 | + private ImageView mIvBack, mIvCouponPhoto, mIvBarcode; |
35 | - private TextView mTvTerms, mTvCouponCode, mTvCouponTitle, mTvCouponSubtitle, mTvCouponDate; | 42 | + private TextView mTvTerms, mTvCouponCode, mTvCouponTitle, mTvCouponSubtitle, mTvCouponDate, mTvBarcodeCode; |
36 | private LinearLayout mLlGiftIt; | 43 | private LinearLayout mLlGiftIt; |
37 | private Coupon mCoupon; | 44 | private Coupon mCoupon; |
38 | 45 | ||
... | @@ -54,7 +61,8 @@ public class CouponInfoActivity extends Activity implements View.OnClickListener | ... | @@ -54,7 +61,8 @@ public class CouponInfoActivity extends Activity implements View.OnClickListener |
54 | mTvCouponTitle = findViewById(R.id.textView13); | 61 | mTvCouponTitle = findViewById(R.id.textView13); |
55 | mTvCouponSubtitle = findViewById(R.id.textView14); | 62 | mTvCouponSubtitle = findViewById(R.id.textView14); |
56 | mTvCouponDate = findViewById(R.id.textView17); | 63 | mTvCouponDate = findViewById(R.id.textView17); |
57 | - mIvCoupoPhoto = findViewById(R.id.imageView6); | 64 | + mIvCouponPhoto = findViewById(R.id.imageView6); |
65 | + mIvBarcode = findViewById(R.id.iv_barcode); | ||
58 | 66 | ||
59 | initViews(); | 67 | initViews(); |
60 | } | 68 | } |
... | @@ -104,15 +112,36 @@ public class CouponInfoActivity extends Activity implements View.OnClickListener | ... | @@ -104,15 +112,36 @@ public class CouponInfoActivity extends Activity implements View.OnClickListener |
104 | // .error(R.drawable.ic_default_contact_photo)) | 112 | // .error(R.drawable.ic_default_contact_photo)) |
105 | .load(mCoupon.getImage()) | 113 | .load(mCoupon.getImage()) |
106 | .diskCacheStrategy(DiskCacheStrategy.DATA) | 114 | .diskCacheStrategy(DiskCacheStrategy.DATA) |
107 | - .into(mIvCoupoPhoto); | 115 | + .into(mIvCouponPhoto); |
108 | } else { | 116 | } else { |
109 | Glide.with(this) | 117 | Glide.with(this) |
110 | .load(R.drawable.ic_cosmote_logo_horizontal_grey) | 118 | .load(R.drawable.ic_cosmote_logo_horizontal_grey) |
111 | - .into(mIvCoupoPhoto); | 119 | + .into(mIvCouponPhoto); |
112 | } | 120 | } |
113 | mIvBack.setOnClickListener(this); | 121 | mIvBack.setOnClickListener(this); |
114 | mTvTerms.setPaintFlags(mTvTerms.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG); | 122 | mTvTerms.setPaintFlags(mTvTerms.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG); |
115 | mLlGiftIt.setOnClickListener(this); | 123 | mLlGiftIt.setOnClickListener(this); |
124 | + | ||
125 | + createBarcodeBitmap(mCoupon.getCoupon()); | ||
126 | + } | ||
127 | + | ||
128 | + private void createBarcodeBitmap(String barcodeString) { | ||
129 | + EAN13Writer writer = new EAN13Writer(); | ||
130 | + try { | ||
131 | + BitMatrix bitMatrix = writer.encode(barcodeString, BarcodeFormat.EAN_13, 1024, 512); | ||
132 | + int width = bitMatrix.getWidth(); | ||
133 | + int height = bitMatrix.getHeight(); | ||
134 | + Bitmap bmp = Bitmap.createBitmap(width, height, Bitmap.Config.RGB_565); | ||
135 | + for (int x = 0; x < width; x++) { | ||
136 | + for (int y = 0; y < height; y++) { | ||
137 | + bmp.setPixel(x, y, bitMatrix.get(x, y) ? Color.BLACK : Color.WHITE); | ||
138 | + } | ||
139 | + } | ||
140 | + mIvBarcode.setImageBitmap(bmp); | ||
141 | + | ||
142 | + } catch (Exception e) { | ||
143 | + e.printStackTrace(); | ||
144 | + } | ||
116 | } | 145 | } |
117 | 146 | ||
118 | // =========================================================== | 147 | // =========================================================== | ... | ... |
1.93 KB
... | @@ -70,14 +70,14 @@ | ... | @@ -70,14 +70,14 @@ |
70 | android:layout_height="wrap_content" | 70 | android:layout_height="wrap_content" |
71 | android:layout_marginTop="32dp" | 71 | android:layout_marginTop="32dp" |
72 | android:paddingHorizontal="32dp" | 72 | android:paddingHorizontal="32dp" |
73 | - tools:text="Πάρε δωρεάν μηνιαία πακέτα με πάνες στα supermarket Σκλαβενίτης!" | ||
74 | android:textColor="#415564" | 73 | android:textColor="#415564" |
75 | android:textSize="18sp" | 74 | android:textSize="18sp" |
76 | android:textStyle="bold" | 75 | android:textStyle="bold" |
77 | app:layout_constraintEnd_toEndOf="parent" | 76 | app:layout_constraintEnd_toEndOf="parent" |
78 | app:layout_constraintHorizontal_bias="0.509" | 77 | app:layout_constraintHorizontal_bias="0.509" |
79 | app:layout_constraintStart_toStartOf="parent" | 78 | app:layout_constraintStart_toStartOf="parent" |
80 | - app:layout_constraintTop_toBottomOf="@+id/imageView6" /> | 79 | + app:layout_constraintTop_toBottomOf="@+id/imageView6" |
80 | + tools:text="Πάρε δωρεάν μηνιαία πακέτα με πάνες στα supermarket Σκλαβενίτης!" /> | ||
81 | 81 | ||
82 | <TextView | 82 | <TextView |
83 | android:id="@+id/textView14" | 83 | android:id="@+id/textView14" |
... | @@ -85,12 +85,12 @@ | ... | @@ -85,12 +85,12 @@ |
85 | android:layout_height="wrap_content" | 85 | android:layout_height="wrap_content" |
86 | android:layout_marginTop="16dp" | 86 | android:layout_marginTop="16dp" |
87 | android:paddingHorizontal="32dp" | 87 | android:paddingHorizontal="32dp" |
88 | - tools:text="Χρησιμοποίησε τον παρακάτω κωδικό και πάρε δωρεάν πακέτο πάνες Pampers αποκλειστικά στα Supermarket Σκλαβενίτης" | ||
89 | android:textColor="#415564" | 88 | android:textColor="#415564" |
90 | android:textSize="16sp" | 89 | android:textSize="16sp" |
91 | app:layout_constraintEnd_toEndOf="parent" | 90 | app:layout_constraintEnd_toEndOf="parent" |
92 | app:layout_constraintStart_toStartOf="parent" | 91 | app:layout_constraintStart_toStartOf="parent" |
93 | - app:layout_constraintTop_toBottomOf="@+id/textView13" /> | 92 | + app:layout_constraintTop_toBottomOf="@+id/textView13" |
93 | + tools:text="Χρησιμοποίησε τον παρακάτω κωδικό και πάρε δωρεάν πακέτο πάνες Pampers αποκλειστικά στα Supermarket Σκλαβενίτης" /> | ||
94 | 94 | ||
95 | <TextView | 95 | <TextView |
96 | android:id="@+id/textView15" | 96 | android:id="@+id/textView15" |
... | @@ -114,24 +114,45 @@ | ... | @@ -114,24 +114,45 @@ |
114 | android:layout_marginTop="12dp" | 114 | android:layout_marginTop="12dp" |
115 | android:background="@drawable/banner_border_light_blue" | 115 | android:background="@drawable/banner_border_light_blue" |
116 | android:gravity="center" | 116 | android:gravity="center" |
117 | - tools:text="1A2C378" | ||
118 | android:textColor="#415564" | 117 | android:textColor="#415564" |
119 | android:textSize="25dp" | 118 | android:textSize="25dp" |
120 | android:textStyle="bold" | 119 | android:textStyle="bold" |
121 | app:layout_constraintEnd_toEndOf="parent" | 120 | app:layout_constraintEnd_toEndOf="parent" |
122 | app:layout_constraintStart_toStartOf="parent" | 121 | app:layout_constraintStart_toStartOf="parent" |
123 | - app:layout_constraintTop_toBottomOf="@+id/textView15" /> | 122 | + app:layout_constraintTop_toBottomOf="@+id/textView15" |
123 | + tools:text="1A2C378" /> | ||
124 | + | ||
125 | + <View | ||
126 | + android:id="@+id/view4" | ||
127 | + android:layout_width="320dp" | ||
128 | + android:layout_height="0.8dp" | ||
129 | + android:layout_marginTop="20dp" | ||
130 | + android:background="#E6E6E6" | ||
131 | + app:layout_constraintEnd_toEndOf="parent" | ||
132 | + app:layout_constraintHorizontal_bias="0.505" | ||
133 | + app:layout_constraintStart_toStartOf="parent" | ||
134 | + app:layout_constraintTop_toBottomOf="@+id/iv_barcode" /> | ||
135 | + | ||
136 | + <View | ||
137 | + android:id="@+id/view5" | ||
138 | + android:layout_width="320dp" | ||
139 | + android:layout_height="0.8dp" | ||
140 | + android:layout_marginTop="16dp" | ||
141 | + android:background="#E6E6E6" | ||
142 | + app:layout_constraintEnd_toEndOf="parent" | ||
143 | + app:layout_constraintStart_toStartOf="parent" | ||
144 | + app:layout_constraintTop_toBottomOf="@+id/textView16" /> | ||
124 | 145 | ||
125 | <TextView | 146 | <TextView |
126 | android:id="@+id/textView17" | 147 | android:id="@+id/textView17" |
127 | android:layout_width="wrap_content" | 148 | android:layout_width="wrap_content" |
128 | android:layout_height="wrap_content" | 149 | android:layout_height="wrap_content" |
129 | - android:layout_marginTop="24dp" | 150 | + android:layout_marginTop="40dp" |
130 | - tools:text="@string/cos_coupon_date" | ||
131 | android:textColor="#415564" | 151 | android:textColor="#415564" |
132 | app:layout_constraintEnd_toEndOf="parent" | 152 | app:layout_constraintEnd_toEndOf="parent" |
133 | app:layout_constraintStart_toStartOf="parent" | 153 | app:layout_constraintStart_toStartOf="parent" |
134 | - app:layout_constraintTop_toBottomOf="@+id/textView16" /> | 154 | + app:layout_constraintTop_toBottomOf="@+id/view4" |
155 | + tools:text="@string/cos_coupon_date" /> | ||
135 | 156 | ||
136 | <LinearLayout | 157 | <LinearLayout |
137 | android:id="@+id/ll_gift_it" | 158 | android:id="@+id/ll_gift_it" |
... | @@ -151,7 +172,7 @@ | ... | @@ -151,7 +172,7 @@ |
151 | android:layout_height="25dp" | 172 | android:layout_height="25dp" |
152 | android:layout_marginRight="15dp" | 173 | android:layout_marginRight="15dp" |
153 | android:adjustViewBounds="true" | 174 | android:adjustViewBounds="true" |
154 | - android:src="@drawable/phone_white" /> | 175 | + android:src="@drawable/gift_icon" /> |
155 | 176 | ||
156 | <TextView | 177 | <TextView |
157 | android:layout_width="wrap_content" | 178 | android:layout_width="wrap_content" |
... | @@ -200,6 +221,18 @@ | ... | @@ -200,6 +221,18 @@ |
200 | app:layout_constraintStart_toStartOf="parent" | 221 | app:layout_constraintStart_toStartOf="parent" |
201 | app:layout_constraintTop_toBottomOf="@+id/ll_get_gift" /> | 222 | app:layout_constraintTop_toBottomOf="@+id/ll_get_gift" /> |
202 | 223 | ||
224 | + <ImageView | ||
225 | + android:id="@+id/iv_barcode" | ||
226 | + android:layout_width="284dp" | ||
227 | + android:layout_height="86dp" | ||
228 | + android:layout_marginTop="16dp" | ||
229 | + android:scaleType="fitXY" | ||
230 | + app:layout_constraintEnd_toEndOf="parent" | ||
231 | + app:layout_constraintHorizontal_bias="0.496" | ||
232 | + app:layout_constraintStart_toStartOf="parent" | ||
233 | + app:layout_constraintTop_toBottomOf="@+id/view5" | ||
234 | + tools:srcCompat="@tools:sample/avatars" /> | ||
235 | + | ||
203 | </androidx.constraintlayout.widget.ConstraintLayout> | 236 | </androidx.constraintlayout.widget.ConstraintLayout> |
204 | </androidx.constraintlayout.widget.ConstraintLayout> | 237 | </androidx.constraintlayout.widget.ConstraintLayout> |
205 | </ScrollView> | 238 | </ScrollView> | ... | ... |
-
Please register or login to post a comment