1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

Android: Added the ability to associate a particular file-extension to a mime-type at runtime

This commit is contained in:
hogliux 2022-11-01 15:44:21 +01:00
parent e30f6e7c0d
commit 4054e25052
5 changed files with 698 additions and 649 deletions

File diff suppressed because it is too large Load diff

View file

@ -31,6 +31,9 @@ namespace juce
namespace MimeTypeTable
{
/* @internal */
void registerCustomMimeTypeForFileExtension (const String& mimeType, const String& fileExtension);
/* @internal */
StringArray getMimeTypesForFileExtension (const String& fileExtension);

View file

@ -270,6 +270,13 @@ void FileChooser::finished (const Array<URL>& asyncResults)
callback (*this);
}
#if ! JUCE_ANDROID
void FileChooser::registerCustomMimeTypeForFileExtension ([[maybe_unused]] const String& mimeType,
[[maybe_unused]] const String& fileExtension)
{
}
#endif
//==============================================================================
FilePreviewComponent::FilePreviewComponent() {}
FilePreviewComponent::~FilePreviewComponent() {}

View file

@ -293,6 +293,19 @@ public:
*/
static bool isPlatformDialogAvailable();
/** Associate a particular file-extension to a mime-type
On Android, JUCE needs to convert common file extensions to mime-types when using
wildcard filters in native file chooser dialog boxes. JUCE has an extensive conversion
table to convert between the most common file-types and mime-types transparently, but
some more obscure file-types may be missing. Use this method to register your own
mime-type to file extension conversions. Please contact the JUCE team if you think
that a common mime-type/file-extension entry is missing in JUCE's internal tables.
Does nothing on other platforms.
*/
static void registerCustomMimeTypeForFileExtension (const String& mimeType,
const String& fileExtension);
//==============================================================================
#ifndef DOXYGEN
class Native;

View file

@ -277,4 +277,10 @@ bool FileChooser::isPlatformDialogAvailable()
#endif
}
void FileChooser::registerCustomMimeTypeForFileExtension (const String& mimeType,
const String& fileExtension)
{
MimeTypeTable::registerCustomMimeTypeForFileExtension (mimeType, fileExtension);
}
} // namespace juce