Showing
9 changed files
with
216 additions
and
1 deletions
| ... | @@ -10,6 +10,7 @@ import android.text.TextUtils; | ... | @@ -10,6 +10,7 @@ import android.text.TextUtils; |
| 10 | import android.util.TypedValue; | 10 | import android.util.TypedValue; |
| 11 | import android.view.LayoutInflater; | 11 | import android.view.LayoutInflater; |
| 12 | import android.view.View; | 12 | import android.view.View; |
| 13 | +import android.view.ViewGroup; | ||
| 13 | import android.widget.ImageView; | 14 | import android.widget.ImageView; |
| 14 | import android.widget.LinearLayout; | 15 | import android.widget.LinearLayout; |
| 15 | import android.widget.RelativeLayout; | 16 | import android.widget.RelativeLayout; |
| ... | @@ -24,6 +25,8 @@ import androidx.viewpager2.widget.ViewPager2; | ... | @@ -24,6 +25,8 @@ import androidx.viewpager2.widget.ViewPager2; |
| 24 | 25 | ||
| 25 | import com.bumptech.glide.Glide; | 26 | import com.bumptech.glide.Glide; |
| 26 | import com.bumptech.glide.load.engine.DiskCacheStrategy; | 27 | import com.bumptech.glide.load.engine.DiskCacheStrategy; |
| 28 | +import com.google.android.material.bottomsheet.BottomSheetBehavior; | ||
| 29 | +import com.google.android.material.bottomsheet.BottomSheetDialog; | ||
| 27 | 30 | ||
| 28 | import java.util.ArrayList; | 31 | import java.util.ArrayList; |
| 29 | import java.util.LinkedHashMap; | 32 | import java.util.LinkedHashMap; |
| ... | @@ -58,7 +61,7 @@ public class HomeActivity extends Activity implements View.OnClickListener, Coup | ... | @@ -58,7 +61,7 @@ public class HomeActivity extends Activity implements View.OnClickListener, Coup |
| 58 | 61 | ||
| 59 | private RelativeLayout mPbLoading; | 62 | private RelativeLayout mPbLoading; |
| 60 | private TextView mTvHeaderTitle, mTvMyCouponsTitle, mTvMyCouponsValue, mTvSearchTitle; | 63 | private TextView mTvHeaderTitle, mTvMyCouponsTitle, mTvMyCouponsValue, mTvSearchTitle; |
| 61 | - private LinearLayout mLlUserTags, mLlMyCoupons; | 64 | + private LinearLayout mLlUserTags, mLlMyCoupons, mLlSearchFilterButton; |
| 62 | /* View Pager */ | 65 | /* View Pager */ |
| 63 | // private ViewPager2 mBannerViewPager; | 66 | // private ViewPager2 mBannerViewPager; |
| 64 | private RecyclerView mRvBannerViewPager; | 67 | private RecyclerView mRvBannerViewPager; |
| ... | @@ -114,6 +117,10 @@ public class HomeActivity extends Activity implements View.OnClickListener, Coup | ... | @@ -114,6 +117,10 @@ public class HomeActivity extends Activity implements View.OnClickListener, Coup |
| 114 | startActivity(myIntent); | 117 | startActivity(myIntent); |
| 115 | return; | 118 | return; |
| 116 | } | 119 | } |
| 120 | + if (v.getId() == R.id.ll_search_filter_button) { | ||
| 121 | + showFilterDialog(); | ||
| 122 | + return; | ||
| 123 | + } | ||
| 117 | if (v.getId() == R.id.ll_all) { | 124 | if (v.getId() == R.id.ll_all) { |
| 118 | String categoryName = (String) v.getTag(); | 125 | String categoryName = (String) v.getTag(); |
| 119 | Intent myIntent = new Intent(HomeActivity.this, CouponsetsActivity.class); | 126 | Intent myIntent = new Intent(HomeActivity.this, CouponsetsActivity.class); |
| ... | @@ -138,6 +145,8 @@ public class HomeActivity extends Activity implements View.OnClickListener, Coup | ... | @@ -138,6 +145,8 @@ public class HomeActivity extends Activity implements View.OnClickListener, Coup |
| 138 | mPbLoading.setOnTouchListener((v, event) -> true); | 145 | mPbLoading.setOnTouchListener((v, event) -> true); |
| 139 | mLlMyCoupons = findViewById(R.id.ll_my_coupons); | 146 | mLlMyCoupons = findViewById(R.id.ll_my_coupons); |
| 140 | mLlMyCoupons.setOnClickListener(this); | 147 | mLlMyCoupons.setOnClickListener(this); |
| 148 | + mLlSearchFilterButton = findViewById(R.id.ll_search_filter_button); | ||
| 149 | + mLlSearchFilterButton.setOnClickListener(this); | ||
| 141 | mViewPager = findViewById(R.id.cl_viewpager); | 150 | mViewPager = findViewById(R.id.cl_viewpager); |
| 142 | mSectionsContainer = findViewById(R.id.ll_sections_container); | 151 | mSectionsContainer = findViewById(R.id.ll_sections_container); |
| 143 | mSectionsLoading = findViewById(R.id.rl_sections_loading); | 152 | mSectionsLoading = findViewById(R.id.rl_sections_loading); |
| ... | @@ -355,6 +364,122 @@ public class HomeActivity extends Activity implements View.OnClickListener, Coup | ... | @@ -355,6 +364,122 @@ public class HomeActivity extends Activity implements View.OnClickListener, Coup |
| 355 | mSectionsLoading.setVisibility(View.GONE); | 364 | mSectionsLoading.setVisibility(View.GONE); |
| 356 | } | 365 | } |
| 357 | 366 | ||
| 367 | + private void showFilterDialog() { | ||
| 368 | + Filter filter = WarplyManagerHelper.getFilter(); | ||
| 369 | + if (filter == null || filter.getOfferCategories() == null || filter.getOfferCategories().isEmpty()) { | ||
| 370 | + return; | ||
| 371 | + } | ||
| 372 | + | ||
| 373 | + BottomSheetDialog bottomSheetDialog = new BottomSheetDialog(this, R.style.FullScreenBottomSheetDialog); | ||
| 374 | + View dialogView = LayoutInflater.from(this).inflate(R.layout.dl_filter, null); | ||
| 375 | + bottomSheetDialog.setContentView(dialogView); | ||
| 376 | + | ||
| 377 | + LinearLayout llFilterContainer = dialogView.findViewById(R.id.ll_filter_container); | ||
| 378 | + | ||
| 379 | + // Static "Top Offers" row | ||
| 380 | + View topOffersRow = LayoutInflater.from(this).inflate(R.layout.item_filter_category, llFilterContainer, false); | ||
| 381 | + TextView tvTopOffers = topOffersRow.findViewById(R.id.tv_category_name); | ||
| 382 | + tvTopOffers.setText(getString(R.string.lbl_top_offers)); | ||
| 383 | + WarpUtils.renderCustomFont(this, R.font.ping_lcg_regular, tvTopOffers); | ||
| 384 | + topOffersRow.setTag(R.string.lbl_top_offers); | ||
| 385 | + topOffersRow.setOnClickListener(v -> { | ||
| 386 | + // TODO: filter action | ||
| 387 | + bottomSheetDialog.dismiss(); | ||
| 388 | + }); | ||
| 389 | + llFilterContainer.addView(topOffersRow); | ||
| 390 | + | ||
| 391 | + // Divider after Top Offers | ||
| 392 | + View divider = new View(this); | ||
| 393 | + LinearLayout.LayoutParams dividerParams = new LinearLayout.LayoutParams( | ||
| 394 | + LinearLayout.LayoutParams.MATCH_PARENT, 1); | ||
| 395 | + int dividerMarginPx = (int) TypedValue.applyDimension( | ||
| 396 | + TypedValue.COMPLEX_UNIT_DIP, 24, getResources().getDisplayMetrics()); | ||
| 397 | + dividerParams.setMarginStart(dividerMarginPx); | ||
| 398 | + dividerParams.setMarginEnd(dividerMarginPx); | ||
| 399 | + divider.setLayoutParams(dividerParams); | ||
| 400 | + divider.setBackgroundColor(getColor(R.color.custom_grey12)); | ||
| 401 | + llFilterContainer.addView(divider); | ||
| 402 | + | ||
| 403 | + // Dynamic categories from Filter | ||
| 404 | + for (Filter.OfferCategory parent : filter.getOfferCategories()) { | ||
| 405 | + if (parent.getAdminName() == null) continue; | ||
| 406 | + | ||
| 407 | + View categoryRow = LayoutInflater.from(this).inflate(R.layout.item_filter_category, llFilterContainer, false); | ||
| 408 | + TextView tvCategoryName = categoryRow.findViewById(R.id.tv_category_name); | ||
| 409 | + ImageView ivArrow = categoryRow.findViewById(R.id.iv_arrow); | ||
| 410 | + | ||
| 411 | + tvCategoryName.setText(parent.getAdminName()); | ||
| 412 | + WarpUtils.renderCustomFont(this, R.font.ping_lcg_regular, tvCategoryName); | ||
| 413 | + | ||
| 414 | + boolean hasChildren = parent.getChildren() != null && !parent.getChildren().isEmpty(); | ||
| 415 | + | ||
| 416 | + if (!hasChildren) { | ||
| 417 | + ivArrow.setVisibility(View.GONE); | ||
| 418 | + categoryRow.setTag(parent.getAdminName()); | ||
| 419 | + categoryRow.setOnClickListener(v -> { | ||
| 420 | + // TODO: filter action | ||
| 421 | + bottomSheetDialog.dismiss(); | ||
| 422 | + }); | ||
| 423 | + llFilterContainer.addView(categoryRow); | ||
| 424 | + } else { | ||
| 425 | + ivArrow.setVisibility(View.VISIBLE); | ||
| 426 | + | ||
| 427 | + // Child container (collapsed by default) | ||
| 428 | + LinearLayout childContainer = new LinearLayout(this); | ||
| 429 | + childContainer.setOrientation(LinearLayout.VERTICAL); | ||
| 430 | + childContainer.setVisibility(View.GONE); | ||
| 431 | + childContainer.setLayoutParams(new LinearLayout.LayoutParams( | ||
| 432 | + LinearLayout.LayoutParams.MATCH_PARENT, | ||
| 433 | + LinearLayout.LayoutParams.WRAP_CONTENT)); | ||
| 434 | + | ||
| 435 | + for (Filter.OfferCategory child : parent.getChildren()) { | ||
| 436 | + if (child.getAdminName() == null) continue; | ||
| 437 | + View childRow = LayoutInflater.from(this).inflate(R.layout.item_filter_subcategory, childContainer, false); | ||
| 438 | + TextView tvSubcategoryName = childRow.findViewById(R.id.tv_subcategory_name); | ||
| 439 | + tvSubcategoryName.setText(child.getAdminName()); | ||
| 440 | + WarpUtils.renderCustomFont(this, R.font.ping_lcg_regular, tvSubcategoryName); | ||
| 441 | + childRow.setTag(child.getAdminName()); | ||
| 442 | + childRow.setOnClickListener(v -> { | ||
| 443 | + // TODO: filter action | ||
| 444 | + bottomSheetDialog.dismiss(); | ||
| 445 | + }); | ||
| 446 | + childContainer.addView(childRow); | ||
| 447 | + } | ||
| 448 | + | ||
| 449 | + categoryRow.setOnClickListener(v -> { | ||
| 450 | + boolean isExpanded = childContainer.getVisibility() == View.VISIBLE; | ||
| 451 | + if (isExpanded) { | ||
| 452 | + childContainer.setVisibility(View.GONE); | ||
| 453 | + ivArrow.animate().rotation(0f).setDuration(200).start(); | ||
| 454 | + } else { | ||
| 455 | + childContainer.setVisibility(View.VISIBLE); | ||
| 456 | + ivArrow.animate().rotation(180f).setDuration(200).start(); | ||
| 457 | + } | ||
| 458 | + }); | ||
| 459 | + | ||
| 460 | + llFilterContainer.addView(categoryRow); | ||
| 461 | + llFilterContainer.addView(childContainer); | ||
| 462 | + } | ||
| 463 | + } | ||
| 464 | + | ||
| 465 | + bottomSheetDialog.setOnShowListener(dialog -> { | ||
| 466 | + View bottomSheet = bottomSheetDialog.findViewById(com.google.android.material.R.id.design_bottom_sheet); | ||
| 467 | + if (bottomSheet != null) { | ||
| 468 | + bottomSheet.post(() -> { | ||
| 469 | + int screenHeight = getResources().getDisplayMetrics().heightPixels; | ||
| 470 | + ViewGroup.LayoutParams lp = bottomSheet.getLayoutParams(); | ||
| 471 | + lp.height = screenHeight; | ||
| 472 | + bottomSheet.setLayoutParams(lp); | ||
| 473 | + BottomSheetBehavior<View> behavior = BottomSheetBehavior.from(bottomSheet); | ||
| 474 | + behavior.setSkipCollapsed(true); | ||
| 475 | + behavior.setPeekHeight(screenHeight); | ||
| 476 | + behavior.setState(BottomSheetBehavior.STATE_EXPANDED); | ||
| 477 | + }); | ||
| 478 | + } | ||
| 479 | + }); | ||
| 480 | + bottomSheetDialog.show(); | ||
| 481 | + } | ||
| 482 | + | ||
| 358 | private Couponset findCouponsetByUuid(String uuid) { | 483 | private Couponset findCouponsetByUuid(String uuid) { |
| 359 | LinkedHashMap<String, ArrayList<Couponset>> categorizedMap = WarplyManagerHelper.getCouponsetCategorizedMap(); | 484 | LinkedHashMap<String, ArrayList<Couponset>> categorizedMap = WarplyManagerHelper.getCouponsetCategorizedMap(); |
| 360 | if (categorizedMap != null) { | 485 | if (categorizedMap != null) { | ... | ... |
941 Bytes
| 1 | +<?xml version="1.0" encoding="utf-8"?> | ||
| 2 | +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
| 3 | + android:layout_width="match_parent" | ||
| 4 | + android:layout_height="match_parent" | ||
| 5 | + android:background="@color/custom_black7" | ||
| 6 | + android:orientation="vertical"> | ||
| 7 | + | ||
| 8 | + <androidx.core.widget.NestedScrollView | ||
| 9 | + android:layout_width="match_parent" | ||
| 10 | + android:layout_height="match_parent"> | ||
| 11 | + | ||
| 12 | + <LinearLayout | ||
| 13 | + android:id="@+id/ll_filter_container" | ||
| 14 | + android:layout_width="match_parent" | ||
| 15 | + android:layout_height="wrap_content" | ||
| 16 | + android:orientation="vertical" /> | ||
| 17 | + | ||
| 18 | + </androidx.core.widget.NestedScrollView> | ||
| 19 | + | ||
| 20 | +</LinearLayout> |
| 1 | +<?xml version="1.0" encoding="utf-8"?> | ||
| 2 | +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
| 3 | + android:layout_width="match_parent" | ||
| 4 | + android:layout_height="56dp" | ||
| 5 | + android:background="@color/custom_black7" | ||
| 6 | + android:paddingHorizontal="24dp"> | ||
| 7 | + | ||
| 8 | + <TextView | ||
| 9 | + android:id="@+id/tv_category_name" | ||
| 10 | + android:layout_width="wrap_content" | ||
| 11 | + android:layout_height="wrap_content" | ||
| 12 | + android:layout_centerVertical="true" | ||
| 13 | + android:layout_alignParentStart="true" | ||
| 14 | + android:includeFontPadding="false" | ||
| 15 | + android:textColor="@color/white" | ||
| 16 | + android:textSize="16sp" /> | ||
| 17 | + | ||
| 18 | + <ImageView | ||
| 19 | + android:id="@+id/iv_arrow" | ||
| 20 | + android:layout_width="16dp" | ||
| 21 | + android:layout_height="16dp" | ||
| 22 | + android:layout_alignParentEnd="true" | ||
| 23 | + android:layout_centerVertical="true" | ||
| 24 | + android:src="@drawable/ic_arrow_down_white" | ||
| 25 | + android:visibility="gone" /> | ||
| 26 | + | ||
| 27 | +</RelativeLayout> |
| 1 | +<?xml version="1.0" encoding="utf-8"?> | ||
| 2 | +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
| 3 | + android:layout_width="match_parent" | ||
| 4 | + android:layout_height="56dp" | ||
| 5 | + android:background="@color/custom_black7" | ||
| 6 | + android:paddingHorizontal="24dp"> | ||
| 7 | + | ||
| 8 | + <TextView | ||
| 9 | + android:id="@+id/tv_subcategory_name" | ||
| 10 | + android:layout_width="wrap_content" | ||
| 11 | + android:layout_height="wrap_content" | ||
| 12 | + android:layout_centerVertical="true" | ||
| 13 | + android:layout_alignParentStart="true" | ||
| 14 | + android:layout_marginStart="32dp" | ||
| 15 | + android:includeFontPadding="false" | ||
| 16 | + android:textColor="@color/custom_skyblue4" | ||
| 17 | + android:textSize="16sp" /> | ||
| 18 | + | ||
| 19 | +</RelativeLayout> |
| ... | @@ -44,4 +44,5 @@ | ... | @@ -44,4 +44,5 @@ |
| 44 | <color name="custom_grey10">#ECEDEF</color> | 44 | <color name="custom_grey10">#ECEDEF</color> |
| 45 | <color name="custom_grey11">#E7E7E7</color> | 45 | <color name="custom_grey11">#E7E7E7</color> |
| 46 | <color name="custom_blue">#004E6E</color> | 46 | <color name="custom_blue">#004E6E</color> |
| 47 | + <color name="custom_grey12">#EBEDEF</color> | ||
| 47 | </resources> | 48 | </resources> | ... | ... |
| ... | @@ -42,4 +42,5 @@ | ... | @@ -42,4 +42,5 @@ |
| 42 | <string name="demo_partners_title">Partner businesses</string> | 42 | <string name="demo_partners_title">Partner businesses</string> |
| 43 | <string name="demo_search_title">Αναζήτηση</string> | 43 | <string name="demo_search_title">Αναζήτηση</string> |
| 44 | <string name="lbl_directions">Οδηγίες</string> | 44 | <string name="lbl_directions">Οδηγίες</string> |
| 45 | + <string name="lbl_top_offers">Top Offers</string> | ||
| 45 | </resources> | 46 | </resources> | ... | ... |
| ... | @@ -47,4 +47,22 @@ | ... | @@ -47,4 +47,22 @@ |
| 47 | <item name="cornerSizeBottomLeft">0dp</item> | 47 | <item name="cornerSizeBottomLeft">0dp</item> |
| 48 | <item name="cornerSizeBottomRight">0dp</item> | 48 | <item name="cornerSizeBottomRight">0dp</item> |
| 49 | </style> | 49 | </style> |
| 50 | + | ||
| 51 | + <style name="FullScreenBottomSheetDialog" parent="Theme.MaterialComponents.Light.BottomSheetDialog"> | ||
| 52 | + <item name="android:windowIsFloating">false</item> | ||
| 53 | + <item name="android:windowFullscreen">true</item> | ||
| 54 | + <item name="android:windowContentOverlay">@null</item> | ||
| 55 | + <item name="bottomSheetStyle">@style/FullScreenBottomSheetStyle</item> | ||
| 56 | + </style> | ||
| 57 | + | ||
| 58 | + <style name="FullScreenBottomSheetStyle" parent="Widget.MaterialComponents.BottomSheet.Modal"> | ||
| 59 | + <item name="android:layout_height">match_parent</item> | ||
| 60 | + <item name="shapeAppearanceOverlay">@style/NoCornerShapeAppearance</item> | ||
| 61 | + <item name="behavior_peekHeight">@dimen/bottom_sheet_full_height</item> | ||
| 62 | + <item name="behavior_skipCollapsed">true</item> | ||
| 63 | + </style> | ||
| 64 | + | ||
| 65 | + <style name="NoCornerShapeAppearance" parent=""> | ||
| 66 | + <item name="cornerSize">0dp</item> | ||
| 67 | + </style> | ||
| 50 | </resources> | 68 | </resources> | ... | ... |
-
Please register or login to post a comment