From 96890c7b92f34cf8d87eb98c0e4b5ddf9b68c6dc Mon Sep 17 00:00:00 2001 From: CrisPRuz Date: Sat, 23 Jan 2021 18:13:09 +0100 Subject: [PATCH] feat(android-notch): add cordova plugin wrapper (#3592) * feat(android-notch): cordova plugin wrapper * Update index.ts Co-authored-by: Cristina Co-authored-by: Daniel Sogl --- .../plugins/android-notch/index.ts | 99 +++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 src/@ionic-native/plugins/android-notch/index.ts diff --git a/src/@ionic-native/plugins/android-notch/index.ts b/src/@ionic-native/plugins/android-notch/index.ts new file mode 100644 index 0000000000..6d8c8c0d7b --- /dev/null +++ b/src/@ionic-native/plugins/android-notch/index.ts @@ -0,0 +1,99 @@ +import { Injectable } from '@angular/core'; +import { Plugin, Cordova, IonicNativePlugin } from '@ionic-native/core'; + +/** + * @name Android Notch + * @description + * This plugin enables developers to get the cutout and android devices inset sizes + * It is based on the cordova plugin developed by @tobspr: https://github.com/tobspr/cordova-plugin-android-notch + * This plugin works on all android versions, but we can only detect notches starting from Android 9. + * + * @usage + * ```typescript + * import { AndroidNotch } from '@ionic-native/android-notch/nx'; + * + * + * constructor(private androidNotch: AndroidNotch) { } + * + * ... + * + * + * this.androidNotch.hasCutout() + * .then((px: number) => console.log('Inset size: '), px) + * .catch((error: any) => console.log('Error: ', error)) + * + * this.androidNotch.getInsetTop() + * .then((px: number) => console.log('Inset size: '), px) + * .catch((error: any) => console.log('Error: ', error)) + * + * this.androidNotch.getInsetRight() + * .then((px: number) => console.log('Inset size: '), px) + * .catch((error: any) => console.log('Error: ', error)) + * + * this.androidNotch.getInsetBottom() + * .then((px: number) => console.log('Inset size: '), px) + * .catch((error: any) => console.log('Error: ', error)) + * + * this.androidNotch.getInsetLeft() + * .then((px: number) => console.log('Inset size: '), px) + * .catch((error: any) => console.log('Error: ', error)) + * + * ``` + */ +@Plugin({ + pluginName: 'AndroidNotch', + plugin: 'cordova-plugin-android-notch', + pluginRef: 'AndroidNotch', + repo: 'https://github.com/tobspr/cordova-plugin-android-notch.git', + platforms: ['Android'], +}) +@Injectable() +export class AndroidNotch extends IonicNativePlugin { + /** + * Returns true if the android device has cutout + * + * @return {Promise} + */ + @Cordova() + hasCutout(): Promise { + return; + } + + /** + * Returns the heigth of the top inset + * + * @return {Promise} + */ + @Cordova() + getInsetTop(): Promise { + return; + } + + /** + * Returns the heigth of the right inset + * + * @return {Promise} + */ + @Cordova() + getInsetRight(): Promise { + return; + } + + /** + * Returns the heigth of the bottom inset + * @return {Promise} + */ + @Cordova() + getInsetBottom(): Promise { + return; + } + + /** + * Returns the heigth of the left inset + * @return {Promise} + */ + @Cordova() + getInsetLeft(): Promise { + return; + } +}