mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
ImageDemo: Fix permissions on mobile devices
Co-authored-by: MajorMurphy <major@murphyindustries.net>
This commit is contained in:
parent
26b817b7a4
commit
c2398791be
2 changed files with 19 additions and 3 deletions
|
|
@ -56,8 +56,6 @@ public:
|
||||||
ImagesDemo()
|
ImagesDemo()
|
||||||
{
|
{
|
||||||
setOpaque (true);
|
setOpaque (true);
|
||||||
imageList.setDirectory (File::getSpecialLocation (File::userPicturesDirectory), true, true);
|
|
||||||
directoryThread.startThread (Thread::Priority::background);
|
|
||||||
|
|
||||||
fileTree.setTitle ("Files");
|
fileTree.setTitle ("Files");
|
||||||
fileTree.addListener (this);
|
fileTree.addListener (this);
|
||||||
|
|
@ -81,6 +79,24 @@ public:
|
||||||
-0.7); // and its preferred size is 70% of the total available space
|
-0.7); // and its preferred size is 70% of the total available space
|
||||||
|
|
||||||
setSize (500, 500);
|
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
|
~ImagesDemo() override
|
||||||
|
|
|
||||||
|
|
@ -297,7 +297,7 @@ private:
|
||||||
|
|
||||||
if (jniCheckHasExceptionOccurredAndClear())
|
if (jniCheckHasExceptionOccurredAndClear())
|
||||||
{
|
{
|
||||||
// An exception has occurred, have you acquired RuntimePermission::readExternalStorage permission?
|
// An exception has occurred, have you acquired RuntimePermissions::readExternalStorage permission?
|
||||||
jassertfalse;
|
jassertfalse;
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue