Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 3 commits into
base: version_component
Choose a base branch
from

Conversation

wdeo3601
Copy link

安卓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

@wdeo3601 wdeo3601 changed the title 优化安卓14上媒体重选逻辑(根据谷歌官方推荐写法) targetSdkVersion 为安卓14时,优化安卓14上媒体重选逻辑(根据谷歌官方推荐写法) Jan 18, 2024
@giapmn-1380
Copy link

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

@wdeo3601
Copy link
Author

wdeo3601 commented May 9, 2024

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
Copy link

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants