feat: 考勤打卡模块(NFC)重新开发
基于新方法论(11层源码分析+独立评审)重新开发考勤打卡功能: - 首页下拉展开打卡面板,点击按钮开启NFC贴卡打卡 - 支持上班打卡、下班打卡、撤销打卡 - NFC超时自动关闭,音效反馈(4种planId) - MQTT type=5 上下班状态推送处理 - 按钮状态矩阵:onPunchState×offPunchState决定显示 新增: AttendanceStatus / PunchApi / PunchViewModel / PunchPanelView 修改: NetworkModule / HomeFragment / fragment_home.xml 删除: AttendanceInfo(被AttendanceStatus替代) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
16
app/src/main/res/drawable/bg_btn_primary.xml
Normal file
16
app/src/main/res/drawable/bg_btn_primary.xml
Normal file
@@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- 主按钮背景(深蓝色圆角) -->
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:state_pressed="true">
|
||||
<shape android:shape="rectangle">
|
||||
<solid android:color="#FF1565C0" />
|
||||
<corners android:radius="12dp" />
|
||||
</shape>
|
||||
</item>
|
||||
<item>
|
||||
<shape android:shape="rectangle">
|
||||
<solid android:color="#FF1E88E5" />
|
||||
<corners android:radius="12dp" />
|
||||
</shape>
|
||||
</item>
|
||||
</selector>
|
||||
16
app/src/main/res/drawable/bg_btn_secondary.xml
Normal file
16
app/src/main/res/drawable/bg_btn_secondary.xml
Normal file
@@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- 次按钮背景(深灰色圆角) -->
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:state_pressed="true">
|
||||
<shape android:shape="rectangle">
|
||||
<solid android:color="#FF424242" />
|
||||
<corners android:radius="12dp" />
|
||||
</shape>
|
||||
</item>
|
||||
<item>
|
||||
<shape android:shape="rectangle">
|
||||
<solid android:color="#FF333333" />
|
||||
<corners android:radius="12dp" />
|
||||
</shape>
|
||||
</item>
|
||||
</selector>
|
||||
@@ -1,26 +1,46 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- 首页容器:固定状态栏 + ViewPager2 左右滑动 -->
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<!-- 首页容器:固定状态栏 + ViewPager2 + 打卡面板覆盖层 -->
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/background"
|
||||
android:orientation="vertical"
|
||||
android:paddingStart="21dp"
|
||||
android:paddingTop="27dp"
|
||||
android:paddingEnd="21dp">
|
||||
android:background="@color/background">
|
||||
|
||||
<!-- 固定状态栏 -->
|
||||
<com.xiaoqu.watch.ui.widget.StatusBarView
|
||||
android:id="@+id/statusBar"
|
||||
<!-- 主内容区 -->
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="24dp"
|
||||
android:layout_marginBottom="3dp" />
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:paddingStart="21dp"
|
||||
android:paddingTop="27dp"
|
||||
android:paddingEnd="21dp">
|
||||
|
||||
<!-- ViewPager2 -->
|
||||
<androidx.viewpager2.widget.ViewPager2
|
||||
android:id="@+id/viewPager"
|
||||
<!-- 固定状态栏 -->
|
||||
<com.xiaoqu.watch.ui.widget.StatusBarView
|
||||
android:id="@+id/statusBar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="24dp"
|
||||
android:layout_marginBottom="3dp" />
|
||||
|
||||
<!-- ViewPager2 -->
|
||||
<androidx.viewpager2.widget.ViewPager2
|
||||
android:id="@+id/viewPager"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<!-- 考勤打卡面板(覆盖层,默认隐藏) -->
|
||||
<com.xiaoqu.watch.ui.punch.PunchPanelView
|
||||
android:id="@+id/punchPanel"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1" />
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
</LinearLayout>
|
||||
<!-- 弹窗容器(最顶层,用于 QuTipDialog) -->
|
||||
<FrameLayout
|
||||
android:id="@+id/dialogContainer"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:visibility="gone" />
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
114
app/src/main/res/layout/view_punch_panel.xml
Normal file
114
app/src/main/res/layout/view_punch_panel.xml
Normal file
@@ -0,0 +1,114 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- 考勤打卡面板(嵌入首页,下拉展开) -->
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:clickable="true"
|
||||
android:focusable="true">
|
||||
|
||||
<!-- 半透明遮罩(点击收回面板) -->
|
||||
<View
|
||||
android:id="@+id/overlay"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="#80000000" />
|
||||
|
||||
<!-- 面板内容区 -->
|
||||
<LinearLayout
|
||||
android:id="@+id/panelContent"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="top"
|
||||
android:background="@color/background"
|
||||
android:gravity="center_horizontal"
|
||||
android:orientation="vertical"
|
||||
android:paddingStart="28dp"
|
||||
android:paddingTop="27dp"
|
||||
android:paddingEnd="28dp"
|
||||
android:paddingBottom="20dp">
|
||||
|
||||
<!-- 时间显示(大字体,老年用户) -->
|
||||
<TextView
|
||||
android:id="@+id/tvPunchTime"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:fontFamily="sans-serif-medium"
|
||||
android:text="00:00"
|
||||
android:textColor="@color/text_primary"
|
||||
android:textSize="48sp" />
|
||||
|
||||
<!-- 日期显示 -->
|
||||
<TextView
|
||||
android:id="@+id/tvPunchDate"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="4dp"
|
||||
android:text="1月1日 星期一"
|
||||
android:textColor="@color/text_secondary"
|
||||
android:textSize="16sp" />
|
||||
|
||||
<!-- NFC 扫描提示(默认隐藏) -->
|
||||
<TextView
|
||||
android:id="@+id/tvNfcHint"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="16dp"
|
||||
android:text="请将手表贴近打卡信标"
|
||||
android:textColor="@color/warning"
|
||||
android:textSize="18sp"
|
||||
android:visibility="gone" />
|
||||
|
||||
<!-- 按钮区域 -->
|
||||
<LinearLayout
|
||||
android:id="@+id/buttonContainer"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="16dp"
|
||||
android:gravity="center"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<!-- 上班打卡按钮 -->
|
||||
<TextView
|
||||
android:id="@+id/btnPunchIn"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="56dp"
|
||||
android:layout_weight="1"
|
||||
android:background="@drawable/bg_btn_primary"
|
||||
android:gravity="center"
|
||||
android:text="上班打卡"
|
||||
android:textColor="@color/text_primary"
|
||||
android:textSize="20sp"
|
||||
android:visibility="gone" />
|
||||
|
||||
<!-- 下班打卡按钮 -->
|
||||
<TextView
|
||||
android:id="@+id/btnPunchOut"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="56dp"
|
||||
android:layout_weight="1"
|
||||
android:background="@drawable/bg_btn_primary"
|
||||
android:gravity="center"
|
||||
android:text="下班打卡"
|
||||
android:textColor="@color/text_primary"
|
||||
android:textSize="20sp"
|
||||
android:visibility="gone" />
|
||||
|
||||
<!-- 撤销打卡按钮 -->
|
||||
<TextView
|
||||
android:id="@+id/btnRevoke"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="56dp"
|
||||
android:layout_weight="1"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:background="@drawable/bg_btn_secondary"
|
||||
android:gravity="center"
|
||||
android:text="撤销打卡"
|
||||
android:textColor="@color/text_secondary"
|
||||
android:textSize="18sp"
|
||||
android:visibility="gone" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</FrameLayout>
|
||||
@@ -59,12 +59,6 @@
|
||||
<argument android:name="taskId" android:defaultValue="0L" app:argType="long" />
|
||||
</fragment>
|
||||
|
||||
<!-- 打卡页 -->
|
||||
<fragment
|
||||
android:id="@+id/punchFragment"
|
||||
android:name="com.xiaoqu.watch.ui.punch.PunchFragment"
|
||||
android:label="打卡" />
|
||||
|
||||
<!-- 设备信息 -->
|
||||
<fragment
|
||||
android:id="@+id/infoFragment"
|
||||
|
||||
Reference in New Issue
Block a user