PictureSelector
PictureSelector copied to clipboard
targetSdkVersion 为安卓14时,优化安卓14上媒体重选逻辑(根据谷歌官方推荐写法)
安卓14设备上,如果媒体授权时用户选了选择部分照片和视频
选项的话,之后每次进入相册,都会无提示自动弹出系统的选择允许此应用访问的照片和视频
弹窗。这个逻辑对用户来说不太友好,查了谷歌官方文档,官方推荐在无媒体授权且有READ_MEDIA_VISUAL_USER_SELECTED授权
时,提示用户,让用户去选择是否重选媒体文件。
官方文档:https://developer.android.google.cn/about/versions/14/changes/partial-photo-video-access?hl=zh-cn#media-reselection
我做的修改:
- 创建自定义 View
MediaReselectionTipView
,用于安卓14上的媒体重选提示 - 媒体重选提示文案国际化适配
- 修改
PictureSelectorFragment
中权限判断相关逻辑,细化出需要处理媒体重选的情况并处理
一些情况说明:
-
MediaReselectionTipView
的样式配置使用了BottomNavBarStyle
中背景色、预览正常字体颜色、预览选中字体颜色、预览正常字体大小 - 由于
ps_fragment_selector.xml
布局中新加了MediaReselectionTipView
,有自己自定义布局的,需要在自己的布局中合适位置加入 MediaReselectionTipView,否则会报错NPE
demo 中各样式效果:
Hello, can you review, merged PR and release this function?
Hello, can you review, merged PR and release this function?
Sorry, I don't have the permission to merge PR and publish. You can ask the source code developer or pull the code to create a new repository and publish it yourself.
Sorry, I don't have the permission to merge PR and publish. You can ask the source code developer or pull the code to create a new repository and publish it yourself.
@wdeo3601 🙇
@LuckSiege @luck1991 Hello, can you review, merged PR and release this function?