feat(ota): OTA APK 下载更新模块
REQ-20260430-0041 新增 UpdateManager: - POST newAppVersion/queryWatch 检查版本(5分钟最小间隔) - OkHttp 下载 APK(进度回调,独立超时配置) - FileProvider + Intent ACTION_VIEW 触发系统安装 - 非 .apk 链接自动跳过 新增 UpdateDialogView: - 全屏覆盖弹窗,三种状态(发现新版本/下载中/下载失败) - 进度条支持百分比和未知大小两种模式 配置变更: - AndroidManifest: REQUEST_INSTALL_PACKAGES + FileProvider - CommonApi.checkVersion: GET→POST,传 version 参数 集成点: - HomeFragment.onResume → MainActivity.checkForUpdate() - MainActivity 管理弹窗交互和下载流程 - 更新时停止蓝牙扫描 + 保持屏幕常亮 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -33,4 +33,11 @@
|
||||
android:layout_height="match_parent"
|
||||
android:visibility="gone" />
|
||||
|
||||
<!-- Layer 4: OTA 更新弹窗(最顶层,全屏覆盖,默认隐藏) -->
|
||||
<com.xiaoqu.watch.ui.widget.UpdateDialogView
|
||||
android:id="@+id/updateDialog"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:visibility="gone" />
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
89
app/src/main/res/layout/view_update_dialog.xml
Normal file
89
app/src/main/res/layout/view_update_dialog.xml
Normal file
@@ -0,0 +1,89 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- OTA 更新弹窗(全屏覆盖,阻断用户操作) -->
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="#E6000000"
|
||||
android:clickable="true"
|
||||
android:focusable="true">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical"
|
||||
android:padding="24dp">
|
||||
|
||||
<!-- 图标 -->
|
||||
<TextView
|
||||
android:id="@+id/tvIcon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:fontFamily="@font/iconfont"
|
||||
android:text=""
|
||||
android:textColor="@android:color/white"
|
||||
android:textSize="40sp" />
|
||||
|
||||
<!-- 标题 -->
|
||||
<TextView
|
||||
android:id="@+id/tvTitle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="12dp"
|
||||
android:text="发现新版本"
|
||||
android:textColor="@android:color/white"
|
||||
android:textSize="18sp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<!-- 描述(下载中显示"请勿关机!正在升级系统...") -->
|
||||
<TextView
|
||||
android:id="@+id/tvDesc"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="4dp"
|
||||
android:textColor="#AAFFFFFF"
|
||||
android:textSize="12sp"
|
||||
android:visibility="gone" />
|
||||
|
||||
<!-- 进度条(下载中显示) -->
|
||||
<FrameLayout
|
||||
android:id="@+id/progressContainer"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="8dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:background="#33FFFFFF"
|
||||
android:visibility="gone">
|
||||
|
||||
<View
|
||||
android:id="@+id/progressBar"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:background="#4CAF50" />
|
||||
</FrameLayout>
|
||||
|
||||
<!-- 进度文字 -->
|
||||
<TextView
|
||||
android:id="@+id/tvProgress"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="4dp"
|
||||
android:textColor="#AAFFFFFF"
|
||||
android:textSize="12sp"
|
||||
android:visibility="gone" />
|
||||
|
||||
<!-- 按钮(立即更新 / 重新下载) -->
|
||||
<TextView
|
||||
android:id="@+id/btnAction"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="16dp"
|
||||
android:background="@drawable/bg_btn_primary"
|
||||
android:paddingHorizontal="24dp"
|
||||
android:paddingVertical="8dp"
|
||||
android:text="立即更新"
|
||||
android:textColor="@android:color/white"
|
||||
android:textSize="14sp" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</FrameLayout>
|
||||
5
app/src/main/res/xml/file_paths.xml
Normal file
5
app/src/main/res/xml/file_paths.xml
Normal file
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- FileProvider 路径配置(用于 OTA APK 安装) -->
|
||||
<paths>
|
||||
<external-files-path name="apk" path="." />
|
||||
</paths>
|
||||
Reference in New Issue
Block a user