1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-09 23:34:20 +00:00

ImageDemo: Fix permissions on mobile devices

Co-authored-by: MajorMurphy <major@murphyindustries.net>
This commit is contained in:
reuk 2024-03-07 13:44:25 +00:00
parent 26b817b7a4
commit c2398791be
No known key found for this signature in database
GPG key ID: FCB43929F012EE5C
2 changed files with 19 additions and 3 deletions

View file

@ -56,8 +56,6 @@ public:
ImagesDemo()
{
setOpaque (true);
imageList.setDirectory (File::getSpecialLocation (File::userPicturesDirectory), true, true);
directoryThread.startThread (Thread::Priority::background);
fileTree.setTitle ("Files");
fileTree.addListener (this);
@ -81,6 +79,24 @@ public:
-0.7); // and its preferred size is 70% of the total available space
setSize (500, 500);
RuntimePermissions::request (RuntimePermissions::readMediaImages, [self = SafePointer { this }] (bool granted)
{
if (self == nullptr)
return;
if (! granted)
{
AlertWindow::showMessageBoxAsync (MessageBoxIconType::WarningIcon,
"Permissions warning",
"External storage access permission not granted, some files"
" may be inaccessible.");
return;
}
self->imageList.setDirectory (File::getSpecialLocation (File::userPicturesDirectory), true, true);
self->directoryThread.startThread (Thread::Priority::background);
});
}
~ImagesDemo() override