LuckSiege / PictureSelector

Picture Selector Library for Android or 图片选择器
Apache License 2.0
13.23k stars 3k forks source link

targetSdkVersion 为安卓14时,优化安卓14上媒体重选逻辑(根据谷歌官方推荐写法) #2837

Open wdeo3601 opened 7 months ago

wdeo3601 commented 7 months ago

安卓14设备上,如果媒体授权时用户选了选择部分照片和视频选项的话,之后每次进入相册,都会无提示自动弹出系统的选择允许此应用访问的照片和视频弹窗。这个逻辑对用户来说不太友好,查了谷歌官方文档,官方推荐在无媒体授权且有READ_MEDIA_VISUAL_USER_SELECTED授权时,提示用户,让用户去选择是否重选媒体文件。
官方文档:https://developer.android.google.cn/about/versions/14/changes/partial-photo-video-access?hl=zh-cn#media-reselection
image
我做的修改:

  1. 创建自定义 View MediaReselectionTipView,用于安卓14上的媒体重选提示
  2. 媒体重选提示文案国际化适配
  3. 修改 PictureSelectorFragment 中权限判断相关逻辑,细化出需要处理媒体重选的情况并处理

一些情况说明:

  1. MediaReselectionTipView的样式配置使用了 BottomNavBarStyle 中背景色、预览正常字体颜色、预览选中字体颜色、预览正常字体大小
  2. 由于 ps_fragment_selector.xml 布局中新加了 MediaReselectionTipView,有自己自定义布局的,需要在自己的布局中合适位置加入 MediaReselectionTipView,否则会报错NPE

demo 中各样式效果:
image image

giapmn-1380 commented 3 months ago

Hello, can you review, merged PR and release this function?

wdeo3601 commented 3 months ago

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.

giapmn-1380 commented 3 months ago

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?