Skip to content

Commit

Permalink
Android: Fix permissions for ImageDemo
Browse files Browse the repository at this point in the history
  • Loading branch information
MajorMurphy committed Mar 6, 2024
1 parent 6209cab commit de93bf2
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions examples/GUI/ImagesDemo.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,6 @@ class ImagesDemo final : public Component,
ImagesDemo()
{
setOpaque (true);
imageList.setDirectory (File::getSpecialLocation (File::userPicturesDirectory), true, true);
directoryThread.startThread (Thread::Priority::background);

fileTree.setTitle ("Files");
fileTree.addListener (this);
fileTree.setColour (TreeView::backgroundColourId, Colours::grey);
Expand All @@ -81,6 +78,20 @@ class ImagesDemo final : public Component,
-0.7); // and its preferred size is 70% of the total available space

setSize (500, 500);

RuntimePermissions::request (RuntimePermissions::readMediaImages,
[this] (bool granted)
{
if (! granted)
{
AlertWindow::showMessageBoxAsync (MessageBoxIconType::WarningIcon,
"Permissions warning",
"External storage access permission not granted, some files"
" may be inaccessible.");
}
imageList.setDirectory (File::getSpecialLocation (File::userPicturesDirectory), true, true);
directoryThread.startThread (Thread::Priority::background);
});
}

~ImagesDemo() override
Expand Down

0 comments on commit de93bf2

Please sign in to comment.