diff options
Diffstat (limited to 'src/ios.m')
-rw-r--r-- | src/ios.m | 26 |
1 files changed, 24 insertions, 2 deletions
@@ -181,11 +181,22 @@ static AppState *appState_; | |||
181 | 181 | ||
182 | - (void)documentPicker:(UIDocumentPickerViewController *)controller | 182 | - (void)documentPicker:(UIDocumentPickerViewController *)controller |
183 | didPickDocumentsAtURLs:(NSArray<NSURL *> *)urls { | 183 | didPickDocumentsAtURLs:(NSArray<NSURL *> *)urls { |
184 | [self removeSavedFile]; | 184 | if (fileBeingSaved) { |
185 | [self removeSavedFile]; | ||
186 | } | ||
187 | else { | ||
188 | /* A file is being opened. */ | ||
189 | NSURL *url = [urls firstObject]; | ||
190 | iString *path = localFilePathFromUrl_String(collectNewCStr_String([[url absoluteString] | ||
191 | UTF8String])); | ||
192 | postCommandf_App("file.open temp:1 path:%s", cstrCollect_String(path)); | ||
193 | } | ||
185 | } | 194 | } |
186 | 195 | ||
187 | - (void)documentPickerWasCancelled:(UIDocumentPickerViewController *)controller { | 196 | - (void)documentPickerWasCancelled:(UIDocumentPickerViewController *)controller { |
188 | [self removeSavedFile]; | 197 | if (fileBeingSaved) { |
198 | [self removeSavedFile]; | ||
199 | } | ||
189 | } | 200 | } |
190 | 201 | ||
191 | -(void)keyboardOnScreen:(NSNotification *)notification { | 202 | -(void)keyboardOnScreen:(NSNotification *)notification { |
@@ -335,6 +346,17 @@ void exportDownloadedFile_iOS(const iString *path) { | |||
335 | [viewController_(get_Window()) presentViewController:picker animated:YES completion:nil]; | 346 | [viewController_(get_Window()) presentViewController:picker animated:YES completion:nil]; |
336 | } | 347 | } |
337 | 348 | ||
349 | void pickFileForOpening_iOS(void) { | ||
350 | UIDocumentPickerViewController *picker = [[UIDocumentPickerViewController alloc] | ||
351 | initWithDocumentTypes:@[@"fi.skyjake.lagrange.gemini", | ||
352 | @"public.text", | ||
353 | @"public.image", | ||
354 | @"public.audio"] | ||
355 | inMode:UIDocumentPickerModeImport]; | ||
356 | picker.delegate = appState_; | ||
357 | [viewController_(get_Window()) presentViewController:picker animated:YES completion:nil]; | ||
358 | } | ||
359 | |||
338 | /*----------------------------------------------------------------------------------------------*/ | 360 | /*----------------------------------------------------------------------------------------------*/ |
339 | 361 | ||
340 | enum iAVFAudioPlayerState { | 362 | enum iAVFAudioPlayerState { |