feat: 消息通知模块(横幅+红点+跳转)
MQTT type=1 新任务推送 → 震动+亮屏+顶部蓝色横幅+卡片红点。 新增: - NotificationManager: 去抖1s+内存存储taskIds+统计对比红点 - NotificationBannerView: Activity层横幅(滑入/10s倒计时/点击) - AppEvent.NewTaskArrived: 携带taskIds和count 集成: - MainActivity: 监听MQTT type=1→NotificationManager→横幅 - HomeFragment: 监听NewTaskArrived→刷新统计+对比红点+横幅点击跳转 - page_main.xml: 3个卡片各加红点角标(FrameLayout包裹) - nav_main.xml: 新增action_home_to_taskDetail Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -19,7 +19,14 @@
|
||||
app:defaultNavHost="true"
|
||||
app:navGraph="@navigation/nav_main" />
|
||||
|
||||
<!-- Layer 2: 全局弹窗层(QuTipDialog / QuConfirmDialog 动态添加,默认隐藏) -->
|
||||
<!-- Layer 2: 通知横幅(所有 Fragment 之上,MQTT 新任务时显示) -->
|
||||
<com.xiaoqu.watch.ui.widget.NotificationBannerView
|
||||
android:id="@+id/notificationBanner"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="top" />
|
||||
|
||||
<!-- Layer 3: 全局弹窗层(QuTipDialog / QuConfirmDialog 动态添加,默认隐藏) -->
|
||||
<FrameLayout
|
||||
android:id="@+id/dialog_container"
|
||||
android:layout_width="match_parent"
|
||||
|
||||
@@ -48,13 +48,17 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<!-- 接单池(蓝色)padding top14→19, bottom12→16, radius14→19 -->
|
||||
<LinearLayout
|
||||
android:id="@+id/cardPool"
|
||||
<!-- 接单池(蓝色)+ 红点角标 -->
|
||||
<FrameLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:layout_marginEnd="5dp"
|
||||
android:layout_marginEnd="5dp">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/cardPool"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/bg_quick_blue"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical"
|
||||
@@ -83,14 +87,31 @@
|
||||
android:layout_marginTop="5dp" />
|
||||
</LinearLayout>
|
||||
|
||||
<!-- 待打卡(橙色) -->
|
||||
<LinearLayout
|
||||
android:id="@+id/cardPunch"
|
||||
<!-- 红点角标 -->
|
||||
<View
|
||||
android:id="@+id/dotPool"
|
||||
android:layout_width="10dp"
|
||||
android:layout_height="10dp"
|
||||
android:layout_gravity="top|end"
|
||||
android:layout_marginTop="4dp"
|
||||
android:layout_marginEnd="4dp"
|
||||
android:background="@drawable/bg_red_dot"
|
||||
android:visibility="gone" />
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
<!-- 待打卡(橙色)+ 红点角标 -->
|
||||
<FrameLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:layout_marginStart="3dp"
|
||||
android:layout_marginEnd="3dp"
|
||||
android:layout_marginEnd="3dp">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/cardPunch"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/bg_quick_orange"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical"
|
||||
@@ -117,13 +138,29 @@
|
||||
android:layout_marginTop="5dp" />
|
||||
</LinearLayout>
|
||||
|
||||
<!-- 待完成(绿色) -->
|
||||
<LinearLayout
|
||||
android:id="@+id/cardComplete"
|
||||
<View
|
||||
android:id="@+id/dotPunch"
|
||||
android:layout_width="10dp"
|
||||
android:layout_height="10dp"
|
||||
android:layout_gravity="top|end"
|
||||
android:layout_marginTop="4dp"
|
||||
android:layout_marginEnd="4dp"
|
||||
android:background="@drawable/bg_red_dot"
|
||||
android:visibility="gone" />
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
<!-- 待完成(绿色)+ 红点角标 -->
|
||||
<FrameLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:layout_marginStart="5dp"
|
||||
android:layout_marginStart="5dp">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/cardComplete"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/bg_quick_green"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical"
|
||||
@@ -150,6 +187,18 @@
|
||||
android:layout_marginTop="5dp" />
|
||||
</LinearLayout>
|
||||
|
||||
<View
|
||||
android:id="@+id/dotComplete"
|
||||
android:layout_width="10dp"
|
||||
android:layout_height="10dp"
|
||||
android:layout_gravity="top|end"
|
||||
android:layout_marginTop="4dp"
|
||||
android:layout_marginEnd="4dp"
|
||||
android:background="@drawable/bg_red_dot"
|
||||
android:visibility="gone" />
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<!-- 页面指示器 margin-top:10px→13dp -->
|
||||
|
||||
35
app/src/main/res/layout/view_notification_banner.xml
Normal file
35
app/src/main/res/layout/view_notification_banner.xml
Normal file
@@ -0,0 +1,35 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- 通知横幅(Activity 层,所有页面之上) -->
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/bannerRoot"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="#E80A84FF"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal"
|
||||
android:paddingStart="24dp"
|
||||
android:paddingTop="20dp"
|
||||
android:paddingEnd="24dp"
|
||||
android:paddingBottom="16dp">
|
||||
|
||||
<!-- 主文字:"有 N 条新任务" -->
|
||||
<TextView
|
||||
android:id="@+id/tvBannerText"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="有 1 条新任务"
|
||||
android:textColor="#FFFFFFFF"
|
||||
android:textSize="20sp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<!-- 提示文字:"点击查看 · 8s" -->
|
||||
<TextView
|
||||
android:id="@+id/tvBannerHint"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="点击查看 · 10s"
|
||||
android:textColor="#99FFFFFF"
|
||||
android:textSize="14sp" />
|
||||
|
||||
</LinearLayout>
|
||||
Reference in New Issue
Block a user