feat: 实现 UI 适配支持视频选择和预览(Phase 4)
- Phase 4: 更新用户界面以支持视频选择、显示和预览 * AlbumEditorActivity 支持选择视频文件(MIME 类型 image/* 和 video/*) * 新增 MediaPreviewActivity 支持视频和图片全屏预览 * 新增 MediaAdapter 统一显示图片和视频列表 * SettingsFragment 添加视频设置选项(启用、静音、省电) * 新增媒体列表项布局 item_media.xml(缩略图、角标、时长、删除按钮) * 新增预览页面布局 activity_media_preview.xml * AndroidManifest 注册 MediaPreviewActivity 核心功能: 1. AlbumEditorActivity 视频选择 - 文件选择器支持图片和视频 MIME 类型 - 根据 MIME 类型自动分类保存到 imageUris/videoUris - addVideoUri() 和 removeVideoUri() 方法管理视频列表 - 保存时分别存储到相册配置 2. 媒体列表显示 - MediaAdapter 统一显示图片和视频 - 视频项显示播放角标(ic_play 图标) - 视频项显示时长(HH:MM:SS 格式) - 图片缩略图通过 Glide 加载 - 视频缩略图异步生成(避免阻塞 UI) - 点击预览、滑动删除功能 3. MediaPreviewActivity 媒体预览 - 支持图片全屏预览(Glide 加载) - 支持视频全屏播放(VideoView + MediaController) - 循环播放视频 - 生命周期管理(onPause 暂停、onResume 恢复) - 静态启动方法 startPreview() 4. SettingsFragment 视频设置 - 启用视频壁纸开关 - 视频静音开关(依赖启用视频) - 电池供电时暂停视频开关(依赖启用视频) - 设置实时生效并持久化 - onResume 时重新加载配置 5. 布局文件 - item_media.xml:媒体列表项布局(缩略图、角标、时长、删除按钮) - activity_media_preview.xml:预览页面布局(ImageView + VideoView) - fragment_settings.xml:添加视频设置控件 这些变更使用户能够在相册编辑器中选择视频文件,在媒体列表中查看视频缩略图和时长,全屏预览视频播放,以及在设置页面配置视频相关选项。 Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
1ac9e3f428
commit
469df2f3f9
10 files changed
+676
-106
No files matched your search
@@ -0,0 +1,22 @@
|
||||
<?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:background="@android:color/black">
|
||||
|
||||
<!-- 图片预览 -->
|
||||
<ImageView
|
||||
android:id="@+id/image_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:scaleType="fitCenter"
|
||||
android:visibility="gone" />
|
||||
|
||||
<!-- 视频预览 -->
|
||||
<VideoView
|
||||
android:id="@+id/video_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="center"
|
||||
android:visibility="gone" />
|
||||
</FrameLayout>
|
||||
@@ -124,6 +124,96 @@
|
||||
|
||||
</com.google.android.material.card.MaterialCardView>
|
||||
|
||||
<!-- 视频设置卡片 -->
|
||||
<TextView
|
||||
android:id="@+id/tvVideoSettingsLabel"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/spacing_lg"
|
||||
android:text="视频设置"
|
||||
android:textSize="@dimen/text_size_xxl"
|
||||
android:textStyle="bold"
|
||||
android:textColor="@color/text_primary"
|
||||
app:layout_constraintTop_toBottomOf="@id/cardBackground"
|
||||
app:layout_constraintStart_toStartOf="parent" />
|
||||
|
||||
<com.google.android.material.card.MaterialCardView
|
||||
android:id="@+id/cardVideoSettings"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/spacing_sm"
|
||||
app:cardElevation="@dimen/card_elevation"
|
||||
app:cardCornerRadius="@dimen/corner_radius_md"
|
||||
app:cardBackgroundColor="@color/bg_card"
|
||||
app:strokeColor="@color/glass_border"
|
||||
app:strokeWidth="@dimen/glass_border_width"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvVideoSettingsLabel"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:padding="@dimen/card_padding">
|
||||
|
||||
<!-- 启用视频壁纸 -->
|
||||
<Switch
|
||||
android:id="@+id/switchVideoEnabled"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="启用视频壁纸"
|
||||
android:textSize="@dimen/text_size_md"
|
||||
android:textColor="@color/text_primary"
|
||||
android:minHeight="48dp" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="允许使用视频文件作为动态壁纸"
|
||||
android:textSize="@dimen/text_size_sm"
|
||||
android:textColor="@color/text_secondary"
|
||||
android:layout_marginBottom="@dimen/spacing_md" />
|
||||
|
||||
<!-- 视频静音 -->
|
||||
<Switch
|
||||
android:id="@+id/switchVideoMuted"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="视频静音"
|
||||
android:textSize="@dimen/text_size_md"
|
||||
android:textColor="@color/text_primary"
|
||||
android:minHeight="48dp" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="播放视频时自动静音"
|
||||
android:textSize="@dimen/text_size_sm"
|
||||
android:textColor="@color/text_secondary"
|
||||
android:layout_marginBottom="@dimen/spacing_md" />
|
||||
|
||||
<!-- 电池供电时暂停 -->
|
||||
<Switch
|
||||
android:id="@+id/switchVideoPauseOnBattery"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="电池供电时暂停视频"
|
||||
android:textSize="@dimen/text_size_md"
|
||||
android:textColor="@color/text_primary"
|
||||
android:minHeight="48dp" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="仅在充电时播放视频,节省电量"
|
||||
android:textSize="@dimen/text_size_sm"
|
||||
android:textColor="@color/text_secondary" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</com.google.android.material.card.MaterialCardView>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
@@ -0,0 +1,50 @@
|
||||
<?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="120dp"
|
||||
android:layout_margin="8dp">
|
||||
|
||||
<!-- 缩略图 -->
|
||||
<ImageView
|
||||
android:id="@+id/thumbnail"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:scaleType="centerCrop"
|
||||
android:background="#EEEEEE" />
|
||||
|
||||
<!-- 视频角标 -->
|
||||
<ImageView
|
||||
android:id="@+id/video_badge"
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="40dp"
|
||||
android:layout_gravity="center"
|
||||
android:src="@drawable/ic_play"
|
||||
android:visibility="gone" />
|
||||
|
||||
<!-- 视频时长 -->
|
||||
<TextView
|
||||
android:id="@+id/duration"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom|end"
|
||||
android:layout_margin="8dp"
|
||||
android:background="#80000000"
|
||||
android:paddingHorizontal="6dp"
|
||||
android:paddingVertical="2dp"
|
||||
android:text="00:00"
|
||||
android:textColor="@android:color/white"
|
||||
android:textSize="12sp"
|
||||
android:visibility="gone" />
|
||||
|
||||
<!-- 删除按钮 -->
|
||||
<ImageView
|
||||
android:id="@+id/delete_btn"
|
||||
android:layout_width="32dp"
|
||||
android:layout_height="32dp"
|
||||
android:layout_gravity="top|end"
|
||||
android:layout_margin="4dp"
|
||||
android:background="#80000000"
|
||||
android:padding="4dp"
|
||||
android:src="@drawable/ic_close"
|
||||
android:scaleType="centerInside" />
|
||||
</FrameLayout>
|
||||
Reference in new issue
Block a user