From fa843abbe9fd4da4b91c467dfc60cb61ff30d7e6 Mon Sep 17 00:00:00 2001 From: Marc Kassay Date: Tue, 15 Jan 2019 19:39:49 -0500 Subject: [PATCH] [clovelced-plugin-audiomanagement] Add types --- .../clovelced-plugin-audiomanagement-tests.ts | 29 ++++++++ .../index.d.ts | 67 +++++++++++++++++++ .../tsconfig.json | 23 +++++++ .../tslint.json | 3 + 4 files changed, 122 insertions(+) create mode 100644 types/clovelced-plugin-audiomanagement/clovelced-plugin-audiomanagement-tests.ts create mode 100644 types/clovelced-plugin-audiomanagement/index.d.ts create mode 100644 types/clovelced-plugin-audiomanagement/tsconfig.json create mode 100644 types/clovelced-plugin-audiomanagement/tslint.json diff --git a/types/clovelced-plugin-audiomanagement/clovelced-plugin-audiomanagement-tests.ts b/types/clovelced-plugin-audiomanagement/clovelced-plugin-audiomanagement-tests.ts new file mode 100644 index 0000000000..ed544553b9 --- /dev/null +++ b/types/clovelced-plugin-audiomanagement/clovelced-plugin-audiomanagement-tests.ts @@ -0,0 +1,29 @@ +import * as AudioManagement from 'clovelced-plugin-audiomanagement'; + +AudioManagement.setAudioMode(AudioManagement.AudioMode.NORMAL, () => { +}, (error: any) => { +}); + +AudioManagement.getAudioMode((results) => { + results.audioMode; + results.label; +}, (error: any) => { +}); + +AudioManagement.setVolume(AudioManagement.VolumeType.MUSIC, 5, () => { +}, (error: any) => { +}); + +AudioManagement.getVolume(AudioManagement.VolumeType.NOTIFICATION, (results) => { + results.volume; +}, (error: any) => { +}); + +AudioManagement.getMaxVolume(AudioManagement.VolumeType.RING, (results) => { + results.maxVolume; +}, (error: any) => { +}); + +AudioManagement.AudioMode.SILENT; +AudioManagement.AudioMode.VIBRATE; +AudioManagement.VolumeType.SYSTEM; diff --git a/types/clovelced-plugin-audiomanagement/index.d.ts b/types/clovelced-plugin-audiomanagement/index.d.ts new file mode 100644 index 0000000000..efd51a941a --- /dev/null +++ b/types/clovelced-plugin-audiomanagement/index.d.ts @@ -0,0 +1,67 @@ +// Type definitions for clovelced-plugin-audiomanagement 1.0 +// Project: https://github.com/clovelCed/cordova-plugin-audiomanagement#readme +// Definitions by: Marc Kassay +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export enum AudioMode { + SILENT = 0, + VIBRATE, + NORMAL +} + +export enum VolumeType { + RING = 0, + MUSIC, + NOTIFICATION, + SYSTEM +} + +/** + * Sets the `AudioManagement.AudioMode` for the device. + * + * @param mode the device can be set to: Silent, Normal, Vibrate + * @param onSuccess a callback when setting succeeds. + * @param onError a callback when setting fails. + * @returns void + */ +export function setAudioMode(mode: AudioMode, onSuccess: () => void, onError: (error: any) => void): void; + +/** + * Gets the current `AudioManagement.AudioMode` of the device. + * + * @param onSuccess a callback when succeeds with an object with `label` and `audioMode` properties. + * @param onError a callback when getting fails. + * @returns void + */ +export function getAudioMode(onSuccess: (results: { audioMode: AudioMode, label: string }) => void, onError: (error: any) => void): void; + +/** + * Sets the specified `AudioManagement.VolumeType` for the device with the value from `volume`. + * + * @param type the `AudioManagement.VolumeType` to set + * @param volume the volume value + * @param onSuccess a callback when setting succeeds. + * @param onError a callback when setting fails. + * @returns void + */ +export function setVolume(type: VolumeType, volume: number, onSuccess: () => void, onError: (error: any) => void): void; + +/** + * Gets the specified `AudioManagement.VolumeType`'s `volume`. + * + * @param type the `AudioManagement.VolumeType` to get + * @param onSuccess a callback when getting succeeds with an object with numeric `volume` property. + * @param onError a callback when getting fails. + * @returns void + */ +export function getVolume(type: VolumeType, onSuccess: (results: { volume: number }) => void, onError: (error: any) => void): void; + +/** + * Gets the specified `AudioManagement.VolumeType`'s maximum `volume` that the device is currently set to. + * + * @param type the `AudioManagement.VolumeType` to get + * @param onSuccess a callback when getting succeeds with an object with numeric `maxVolume` property. + * @param onError a callback when getting fails. + * @returns void + */ +export function getMaxVolume(type: VolumeType, onSuccess: (results: { maxVolume: number }) => void, onError: (error: any) => void): void; diff --git a/types/clovelced-plugin-audiomanagement/tsconfig.json b/types/clovelced-plugin-audiomanagement/tsconfig.json new file mode 100644 index 0000000000..20d97699ce --- /dev/null +++ b/types/clovelced-plugin-audiomanagement/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": false, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "clovelced-plugin-audiomanagement-tests.ts" + ] +} diff --git a/types/clovelced-plugin-audiomanagement/tslint.json b/types/clovelced-plugin-audiomanagement/tslint.json new file mode 100644 index 0000000000..f93cf8562a --- /dev/null +++ b/types/clovelced-plugin-audiomanagement/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +}