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

Android: Fix ImageDemo Permissions #1362

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
2 changes: 1 addition & 1 deletion modules/juce_core/native/juce_Files_android.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ struct AndroidContentUriResolver

if (jniCheckHasExceptionOccurredAndClear())
{
// An exception has occurred, have you acquired RuntimePermission::readExternalStorage permission?
// An exception has occurred, have you acquired RuntimePermissions::readExternalStorage permission?
jassertfalse;
return {};
}
Expand Down