commit
fbc19eed43
|
@ -20,7 +20,6 @@
|
|||
"@angular/router": "^16.2.0",
|
||||
"@awesome-cordova-plugins/badge": "^6.3.0",
|
||||
"@awesome-cordova-plugins/camera": "^6.3.0",
|
||||
"@awesome-cordova-plugins/chooser": "^6.3.0",
|
||||
"@awesome-cordova-plugins/clipboard": "^6.3.0",
|
||||
"@awesome-cordova-plugins/core": "^6.3.0",
|
||||
"@awesome-cordova-plugins/device": "^6.3.0",
|
||||
|
@ -808,18 +807,6 @@
|
|||
"rxjs": "^5.5.0 || ^6.5.0 || ^7.3.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@awesome-cordova-plugins/chooser": {
|
||||
"version": "6.4.0",
|
||||
"resolved": "https://registry.npmjs.org/@awesome-cordova-plugins/chooser/-/chooser-6.4.0.tgz",
|
||||
"integrity": "sha512-/0Tei8A9Ms2sE9VyWKtt0pVC9r+d9hURQxFnVmtZfKX3nM5fdYRRfzh5BBIrJzn4YMV+TIOv6g3EE1YAhvYTpA==",
|
||||
"dependencies": {
|
||||
"@types/cordova": "latest"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@awesome-cordova-plugins/core": "^6.0.1",
|
||||
"rxjs": "^5.5.0 || ^6.5.0 || ^7.3.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@awesome-cordova-plugins/clipboard": {
|
||||
"version": "6.4.0",
|
||||
"resolved": "https://registry.npmjs.org/@awesome-cordova-plugins/clipboard/-/clipboard-6.4.0.tgz",
|
||||
|
|
|
@ -55,7 +55,6 @@
|
|||
"@angular/router": "^16.2.0",
|
||||
"@awesome-cordova-plugins/badge": "^6.3.0",
|
||||
"@awesome-cordova-plugins/camera": "^6.3.0",
|
||||
"@awesome-cordova-plugins/chooser": "^6.3.0",
|
||||
"@awesome-cordova-plugins/clipboard": "^6.3.0",
|
||||
"@awesome-cordova-plugins/core": "^6.3.0",
|
||||
"@awesome-cordova-plugins/device": "^6.3.0",
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
import { Injectable } from '@angular/core';
|
||||
import { ActionSheetButton } from '@ionic/core';
|
||||
import { CameraOptions } from '@awesome-cordova-plugins/camera/ngx';
|
||||
import { ChooserResult } from '@awesome-cordova-plugins/chooser/ngx';
|
||||
import { ChooserResult } from 'cordova-plugin-chooser';
|
||||
import { FileEntry, IFile } from '@awesome-cordova-plugins/file/ngx';
|
||||
import { MediaFile } from '@awesome-cordova-plugins/media-capture/ngx';
|
||||
|
||||
|
@ -25,7 +25,7 @@ import { CoreDomUtils } from '@services/utils/dom';
|
|||
import { CoreMimetypeUtils } from '@services/utils/mimetype';
|
||||
import { CoreTextUtils } from '@services/utils/text';
|
||||
import { CoreUtils } from '@services/utils/utils';
|
||||
import { makeSingleton, Translate, Camera, Chooser, ActionSheetController } from '@singletons';
|
||||
import { makeSingleton, Translate, Camera, ActionSheetController } from '@singletons';
|
||||
import { CoreLogger } from '@singletons/logger';
|
||||
import { CoreCanceledError } from '@classes/errors/cancelederror';
|
||||
import { CoreError } from '@classes/errors/error';
|
||||
|
@ -43,6 +43,7 @@ import { CoreSites } from '@services/sites';
|
|||
import { CorePath } from '@singletons/path';
|
||||
import { CorePromisedValue } from '@classes/promised-value';
|
||||
import { CorePlatform } from '@services/platform';
|
||||
import { Chooser } from '@features/native/plugins';
|
||||
|
||||
/**
|
||||
* Helper service to upload files.
|
||||
|
|
|
@ -16,7 +16,7 @@ import { NgModule } from '@angular/core';
|
|||
|
||||
import { Badge } from '@awesome-cordova-plugins/badge/ngx';
|
||||
import { Camera } from '@awesome-cordova-plugins/camera/ngx';
|
||||
import { Chooser } from '@awesome-cordova-plugins/chooser/ngx';
|
||||
import { Chooser } from '@features/native/plugins/chooser';
|
||||
import { Clipboard } from '@awesome-cordova-plugins/clipboard/ngx';
|
||||
import { Device } from '@awesome-cordova-plugins/device/ngx';
|
||||
import { Diagnostic } from '@awesome-cordova-plugins/diagnostic/ngx';
|
||||
|
@ -68,7 +68,6 @@ export const CORE_NATIVE_SERVICES = [
|
|||
providers: [
|
||||
Badge,
|
||||
Camera,
|
||||
Chooser,
|
||||
Clipboard,
|
||||
Device,
|
||||
Diagnostic,
|
||||
|
|
|
@ -0,0 +1,47 @@
|
|||
// (C) Copyright 2015 Moodle Pty Ltd.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
import { Injectable } from '@angular/core';
|
||||
|
||||
/**
|
||||
* Chooser plugin wrapper.
|
||||
*/
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class Chooser {
|
||||
|
||||
/**
|
||||
* Displays native prompt for user to select a file.
|
||||
*
|
||||
* @param accept Optional MIME type filter (e.g. 'image/gif,video/*').
|
||||
* @returns Selected file's raw binary data, base64-encoded data: URI, MIME type, display name, and original URI.
|
||||
* If user cancels, promise will be resolved as undefined.
|
||||
* If error occurs, promise will be rejected.
|
||||
*/
|
||||
getFile(accept?: string): Promise<IChooserResult | undefined> {
|
||||
return cordova.chooser.getFile(accept);
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays native prompt for user to select a file.
|
||||
*
|
||||
* @param accept Optional MIME type filter (e.g. 'image/gif,video/*').
|
||||
* @returns Selected file's MIME type, display name, and original URI.
|
||||
* If user cancels, promise will be resolved as undefined.
|
||||
* If error occurs, promise will be rejected.
|
||||
*/
|
||||
getFileMetadata(accept?: string): Promise<IChooserResult | undefined> {
|
||||
return cordova.chooser.getFileMetadata(accept);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
// (C) Copyright 2015 Moodle Pty Ltd.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
import { makeSingleton } from '@singletons';
|
||||
import { Chooser as ChooserService } from './chooser';
|
||||
|
||||
export const Chooser = makeSingleton(ChooserService);
|
|
@ -39,7 +39,6 @@ import {
|
|||
|
||||
import { Badge as BadgeService } from '@awesome-cordova-plugins/badge/ngx';
|
||||
import { Camera as CameraService } from '@awesome-cordova-plugins/camera/ngx';
|
||||
import { Chooser as ChooserService } from '@awesome-cordova-plugins/chooser/ngx';
|
||||
import { Clipboard as ClipboardService } from '@awesome-cordova-plugins/clipboard/ngx';
|
||||
import { Diagnostic as DiagnosticService } from '@awesome-cordova-plugins/diagnostic/ngx';
|
||||
import { Device as DeviceService } from '@awesome-cordova-plugins/device/ngx';
|
||||
|
@ -175,7 +174,6 @@ export function makeSingleton<Service extends object = object>(
|
|||
|
||||
// Convert ionic-native services to singleton.
|
||||
export const Badge = makeSingleton(BadgeService);
|
||||
export const Chooser = makeSingleton(ChooserService);
|
||||
export const Clipboard = makeSingleton(ClipboardService);
|
||||
export const Diagnostic = makeSingleton(DiagnosticService);
|
||||
export const File = makeSingleton(FileService);
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
// (C) Copyright 2015 Moodle Pty Ltd.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
/**
|
||||
* Types for chooser cordova plugin.
|
||||
*
|
||||
* @see https://github.com/cyph/cordova-plugin-chooser
|
||||
*/
|
||||
|
||||
interface IChooserResult {
|
||||
data?: Uint8Array;
|
||||
dataURI?: string;
|
||||
mediaType: string;
|
||||
name: string;
|
||||
uri: string;
|
||||
}
|
||||
|
||||
interface Cordova {
|
||||
|
||||
chooser: {
|
||||
getFile(accept?: string): Promise<IChooserResult | undefined>;
|
||||
getFileMetadata(accept?: string): Promise<IChooserResult | undefined>;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
declare module 'cordova-plugin-chooser' {
|
||||
export type ChooserResult = IChooserResult;
|
||||
}
|
Loading…
Reference in New Issue