implement file picker in iOS with .ext to UTI filtering

This commit is contained in:
2019-09-09 15:31:47 +02:00
parent 4b3b1749d6
commit 096930b02e
5 changed files with 83 additions and 46 deletions

View File

@@ -105,8 +105,7 @@ void App::showKeyboard()
redraw = true;
#ifdef __IOS__
dispatch_async(dispatch_get_main_queue(), ^{
//[ios_view registerForKeyboardNotifications];
[ios_view becomeFirstResponder];
[ios_view show_keyboard];
});
#elif __ANDROID__
displayKeyboard(true);
@@ -119,8 +118,7 @@ void App::hideKeyboard()
redraw = true;
#ifdef __IOS__
dispatch_async(dispatch_get_main_queue(), ^{
[ios_view resignFirstResponder];
// [ios_view unregisterForKeyboardNotifications];
[ios_view hide_keyboard];
});
#elif __ANDROID__
displayKeyboard(false);
@@ -154,14 +152,14 @@ void App::pick_file(std::vector<std::string> types, std::function<void (std::str
{
redraw = true;
#ifdef __IOS__
// not implemented on ios
// fallback to pick_image
dispatch_async(dispatch_get_main_queue(), ^{
[ios_view pick_photo:callback];
NSMutableArray<NSString*>* fileTypes = [NSMutableArray arrayWithCapacity:types.size()];
for (const auto& t : types)
[fileTypes addObject:[NSString stringWithCString:t.c_str() encoding:NSUTF8StringEncoding]];
[ios_view pick_file:fileTypes then:callback];
});
#elif __OSX__
dispatch_async(dispatch_get_main_queue(), ^{
//NSArray* fileTypes = [NSArray arrayWithObjects:@"ppi", @"PPI", nil];
NSMutableArray<NSString*>* fileTypes = [NSMutableArray arrayWithCapacity:types.size()];
for (const auto& t : types)
[fileTypes addObject:[NSString stringWithCString:t.c_str() encoding:NSUTF8StringEncoding]];
@@ -198,11 +196,9 @@ void App::pick_file_save(std::vector<std::string> types, std::function<void (std
{
redraw = true;
#ifdef __IOS__
// not implemented on ios
// fallback to pick_image
//dispatch_async(dispatch_get_main_queue(), ^{
// [ios_view pick_photo:callback];
//});
// dispatch_async(dispatch_get_main_queue(), ^{
// [ios_view pick_file_save:callback];
// });
#elif __OSX__
dispatch_async(dispatch_get_main_queue(), ^{
//NSArray* fileTypes = [NSArray arrayWithObjects:@"ppi", @"PPI", nil];