The “attach from gallery” action is used in a number of places, it always asks for storage permission, which is not necessary on modern Android where the system gallery picker can be used instead.
the permission is not for the picker itself, but for he “quick view” or “camera roll” of the most recent images.
for 2. and 3. it might indeed not be needed, but it may still make sense maintenance-wise to just use the same code path. esp. as we need to support lots of android and only more recent ones do not need the permission, it makes sense to use simple code here, and not have subtile bugs in rarely used codepaths - in general, we avoid rarely used codepaths whereever we can.
this just as some background, i am not saying that it cannot be improved or should iterated over, but it is probably not an oversight and probably no priority
normally after you reject the permission it should not ask for it anymore, as said by @r10s you will then not have the quick-access gallery preview roll, but you can then pick images without giving the permission
That would have been nice, but it does not work that way, at least not on Android 15. When I press Gallery, it prompts
Permission required
To receive or send files, go to the app settings, select “Permissions”, and enable “Storage”.
Cancel / Continue
If I cancel, I won’t get any further. It doesn’t matter if it’s in the chat view or “set profile picture”. Nothing happens. And it will repeat next time.
I agree about keeping one code path, but maybe it could be satisfied by adding a “needs_roll” boolean arg to that common handler? Then the compelling part can be wrapped in an if-statement. Not exactly zero maintenance burden, but perhaps good enough?
I believe that the Android API takes care of the compatibility check and handles fallback when necessary. For example, today when I attach a file to a chat, it just shows the file picker. But had I used an older Android, I would probably have been prompted to allow storage permission.