Browse Source

ImageDemo: Fix permissions on mobile devices

Co-authored-by: MajorMurphy <major@murphyindustries.net>
v7.0.12
reuk 1 year ago
parent
commit
c2398791be
No known key found for this signature in database GPG Key ID: FCB43929F012EE5C
2 changed files with 19 additions and 3 deletions
  1. +18
    -2
      examples/GUI/ImagesDemo.h
  2. +1
    -1
      modules/juce_core/native/juce_Files_android.cpp

+ 18
- 2
examples/GUI/ImagesDemo.h 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


+ 1
- 1
modules/juce_core/native/juce_Files_android.cpp View File

@@ -297,7 +297,7 @@ private:
if (jniCheckHasExceptionOccurredAndClear())
{
// An exception has occurred, have you acquired RuntimePermission::readExternalStorage permission?
// An exception has occurred, have you acquired RuntimePermissions::readExternalStorage permission?
jassertfalse;
return {};
}


Loading…
Cancel
Save