From 3b1764b75c303d0ec8fb2c7ffe3b3443ccc2668c Mon Sep 17 00:00:00 2001 From: TaiwanStar Developer Date: Thu, 11 Jun 2026 10:24:04 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E5=95=86=E5=93=81?= =?UTF-8?q?=E5=87=BA=E8=B2=A8=E6=88=90=E5=8A=9F=E8=88=87=E6=A9=9F=E5=99=A8?= =?UTF-8?q?=E5=B7=A1=E6=AA=A2=E4=B8=AD=20UI=20=E5=BD=88=E8=B7=B3=E8=A6=96?= =?UTF-8?q?=E7=AA=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ui/dialog/PickupSuccessDialog.java | 148 ++++++++++++++++++ .../ui/dialog/SystemInspectionDialog.java | 44 ++++++ .../main/res/drawable/bg_circle_primary.xml | 6 + .../main/res/layout/dialog_pickup_success.xml | 97 ++++++++++++ .../res/layout/dialog_system_inspection.xml | 83 ++++++++++ app/src/main/res/values/strings.xml | 4 + 6 files changed, 382 insertions(+) create mode 100644 app/src/main/java/com/unibuy/smartdevice/ui/dialog/PickupSuccessDialog.java create mode 100644 app/src/main/java/com/unibuy/smartdevice/ui/dialog/SystemInspectionDialog.java create mode 100644 app/src/main/res/drawable/bg_circle_primary.xml create mode 100644 app/src/main/res/layout/dialog_pickup_success.xml create mode 100644 app/src/main/res/layout/dialog_system_inspection.xml diff --git a/app/src/main/java/com/unibuy/smartdevice/ui/dialog/PickupSuccessDialog.java b/app/src/main/java/com/unibuy/smartdevice/ui/dialog/PickupSuccessDialog.java new file mode 100644 index 0000000..fd16d2b --- /dev/null +++ b/app/src/main/java/com/unibuy/smartdevice/ui/dialog/PickupSuccessDialog.java @@ -0,0 +1,148 @@ +package com.unibuy.smartdevice.ui.dialog; + +import android.content.Context; + +import com.unibuy.smartdevice.DialogAbstract; +import com.unibuy.smartdevice.databinding.DialogPickupSuccessBinding; +import com.unibuy.smartdevice.tools.HandlerMain; +import com.unibuy.smartdevice.tools.HandlerMainCountdown; +import com.unibuy.smartdevice.tools.ToastHandlerMain; + +import java.util.HashMap; +import java.util.Map; + +public class PickupSuccessDialog extends DialogAbstract { + public enum Option { + TOAST(0), + COUNTDOWN_CANCEL(1), + SET_COUNTDOWN_TEXT(2), + RESET_COUNTDOWN(3), + ; + + private int option; + + public int getOption() { + return option; + } + + Option(int option) { + this.option = option; + } + } + + public PickupSuccessDialog(Context context, HandlerMain srcHandlerMain) { + super(context, srcHandlerMain); + getLogs().info("PickupSuccessDialog:" + getClass().getSimpleName()); + } + + public static final Map optionMap = new HashMap<>(); + static { + for (Option option : Option.values()) { + optionMap.put(option.getOption(), option); + } + } + + @Override + protected Context setCtx() { + return this.getContext(); + } + + @Override + protected Class setCls() { + return getClass(); + } + + @Override + protected HandlerMain setHandlerMain() { + return new ToastHandlerMain(getContext(), getLogs()) { + @Override + protected void execute(Context context, int commandCode, String message) { + Option option = optionMap.get(commandCode); + if (option != null) { + switch (option) { + case TOAST: + super.execute(context, commandCode, message); + break; + case COUNTDOWN_CANCEL: + cancelOnThreadCountdown(); + break; + case SET_COUNTDOWN_TEXT: + setButtonConfirmText(Integer.valueOf(message)); + break; + case RESET_COUNTDOWN: + closeDialogCountdown.setCountdown(15); + break; + } + } + } + }; + } + + private DialogPickupSuccessBinding binding; + private CloseDialogOnThreadHandler closeDialogCountdown; + private String laneNumber = "99"; // 預設貨道號碼 + + public void setLaneNumber(String laneNumber) { + this.laneNumber = laneNumber; + if (binding != null) { + binding.tvLaneNumber.setText(laneNumber); + binding.tvSubtitle.setText("請至" + laneNumber + "號櫃門拿取您的商品"); + } + } + + @Override + protected void onCreate(Context context) { + binding = DialogPickupSuccessBinding.inflate(getLayoutInflater()); + setContentView(binding.getRoot()); + + // 初始化貨道數字與副標文字 + setLaneNumber(laneNumber); + + binding.btnConfirm.setOnClickListener(v -> dialogCancel()); + + closeDialogCountdown = new CloseDialogOnThreadHandler(getHandlerMain()); + closeDialogCountdown.start(15); + } + + public void dialogCancel() { + if (closeDialogCountdown != null) { + closeDialogCountdown.shutdown(); + } + cancel(); + } + + public void cancelOnThreadCountdown() { + getTools().dialogClose(); + cancel(); + } + + public void setButtonConfirmText(long countdown) { + binding.btnConfirm.setText("確認已取貨(" + countdown + "秒)"); + } + + public static class CloseDialogOnThreadHandler extends HandlerMainCountdown { + public CloseDialogOnThreadHandler(HandlerMain handlerMain) { + super(handlerMain); + } + + @Override + protected HandlerMain setHandlerMain() { + return getSrcHandlerMain(); + } + + @Override + protected void close(HandlerMain handlerMain) { + handlerMain.start(getClass().getSimpleName(), Option.COUNTDOWN_CANCEL.getOption(), "close dialog"); + } + + @Override + protected void execute(long countdown, HandlerMain handlerMain) { + handlerMain.start(getClass().getSimpleName(), Option.SET_COUNTDOWN_TEXT.getOption(), String.valueOf(countdown)); + } + + @Override + protected Class setCls() { + return getClass(); + } + } +} diff --git a/app/src/main/java/com/unibuy/smartdevice/ui/dialog/SystemInspectionDialog.java b/app/src/main/java/com/unibuy/smartdevice/ui/dialog/SystemInspectionDialog.java new file mode 100644 index 0000000..05feb99 --- /dev/null +++ b/app/src/main/java/com/unibuy/smartdevice/ui/dialog/SystemInspectionDialog.java @@ -0,0 +1,44 @@ +package com.unibuy.smartdevice.ui.dialog; + +import android.content.Context; + +import com.unibuy.smartdevice.DialogAbstract; +import com.unibuy.smartdevice.databinding.DialogSystemInspectionBinding; +import com.unibuy.smartdevice.tools.HandlerMain; +import com.unibuy.smartdevice.tools.ToastHandlerMain; + +public class SystemInspectionDialog extends DialogAbstract { + + public SystemInspectionDialog(Context context, HandlerMain srcHandlerMain) { + super(context, srcHandlerMain); + getLogs().info("SystemInspectionDialog:" + getClass().getSimpleName()); + } + + @Override + protected Context setCtx() { + return this.getContext(); + } + + @Override + protected Class setCls() { + return getClass(); + } + + @Override + protected HandlerMain setHandlerMain() { + return new ToastHandlerMain(getContext(), getLogs()) { + @Override + protected void execute(Context context, int commandCode, String message) { + super.execute(context, commandCode, message); + } + }; + } + + private DialogSystemInspectionBinding binding; + + @Override + protected void onCreate(Context context) { + binding = DialogSystemInspectionBinding.inflate(getLayoutInflater()); + setContentView(binding.getRoot()); + } +} diff --git a/app/src/main/res/drawable/bg_circle_primary.xml b/app/src/main/res/drawable/bg_circle_primary.xml new file mode 100644 index 0000000..8a6a5f6 --- /dev/null +++ b/app/src/main/res/drawable/bg_circle_primary.xml @@ -0,0 +1,6 @@ + + + + + diff --git a/app/src/main/res/layout/dialog_pickup_success.xml b/app/src/main/res/layout/dialog_pickup_success.xml new file mode 100644 index 0000000..357f90c --- /dev/null +++ b/app/src/main/res/layout/dialog_pickup_success.xml @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/dialog_system_inspection.xml b/app/src/main/res/layout/dialog_system_inspection.xml new file mode 100644 index 0000000..5228171 --- /dev/null +++ b/app/src/main/res/layout/dialog_system_inspection.xml @@ -0,0 +1,83 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 95522f4..ee04141 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -334,4 +334,8 @@ 購物車最多可購買 8 件商品 已加入購物車 數據異常 + 商品出貨成功 + 請至99號櫃門拿取您的商品 + 確認已取貨(15秒) + 機器巡檢中請稍後